Example usage for org.jdom2 Element addContent

List of usage examples for org.jdom2 Element addContent

Introduction

In this page you can find the example usage for org.jdom2 Element addContent.

Prototype

@Override
public Element addContent(final Collection<? extends Content> newContent) 

Source Link

Document

Appends all children in the given collection to the end of the content list.

Usage

From source file:de.danielluedecke.zettelkasten.database.DesktopData.java

License:Open Source License

/**
 * Adds a new bullet-point to the xml-document.
 * /*  www .  j  a va  2s.  com*/
 * @param timestamp the timestamp of the currently selected bullet-point after which the new bullet should
 * be inserted.
 * @param name the name of the bullet-point
 * @return the timestamp of the added bullet-element as {@code String} or {@code null} if an error
 * occured.
 */
public String addBullet(String timestamp, String name) {
    // find the bulletgroup that is described in the treepath
    Element parentb = (timestamp != null) ? findEntryElementFromTimestamp(getCurrentDesktopElement(), timestamp)
            : getCurrentDesktopElement();
    String newts;
    // if we have a valid bullet-group, add the new bullet to the xml-file
    if (parentb != null) {
        // create a new element from the given name
        Element b = new Element(ELEMENT_BULLET);
        try {
            b.setAttribute("name", name);
            // set attribute for collapsed/expanded state of bullet
            b.setAttribute("treefold", TREE_FOLDING_EXPANDED);
            // create timestamp
            newts = Tools.getTimeStampWithMilliseconds();
            // check whether timestamp already exists. this is particulary the
            // case when a user adds several entries at once.
            while (timeStampExists(newts))
                newts = Tools.getTimeStampWithMilliseconds();
            // set timestamp as attribute
            b.setAttribute(ATTR_TIMESTAMP, newts);
            // add a "comment" to that bullet. remember, that each bullet
            // automatically gets a child-element called "comment"
            b.addContent(new Element(ATTR_COMMENT));
            // add new bullet to the bulletgroup
            parentb.addContent(b);
            // change modified state
            setModified(true);
            // return timestamp of addes bullet
            return newts;
        } catch (IllegalNameException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
            return null;
        } catch (IllegalDataException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
            return null;
        } catch (IllegalAddException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
            return null;
        }
    }
    return null;
}

From source file:de.danielluedecke.zettelkasten.database.DesktopData.java

License:Open Source License

/**
 * Pastes the bullet-point {@code clipbullet} into the xml-document. The Element {@code clipbullet}
 * must be retrieved by {@link #copyBulletToClip(java.util.LinkedList) copyBulletToClip(java.util.LinkedList)}.
 *
 * @param timestamp the timestamp of the bullet that should be inserted
 * @param isRoot {@code true} when the drop-source is the root-element of the jTree, {@code false} when
 * the drop-source is any other parent-element
 *///from  www .j  av a 2 s. com
public void pasteBulletFromClip(String timestamp, boolean isRoot) {
    // find the bulletgroup that is described in the treepath
    Element parentb = (isRoot) ? getCurrentDesktopElement()
            : findEntryElementFromTimestamp(getCurrentDesktopElement(), timestamp);
    // if we have a valid bullet-group, add the new bullet to the xml-file
    if (parentb != null && clipbullet != null) {
        // create a new element
        Element b = new Element(ELEMENT_BULLET);
        try {
            // set the name of the copied bullet-value
            b.setAttribute("name", clipbullet.getAttributeValue("name"));
            // and use copied timestamp
            b.setAttribute(ATTR_TIMESTAMP, clipbullet.getAttributeValue(ATTR_TIMESTAMP));
            // clone the content from the clipboard-bullet to the new element. we
            // have to clone the content, since the element "clipbullet" still might
            // be attached to the document, when the bullet is just copied, not cut.
            b.addContent(clipbullet.cloneContent());
            // add new bullet to the bulletgroup
            parentb.addContent(b);
            // change modified state
            setModified(true);
        } catch (IllegalNameException ex) {
            Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage());
        } catch (IllegalDataException ex) {
            Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage());
        } catch (IllegalAddException ex) {
            Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage());
        }
    }
}

From source file:de.danielluedecke.zettelkasten.database.DesktopData.java

License:Open Source License

/**
 * This method initialises the desktopNotes-xml-file during an update-process.<br><br>
 * This method is called when updating a file with version number 3.0 or 3.1 to 3.2 and higher.
 *///w w  w  . j  a v  a2s .  c  o m
public void initDesktopNotesUpdate() {
    // iterate all desktops
    for (int cnt = 0; cnt < getCount(); cnt++) {
        // retrieve desktopname
        String dname = getDesktopName(cnt);
        // create new desktop-element
        Element desk = new Element("desktop");
        try {
            // set name attribute
            desk.setAttribute("name", dname);
            // add notes-sub-elements
            desk.addContent(new Element("notes1"));
            desk.addContent(new Element("notes2"));
            desk.addContent(new Element("notes3"));
            // add element to desktop-notes
            desktopNotes.getRootElement().addContent(desk);
        } catch (IllegalNameException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        } catch (IllegalDataException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        } catch (IllegalAddException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        }
    }
}

From source file:de.danielluedecke.zettelkasten.database.DesktopData.java

License:Open Source License

/**
 * This method archives the desktop-data of the desktop with the name {@code name} to a
 * zipped xml-file. The file contains the desktop-data, the modifed-entries-data for those entries
 * that appear on the desktop and the saved desktop-notes.
 *
 * @param name the name of the desktop that should be archived.
 * @return the archived document as XML-focument, or {@code null} if an error occured.
 *///from   w  w w. j a v  a2 s . c o m
public Document archiveDesktop(String name) {
    // create new document
    Document archive = new Document(new Element("archivedDesktop"));
    // add desktop-element of desktop that should be archived
    Element deskel = getDesktopElement(name);
    // if we found a valid value, go on
    if (deskel != null) {
        try {
            // set name attribute
            archive.getRootElement().setAttribute("name", name);
            // create desktop-element
            Element content_desktop = new Element("desktop");
            // clone content from current desktop
            content_desktop.addContent(deskel.cloneContent());
            // add element to archive-file
            archive.getRootElement().addContent(content_desktop);
            // now retrieve desktop-notes
            Element noteel = getDesktopNotes(name);
            // if we found a valid value, go on
            if (noteel != null) {
                // create notes-element
                Element content_notes = new Element("desktopNotes");
                // clone content from current desktop-notes
                content_notes.addContent(noteel.cloneContent());
                // add content
                archive.getRootElement().addContent(content_notes);
            }
            // now retrieve all timestamps from the archived desktop
            // and look for modified entries...
            // create new list that will contain the timestamps
            timestampList = new ArrayList<String>();
            // fill list with all entry-numbers. since we have sub-bullets/levels, we
            // recursevly go through the desktop-data
            retrieveDesktopEntriesTimestamps(deskel);
            // if we have any results, go on...
            if (timestampList.size() > 0) {
                // create base element
                Element modifiedel = new Element("modifiedEntries");
                // add all modified entries that appear on the archived desktop
                String[] timestamps = timestampList.toArray(new String[timestampList.size()]);
                for (String ts : timestamps) {
                    // retrieve modifed entry
                    Element me_dummy = retrieveModifiedEntryElementFromTimestamp(ts);
                    // check for valid value
                    if (me_dummy != null) {
                        // crate new modified-entry-element
                        Element me = new Element(ELEMENT_ENTRY);
                        // set timestamp-attribute
                        me.setAttribute(ATTR_TIMESTAMP, ts);
                        // and add modified text
                        me.setText(me_dummy.getText());
                        // and add content
                        modifiedel.addContent(me);
                    }
                }
                archive.getRootElement().addContent(modifiedel);
            }
        } catch (IllegalNameException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
            return null;
        } catch (IllegalDataException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
            return null;
        } catch (IllegalAddException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
            return null;
        }
    }
    return archive;
}

From source file:de.danielluedecke.zettelkasten.database.DesktopData.java

License:Open Source License

/**
 * This method imports an archived desktop-file and appends it to the current desktop-data.
 * desktop-content, desktop-notes and modifed entries are being added.
 * @param archive the archive-file as xml-Document
 * @return one of the following return values:<br>
 * <ul>// ww  w. j  av  a2  s.c o m
 * <li>{@link #IMPORT_ARCHIVE_OK IMPORT_ARCHIVE_OK} in case the import was successful</li>
 * <li>{@link #IMPORT_ARCHIVE_ERR_DESKTOPNAME_EXISTS IMPORT_ARCHIVE_ERR_DESKTOPNAME_EXISTS} in case
 * the desktop-name already exists, so the user is asked to enter another name</li>>
 * <li>{@link #IMPORT_ARCHIVE_ERR_OTHER IMPORT_ARCHIVE_ERR_OTHER} in case a general error occured</li>
 * </ul>
 */
public int importArchivedDesktop(Document archive) {
    // get imported desktopname
    String name = archive.getRootElement().getAttributeValue("name");
    // check whether we have any name at all. if not, return false
    if (null == name || name.isEmpty())
        return IMPORT_ARCHIVE_ERR_DESKTOPNAME_EXISTS;
    // first of all, go through all desktops and check whether the name
    // already exist, to avoid double naming...
    // when such a desktopname as "name" already exists, return false
    for (int cnt = 0; cnt < getCount(); cnt++)
        if (name.equalsIgnoreCase(getDesktopName(cnt)))
            return IMPORT_ARCHIVE_ERR_DESKTOPNAME_EXISTS;
    // create new element
    Element d = new Element("desktop");
    try {
        // set the desktop's name as attribute
        d.setAttribute("name", name);
        // get desktop-content from archive
        d.addContent(archive.getRootElement().getChild("desktop").cloneContent());
        // add the element to the desktop
        desktop.getRootElement().addContent(d);
        // set currentDesktop index to the new desktop-element
        currentDesktop = desktop.getRootElement().getContentSize() - 1;
        // also add new desktop-notes-element
        Element desk = new Element("desktop");
        // set name attribute
        desk.setAttribute("name", name);
        // create notes elements
        Element n1 = new Element("notes1");
        Element n2 = new Element("notes2");
        Element n3 = new Element("notes3");
        // get notes-child
        Element noteschild = archive.getRootElement().getChild("desktopNotes");
        // check whether we have any content
        if (noteschild != null) {
            // get and add notes...
            Element nc1 = noteschild.getChild("notes1");
            if (nc1 != null)
                n1.setText(nc1.getText());
            // get and add notes...
            Element nc2 = noteschild.getChild("notes2");
            if (nc2 != null)
                n2.setText(nc2.getText());
            // get and add notes...
            Element nc3 = noteschild.getChild("notes3");
            if (nc3 != null)
                n3.setText(nc3.getText());
        }
        // add notes-sub-elements
        desk.addContent(n1);
        desk.addContent(n2);
        desk.addContent(n3);
        // add element to desktop-notes
        desktopNotes.getRootElement().addContent(desk);
        // finally, add modified entries...
        List<Element> modent = archive.getRootElement().getChild("modifiedEntries").getChildren();
        // create iterator
        Iterator<Element> modit = modent.iterator();
        // and add all mofied entries
        while (modit.hasNext()) {
            // get element
            Element mod = modit.next();
            // and add modified entry
            addModifiedEntry(mod.getAttributeValue(ATTR_TIMESTAMP), mod.getText());
        }
        setModified(true);
    } catch (IllegalNameException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        return IMPORT_ARCHIVE_ERR_OTHER;
    } catch (IllegalDataException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        return IMPORT_ARCHIVE_ERR_OTHER;
    } catch (IllegalAddException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        return IMPORT_ARCHIVE_ERR_OTHER;
    }
    return IMPORT_ARCHIVE_OK;
}

From source file:de.danielluedecke.zettelkasten.database.SearchRequests.java

License:Open Source License

/**
 * This method adds a new search request to the search-object. The relevant parameters
 * are stored in an xml-file, so we can save/load the data easily.
 * /*from  w w  w .j a v a  2 s .  c o  m*/
 * @param s the search terms, in a string-array
 * @param w where we want to look (e.g. in keywords, content, authors...
 * @param l which kind of logical-combination we have
 * @param ww if true, find wholewords only
 * @param mc if true, search is case-sensitive
 * @param syn true, if the search included synonyms, false otherwise
 * @param rex true, if the search term is a regular expression, false otherwise
 * @param r the search results, i.e. the entry-numbers as integer-array
 * @param n a shorted description of the search request, so we know what the user was looking for
 * @param ld a long description of the search request, so we know what the user was looking for
 * @return {@code true} if search result was successfully added, {@code false} if an error occured
 */
public boolean addSearch(String[] s, int w, int l, boolean ww, boolean mc, boolean syn, boolean rex, int[] r,
        String n, String ld) {
    // check for valid parameters. do we have search terms?
    if (null == s || s.length < 1) {
        return false;
    }
    // do we have search results?
    if (null == r || r.length < 1) {
        return false;
    }
    // create a new element for search requests
    Element sr = new Element("searchrequest");
    try {
        // and add it to the document
        searches.getRootElement().addContent(sr);
        // create the child-elements
        Element st = new Element("searchterms");
        // iterate search terms and add each term as sub-element
        for (String sterm : s) {
            Element term = new Element("term");
            term.setText(sterm);
            st.addContent(term);
        }
        // now add the search terms to the parent
        sr.addContent(st);
        // create element for where to look
        Element where = new Element("where");
        where.setText(String.valueOf(w));
        // now add the element to the parent
        sr.addContent(where);
        // create element for the logical combination
        Element log = new Element("logical");
        log.setText(String.valueOf(l));
        // now add the element to the parent
        sr.addContent(log);
        // create element for whole-word
        Element whole = new Element("wholeword");
        whole.setText((ww) ? "true" : "false");
        // now add the element to the parent
        sr.addContent(whole);
        // create element for match case
        Element match = new Element("matchcase");
        match.setText((mc) ? "true" : "false");
        // now add the element to the parent
        sr.addContent(match);
        // create element for synonymsearch
        Element synonyms = new Element("synonyms");
        synonyms.setText((syn) ? "true" : "false");
        // now add the element to the parent
        sr.addContent(synonyms);
        // create element for synonymsearch
        Element regex = new Element("regex");
        regex.setText((rex) ? "true" : "false");
        // now add the element to the parent
        sr.addContent(regex);
        // create element for the description
        Element label = new Element(Daten.ELEMEMT_DESCRIPTION);
        label.setText(n);
        // now add the element to the parent
        sr.addContent(label);
        // create element for the long description
        Element longlabel = new Element("longdesc");
        longlabel.setText(ld);
        // now add the element to the parent
        sr.addContent(longlabel);
        // create element for search results
        Element results = new Element("results");
        // create stringbuilder, since we want to copy the ineger array
        // to an stringarray
        StringBuilder sb = new StringBuilder("");
        // iterate array and convert all integer to string
        for (int nr : r) {
            sb.append(String.valueOf(nr));
            sb.append(",");
        }
        // delete last comma
        if (sb.length() > 1) {
            sb.setLength(sb.length() - 1);
        }
        // add string to element
        results.setText(sb.toString());
        // now add the element to the parent
        sr.addContent(results);
        // change modified state
        setModified(true);
        // return success
        return true;
    } catch (IllegalAddException ex) {
        // log error
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
    } catch (IllegalDataException ex) {
        // log error
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
    }
    return false;
}

From source file:de.danielluedecke.zettelkasten.database.Settings.java

License:Open Source License

/**
 * This method creates all the settings-child-elements, but only, if they don't
 * already exist. We do this because when loading older settings-xml-document-structures,
 * we might have new elements that would not be initialised. but now we can call this 
 * method after loading the xml-document, and create elements and default values for all
 * new elements. This ensures compatibility to older/news settings-file-versions.
 *///  w w w . j a v  a 2s. co  m
public void fillElements() {
    for (int cnt = 0; cnt < recentDocCount; cnt++) {
        // create field-identifier
        String fi = SETTING_RECENT_DOC + String.valueOf(cnt + 1);
        // retrieve content
        if (null == settingsFile.getRootElement().getChild(fi)) {
            // create a filepath-element
            Element el = new Element(fi);
            el.setText("");
            // and add it to the document
            settingsFile.getRootElement().addContent(el);
        }
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LOCALE)) {
        // create a filepath-element
        Element el = new Element(SETTING_LOCALE);
        el.setText(Locale.getDefault().getLanguage());
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_FILEPATH)) {
        // create a filepath-element
        Element el = new Element(SETTING_FILEPATH);
        el.setText("");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_PANDOCPATH)) {
        // create a filepath-element
        Element el = new Element(SETTING_PANDOCPATH);
        el.setText("pandoc");
        if (PlatformUtil.isMacOS()) {
            el.setText("/usr/local/bin/pandoc");
        } else if (PlatformUtil.isLinux()) {
            el.setText("/usr/bin/pandoc");
        }
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHFRAMESPLITLAYOUT)) {
        // create a filepath-element
        Element el = new Element(SETTING_SEARCHFRAMESPLITLAYOUT);
        el.setText(String.valueOf(JSplitPane.VERTICAL_SPLIT));
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_CUSTOMCSSENTRY)) {
        // create a filepath-element
        Element el = new Element(SETTING_CUSTOMCSSENTRY);
        el.setText("");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_CUSTOMCSSDESKTOP)) {
        // create a filepath-element
        Element el = new Element(SETTING_CUSTOMCSSDESKTOP);
        el.setText("");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_GETLASTUSEDDESKTOPNUMBER)) {
        // create a filepath-element
        Element el = new Element(SETTING_GETLASTUSEDDESKTOPNUMBER);
        el.setText("0");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_AUTOCOMPLETETAGS)) {
        // create a filepath-element
        Element el = new Element(SETTING_AUTOCOMPLETETAGS);
        el.setText("1");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_MARKDOWNACTIVATED)) {
        // create element
        Element el = new Element(SETTING_MARKDOWNACTIVATED);
        el.setText("0");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DISPLAYEDTOOLBARICONS)) {
        // create a filepath-element
        Element el = new Element(SETTING_DISPLAYEDTOOLBARICONS);
        if (System.getProperty("os.name").toLowerCase().startsWith("mac os")) {
            el.setText("1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,0,1,0,0,1,1,1,1,1");
        } else {
            el.setText("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
        }
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTOPENEDIMPORTDIR)) {
        // create a filepath-element
        Element el = new Element(SETTING_LASTOPENEDIMPORTDIR);
        el.setText("");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTOPENEDEXPORTDIR)) {
        // create a filepath-element
        Element el = new Element(SETTING_LASTOPENEDEXPORTDIR);
        el.setText("");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTOPENEDIMAGEDIR)) {
        // create a filepath-element
        Element el = new Element(SETTING_LASTOPENEDIMAGEDIR);
        el.setText("");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWICONTEXT)) {
        // create a filepath-element
        Element el = new Element(SETTING_SHOWICONTEXT);
        el.setText("1");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_USEMACBACKGROUNDCOLOR)) {
        // create a filepath-element
        Element el = new Element(SETTING_USEMACBACKGROUNDCOLOR);
        el.setText("0");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTOPENEDATTACHMENTDIR)) {
        // create a filepath-element
        Element el = new Element(SETTING_LASTOPENEDATTACHMENTDIR);
        el.setText("");
        // and add it to the document
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_AUTOBACKUP)) {
        // create an element
        Element el = new Element(SETTING_AUTOBACKUP);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_EXTRABACKUP)) {
        // create an element
        Element el = new Element(SETTING_EXTRABACKUP);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_ALWAYSMACSTYLE)) {
        // create an element
        Element el = new Element(SETTING_ALWAYSMACSTYLE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_MINIMIZETOTRAY)) {
        // create an element
        Element el = new Element(SETTING_MINIMIZETOTRAY);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_ADDALLTOHISTORY)) {
        // create an element
        Element el = new Element(SETTING_ADDALLTOHISTORY);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_COPYPLAIN)) {
        // create an element
        Element el = new Element(SETTING_COPYPLAIN);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_EXTRABACKUPPATH)) {
        // create an element
        Element el = new Element(SETTING_EXTRABACKUPPATH);
        settingsFile.getRootElement().addContent(el);
        el.setText("");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_FILLEMPTYPLACES)) {
        // create an element
        Element el = new Element(SETTING_FILLEMPTYPLACES);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_MANUALTIMESTAMP)) {
        // create an element
        Element el = new Element(SETTING_MANUALTIMESTAMP);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHTIME)) {
        // create an element
        Element el = new Element(SETTING_SEARCHTIME);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHALWAYSSYNONYMS)) {
        // create an element
        Element el = new Element(SETTING_SEARCHALWAYSSYNONYMS);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWSYNONYMSINTABLE)) {
        // create an element
        Element el = new Element(SETTING_SHOWSYNONYMSINTABLE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWICONS)) {
        // create an element
        Element el = new Element(SETTING_SHOWICONS);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWALLICONS)) {
        // create an element
        Element el = new Element(SETTING_SHOWALLICONS);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWENTRYHEADLINE)) {
        // create an element
        Element el = new Element(SETTING_SHOWENTRYHEADLINE);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_ICONTHEME)) {
        // create an element
        Element el = new Element(SETTING_ICONTHEME);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWUPDATEHINTVERSION)) {
        // create an element
        Element el = new Element(SETTING_SHOWUPDATEHINTVERSION);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_USECUSTOMCSSENTRY)) {
        // create an element
        Element el = new Element(SETTING_USECUSTOMCSSENTRY);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_USECUSTOMCSSDESKTOP)) {
        // create an element
        Element el = new Element(SETTING_USECUSTOMCSSDESKTOP);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_USEXDGOPEN)) {
        // create an element
        Element el = new Element(SETTING_USEXDGOPEN);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_MANLINKCOLOR)) {
        // create an element
        Element el = new Element(SETTING_MANLINKCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("0033cc");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_FNLINKCOLOR)) {
        // create an element
        Element el = new Element(SETTING_FNLINKCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("0033cc");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LINKCOLOR)) {
        // create an element
        Element el = new Element(SETTING_LINKCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("003399");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_APPENDIXBACKGROUNDCOLOR)) {
        // create an element
        Element el = new Element(SETTING_APPENDIXBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("ffffff");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_TABLEHEADERCOLOR)) {
        // create an element
        Element el = new Element(SETTING_TABLEHEADERCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("e4e4e4");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_TABLEEVENROWCOLOR)) {
        // create an element
        Element el = new Element(SETTING_TABLEEVENROWCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("eeeeee");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_ENTRYHEADERBACKGROUNDCOLOR)) {
        // create an element
        Element el = new Element(SETTING_ENTRYHEADERBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("555555");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_QUOTEBACKGROUNDCOLOR)) {
        // create an element
        Element el = new Element(SETTING_QUOTEBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("f2f2f2");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_MAINBACKGROUNDCOLOR)) {
        // create an element
        Element el = new Element(SETTING_MAINBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("ffffff");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_CONTENTBACKGROUNDCOLOR)) {
        // create an element
        Element el = new Element(SETTING_CONTENTBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("ffffff");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_TABLEODDROWCOLOR)) {
        // create an element
        Element el = new Element(SETTING_TABLEODDROWCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("f8f8f8");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWTABLEBORDER)) {
        // create an element
        Element el = new Element(SETTING_SHOWTABLEBORDER);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWLUHMANNENTRYNUMBER)) {
        // create an element
        Element el = new Element(SETTING_SHOWLUHMANNENTRYNUMBER);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }
    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWDESKTOPENTRYNUMBER)) {
        // create an element
        Element el = new Element(SETTING_SHOWDESKTOPENTRYNUMBER);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPSHOWCOMMENTS)) {
        // create an element
        Element el = new Element(SETTING_DESKTOPSHOWCOMMENTS);
        settingsFile.getRootElement().addContent(el);
        el.setText(String.valueOf(Constants.DESKTOP_WITH_COMMENTS));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTUSEDBIBTEXFORMAT)) {
        // create an element
        Element el = new Element(SETTING_LASTUSEDBIBTEXFORMAT);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWHIGHLIGHTBACKGROUND)) {
        // create an element
        Element el = new Element(SETTING_SHOWHIGHLIGHTBACKGROUND);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWHIGHLIGHTKEYWORDBACKGROUND)) {
        // create an element
        Element el = new Element(SETTING_SHOWHIGHLIGHTKEYWORDBACKGROUND);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWHIGHLIGHTLIVESEARCHBACKGROUND)) {
        // create an element
        Element el = new Element(SETTING_SHOWHIGHLIGHTLIVESEARCHBACKGROUND);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHCOMBOTIME)) {
        // create an element
        Element el = new Element(SETTING_SEARCHCOMBOTIME);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHDATETIME)) {
        // create an element
        Element el = new Element(SETTING_SEARCHDATETIME);
        settingsFile.getRootElement().addContent(el);
        el.setText("");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHLOG)) {
        // create an element
        Element el = new Element(SETTING_SEARCHLOG);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTSEARCHRESULTS)) {
        // create an element
        Element el = new Element(SETTING_HIGHLIGHTSEARCHRESULTS);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTKEYWORDS)) {
        // create an element
        Element el = new Element(SETTING_HIGHLIGHTKEYWORDS);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWSEARCHENTRY)) {
        // create an element
        Element el = new Element(SETTING_SHOWSEARCHENTRY);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SUPFOOTNOTE)) {
        // create an element
        Element el = new Element(SETTING_SUPFOOTNOTE);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_JUMPFOOTNOTE)) {
        // create an element
        Element el = new Element(SETTING_JUMPFOOTNOTE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_STARTUPENTRY)) {
        // now create an element which stores the last shown entry before closing the program
        // so we can show this last viewed entry at startup again
        Element el = new Element(SETTING_STARTUPENTRY);
        el.addContent("1");
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWATSTARTUP)) {
        // now create an element which stores the value for what we want to
        // show directly after startup: either the first entry, a random entry
        // or the startup entry
        Element el = new Element(SETTING_SHOWATSTARTUP);
        el.addContent("0");
        settingsFile.getRootElement().addContent(el);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LOGKEYWORDLIST)) {
        // create an element
        Element el = new Element(SETTING_LOGKEYWORDLIST);
        settingsFile.getRootElement().addContent(el);
        el.setText(SETTING_LOGKEYWORDLIST_OR);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWGRID_HORIZONTAL)) {
        // create an element
        Element el = new Element(SETTING_SHOWGRID_HORIZONTAL);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SHOWGRID_VERTICAL)) {
        // create an element
        Element el = new Element(SETTING_SHOWGRID_VERTICAL);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_CELLSPACING)) {
        // create an element
        Element el = new Element(SETTING_CELLSPACING);
        settingsFile.getRootElement().addContent(el);
        el.setText("1,1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SPELLCORRECT)) {
        // create an element
        Element el = new Element(SETTING_SPELLCORRECT);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_STENOACTIVATED)) {
        // create an element
        Element el = new Element(SETTING_STENOACTIVATED);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTWHOLEWORD)) {
        // create an element
        Element el = new Element(SETTING_HIGHLIGHTWHOLEWORD);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTWHOLEWORDSEARCH)) {
        // create an element
        Element el = new Element(SETTING_HIGHLIGHTWHOLEWORDSEARCH);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_QUICKINPUT)) {
        // create an element
        Element el = new Element(SETTING_QUICKINPUT);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_AUTOUPDATE)) {
        // create an element
        Element el = new Element(SETTING_AUTOUPDATE);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_TOCFORDESKTOPEXPORT)) {
        // create an element
        Element el = new Element(SETTING_TOCFORDESKTOPEXPORT);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_REMOVELINESFORDESKTOPEXPORT)) {
        // create an element
        Element el = new Element(SETTING_REMOVELINESFORDESKTOPEXPORT);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIDEMULTIPLEDESKTOPOCCURENCESDLG)) {
        // create an element
        Element el = new Element(SETTING_HIDEMULTIPLEDESKTOPOCCURENCESDLG);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_AUTONIGHTLYUPDATE)) {
        // create an element
        Element el = new Element(SETTING_AUTONIGHTLYUPDATE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_QUICKINPUTEXTENDED)) {
        // create an element
        Element el = new Element(SETTING_QUICKINPUTEXTENDED);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_IMGRESIZE)) {
        // create an element
        Element el = new Element(SETTING_IMGRESIZE);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_IMGRESIZEWIDTH)) {
        // create an element
        Element el = new Element(SETTING_IMGRESIZEWIDTH);
        settingsFile.getRootElement().addContent(el);
        el.setText("300");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_IMGRESIZEHEIGHT)) {
        // create an element
        Element el = new Element(SETTING_IMGRESIZEHEIGHT);
        settingsFile.getRootElement().addContent(el);
        el.setText("300");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_TABLEFONTSIZE)) {
        // create an element
        Element el = new Element(SETTING_TABLEFONTSIZE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPOUTLINEFONTSIZE)) {
        // create an element
        Element el = new Element(SETTING_DESKTOPOUTLINEFONTSIZE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_TEXTFIELDFONTSIZE)) {
        // create an element
        Element el = new Element(SETTING_TEXTFIELDFONTSIZE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTUSEDSETBIBKEYCHOICE)) {
        // create an element
        Element el = new Element(SETTING_LASTUSEDSETBIBKEYCHOICE);
        settingsFile.getRootElement().addContent(el);
        el.setText(String.valueOf(CSetBibKey.CHOOSE_BIBKEY_MANUAL));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTUSEDSETBIBKEYTYPE)) {
        // create an element
        Element el = new Element(SETTING_LASTUSEDSETBIBKEYTYPE);
        settingsFile.getRootElement().addContent(el);
        el.setText(String.valueOf(CSetBibKey.CHOOSE_BIBKEY_MANUAL));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTUSEDSETBIBIMPORTSOURCE)) {
        // create an element
        Element el = new Element(SETTING_LASTUSEDSETBIBIMPORTSOURCE);
        settingsFile.getRootElement().addContent(el);
        el.setText(String.valueOf(CImportBibTex.BIBTEX_SOURCE_DB));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTFOOTNOTE)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTFOOTNOTE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTFORMTAG)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTFORMTAG);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTSHOWAUTHOR)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTSHOWAUTHOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTREMOVENONSTANDARDTAGS)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTREMOVENONSTANDARDTAGS);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTTABLESTATSTYLE)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTTABLESTATSTYLE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTSHOWMAIL)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTSHOWMAIL);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTCONVERTQUOTES)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTCONVERTQUOTES);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTCENTERFORM)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTCENTERFORM);
        settingsFile.getRootElement().addContent(el);
        el.setText("1");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTLASTUSEDBIBSTYLE)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTLASTUSEDBIBSTYLE);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTDOCUMENTCLASS)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTDOCUMENTCLASS);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTAUTHORVALUE)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTAUTHORVALUE);
        settingsFile.getRootElement().addContent(el);
        el.setText("");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LATEXEXPORTMAILVALUE)) {
        // create an element
        Element el = new Element(SETTING_LATEXEXPORTMAILVALUE);
        settingsFile.getRootElement().addContent(el);
        el.setText("");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LAF)) {
        // create element for look and feel
        Element el = new Element(SETTING_LAF);
        settingsFile.getRootElement().addContent(el);
        // retrieve all installed Look and Feels
        UIManager.LookAndFeelInfo[] installed_laf = UIManager.getInstalledLookAndFeels();
        // init found-variables
        boolean laf_aqua_found = false;
        boolean laf_nimbus_found = false;
        String aquaclassname = "";
        String nimbusclassname = "";
        // in case we find "nimbus" LAF, set this as default on non-mac-os
        // because it simply looks the best.
        for (UIManager.LookAndFeelInfo laf : installed_laf) {
            // check whether laf is mac os x
            if (laf.getName().equalsIgnoreCase("mac os x") || laf.getClassName().contains("Aqua")) {
                laf_aqua_found = true;
                aquaclassname = laf.getClassName();
            }
            // check whether laf is nimbus
            if (laf.getName().equalsIgnoreCase("nimbus") || laf.getClassName().contains("Nimbus")) {
                laf_nimbus_found = true;
                nimbusclassname = laf.getClassName();
            }
        }
        // check which laf was found and set appropriate default value
        if (laf_aqua_found)
            el.setText(aquaclassname);
        else if (laf_nimbus_found)
            el.setText(nimbusclassname);
        else
            el.setText(UIManager.getSystemLookAndFeelClassName());
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHWHERE)) {
        // create element
        Element el = new Element(SETTING_SEARCHWHERE);
        settingsFile.getRootElement().addContent(el);
        // combine fields which should be initiated when opening the search dialog
        int where = Constants.SEARCH_CONTENT | Constants.SEARCH_TITLE | Constants.SEARCH_KEYWORDS
                | Constants.SEARCH_REMARKS;
        el.setText(String.valueOf(where));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_REPLACEWHERE)) {
        // create element
        Element el = new Element(SETTING_REPLACEWHERE);
        settingsFile.getRootElement().addContent(el);
        // combine fields which should be initiated when opening the search dialog
        int where = Constants.SEARCH_CONTENT | Constants.SEARCH_TITLE | Constants.SEARCH_KEYWORDS
                | Constants.SEARCH_REMARKS;
        el.setText(String.valueOf(where));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_EXPORTPARTS)) {
        // create element
        Element el = new Element(SETTING_EXPORTPARTS);
        settingsFile.getRootElement().addContent(el);
        // combine fields which should be initiated when opening the search dialog
        int where = Constants.EXPORT_TITLE | Constants.EXPORT_CONTENT | Constants.EXPORT_AUTHOR
                | Constants.EXPORT_REMARKS;
        el.setText(String.valueOf(where));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_EXPORTFORMAT)) {
        // create element
        Element el = new Element(SETTING_EXPORTFORMAT);
        settingsFile.getRootElement().addContent(el);
        el.setText(String.valueOf(Constants.EXP_TYPE_DESKTOP_DOCX));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPEXPORTFORMAT)) {
        // create element
        Element el = new Element(SETTING_DESKTOPEXPORTFORMAT);
        settingsFile.getRootElement().addContent(el);
        el.setText(String.valueOf(Constants.EXP_TYPE_DESKTOP_DOCX));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPCOMMENTEXPORT)) {
        // create element
        Element el = new Element(SETTING_DESKTOPCOMMENTEXPORT);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPDISPLAYITEMS)) {
        // create element
        Element el = new Element(SETTING_DESKTOPDISPLAYITEMS);
        settingsFile.getRootElement().addContent(el);
        // combine fields which should be initiated when opening the desktop dialog
        int where = Constants.DESKTOP_SHOW_REMARKS | Constants.DESKTOP_SHOW_AUTHORS;
        el.setText(String.valueOf(where));
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHWHAT)) {
        // create element
        Element el = new Element(SETTING_SEARCHWHAT);
        settingsFile.getRootElement().addContent(el);
        el.setText("");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_REPLACEWHAT)) {
        // create element
        Element el = new Element(SETTING_REPLACEWHAT);
        settingsFile.getRootElement().addContent(el);
        el.setText("");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_SEARCHOPTION)) {
        // create element
        Element el = new Element(SETTING_SEARCHOPTION);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_REPLACEOPTION)) {
        // create element
        Element el = new Element(SETTING_REPLACEOPTION);
        settingsFile.getRootElement().addContent(el);
        el.setText("0");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_LASTUSEDBIBTEXFILE)) {
        // create element
        Element el = new Element(SETTING_LASTUSEDBIBTEXFILE);
        settingsFile.getRootElement().addContent(el);
        el.setText("");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTSEARCHSTYLE)) {
        // create element for font
        Element el = new Element(SETTING_HIGHLIGHTSEARCHSTYLE);
        settingsFile.getRootElement().addContent(el);
        el.setAttribute("size", "0");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "0000ff");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTKEYWORDSTYLE)) {
        // create element for font
        Element el = new Element(SETTING_HIGHLIGHTKEYWORDSTYLE);
        settingsFile.getRootElement().addContent(el);
        el.setAttribute("size", "0");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "0000ff");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTLIVESEARCHSTYLE)) {
        // create element for font
        Element el = new Element(SETTING_HIGHLIGHTLIVESEARCHSTYLE);
        settingsFile.getRootElement().addContent(el);
        el.setAttribute("size", "0");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "0000ff");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTBACKGROUNDCOLOR)) {
        // create element
        Element el = new Element(SETTING_HIGHLIGHTBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("ffff66");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTKEYWORDBACKGROUNDCOLOR)) {
        // create element
        Element el = new Element(SETTING_HIGHLIGHTKEYWORDBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("ffff66");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HIGHLIGHTLIVESEARCHBACKGROUNDCOLOR)) {
        // create element
        Element el = new Element(SETTING_HIGHLIGHTLIVESEARCHBACKGROUNDCOLOR);
        settingsFile.getRootElement().addContent(el);
        el.setText("ffff66");
    }

    // init standard font. on mac, it's helvetica
    String font = "Helvetica";
    // on older windows arial
    if (System.getProperty("os.name").startsWith("Windows")) {
        font = "Arial";
        // on new windows Calibri
        if (System.getProperty("os.name").startsWith("Windows 7")
                || System.getProperty("os.name").startsWith("Windows 8")) {
            font = "Calibri";
        }

    }
    // and on linux we take Nimbus Sans L Regular
    else if (System.getProperty("os.name").startsWith("Linux")) {
        font = "Nimbus Sans L Regular";
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_TABLEFONT)) {
        // create element for font
        Element el = new Element(SETTING_TABLEFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPOUTLINEFONT)) {
        // create element for font
        Element el = new Element(SETTING_DESKTOPOUTLINEFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_MAINFONT)) {
        // create element for font
        Element el = new Element(SETTING_MAINFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "11");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "000000");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_QUOTEFONT)) {
        // create element for font
        Element el = new Element(SETTING_QUOTEFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "11");
        el.setAttribute("color", "333333");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_ENTRYHEADERFONT)) {
        // create element for font
        Element el = new Element(SETTING_ENTRYHEADERFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "10");
        el.setAttribute("color", "F4F4F4");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_AUTHORFONT)) {
        // create element for font
        Element el = new Element(SETTING_AUTHORFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "10");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "333333");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_CODEFONT)) {
        // create element for font
        Element el = new Element(SETTING_CODEFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "11");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "333333");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_REMARKSFONT)) {
        // create element for font
        Element el = new Element(SETTING_REMARKSFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "10");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "333333");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPHEADERFONT)) {
        // create element for font
        Element el = new Element(SETTING_DESKTOPHEADERFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "14");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "bold");
        el.setAttribute("color", "000000");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPITEMHEADERFONT)) {
        // create element for font
        Element el = new Element(SETTING_DESKTOPITEMHEADERFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "12");
        el.setAttribute("style", "italic");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "555555");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPITEMFONT)) {
        // create element for font
        Element el = new Element(SETTING_DESKTOPITEMFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "10");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "808080");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_DESKTOPCOMMENTFONT)) {
        // create element for font
        Element el = new Element(SETTING_DESKTOPCOMMENTFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "9");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "normal");
        el.setAttribute("color", "333333");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_TITLEFONT)) {
        // create element for font
        Element el = new Element(SETTING_TITLEFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "13");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "bold");
        el.setAttribute("color", "800000");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_APPENDIXHEADERFONT)) {
        // create element for font
        Element el = new Element(SETTING_APPENDIXHEADERFONT);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "13");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "bold");
        el.setAttribute("color", "555555");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HEADERFONT1)) {
        // create element for font
        Element el = new Element(SETTING_HEADERFONT1);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "12");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "bold");
        el.setAttribute("color", "000040");
    }

    if (null == settingsFile.getRootElement().getChild(SETTING_HEADERFONT2)) {
        // create element for font
        Element el = new Element(SETTING_HEADERFONT2);
        settingsFile.getRootElement().addContent(el);
        el.setText(font);
        el.setAttribute("size", "11");
        el.setAttribute("style", "normal");
        el.setAttribute("weight", "bold");
        el.setAttribute("color", "000000");
    }
}

From source file:de.danielluedecke.zettelkasten.database.Synonyms.java

License:Open Source License

public void addSynonym(String[] synline) {
    // we need at least two elements in the array: the original word and at least one synonym
    if (null == synline || synline.length < 2) {
        return;/*w  w  w .ja  v a 2  s.c o  m*/
    }
    // if the synonyms-index-word already exists, don't add it...
    if (getSynonymPosition(synline[0]) != -1) {
        return;
    }
    // create new synonyms element
    Element synonym = new Element(Daten.ELEMENT_ENTRY);
    try {
        // trim spaces
        synline[0] = synline[0].trim();
        // set the original word as value-attribute to the "entry"-element
        synonym.setAttribute("indexword", synline[0]);
        // now go through the rest of the string-array
        for (int cnt = 1; cnt < synline.length; cnt++) {
            // create a sub-child "syn" for each further synonym
            Element syn = new Element("syn");
            // set text from string array
            syn.setText(synline[cnt].trim());
            // add child to synonym-element
            synonym.addContent(syn);
        }
        // finally, add new element to the document
        synonymsFile.getRootElement().addContent(synonym);
        setModified(true);
    } catch (IllegalNameException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
    } catch (IllegalDataException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
    } catch (IllegalAddException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
    }
}

From source file:de.danielluedecke.zettelkasten.database.Synonyms.java

License:Open Source License

/**
 * This method sets a new synonm-line, i.e. a synonym (as index-word) with its related synonyms.
 * The new synonyms have to passed as string-parameter {@code synline}.
 *
 * @param nr the number of the requested synonym, with a range from 0 to (getCount()-1)
 * @param synline a string-array with the first element being the index-word, and the following elements
 * being the related synonyms/*from  w ww .ja va 2  s  . co m*/
 */
public void setSynonymLine(int nr, String[] synline) {
    // get element
    Element synonym = retrieveElement(nr);
    // remove all child-content (i.e. all synonyms)
    synonym.removeContent();
    try {
        // set the original word as value-attribute to the "entry"-element
        synonym.setAttribute("indexword", synline[0]);
        // now go through the rest of the string-array
        for (int cnt = 1; cnt < synline.length; cnt++) {
            // create a sub-child "syn" for each further synonym
            Element syn = new Element("syn");
            // set text from string array
            syn.setText(synline[cnt]);
            // add child to synonym-element
            synonym.addContent(syn);
            setModified(true);
        }
    } catch (IllegalDataException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
    } catch (IllegalNameException ex) {
        Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
    }
}

From source file:de.danielluedecke.zettelkasten.database.Synonyms.java

License:Open Source License

/**
 * This method adds a new synonym {@code appendsyn} to an existing synonym-line {@code nr}.
 * @param nr the number of the existing synonym-line
 * @param appendsyn the new synonym that should be appended to that line.
 *///  www .  j  a v  a2s.c om
public void appendSingleSynonym(int nr, String appendsyn) {
    // get element
    Element synonym = retrieveElement(nr);
    // chekc for valid value
    if (synonym != null) {
        try {
            // create a sub-child "syn" for each further synonym
            Element syn = new Element("syn");
            // set text from string array
            syn.setText(appendsyn);
            // add child to synonym-element
            synonym.addContent(syn);
            setModified(true);
        } catch (IllegalAddException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        } catch (IllegalDataException ex) {
            Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage());
        }
    }
}