List of usage examples for org.jdom2 Element setText
public Element setText(final String text)
From source file:de.danielluedecke.zettelkasten.database.DesktopData.java
License:Open Source License
/** * Returns one of the three notes that can be saved with the desktop. * @param nr the number of the notes, either 1, 2 or 3 * @param note the content of the notes-textfield *///from w w w . j av a 2 s . co m public void setDesktopNotes(int nr, String note) { // check for valid parameter if (nr >= 1 && nr <= 3 && note != null) { // first check, whether the note has been modified or not. therefor, retrieve // current note-text and compare it to the parameter String currentnote = getDesktopNotes(nr); // if notes don't equal, go on... if (!currentnote.equals(note)) { // get all children from deskopNotes, since we need to find the right // desktop-element first... List<Element> elementList = desktopNotes.getRootElement().getChildren(); // create an iterartor Iterator<Element> it = elementList.iterator(); // go through all desktop-elements of the desktopNores-file while (it.hasNext()) { // retrieve element Element desk = it.next(); // get name sttribute String att = desk.getAttributeValue("name"); // check for desktop-name if (att != null && att.equals(getCurrentDesktopName())) { // retrieve notes-element Element el = desk.getChild("notes" + String.valueOf(nr)); // set note text el.setText(note); // change modify-tag setModified(true); } } } } }
From source file:de.danielluedecke.zettelkasten.database.DesktopData.java
License:Open Source License
/** * This method adds a modified entry to the {@link #modifiedEntries modifiedEntries}-Document, * in case the user modifies an entry on the desktop, while the original content of that entry * in the main database should be left unchanged. * * @param timestamp a unique timestamp which is associated to the entry that is modified, so we * can later easily find the related modified content. * @param content the modified content itself. * @return {@code true} if entry was successfully saved, {@code false} if an error occured. *//*from ww w.j a v a 2 s . co m*/ public boolean addModifiedEntry(String timestamp, String content) { // check for valid parameters if (null == timestamp || timestamp.isEmpty()) return false; if (null == content) content = ""; // first check, whether modified entry already exists. this may // occur, when importing archived desktop-files if (null == retrieveModifiedEntryElementFromTimestamp(timestamp)) { // create a new element Element entry = new Element(ELEMENT_ENTRY); try { // set timestamp-attribute entry.setAttribute(ATTR_TIMESTAMP, timestamp); // add content-string entry.setText(content); // add element to XML-document modifiedEntries.getRootElement().addContent(entry); // change modified-flag setModified(true); } catch (IllegalNameException ex) { Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage()); return false; } catch (IllegalDataException ex) { Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage()); return false; } catch (IllegalAddException ex) { Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage()); return false; } } return true; }
From source file:de.danielluedecke.zettelkasten.database.DesktopData.java
License:Open Source License
/** * This method changes the content of a modified entry in the {@link #modifiedEntries modifiedEntries}-Document. * Modified entries are entries that the user modifies on the desktop, while the original content of that entry * in the main database should be left unchanged. * * @param timestamp a unique timestamp which is associated to the entry that is modified, so we * can later easily find the related modified content. * @param content the modified content itself. * @return {@code true} if the entry was successfully changed, {@code false} if an error occured. *//*from w ww .jav a 2 s . co m*/ public boolean changeEntry(String timestamp, String content) { // retrieve entry-element that should be changed Element entry = retrieveModifiedEntryElementFromTimestamp(timestamp); // check for valid element if (null == entry) { // if we have no such element, add the modified entry return addModifiedEntry(timestamp, content); } else { try { // else change the content of that element entry.setText(content); // and change modified flag setModified(true); } catch (IllegalDataException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); return false; } } return true; }
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. */// www. j a v a 2 s .c om 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>/*from w w w . j a v a 2 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 ww w . j a v a 2 s. c om * @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
/** * Add a new recent document to the position {@code nr} in the list of recent documents. * @param nr the number of the requested recent document. use a value from 1 to {@link #recentDocCount recentDocCount}. * @param fp the filepath to the recently used document as string *///www. j av a2 s . c om public void setRecentDoc(int nr, String fp) { // check for valid parameter if (null == fp) return; // retrieve element Element el = settingsFile.getRootElement().getChild(SETTING_RECENT_DOC + String.valueOf(nr)); // if element exists... if (el != null) { // add filepath el.setText(fp); } else { // create a filepath-element el = new Element(SETTING_RECENT_DOC + String.valueOf(nr)); // add filepath el.setText(fp); // and add it to the document settingsFile.getRootElement().addContent(el); } }
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 w ww.j a v a 2 s. 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
/** * Sets the filepath of the currently used main datafile * @param fp (the filepath of the currently used main datafile) *//*from w w w . j a v a2s . c o m*/ public void setFilePath(File fp) { // try to find filepath-element Element el = settingsFile.getRootElement().getChild(SETTING_FILEPATH); if (null == el) { el = new Element(SETTING_FILEPATH); settingsFile.getRootElement().addContent(el); } // set new file path which should be now relative to the zkn-path el.setText((null == fp) ? "" : fp.toString()); }
From source file:de.danielluedecke.zettelkasten.database.Settings.java
License:Open Source License
/** * Sets the filepath of the last used image path when inserting images to a new entry * @param fp the filepath of the last opened image directory *//*from w ww . j a va 2 s. com*/ public void setLastOpenedImageDir(File fp) { // try to find filepath-element Element el = settingsFile.getRootElement().getChild(SETTING_LASTOPENEDIMAGEDIR); if (null == el) { el = new Element(SETTING_LASTOPENEDIMAGEDIR); settingsFile.getRootElement().addContent(el); } // set new file path which should be now relative to the zkn-path el.setText((null == fp) ? "" : fp.toString()); }