List of usage examples for org.jdom2 Element setAttribute
public Element setAttribute(final String name, final String value)
This sets an attribute value for this element.
From source file:de.danielluedecke.zettelkasten.database.Settings.java
License:Open Source License
/** * Changes settings for the desktop-window's commentfont. * @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>/*w ww . j a v a 2 s . c o m*/ * - FONTSIZE<br> * - FONTCOLOR<br> * - FONTSTYLE<br> * - FONTWEIGHT<br> */ public void setDesktopCommentfont(String value, int what) { Element el = settingsFile.getRootElement().getChild(SETTING_DESKTOPCOMMENTFONT); if (null == el) { el = new Element(SETTING_DESKTOPCOMMENTFONT); 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 titlefont (the font used for the main-entry's title). * @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 v a2s . c om*/ * - FONTSIZE<br> * - FONTCOLOR<br> * - FONTSTYLE<br> * - FONTWEIGHT<br> */ public void setTitleFont(String value, int what) { Element el = settingsFile.getRootElement().getChild(SETTING_TITLEFONT); if (null == el) { el = new Element(SETTING_TITLEFONT); 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 titlefont (the font used for the main-entry's title). * @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. j a va2 s.c o m * - FONTSIZE<br> * - FONTCOLOR<br> * - FONTSTYLE<br> * - FONTWEIGHT<br> */ public void setAppendixHeaderFont(String value, int what) { Element el = settingsFile.getRootElement().getChild(SETTING_APPENDIXHEADERFONT); if (null == el) { el = new Element(SETTING_APPENDIXHEADERFONT); 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 header-1-font (the font used for the main-entry's 1st heading-tags). * @param what (indicates, which font-characteristic we want to have. use following constants:<br> * @param value (the new value for the font-characteristic) * - FONTNAME<br>/* w w w . j av a 2 s.c o m*/ * - FONTSIZE<br> * - FONTCOLOR<br> * - FONTSTYLE<br> * - FONTWEIGHT<br> */ public void setHeaderfont1(String value, int what) { Element el = settingsFile.getRootElement().getChild(SETTING_HEADERFONT1); if (null == el) { el = new Element(SETTING_HEADERFONT1); 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 header-2-font (the font used for the main-entry's 2nd heading-tags). * @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 ava 2 s. co m*/ * - FONTSIZE<br> * - FONTCOLOR<br> * - FONTSTYLE<br> * - FONTWEIGHT<br> */ public void setHeaderfont2(String value, int what) { Element el = settingsFile.getRootElement().getChild(SETTING_HEADERFONT2); if (null == el) { el = new Element(SETTING_HEADERFONT2); 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 header-2-font (the font used for the main-entry's 2nd heading-tags). * @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>// ww w .ja v a 2 s .c o m * - FONTSIZE<br> * - FONTCOLOR<br> * - FONTSTYLE<br> * - FONTWEIGHT<br> */ public void setQuoteFont(String value, int what) { Element el = settingsFile.getRootElement().getChild(SETTING_QUOTEFONT); if (null == el) { el = new Element(SETTING_QUOTEFONT); 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; } }
From source file:de.danielluedecke.zettelkasten.database.Settings.java
License:Open Source License
/** * Changes settings for the header-2-font (the font used for the main-entry's 2nd heading-tags). * @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 v a 2s .co m*/ * - FONTSIZE<br> * - FONTCOLOR<br> * - FONTSTYLE<br> * - FONTWEIGHT<br> */ public void setEntryHeadeFont(String value, int what) { Element el = settingsFile.getRootElement().getChild(SETTING_ENTRYHEADERFONT); if (null == el) { el = new Element(SETTING_ENTRYHEADERFONT); 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; } }
From source file:de.danielluedecke.zettelkasten.database.StenoData.java
License:Open Source License
/** * Adds a new pair of steno/long words to the document * * @param abbr the short, steno-abbreviation of the word * @param longword the long, original version of the word * @return {@code true} if element was successfully addes, false if {@code stenoword} already existed *///from w w w . j a v a 2 s. c o m public boolean addElement(String abbr, String longword) { // check for existence if (exists(abbr)) { return false; } // if it doesn't already exist, create new element Element e = new Element(Daten.ELEMENT_ENTRY); try { // set id-attribute e.setAttribute("id", abbr); // set content e.setText(longword); // and add it to the document steno.getRootElement().addContent(e); } catch (IllegalAddException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); return false; } catch (IllegalDataException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); return false; } // return success return true; }
From source file:de.danielluedecke.zettelkasten.database.Synonyms.java
License:Open Source License
public void addSynonym(String[] synline) { // we need at least two elements in the array: the original word and at least one synonym if (null == synline || synline.length < 2) { return;//from w w w. j av a 2 s . c om } // if the synonyms-index-word already exists, don't add it... if (getSynonymPosition(synline[0]) != -1) { return; } // create new synonyms element Element synonym = new Element(Daten.ELEMENT_ENTRY); try { // trim spaces synline[0] = synline[0].trim(); // set the original word as value-attribute to the "entry"-element synonym.setAttribute("indexword", synline[0]); // now go through the rest of the string-array for (int cnt = 1; cnt < synline.length; cnt++) { // create a sub-child "syn" for each further synonym Element syn = new Element("syn"); // set text from string array syn.setText(synline[cnt].trim()); // add child to synonym-element synonym.addContent(syn); } // finally, add new element to the document synonymsFile.getRootElement().addContent(synonym); setModified(true); } catch (IllegalNameException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } catch (IllegalDataException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } catch (IllegalAddException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } }
From source file:de.danielluedecke.zettelkasten.database.Synonyms.java
License:Open Source License
/** * This method sets a new synonm-line, i.e. a synonym (as index-word) with its related synonyms. * The new synonyms have to passed as string-parameter {@code synline}. * * @param nr the number of the requested synonym, with a range from 0 to (getCount()-1) * @param synline a string-array with the first element being the index-word, and the following elements * being the related synonyms//from w ww. ja v a 2 s .c o m */ public void setSynonymLine(int nr, String[] synline) { // get element Element synonym = retrieveElement(nr); // remove all child-content (i.e. all synonyms) synonym.removeContent(); try { // set the original word as value-attribute to the "entry"-element synonym.setAttribute("indexword", synline[0]); // now go through the rest of the string-array for (int cnt = 1; cnt < synline.length; cnt++) { // create a sub-child "syn" for each further synonym Element syn = new Element("syn"); // set text from string array syn.setText(synline[cnt]); // add child to synonym-element synonym.addContent(syn); setModified(true); } } catch (IllegalDataException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } catch (IllegalNameException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } }