Example usage for org.dom4j Element addAttribute

List of usage examples for org.dom4j Element addAttribute

Introduction

In this page you can find the example usage for org.dom4j Element addAttribute.

Prototype

Element addAttribute(QName qName, String value);

Source Link

Document

Adds the attribute value of the given fully qualified name.

Usage

From source file:cc.warlock.core.client.settings.internal.HighlightConfigurationProvider.java

License:Open Source License

protected Element createStyleElement(Element parent, IWarlockStyle style) {
    Element element = null;
    if (parent != null) {
        element = parent.addElement("style");
    } else {/*from   w w  w.  ja v a 2 s .  c  o m*/
        element = DocumentHelper.createElement("style");
    }

    if (style.getName() != null)
        element.addAttribute("name", style.getName());

    element.addAttribute("background", colorString(style.getBackgroundColor()));
    element.addAttribute("foreground", colorString(style.getForegroundColor()));

    for (IWarlockStyle.StyleType styleType : style.getStyleTypes()) {
        Element sElement = element.addElement("styleType");
        sElement.setText(styleType.name());
    }

    element.addAttribute("full-line", "" + style.isFullLine());
    //System.out.println("saving sound " + style.getSound());
    element.addAttribute("sound", style.getSound());
    return element;
}

From source file:cc.warlock.core.client.settings.internal.PatternConfigurationProvider.java

License:Open Source License

protected void fillElement(Element element, IPatternSetting setting) {
    element.addAttribute("pattern", setting.getText());
    element.addAttribute("literal", "" + setting.isLiteral());
    element.addAttribute("caseSensitive", "" + setting.isCaseSensitive());
    element.addAttribute("fullWordMatch", "" + setting.isFullWordMatch());
}

From source file:cc.warlock.core.client.settings.internal.VariableConfigurationProvider.java

License:Open Source License

@Override
protected void saveTo(List<Element> elements) {
    Element varsElement = DocumentHelper.createElement("variables");

    for (Map.Entry<String, IVariable> entry : variables.entrySet()) {
        Element element = varsElement.addElement("variable");
        element.addAttribute("id", entry.getKey());
        element.addText(entry.getValue().getValue());

    }//  www.j ava  2 s .  c om
    elements.add(varsElement);
}

From source file:cc.warlock.core.client.settings.internal.WindowSettingsConfigurationProvider.java

License:Open Source License

@Override
protected void saveTo(List<Element> elements) {
    Element windows = DocumentHelper.createElement("windows");

    for (IWindowSettings settings : windowSettings) {
        Element window = windows.addElement("window");
        window.addAttribute("id", settings.getId());
        window.addAttribute("background", colorString(settings.getBackgroundColor()));
        window.addAttribute("foreground", colorString(settings.getForegroundColor()));

        window.add(fontToElement(settings.getFont(), "font"));
        window.add(fontToElement(settings.getColumnFont(), "columnFont"));
    }//from  www  .ja v  a  2  s  .c  o m

    elements.add(windows);
}

From source file:cc.warlock.core.client.settings.macro.internal.MacroConfigurationProvider.java

License:Open Source License

@Override
protected void saveTo(List<Element> elements) {
    Element macrosElement = DocumentHelper.createElement("macros");
    for (IMacro macro : macros) {
        if (macro.getHandlers().size() == 1) {

            IMacroHandler first = macro.getHandlers().iterator().next();
            if (first instanceof CommandMacroHandler) {
                CommandMacroHandler handler = (CommandMacroHandler) first;

                Element mElement = macrosElement.addElement("macro");
                mElement.addAttribute("command", handler.getCommand());
                mElement.addAttribute("keycode", macro.getKeyCode() + "");
                mElement.addAttribute("modifiers", macro.getModifiers() + "");
            }//from w  w w. ja  va  2  s. c  o m
        }
    }

    elements.add(macrosElement);
}

From source file:cc.warlock.core.script.configuration.ScriptConfiguration.java

License:Open Source License

protected void addScriptConfigElements(Element scriptConfig) {
    for (File dir : scriptDirectories) {
        Element dirElement = DocumentHelper.createElement("dir");
        dirElement.setText(dir.getAbsolutePath());

        scriptConfig.add(dirElement);/*from   w ww  . jav  a2 s  .  c o  m*/
    }

    Element autoScanElement = DocumentHelper.createElement("autoScan");
    autoScanElement.addAttribute("timeout", "" + scanTimeout.get());
    autoScanElement.setText(autoScan.get() + "");
    scriptConfig.add(autoScanElement);

    Element suppressExceptionsElement = DocumentHelper.createElement("suppressExceptions");
    suppressExceptionsElement.setText(suppressExceptions.get() + "");
    scriptConfig.add(suppressExceptionsElement);

    Element scriptPrefixElement = DocumentHelper.createElement("script-prefix");
    scriptPrefixElement.setText(scriptPrefix);
    scriptConfig.add(scriptPrefixElement);

    addEngineExtensionsConfig(scriptConfig);
}

From source file:cc.warlock.core.script.configuration.ScriptConfiguration.java

License:Open Source License

protected void addEngineExtensionsConfig(Element scriptConfig) {
    for (Map.Entry<String, ArrayList<String>> entry : engineExtensions.entrySet()) {
        Element engineElement = DocumentHelper.createElement("engine-file-extensions");
        engineElement.addAttribute("engineId", entry.getKey());
        scriptConfig.add(engineElement);

        for (String extension : entry.getValue()) {
            Element extElement = DocumentHelper.createElement("extension");
            extElement.setText(extension);
            engineElement.add(extElement);
        }//from w w w.  j a va 2 s  .  c  o m
    }
}

From source file:cc.warlock.core.stormfront.ProfileConfiguration.java

License:Open Source License

public List<Element> getTopLevelElements() {
    ArrayList<Element> elements = new ArrayList<Element>();

    for (Account account : accounts.values()) {
        Element aElement = DocumentHelper.createElement("account");
        aElement.addAttribute("name", account.getAccountName());
        aElement.addAttribute("password", Account.encryptPassword(account.getPassword()));

        for (Profile profile : account.getProfiles()) {
            Element pElement = aElement.addElement("profile");
            pElement.addAttribute("id", profile.getId());
            pElement.addAttribute("name", profile.getName());
            pElement.addAttribute("gameCode", profile.getGameCode());
            pElement.addAttribute("gameName", profile.getGameName());
        }/*from  w w  w.ja v  a 2  s.c o  m*/
        elements.add(aElement);
    }
    return elements;
}

From source file:cc.warlock.core.stormfront.settings.internal.CommandLineConfigurationProvider.java

License:Open Source License

@Override
protected void saveTo(List<Element> elements) {
    Element cElement = DocumentHelper.createElement("command-line");
    elements.add(cElement);/*from   w  w w .j  a  va  2 s  .  c o  m*/

    cElement.addAttribute("background", colorString(settings.getBackgroundColor()));
    cElement.addAttribute("foreground", colorString(settings.getForegroundColor()));
    cElement.addAttribute("barColor", colorString(settings.getBarColor()));
    addFontAttributes(settings.getFont(), cElement);
}

From source file:cc.warlock.core.stormfront.settings.StormFrontServerSettings.java

License:Open Source License

@Override
protected void saveTo(List<Element> elements) {
    Element element = DocumentHelper.createElement("stormfront-settings");

    element.addAttribute("client-version", clientVersion);
    element.addAttribute("major-version", majorVersion);
    element.addAttribute("crc", crc);

    elements.add(element);/*from  w ww . jav a 2  s . c  om*/
}