Search in sources :

Example 36 with ConfigureManager

use of jmri.ConfigureManager in project JMRI by JMRI.

the class ManagerDefaultSelector method initialize.

@Override
public void initialize(Profile profile) throws InitializationException {
    if (!this.isInitialized(profile)) {
        // NOI18N
        Preferences settings = ProfileUtils.getPreferences(profile, this.getClass(), true).node("defaults");
        try {
            for (String name : settings.keys()) {
                String connection = settings.get(name, null);
                Class<?> cls = this.classForName(name);
                log.debug("Loading default {} for {}", connection, name);
                if (cls != null) {
                    this.defaults.put(cls, connection);
                    log.debug("Loaded default {} for {}", connection, cls);
                }
            }
        } catch (BackingStoreException ex) {
            log.info("Unable to read preferences for Default Selector.");
        }
        InitializationException ex = this.configure();
        ConfigureManager manager = InstanceManager.getNullableDefault(ConfigureManager.class);
        if (manager != null) {
            // allow ProfileConfig.xml to be written correctly
            manager.registerPref(this);
        }
        this.setInitialized(profile, true);
        if (ex != null) {
            throw ex;
        }
    }
}
Also used : ConfigureManager(jmri.ConfigureManager) BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences) InitializationException(jmri.util.prefs.InitializationException)

Example 37 with ConfigureManager

use of jmri.ConfigureManager in project JMRI by JMRI.

the class ManagerDefaultSelectorXml method load.

@Override
public boolean load(Element shared, Element perNode) {
    List<Element> list = shared.getChildren("setting");
    for (Element s : list) {
        String name = s.getChild("value").getText();
        String className = s.getChild("key").getText();
        Class<?> c = null;
        try {
            c = Class.forName(className);
        } catch (java.lang.ClassNotFoundException ex) {
            continue;
        } catch (java.lang.NoClassDefFoundError ex) {
            continue;
        }
        InstanceManager.getDefault(ManagerDefaultSelector.class).setDefault(c, name);
    }
    // put into effect
    InstanceManager.getDefault(ManagerDefaultSelector.class).configure();
    ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
    if (cm != null) {
        cm.registerPref(InstanceManager.getDefault(ManagerDefaultSelector.class));
    }
    return true;
}
Also used : ManagerDefaultSelector(jmri.managers.ManagerDefaultSelector) ConfigureManager(jmri.ConfigureManager) Element(org.jdom2.Element)

Aggregations

ConfigureManager (jmri.ConfigureManager)37 Color (java.awt.Color)7 Attribute (org.jdom2.Attribute)6 Element (org.jdom2.Element)6 JmriException (jmri.JmriException)4 AbstractXmlAdapter (jmri.configurexml.AbstractXmlAdapter)4 XmlAdapter (jmri.configurexml.XmlAdapter)4 Font (java.awt.Font)3 Point (java.awt.Point)3 File (java.io.File)3 BoxLayout (javax.swing.BoxLayout)3 JMenuBar (javax.swing.JMenuBar)3 ToolTip (jmri.jmrit.display.ToolTip)3 Container (java.awt.Container)2 Dimension (java.awt.Dimension)2 FlowLayout (java.awt.FlowLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 HashMap (java.util.HashMap)2 OverridingMethodsMustInvokeSuper (javax.annotation.OverridingMethodsMustInvokeSuper)2