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;
}
}
}
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;
}
Aggregations