Example usage for org.jdom2 Element setText

List of usage examples for org.jdom2 Element setText

Introduction

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

Prototype

public Element setText(final String text) 

Source Link

Document

Sets the content of the element to be the text given.

Usage

From source file:com.tactfactory.harmony.platform.winphone.updater.XmlProjectWinphone.java

License:Open Source License

public void addPageFile(String filename) {
    final Element newNode = new Element(XML_ELEMENT_PAGE);

    newNode.setAttribute(XML_ATTRIBUT_INCLUDE, filename);

    Element subtype = new Element(XML_ELEMENT_SUBTYPE);
    subtype.setText(XML_CONTENT_DESIGNER);
    Element generator = new Element(XML_ELEMENT_GENERATOR);
    generator.setText(XML_CONTENT_MSBUILD_COMPILE);

    newNode.addContent(subtype);/*from w ww . j  a va 2 s .c om*/
    newNode.addContent(generator);

    Element itemGroup = this.findFirstItemGroup(XML_ELEMENT_PAGE);

    this.removeIfExists(itemGroup, XML_ELEMENT_PAGE, filename);
    itemGroup.addContent(newNode);
}

From source file:com.tactfactory.harmony.updater.impl.XmlAndroid.java

License:Open Source License

@Override
public String addElement(String key, String value) {
    String result = value;//w w w  . j  a  v a2s.  c  o m

    final Element newNode = new Element(XML_ELEMENT_STRING);

    // Add name to element
    newNode.setAttribute(XML_ELEMENT_NAME, key, this.namespace);

    // Set values
    newNode.setText(value);

    // If not found Node, create it
    if (!XMLUtils.addValue(newNode, XML_ELEMENT_NAME, rootNode)) {
        result = newNode.getText();
    }

    return result;
}

From source file:com.tactfactory.harmony.utils.XMLUtils.java

License:Open Source License

/**
 * Add a node to the XML node if it doesn't contains it already.
 * @param newNode The node to add//from   ww w  . j a v a 2 s.com
 * @param id The attribute name to compare
 * @param baseNode The node to add the new node to.
 * @return True if the node was added successfully.
 * False if the node already exists before.
 */
public static boolean addValue(final Element newNode, final String id, final Element baseNode) {

    Element findElement = null;

    // Debug Log
    ConsoleUtils.displayDebug("Update String : " + newNode.getAttributeValue(id));

    findElement = findNode(baseNode, newNode, id);

    // If not found Node, create it
    if (findElement == null) {
        baseNode.addContent(newNode);
        return true;
    } else {
        newNode.setText(findElement.getText());
        return false;
    }
}

From source file:com.thoughtworks.go.config.ConfigCipherUpdater.java

License:Apache License

public void migrate() {
    File cipherFile = systemEnvironment.getDESCipherFile();
    String timestamp = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(timeProvider.currentTime());

    File backupCipherFile = new File(systemEnvironment.getConfigDir(), "cipher.original." + timestamp);
    File configFile = new File(systemEnvironment.getCruiseConfigFile());
    File backupConfigFile = new File(configFile.getParentFile(),
            configFile.getName() + ".original." + timestamp);
    try {/*from  w  w  w  . j  a  v  a 2s.c om*/
        if (!cipherFile.exists() || !FileUtils.readFileToString(cipherFile, UTF_8).equals(FLAWED_VALUE)) {
            return;
        }
        LOGGER.info("Found unsafe cipher {} on server, Go will make an attempt to rekey", FLAWED_VALUE);
        FileUtils.copyFile(cipherFile, backupCipherFile);
        LOGGER.info("Old cipher was successfully backed up to {}", backupCipherFile.getAbsoluteFile());
        FileUtils.copyFile(configFile, backupConfigFile);
        LOGGER.info("Old config was successfully backed up to {}", backupConfigFile.getAbsoluteFile());

        String oldCipher = FileUtils.readFileToString(backupCipherFile, UTF_8);
        new DESCipherProvider(systemEnvironment).resetCipher();

        String newCipher = FileUtils.readFileToString(cipherFile, UTF_8);

        if (newCipher.equals(oldCipher)) {
            LOGGER.warn("Unable to generate a new safe cipher. Your cipher is unsafe.");
            FileUtils.deleteQuietly(backupCipherFile);
            FileUtils.deleteQuietly(backupConfigFile);
            return;
        }
        Document document = new SAXBuilder().build(configFile);
        List<String> encryptedAttributes = Arrays.asList("encryptedPassword", "encryptedManagerPassword");
        List<String> encryptedNodes = Arrays.asList("encryptedValue");
        XPathFactory xPathFactory = XPathFactory.instance();
        for (String attributeName : encryptedAttributes) {
            XPathExpression<Element> xpathExpression = xPathFactory
                    .compile(String.format("//*[@%s]", attributeName), Filters.element());
            List<Element> encryptedPasswordElements = xpathExpression.evaluate(document);
            for (Element element : encryptedPasswordElements) {
                Attribute encryptedPassword = element.getAttribute(attributeName);
                encryptedPassword.setValue(reEncryptUsingNewKey(decodeHex(oldCipher), decodeHex(newCipher),
                        encryptedPassword.getValue()));
                LOGGER.debug("Replaced encrypted value at {}", element.toString());
            }
        }
        for (String nodeName : encryptedNodes) {
            XPathExpression<Element> xpathExpression = xPathFactory.compile(String.format("//%s", nodeName),
                    Filters.element());
            List<Element> encryptedNode = xpathExpression.evaluate(document);
            for (Element element : encryptedNode) {
                element.setText(
                        reEncryptUsingNewKey(decodeHex(oldCipher), decodeHex(newCipher), element.getValue()));
                LOGGER.debug("Replaced encrypted value at {}", element.toString());
            }
        }
        try (FileOutputStream fileOutputStream = new FileOutputStream(configFile)) {
            XmlUtils.writeXml(document, fileOutputStream);
        }
        LOGGER.info("Successfully re-encrypted config");
    } catch (Exception e) {
        LOGGER.error("Re-keying of cipher failed with error: [{}]", e.getMessage(), e);
        if (backupCipherFile.exists()) {
            try {
                FileUtils.copyFile(backupCipherFile, cipherFile);
            } catch (IOException e1) {
                LOGGER.error(
                        "Could not replace the cipher file [{}] with original one [{}], please do so manually. Error: [{}]",
                        cipherFile.getAbsolutePath(), backupCipherFile.getAbsolutePath(), e.getMessage(), e);
                bomb(e1);
            }
        }
    }
}

From source file:com.xebialabs.overcast.support.libvirt.jdom.DomainXml.java

License:Apache License

public static Document setDomainName(Document domainXml, String name) {
    XPathFactory xpf = XPathFactory.instance();

    XPathExpression<Element> nameExpr = xpf.compile("/domain/name", Filters.element());
    Element nameElement = nameExpr.evaluateFirst(domainXml);
    nameElement.setText(name);

    return domainXml;
}

From source file:cz.lbenda.dataman.db.ExportTableData.java

License:Apache License

/** Write rows from sql query to output stream
 * @param sqlQueryRows rows// www  .  j a va2  s.  co  m
 * @param outputStream stream to which are data write */
public static void writeSqlQueryRowsToXMLv2(SQLQueryRows sqlQueryRows, OutputStream outputStream)
        throws IOException {
    Element root = new Element("export");
    root.setAttribute("sql", sqlQueryRows.getSQL());
    root.setAttribute("version", "2");
    List<Element> rows = new ArrayList<>(sqlQueryRows.getRows().size());

    sqlQueryRows.getRows().forEach(rowDesc -> {
        Element row = new Element("row");
        List<Element> cols = new ArrayList<>(sqlQueryRows.getMetaData().getColumns().size());
        sqlQueryRows.getMetaData().getColumns().forEach(columnDesc -> {
            Element element = new Element(columnDesc.getName());
            if (rowDesc.isColumnNull(columnDesc)) {
                element.setAttribute("null", "true");
            } else {
                element.setText(rowDesc.getColumnValueStr(columnDesc));
            }
            cols.add(element);
        });
        row.addContent(cols);
        rows.add(row);
    });
    root.addContent(rows);
    XMLOutputter xmlOutputter = new XMLOutputter();
    xmlOutputter.output(new Document(root), outputStream);
}

From source file:cz.lbenda.dbapp.rc.SessionConfiguration.java

License:Apache License

public final Element storeToElement() {
    Element ses = new Element("session");
    ses.setAttribute("id", getId());
    if (this.connectionTimeout > 0) {
        ses.addContent(new Element("connectionTimeout").setText(Integer.toString(this.connectionTimeout)));
    }/*from w  w w  .ja  v  a2 s.c  o m*/
    if (jdbcConfiguration != null) {
        ses.addContent(jdbcConfiguration.storeToElement());
    }
    Element ed = new Element("extendedDescription");
    ed.setAttribute("type", this.getExtendedConfigurationType().name());
    ed.setText(this.getExtendedConfigurationPath());
    ses.addContent(ed);
    if (!librariesPaths.isEmpty()) {
        Element libs = new Element("libraries");
        for (String path : getLibrariesPaths()) {
            Element lib = new Element("library");
            lib.setText(path);
            libs.addContent(lib);
        }
        ses.addContent(libs);
    }
    return ses;
}

From source file:cz.muni.fi.mir.mathmlcanonicalization.modules.OperatorNormalizer.java

License:Apache License

private void replaceOperators(final Element element, final Map<String, String> replacements) {
    assert element != null && replacements != null;
    List<Element> operatorsToReplace = new ArrayList<Element>();
    for (Element operator : element.getDescendants(new ElementFilter(OPERATOR))) {
        if (replacements.containsKey(operator.getTextTrim())) {
            operatorsToReplace.add(operator);
        }// w w  w  .java 2 s. c  o  m
    }
    for (Element operator : operatorsToReplace) {
        final String oldOperator = operator.getTextTrim();
        final String newOperator = replacements.get(oldOperator);
        operator.setText(newOperator);
        LOGGER.log(Level.FINE, "Operator ''{0}'' was replaced by ''{1}''",
                new Object[] { oldOperator, newOperator });
    }
}

From source file:de.bund.bfr.fskml.FskMetaDataObject.java

License:Open Source License

public FskMetaDataObject(ResourceType resourceType) {

    Element typeNode = factory.element("type", dcNamespace);
    typeNode.setText(resourceType.name());

    Element element = factory.element("element");
    element.addContent(typeNode);//from   w w  w  .  ja  v a  2s  . com

    metaDataObject = new DefaultMetaDataObject(element);
}

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

License:Open Source License

/**
 * This method inits the accelerator table of the main window's menus. We separate
 * the initialisation of the accelerator tables for each window to keep an better
 * overiew./*  w  w  w.j a va 2  s.  c  o  m*/
 * 
 * This method creates all the acceleratorkeys-child-elements, but only, if they don't
 * already exist. We do this because when loading older acceleratorkeys-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.
 */
private void initMainKeys() {
    // 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 main window's file menu
    //

    // the accelerator for the "newEntry" action
    if (!findElement(MAINKEYS, "newEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "newEntry");
        acckey.setText(mask + " N");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "insertEntry" action
    if (!findElement(MAINKEYS, "insertEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "insertEntry");
        acckey.setText(mask + " I");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "quickNewEntry" action
    if (!findElement(MAINKEYS, "quickNewEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "quickNewEntry");
        acckey.setText(mask + " alt N");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "quickNewEntryWithTitle" action
    if (!findElement(MAINKEYS, "quickNewEntryWithTitle")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "quickNewEntryWithTitle");
        acckey.setText(mask + " shift N");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "openDocument" action
    if (!findElement(MAINKEYS, "openDocument")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "openDocument");
        acckey.setText(mask + " O");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "saveDocument" action
    if (!findElement(MAINKEYS, "saveDocument")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "saveDocument");
        acckey.setText(mask + " S");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "saveDocumentAs" action
    if (!findElement(MAINKEYS, "saveDocumentAs")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "saveDocumentAs");
        acckey.setText(mask + " shift S");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "importWindow" action
    if (!findElement(MAINKEYS, "importWindow")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "importWindow");
        acckey.setText(mask + " shift I");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "exportWindow" action
    if (!findElement(MAINKEYS, "exportWindow")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "exportWindow");
        acckey.setText(mask + " shift E");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "quit" action
    if (!findElement(MAINKEYS, "quit")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "quit");
        acckey.setText(mask + " Q");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    //
    // The actions of the main window's edit menu
    //

    // the accelerator for the "copyPlain" action
    if (!findElement(MAINKEYS, "copyPlain")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "copyPlain");
        acckey.setText(mask + " shift C");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "editEntry" action
    if (!findElement(MAINKEYS, "editEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "editEntry");
        acckey.setText(mask + " E");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "deleteCurrentEntry" action
    if (!findElement(MAINKEYS, "deleteCurrentEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "deleteCurrentEntry");
        acckey.setText(mask + " shift " + delkey);
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "manualInsertEntry" action
    if (!findElement(MAINKEYS, "manualInsertEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "manualInsertEntry");
        acckey.setText(mask + " alt I");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "manualInsertLinks" action
    if (!findElement(MAINKEYS, "manualInsertLinks")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "manualInsertLinks");
        acckey.setText(mask + " alt L");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "selectAllText" action
    if (!findElement(MAINKEYS, "selectAllText")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "selectAllText");
        acckey.setText(mask + " A");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "addToDesktop" action
    if (!findElement(MAINKEYS, "addToDesktop")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "addToDesktop");
        acckey.setText("F9");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "addToBookmark" action
    if (!findElement(MAINKEYS, "addToBookmark")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "addToBookmark");
        acckey.setText(mask + " B");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "updateDisplay" action
    if (!findElement(MAINKEYS, "updateDisplay")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "updateDisplay");
        acckey.setText("F5");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    //
    // The actions of the main window's find menu
    //

    // the accelerator for the "find" action
    if (!findElement(MAINKEYS, "find")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "find");
        acckey.setText(mask + " F");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "replace" action
    if (!findElement(MAINKEYS, "replace")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "replace");
        acckey.setText(mask + " R");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "findLive" action
    if (!findElement(MAINKEYS, "findLive")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "findLive");
        acckey.setText(mask + " shift F");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "showFirstEntry" action
    if (!findElement(MAINKEYS, "showFirstEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showFirstEntry");
        acckey.setText(mask + " shift " + minuskey);
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "gotoEntry" action
    if (!findElement(MAINKEYS, "gotoEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "gotoEntry");
        acckey.setText(mask + " G");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }
    // the accelerator for the "showRandomEntry" action
    if (!findElement(MAINKEYS, "showRandomEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showRandomEntry");
        acckey.setText(ctrlkey + " " + numbersign);
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }
    // the accelerator for the "historyFor" action
    if (!findElement(MAINKEYS, "historyFor")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "historyFor");
        acckey.setText(historykey + " RIGHT");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }
    // the accelerator for the "historyBack" action
    if (!findElement(MAINKEYS, "historyBack")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "historyBack");
        acckey.setText(historykey + " LEFT");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }
    // the accelerator for the "showLastEntry" action
    if (!findElement(MAINKEYS, "showLastEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showLastEntry");
        acckey.setText(mask + " shift " + pluskey);
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "showPrevEntry" action
    if (!findElement(MAINKEYS, "showPrevEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showPrevEntry");
        acckey.setText(mask + " " + minuskey);
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "showNextEntry" action
    if (!findElement(MAINKEYS, "showNextEntry")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showNextEntry");
        acckey.setText(mask + " " + pluskey);
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    //
    // The actions of the main window's view menu
    //

    // the accelerator for the "menuShowLinks" action
    if (!findElement(MAINKEYS, "menuShowLinks")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowLinks");
        acckey.setText(mask + " F1");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "menuShowLuhmann" action
    if (!findElement(MAINKEYS, "menuShowLuhmann")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowLuhmann");
        acckey.setText(mask + " F2");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "menuShowKeywords" action
    if (!findElement(MAINKEYS, "menuShowKeywords")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowKeywords");
        acckey.setText(mask + " F3");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "menuShowAuthors" action
    if (!findElement(MAINKEYS, "menuShowAuthors")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowAuthors");
        acckey.setText(mask + " F4");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "menuShowTitles" action
    if (!findElement(MAINKEYS, "menuShowTitles")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowTitles");
        acckey.setText(mask + " F5");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "menuShowCluster" action
    if (!findElement(MAINKEYS, "menuShowCluster")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowCluster");
        acckey.setText(mask + " F6");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "menuShowBookmarks" action
    if (!findElement(MAINKEYS, "menuShowBookmarks")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowBookmarks");
        acckey.setText(mask + " F7");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "menuShowAttachments" action
    if (!findElement(MAINKEYS, "menuShowAttachments")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "menuShowAttachments");
        acckey.setText(mask + " F8");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "showSearchResultWindow" action
    if (!findElement(MAINKEYS, "showSearchResultWindow")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showSearchResultWindow");
        acckey.setText("F3");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "showDesktopWindow" action
    if (!findElement(MAINKEYS, "showDesktopWindow")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showDesktopWindow");
        acckey.setText("F4");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "showNewEntryWindow" action
    if (!findElement(MAINKEYS, "showNewEntryWindow")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "showNewEntryWindow");
        acckey.setText("F11");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "highlightKeywords" action
    if (!findElement(MAINKEYS, "highlightKeywords")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "highlightKeywords");
        acckey.setText("F7");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    //
    // The actions of the main window's popup menu
    //

    // the accelerator for the "addToKeywordList" action
    if (!findElement(MAINKEYS, "addToKeywordList")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "addToKeywordList");
        acckey.setText(mask + " shift K");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "setSelectionAsTitle" action
    if (!findElement(MAINKEYS, "setSelectionAsTitle")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "setSelectionAsTitle");
        acckey.setText(mask + " alt U");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }

    // the accelerator for the "setFirstLineAsTitle" action
    if (!findElement(MAINKEYS, "setFirstLineAsTitle")) {
        acckey = new Element("key");
        acckey.setAttribute("action", "setFirstLineAsTitle");
        acckey.setText(mask + " shift U");
        acceleratorKeysMain.getRootElement().addContent(acckey);
    }
}