Search in sources :

Example 1 with SystemConsolePreferencesManager

use of apps.systemconsole.SystemConsolePreferencesManager in project JMRI by JMRI.

the class SystemConsoleConfigPanelXml method store.

/**
     * Arrange for console settings to be stored
     *
     * @param o Object to store, of type SystemConsole
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    Element e = new Element("console");
    e.setAttribute("class", this.getClass().getName());
    SystemConsolePreferencesManager manager = InstanceManager.getDefault(SystemConsolePreferencesManager.class);
    e.setAttribute("scheme", "" + manager.getScheme());
    e.setAttribute("fontfamily", "" + manager.getFontFamily());
    e.setAttribute("fontsize", "" + manager.getFontSize());
    e.setAttribute("fontstyle", "" + manager.getFontStyle());
    e.setAttribute("wrapstyle", "" + manager.getWrapStyle());
    return e;
}
Also used : Element(org.jdom2.Element) SystemConsolePreferencesManager(apps.systemconsole.SystemConsolePreferencesManager)

Example 2 with SystemConsolePreferencesManager

use of apps.systemconsole.SystemConsolePreferencesManager in project JMRI by JMRI.

the class SystemConsoleConfigPanelXml method load.

@Override
public boolean load(Element shared, Element perNode) throws Exception {
    boolean result = true;
    String value;
    SystemConsolePreferencesManager manager = InstanceManager.getDefault(SystemConsolePreferencesManager.class);
    try {
        if ((value = shared.getAttributeValue("scheme")) != null) {
            manager.setScheme(Integer.parseInt(value));
        }
        if ((value = shared.getAttributeValue("fontfamily")) != null) {
            manager.setFontFamily(value);
        }
        if ((value = shared.getAttributeValue("fontsize")) != null) {
            manager.setFontSize(Integer.parseInt(value));
        }
        if ((value = shared.getAttributeValue("fontstyle")) != null) {
            manager.setFontStyle(Integer.parseInt(value));
        }
        if ((value = shared.getAttributeValue("wrapstyle")) != null) {
            manager.setWrapStyle(Integer.parseInt(value));
        }
    } catch (NumberFormatException ex) {
        log.error("NumberFormatException while setting System Console parameters: " + ex);
        result = false;
    }
    // As we've had a load request, register the system console with the
    // preference manager
    ConfigureManager cm = jmri.InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
    if (cm != null) {
        cm.registerPref(new SystemConsoleConfigPanel());
    }
    return result;
}
Also used : ConfigureManager(jmri.ConfigureManager) SystemConsoleConfigPanel(apps.SystemConsoleConfigPanel) SystemConsolePreferencesManager(apps.systemconsole.SystemConsolePreferencesManager)

Aggregations

SystemConsolePreferencesManager (apps.systemconsole.SystemConsolePreferencesManager)2 SystemConsoleConfigPanel (apps.SystemConsoleConfigPanel)1 ConfigureManager (jmri.ConfigureManager)1 Element (org.jdom2.Element)1