List of usage examples for org.jdom2 Element setText
public Element setText(final String text)
From source file:de.danielluedecke.zettelkasten.database.AcceleratorKeys.java
License:Open Source License
/** * This methos inits the accelerator table of the new entry window's menus. We separate * the initialisation of the accelerator tables for each window to keep an better * overiew.//from w ww. j av a2 s . c o m */ private void initNewEntryKeys() { // this is our element variable which will be used below to set all the child elements Element acckey; // now we have to go through an endless list of accelerator keys. it is important // that the attribute values have exactly the same spelling like the actions' names // which can be found in the properties-files (resources). This ensures we can easily // assign accelerator keys to actions: // // javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(zettelkasten.ZettelkastenApp.class).getContext().getActionMap(ZettelkastenView.class, this); // AbstractAction ac = (AbstractAction) actionMap.get(CAcceleratorKey.getActionName()); // KeyStroke ks = KeyStroke.getKeyStroke(CAcceleratorKey.getAccelerator()); // ac.putValue(AbstractAction.ACCELERATOR_KEY, ks); // // The actions of the new entry window's file menu // // the accelerator for the "closeWindow" action if (!findElement(NEWENTRYKEYS, "closeWindow")) { acckey = new Element("key"); acckey.setAttribute("action", "closeWindow"); acckey.setText(mask + " W"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "applyChanges" action if (!findElement(NEWENTRYKEYS, "applyChanges")) { acckey = new Element("key"); acckey.setAttribute("action", "applyChanges"); acckey.setText(mask + " shift S"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "retrieveKeywordsFromDisplayedEntry" action if (!findElement(NEWENTRYKEYS, "retrieveKeywordsFromDisplayedEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "retrieveKeywordsFromDisplayedEntry"); acckey.setText(mask + " alt G"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // // The actions of the new entry window's edit menu // // the accelerator for the "selecteAllText" action if (!findElement(NEWENTRYKEYS, "selecteAllText")) { acckey = new Element("key"); acckey.setAttribute("action", "selecteAllText"); acckey.setText(mask + " A"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "addSegmentFromQuickList" action if (!findElement(NEWENTRYKEYS, "addSegmentFromQuickList")) { acckey = new Element("key"); acckey.setAttribute("action", "addSegmentFromQuickList"); acckey.setText(mask + " shift G"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "addKeywordFromSelection" action if (!findElement(NEWENTRYKEYS, "addKeywordFromSelection")) { acckey = new Element("key"); acckey.setAttribute("action", "addKeywordFromSelection"); acckey.setText(mask + " shift K"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "addTitleFromSelection" action if (!findElement(NEWENTRYKEYS, "addTitleFromSelection")) { acckey = new Element("key"); acckey.setAttribute("action", "addTitleFromSelection"); acckey.setText(mask + " alt U"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "addTitleFromFirstLine" action if (!findElement(NEWENTRYKEYS, "addTitleFromFirstLine")) { acckey = new Element("key"); acckey.setAttribute("action", "addTitleFromFirstLine"); acckey.setText(mask + " shift U"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "undoAction" action if (!findElement(NEWENTRYKEYS, "undoAction")) { acckey = new Element("key"); acckey.setAttribute("action", "undoAction"); acckey.setText(mask + " Z"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "redoAction" action if (!findElement(NEWENTRYKEYS, "redoAction")) { acckey = new Element("key"); acckey.setAttribute("action", "redoAction"); acckey.setText(mask + " shift Z"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "replace" action if (!findElement(NEWENTRYKEYS, "replace")) { acckey = new Element("key"); acckey.setAttribute("action", "replace"); acckey.setText(mask + " H"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // // The actions of the new entry window's insert menu // // the accelerator for the "addAuthorFromMenu" action if (!findElement(NEWENTRYKEYS, "addAuthorFromMenu")) { acckey = new Element("key"); acckey.setAttribute("action", "addAuthorFromMenu"); acckey.setText(mask + " shift L"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertFootnote" action if (!findElement(NEWENTRYKEYS, "insertFootnote")) { acckey = new Element("key"); acckey.setAttribute("action", "insertFootnote"); acckey.setText(mask + " shift N"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertImage" action if (!findElement(NEWENTRYKEYS, "insertImage")) { acckey = new Element("key"); acckey.setAttribute("action", "insertImage"); acckey.setText(mask + " shift I"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertTable" action if (!findElement(NEWENTRYKEYS, "insertTable")) { acckey = new Element("key"); acckey.setAttribute("action", "insertTable"); acckey.setText(mask + " shift T"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertHyperlink" action if (!findElement(NEWENTRYKEYS, "insertHyperlink")) { acckey = new Element("key"); acckey.setAttribute("action", "insertHyperlink"); acckey.setText(mask + " K"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertManualLink" action if (!findElement(NEWENTRYKEYS, "insertManualLink")) { acckey = new Element("key"); acckey.setAttribute("action", "insertManualLink"); acckey.setText(mask + " shift M"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertAttachment" action if (!findElement(NEWENTRYKEYS, "insertAttachment")) { acckey = new Element("key"); acckey.setAttribute("action", "insertAttachment"); acckey.setText(mask + " shift A"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertSymbol" action if (!findElement(NEWENTRYKEYS, "insertSymbol")) { acckey = new Element("key"); acckey.setAttribute("action", "insertSymbol"); acckey.setText(mask + " alt S"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertForm" action if (!findElement(NEWENTRYKEYS, "insertForm")) { acckey = new Element("key"); acckey.setAttribute("action", "insertForm"); acckey.setText(mask + " shift F"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "insertManualTimestamp" action if (!findElement(NEWENTRYKEYS, "insertManualTimestamp")) { acckey = new Element("key"); acckey.setAttribute("action", "insertManualTimestamp"); acckey.setText(mask + " F7"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // // The actions of the new entry window's format menu // // the accelerator for the "formatBold" action if (!findElement(NEWENTRYKEYS, "formatBold")) { acckey = new Element("key"); acckey.setAttribute("action", "formatBold"); acckey.setText(mask + " B"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatItalic" action if (!findElement(NEWENTRYKEYS, "formatItalic")) { acckey = new Element("key"); acckey.setAttribute("action", "formatItalic"); acckey.setText(mask + " I"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatUnderline" action if (!findElement(NEWENTRYKEYS, "formatUnderline")) { acckey = new Element("key"); acckey.setAttribute("action", "formatUnderline"); acckey.setText(mask + " U"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatStrikeThrough" action if (!findElement(NEWENTRYKEYS, "formatStrikeThrough")) { acckey = new Element("key"); acckey.setAttribute("action", "formatStrikeThrough"); acckey.setText(mask + " D"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatSup" action if (!findElement(NEWENTRYKEYS, "formatSup")) { acckey = new Element("key"); acckey.setAttribute("action", "formatSup"); acckey.setText(mask + " " + pluskey); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatSub" action if (!findElement(NEWENTRYKEYS, "formatSub")) { acckey = new Element("key"); acckey.setAttribute("action", "formatSub"); acckey.setText(ctrlkey + " " + numbersign); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatHeading1" action if (!findElement(NEWENTRYKEYS, "formatHeading1")) { acckey = new Element("key"); acckey.setAttribute("action", "formatHeading1"); acckey.setText(mask + " shift H"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatHeading2" action if (!findElement(NEWENTRYKEYS, "formatHeading2")) { acckey = new Element("key"); acckey.setAttribute("action", "formatHeading2"); acckey.setText(mask + " alt H"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatCite" action if (!findElement(NEWENTRYKEYS, "formatCite")) { acckey = new Element("key"); acckey.setAttribute("action", "formatCite"); acckey.setText(mask + " shift C"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatCode" action if (!findElement(NEWENTRYKEYS, "formatCode")) { acckey = new Element("key"); acckey.setAttribute("action", "formatCode"); acckey.setText(mask + " alt C"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatFont" action if (!findElement(NEWENTRYKEYS, "formatFont")) { acckey = new Element("key"); acckey.setAttribute("action", "formatFont"); acckey.setText(mask + " alt F"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatQuote" action if (!findElement(NEWENTRYKEYS, "formatQuote")) { acckey = new Element("key"); acckey.setAttribute("action", "formatQuote"); acckey.setText(mask + " shift 2"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "alignCenter" action if (!findElement(NEWENTRYKEYS, "alignCenter")) { acckey = new Element("key"); acckey.setAttribute("action", "alignCenter"); acckey.setText(mask + " E"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "alignLeft" action if (!findElement(NEWENTRYKEYS, "alignLeft")) { acckey = new Element("key"); acckey.setAttribute("action", "alignLeft"); acckey.setText(mask + " L"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "alignRight" action if (!findElement(NEWENTRYKEYS, "alignRight")) { acckey = new Element("key"); acckey.setAttribute("action", "alignRight"); acckey.setText(mask + " R"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "alignMargin" action if (!findElement(NEWENTRYKEYS, "alignMargin")) { acckey = new Element("key"); acckey.setAttribute("action", "alignMargin"); acckey.setText(mask + " shift R"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatHighlight" action if (!findElement(NEWENTRYKEYS, "formatHighlight")) { acckey = new Element("key"); acckey.setAttribute("action", "formatHighlight"); acckey.setText(mask + " M"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatList" action if (!findElement(NEWENTRYKEYS, "formatList")) { acckey = new Element("key"); acckey.setAttribute("action", "formatList"); acckey.setText(mask + " alt L"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatList" action if (!findElement(NEWENTRYKEYS, "formatOrderedList")) { acckey = new Element("key"); acckey.setAttribute("action", "formatOrderedList"); acckey.setText(mask + " alt N"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "formatColor" action if (!findElement(NEWENTRYKEYS, "formatColor")) { acckey = new Element("key"); acckey.setAttribute("action", "formatColor"); acckey.setText(mask + " T"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // // The actions of the new entry window's window menu // // the accelerator for the "setFocusToEditPane" action if (!findElement(NEWENTRYKEYS, "setFocusToEditPane")) { acckey = new Element("key"); acckey.setAttribute("action", "setFocusToEditPane"); acckey.setText(mask + " F2"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "setFocusToKeywordList" action if (!findElement(NEWENTRYKEYS, "setFocusToKeywordList")) { acckey = new Element("key"); acckey.setAttribute("action", "setFocusToKeywordList"); acckey.setText(mask + " F3"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } // the accelerator for the "setFocusToAuthorList" action if (!findElement(NEWENTRYKEYS, "setFocusToAuthorList")) { acckey = new Element("key"); acckey.setAttribute("action", "setFocusToAuthorList"); acckey.setText(mask + " F4"); acceleratorKeysNewEntry.getRootElement().addContent(acckey); } }
From source file:de.danielluedecke.zettelkasten.database.AcceleratorKeys.java
License:Open Source License
/** * This methos inits the accelerator table of the desktop window's menus. We separate * the initialisation of the accelerator tables for each window to keep an better * overiew.//from ww w. j a va2 s . c om */ private void initDesktopKeys() { // this is our element variable which will be used below to set all the child elements Element acckey; // now we have to go through an endless list of accelerator keys. it is important // that the attribute values have exactly the same spelling like the actions' names // which can be found in the properties-files (resources). This ensures we can easily // assign accelerator keys to actions: // // javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(zettelkasten.ZettelkastenApp.class).getContext().getActionMap(ZettelkastenView.class, this); // AbstractAction ac = (AbstractAction) actionMap.get(CAcceleratorKey.getActionName()); // KeyStroke ks = KeyStroke.getKeyStroke(CAcceleratorKey.getAccelerator()); // ac.putValue(AbstractAction.ACCELERATOR_KEY, ks); // // The actions of the desktop window's file menu // // the accelerator for the "newDesktop" action if (!findElement(DESKTOPKEYS, "newDesktop")) { acckey = new Element("key"); acckey.setAttribute("action", "newDesktop"); acckey.setText(mask + " shift N"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "addBullet" action if (!findElement(DESKTOPKEYS, "addBullet")) { acckey = new Element("key"); acckey.setAttribute("action", "addBullet"); acckey.setText(mask + " B"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "addEntry" action if (!findElement(DESKTOPKEYS, "addEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "addEntry"); acckey.setText(mask + " alt N"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "addLuhmann" action if (!findElement(DESKTOPKEYS, "addLuhmann")) { acckey = new Element("key"); acckey.setAttribute("action", "addLuhmann"); acckey.setText(mask + " alt I"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "insertEntry" action if (!findElement(DESKTOPKEYS, "insertEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "insertEntry"); acckey.setText(mask + " N"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "exportDesktop" action if (!findElement(DESKTOPKEYS, "exportDesktop")) { acckey = new Element("key"); acckey.setAttribute("action", "exportDesktop"); acckey.setText(mask + " shift E"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "exportMultipleDesktop" action if (!findElement(DESKTOPKEYS, "exportMultipleDesktop")) { acckey = new Element("key"); acckey.setAttribute("action", "exportMultipleDesktop"); acckey.setText(mask + " shift X"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "printContent" action if (!findElement(DESKTOPKEYS, "printContent")) { acckey = new Element("key"); acckey.setAttribute("action", "printContent"); acckey.setText(mask + " P"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "closeWindow" action if (!findElement(DESKTOPKEYS, "closeWindow")) { acckey = new Element("key"); acckey.setAttribute("action", "closeWindow"); acckey.setText(mask + " W"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // // The actions of the desktop window's edit menu // // the accelerator for the "cutNode" action if (!findElement(DESKTOPKEYS, "cutNode")) { acckey = new Element("key"); acckey.setAttribute("action", "cutNode"); acckey.setText(mask + " X"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "copyNode" action if (!findElement(DESKTOPKEYS, "copyNode")) { acckey = new Element("key"); acckey.setAttribute("action", "copyNode"); acckey.setText(mask + " C"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "pasteNode" action if (!findElement(DESKTOPKEYS, "pasteNode")) { acckey = new Element("key"); acckey.setAttribute("action", "pasteNode"); acckey.setText(mask + " V"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "editEntry" action if (!findElement(DESKTOPKEYS, "editEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "editEntry"); acckey.setText(mask + " alt E"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "modifiyEntry" action if (!findElement(DESKTOPKEYS, "modifiyEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "modifiyEntry"); acckey.setText(mask + " E"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "applyModificationsToOriginalEntry" action if (!findElement(DESKTOPKEYS, "applyModificationsToOriginalEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "applyModificationsToOriginalEntry"); acckey.setText(mask + " shift P"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "applyAllModificationsToOriginalEntries" action if (!findElement(DESKTOPKEYS, "applyAllModificationsToOriginalEntries")) { acckey = new Element("key"); acckey.setAttribute("action", "applyAllModificationsToOriginalEntries"); acckey.setText(mask + " alt P"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "moveNodeUp" action if (!findElement(DESKTOPKEYS, "moveNodeUp")) { acckey = new Element("key"); acckey.setAttribute("action", "moveNodeUp"); acckey.setText(mask + " UP"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "moveNodeDown" action if (!findElement(DESKTOPKEYS, "moveNodeDown")) { acckey = new Element("key"); acckey.setAttribute("action", "moveNodeDown"); acckey.setText(mask + " DOWN"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "renameBullet" action if (!findElement(DESKTOPKEYS, "renameBullet")) { acckey = new Element("key"); acckey.setAttribute("action", "renameBullet"); acckey.setText(renamekey); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "commentNode" action if (!findElement(DESKTOPKEYS, "commentNode")) { acckey = new Element("key"); acckey.setAttribute("action", "commentNode"); acckey.setText(mask + " K"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "deleteNode" action if (!findElement(DESKTOPKEYS, "deleteNode")) { acckey = new Element("key"); acckey.setAttribute("action", "deleteNode"); acckey.setText(delkey); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // // The actions of the desktop window's find menu // // the accelerator for the "findLive" action if (!findElement(DESKTOPKEYS, "findLive")) { acckey = new Element("key"); acckey.setAttribute("action", "findLive"); acckey.setText(mask + " shift F"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "findLiveNext" action if (!findElement(DESKTOPKEYS, "findLiveNext")) { acckey = new Element("key"); acckey.setAttribute("action", "findLiveNext"); acckey.setText(mask + " G"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // the accelerator for the "findLivePrev" action if (!findElement(DESKTOPKEYS, "findLivePrev")) { acckey = new Element("key"); acckey.setAttribute("action", "findLivePrev"); acckey.setText(mask + " shift G"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } // // The actions of the desktop window's view menu // // the accelerator for the "updateView" action if (!findElement(DESKTOPKEYS, "updateView")) { acckey = new Element("key"); acckey.setAttribute("action", "updateView"); acckey.setText("F5"); acceleratorKeysDesktop.getRootElement().addContent(acckey); } }
From source file:de.danielluedecke.zettelkasten.database.AcceleratorKeys.java
License:Open Source License
/** * This methos inits the accelerator table of the desktop window's menus. We separate * the initialisation of the accelerator tables for each window to keep an better * overiew.//from ww w . j a va2s . c om */ private void initSearchResultsKeys() { // this is our element variable which will be used below to set all the child elements Element acckey; // now we have to go through an endless list of accelerator keys. it is important // that the attribute values have exactly the same spelling like the actions' names // which can be found in the properties-files (resources). This ensures we can easily // assign accelerator keys to actions: // // javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(zettelkasten.ZettelkastenApp.class).getContext().getActionMap(ZettelkastenView.class, this); // AbstractAction ac = (AbstractAction) actionMap.get(CAcceleratorKey.getActionName()); // KeyStroke ks = KeyStroke.getKeyStroke(CAcceleratorKey.getAccelerator()); // ac.putValue(AbstractAction.ACCELERATOR_KEY, ks); // // The actions of the search results window's edit menu // // the accelerator for the "removeSearchResult" action if (!findElement(SEARCHRESULTSKEYS, "removeSearchResult")) { acckey = new Element("key"); acckey.setAttribute("action", "removeSearchResult"); acckey.setText(mask + " shift " + delkey); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "removeAllSearchResults" action if (!findElement(SEARCHRESULTSKEYS, "removeAllSearchResults")) { acckey = new Element("key"); acckey.setAttribute("action", "removeAllSearchResults"); acckey.setText(mask + " alt shift " + delkey); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "exportEntries" action if (!findElement(SEARCHRESULTSKEYS, "exportEntries")) { acckey = new Element("key"); acckey.setAttribute("action", "exportEntries"); acckey.setText(mask + " shift E"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "closeWindow" action if (!findElement(SEARCHRESULTSKEYS, "closeWindow")) { acckey = new Element("key"); acckey.setAttribute("action", "closeWindow"); acckey.setText(mask + " W"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // // The actions of the search results window's edit menu // // the accelerator for the "selectAll" action if (!findElement(SEARCHRESULTSKEYS, "selectAll")) { acckey = new Element("key"); acckey.setAttribute("action", "selectAll"); acckey.setText(mask + " A"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "editEntry" action if (!findElement(SEARCHRESULTSKEYS, "editEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "editEntry"); acckey.setText(mask + " E"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "findAndReplace" action if (!findElement(SEARCHRESULTSKEYS, "findAndReplace")) { acckey = new Element("key"); acckey.setAttribute("action", "findAndReplace"); acckey.setText(mask + " R"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "removeEntry" action if (!findElement(SEARCHRESULTSKEYS, "removeEntry")) { acckey = new Element("key"); acckey.setAttribute("action", "removeEntry"); acckey.setText(delkey); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "addToManLinks" action if (!findElement(SEARCHRESULTSKEYS, "addToManLinks")) { acckey = new Element("key"); acckey.setAttribute("action", "addToManLinks"); acckey.setText(mask + " alt L"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "addToLuhmann" action if (!findElement(SEARCHRESULTSKEYS, "addToLuhmann")) { acckey = new Element("key"); acckey.setAttribute("action", "addToLuhmann"); acckey.setText(mask + " alt I"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "addToBookmarks" action if (!findElement(SEARCHRESULTSKEYS, "addToBookmarks")) { acckey = new Element("key"); acckey.setAttribute("action", "addToBookmarks"); acckey.setText(mask + " B"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "addToDesktop" action if (!findElement(SEARCHRESULTSKEYS, "addToDesktop")) { acckey = new Element("key"); acckey.setAttribute("action", "addToDesktop"); acckey.setText("F9"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "showEntryInDesktop" action if (!findElement(SEARCHRESULTSKEYS, "showEntryInDesktop")) { acckey = new Element("key"); acckey.setAttribute("action", "showEntryInDesktop"); acckey.setText(mask + " F9"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "toggleHighlightResults" action if (!findElement(SEARCHRESULTSKEYS, "toggleHighlightResults")) { acckey = new Element("key"); acckey.setAttribute("action", "toggleHighlightResults"); acckey.setText("F7"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } // the accelerator for the "switchLayout" action if (!findElement(SEARCHRESULTSKEYS, "switchLayout")) { acckey = new Element("key"); acckey.setAttribute("action", "switchLayout"); acckey.setText(mask + " F7"); acceleratorKeysSearchResults.getRootElement().addContent(acckey); } }
From source file:de.danielluedecke.zettelkasten.database.AcceleratorKeys.java
License:Open Source License
/** * This method sets an accelerator key of an related action. To change an accelerator key, * provide the action's name and the keystroke-value as string parameters. furthermore, we * have to tell the method, to which file the changes should be applied (param what). * /*from w w w. j ava 2s. c o m*/ * Following constants should be used as parameters:<br> * MAINKEYS<br> * NEWENTRYKEYS<br> * DESKTOPKEYS<br> * SEARCHRESULTSKEYS<br> * * @param what (uses constants, see global field definition at top of source) * @param action (the action's name, as string, e.g. "newEntry") * @param keystroke (the keystroke, e.g. "ctrl N" (win/linux) or "meta O" (mac) */ public void setAccelerator(int what, String action, String keystroke) { // create a list of all elements from the xml file try { List<?> elementList = getDocument(what).getRootElement().getContent(); // and an iterator for the loop below Iterator<?> iterator = elementList.iterator(); // counter for the return value if a found element attribute matches the parameter int cnt = 1; // iterate loop while (iterator.hasNext()) { // retrieve each single element Element acckey = (Element) iterator.next(); // if action-attribute matches the parameter string... if (action.equals(acckey.getAttributeValue("action"))) { // ...set the new keystroke acckey.setText(keystroke); // and leave method return; } // else increase counter cnt++; } } catch (IllegalStateException e) { Constants.zknlogger.log(Level.WARNING, e.getLocalizedMessage()); } }
From source file:de.danielluedecke.zettelkasten.database.AutoKorrektur.java
License:Open Source License
/** * Adds a new pair of false/correct words to the document * // w w w. j a v a 2 s .co m * @param falsch the wrong or mispelled word * @param richtig the correct writing * @return {@code true} if element was successfully addes, {@code false} if "falsch" already existed or * one of the parameters were invalid */ public boolean addElement(String falsch, String richtig) { // check for minimum length if (null == falsch || falsch.length() < 2 || null == richtig || richtig.length() < 2) { return false; } // check for existence if (exists(falsch)) { 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", falsch); // set content e.setText(richtig); // and add it to the document autokorrektur.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.Bookmarks.java
License:Open Source License
/** * This method sets the comment of a given bookmark "nr". * /*from w w w . j ava 2 s . c o m*/ * @param nr the bookmark-number of which comment should be changes * @param c * @return false if element/bookmark does not exist, true if comment was successfully changed */ public boolean setComment(int nr, String c) { // retrieve the bookmark-element Element bm = retrieveBookmarkElement(nr); // if element does not exist, return false if (null == bm) { return false; } // else set comment bm.setText(c); // change modified-state setModified(true); // everythings OK return true; }
From source file:de.danielluedecke.zettelkasten.database.Bookmarks.java
License:Open Source License
/** * This method changes the name of the category at position "pos" * /*w w w .j av a2 s . co m*/ * @param pos the position of the requested category * @param name the new name of the category */ public void setCategory(int pos, String name) { // retrieve category element Element cat = retrieveCategoryElement(pos); // set new category name if (cat != null) { cat.setText(name); setModified(true); } }
From source file:de.danielluedecke.zettelkasten.database.Bookmarks.java
License:Open Source License
/** * Adds a new bookmark to the bookmark-file. First, we have to check whether * the bookmark already exists. If not, add it. Then we have to check for the * category. If it already exists, retrieve the category's index-number. Else * add a new category./*ww w . j av a 2s. c o m*/ * <br><br> * Use "getCompleteBookmark" for retrieving a bookmark's entry-number, category * and comment. * * @param index the index-number of the bookmark, i.e. the entry's number * @param cat the category, under which the bookmark should appear. * @param comment an optional comment for the bookmark */ public void addBookmark(int index, String cat, String comment) { // first check whether this index-number was already bookmarked... // if not, a -1 is return, else the index-number // if the bookmark already exists, do nothing if (-1 == getBookmarkPosition(index)) { try { // retrieve the position of the category int catpos = getCategoryPosition(cat); // check whether the category exists if (-1 == catpos) { // if the category doesn't already exist, add it catpos = addCategory(cat); } // create new bookmark-element Element bm = new Element(Daten.ELEMENT_ENTRY); // set the id, i.e. the number of the entry which is bookmarked bm.setAttribute("id", String.valueOf(index)); // set the category-index for this bookmark bm.setAttribute("cat", String.valueOf(catpos)); // and add the comment if (null == comment) { comment = ""; } bm.setText(comment); // retrieve the bookmark-"root"-element Element bookbase = bookmarks.getRootElement().getChild("bookmark"); // and add the bookmark-element bookbase.addContent(bm); // change modified-state setModified(true); } catch (IllegalAddException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } catch (IllegalNameException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } catch (IllegalDataException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } } }
From source file:de.danielluedecke.zettelkasten.database.Bookmarks.java
License:Open Source License
/** * Changes an existing bookmark in the bookmark-file. First, we have to check whether * the bookmark already exists. If not, leave method. Then we have to check for the * category. If it already exists, retrieve the category's index-number. Else * add a new category./*from ww w .java 2s .co m*/ * * @param index the index-number of the bookmark, i.e. the entry's number * @param cat the category, under which the bookmark should appear. * @param comment an optional comment for the bookmark */ public void changeBookmark(int index, String cat, String comment) { // get the bookmark position int pos = getBookmarkPosition(index); // check whether it exists and go on... if (pos != -1) { // retrieve the position of the category int catpos = getCategoryPosition(cat); // check whether the category exists if (-1 == catpos) { // if the category doesn't already exist, add it catpos = addCategory(cat); } try { // get bookmark-element Element bm = retrieveBookmarkElement(pos); // set the id, i.e. the number of the entry which is bookmarked bm.setAttribute("id", String.valueOf(index)); // set the category-index for this bookmark bm.setAttribute("cat", String.valueOf(catpos)); // and add the comment bm.setText(comment); // change modified-state setModified(true); } catch (IllegalNameException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } catch (IllegalDataException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } } }
From source file:de.danielluedecke.zettelkasten.database.Bookmarks.java
License:Open Source License
/** * Adds a new category string to the bookmarks category list. * /* w w w . java 2 s .c o m*/ * @param cat a string with the new category-name * @return the index of the currently added category (which equals the new size of the amount * of categories - 1) */ public int addCategory(String cat) { // get the sub-element "category" of the bookmarks xml datafile Element category = bookmarks.getRootElement().getChild("category"); // create a new category element Element newCat = new Element(Daten.ELEMENT_ENTRY); // add the new category element to the bookmarks datafile category.addContent(newCat); // and finally add the parameter (new category string) to the recently created // category element newCat.setText(cat); setModified(true); // return the new size of the categories, i.e. the category position of // the recently added category entry return bookmarks.getRootElement().getChild("category").getContentSize() - 1; }