Example usage for org.jdom2 Element setAttribute

List of usage examples for org.jdom2 Element setAttribute

Introduction

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

Prototype

public Element setAttribute(final String name, final String value) 

Source Link

Document

This sets an attribute value for this element.

Usage

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>/*from   w  w  w. ja va2s  .  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.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.
 *//*from  ww w.ja va  2s  .  c  o 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.Settings.java

License:Open Source License

/**
 * Changes settings for the mainfont (the font used for the main-entry-textfield).
 * @param value (the new value for the font-characteristic)
 * @param what (indicates, which font-characteristic we want to have. use following constants:<br>
 * - FONTNAME<br>/*from w ww .java  2s . c o  m*/
 * - FONTSIZE<br>
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 */
public void setMainfont(String value, int what) {
    Element el = settingsFile.getRootElement().getChild(SETTING_MAINFONT);
    if (null == el) {
        el = new Element(SETTING_MAINFONT);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTNAME:
        el.setText(value);
        break;
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}

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

License:Open Source License

/**
 * Changes settings for the mainfont (the font used for the main-entry-textfield).
 * @param value (the new value for the font-characteristic)
 * @param what (indicates, which font-characteristic we want to have. use following constants:<br>
 * - FONTNAME<br>//from   w w  w .  j a  va  2 s .  c  o m
 * - FONTSIZE<br>
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 */
public void setAuthorFont(String value, int what) {
    Element el = settingsFile.getRootElement().getChild(SETTING_AUTHORFONT);
    if (null == el) {
        el = new Element(SETTING_AUTHORFONT);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTNAME:
        el.setText(value);
        break;
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}

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

License:Open Source License

/**
 * Changes settings for the mainfont (the font used for the main-entry-textfield).
 * @param value (the new value for the font-characteristic)
 * @param what (indicates, which font-characteristic we want to have. use following constants:<br>
 * - FONTNAME<br>//from   w  w w .ja  va 2 s.  c o m
 * - FONTSIZE<br>
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 */
public void setCodeFont(String value, int what) {
    Element el = settingsFile.getRootElement().getChild(SETTING_CODEFONT);
    if (null == el) {
        el = new Element(SETTING_CODEFONT);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTNAME:
        el.setText(value);
        break;
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}

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

License:Open Source License

/**
 * Changes settings for the mainfont (the font used for the main-entry-textfield).
 * @param value (the new value for the font-characteristic)
 * @param what (indicates, which font-characteristic we want to have. use following constants:<br>
 * - FONTNAME<br>//from www .j a v  a2s .  co  m
 * - FONTSIZE<br>
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 */
public void setRemarksFont(String value, int what) {
    Element el = settingsFile.getRootElement().getChild(SETTING_REMARKSFONT);
    if (null == el) {
        el = new Element(SETTING_REMARKSFONT);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTNAME:
        el.setText(value);
        break;
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}

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

License:Open Source License

/**
 * Changes settings for the desktop-window's main header font.
 * @param value (the new value for the font-characteristic)
 * @param what (indicates, which font-characteristic we want to have. use following constants:<br>
 * - FONTNAME<br>//www  .  j av  a 2s  . co m
 * - FONTSIZE<br>
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 */
public void setDesktopHeaderfont(String value, int what) {
    Element el = settingsFile.getRootElement().getChild(SETTING_DESKTOPHEADERFONT);
    if (null == el) {
        el = new Element(SETTING_DESKTOPHEADERFONT);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTNAME:
        el.setText(value);
        break;
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}

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

License:Open Source License

/**
 * Changes settings for the desktop-window's item header font (additional display items).
 * @param value (the new value for the font-characteristic)
 * @param what (indicates, which font-characteristic we want to have. use following constants:<br>
 * - FONTNAME<br>/*from   w  w w .j  ava2 s .c  om*/
 * - FONTSIZE<br>
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 */
public void setDesktopItemHeaderfont(String value, int what) {
    Element el = settingsFile.getRootElement().getChild(SETTING_DESKTOPITEMHEADERFONT);
    if (null == el) {
        el = new Element(SETTING_DESKTOPITEMHEADERFONT);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTNAME:
        el.setText(value);
        break;
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}

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

License:Open Source License

/**
 * Changes settings for the desktop-window's item font (additional display items).
 * @param value (the new value for the font-characteristic)
 * @param what (indicates, which font-characteristic we want to have. use following constants:<br>
 * - FONTNAME<br>/*from w ww  .ja  v  a 2  s .  co m*/
 * - FONTSIZE<br>
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 */
public void setDesktopItemfont(String value, int what) {
    Element el = settingsFile.getRootElement().getChild(SETTING_DESKTOPITEMFONT);
    if (null == el) {
        el = new Element(SETTING_DESKTOPITEMFONT);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTNAME:
        el.setText(value);
        break;
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}

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

License:Open Source License

/**
 * Changes settings for the style of highlighting the search terms in the search result window.
 * @param value the new value for the style-characteristic
 * @param what indicates, which style-characteristic we want to have. use following constants:<br>
 * - FONTSIZE<br>// ww w .  j a  va 2s .  c  o  m
 * - FONTCOLOR<br>
 * - FONTSTYLE<br>
 * - FONTWEIGHT<br>
 * @param style
 */
public void setHighlightSearchStyle(String value, int what, int style) {
    String hs_style;
    switch (style) {
    case HtmlUbbUtil.HIGHLIGHT_STYLE_SEARCHRESULTS:
        hs_style = SETTING_HIGHLIGHTSEARCHSTYLE;
        break;
    case HtmlUbbUtil.HIGHLIGHT_STYLE_KEYWORDS:
        hs_style = SETTING_HIGHLIGHTKEYWORDSTYLE;
        break;
    case HtmlUbbUtil.HIGHLIGHT_STYLE_LIVESEARCH:
        hs_style = SETTING_HIGHLIGHTLIVESEARCHSTYLE;
        break;
    default:
        hs_style = SETTING_HIGHLIGHTSEARCHSTYLE;
        break;
    }
    Element el = settingsFile.getRootElement().getChild(hs_style);
    if (null == el) {
        el = new Element(hs_style);
        settingsFile.getRootElement().addContent(el);
    }
    switch (what) {
    case FONTSIZE:
        el.setAttribute("size", value);
        break;
    case FONTCOLOR:
        el.setAttribute("color", value);
        break;
    case FONTSTYLE:
        el.setAttribute("style", value);
        break;
    case FONTWEIGHT:
        el.setAttribute("weight", value);
        break;
    }
}