use of jmri.ConfigureManager in project JMRI by JMRI.
the class PerformFileModel method performAction.
@Override
public void performAction() throws JmriException {
log.info("Loading file {}", this.getFileName());
// load the file
File file = new File(this.getFileName());
ConfigureManager cm = InstanceManager.getNullableDefault(ConfigureManager.class);
if (cm != null) {
cm.load(file);
}
}
use of jmri.ConfigureManager in project JMRI by JMRI.
the class PreferencesPane method updateButtonPressed.
private void updateButtonPressed() {
//Disable any action on the listener.
updateButtonPressed = true;
//EcosPreferences ep = adaptermemo.getPreferenceManager();
ep.setRemoveLocoFromJMRI(getChoiceType(_removeLocosJmri));
ep.setAddLocoToJMRI(getChoiceType(_addLocoJmri));
ep.setRemoveLocoFromEcos(getChoiceType(_removeLocosEcos));
ep.setAddLocoToEcos(getChoiceType(_addLocoEcos));
ep.setRemoveTurnoutsFromJMRI(getChoiceType(_removeTurnoutsJmri));
ep.setAddTurnoutsToJMRI(getChoiceType(_addTurnoutsJmri));
ep.setRemoveTurnoutsFromEcos(getChoiceType(_removeTurnoutsEcos));
//ep.setAddTurnoutsToEcos(getChoiceType(_addTurnoutsEcos));
ep.setLocoMaster(getMasterControlType(_masterControl));
//ep.setDefaultEcosProtocol(getEcosProtocol(_defaultProtocol));
ep.setEcosLocoDescription(_ecosDescription.getText());
ep.setRosterAttribute(_ecosAttSufText.getText());
if (_adhocLocoEcosAsk.isSelected()) {
ep.setAdhocLocoFromEcos(0);
} else if (_adhocLocoEcosLeave.isSelected()) {
ep.setAdhocLocoFromEcos(1);
} else if (_adhocLocoEcosRemove.isSelected()) {
ep.setAdhocLocoFromEcos(2);
} else {
ep.setAdhocLocoFromEcos(0);
}
if (_locoControlForce.isSelected()) {
ep.setLocoControl(true);
} else {
ep.setLocoControl(false);
}
ConfigureManager cm = jmri.InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
if (cm != null) {
cm.storePrefs();
}
updateButtonPressed = false;
}
use of jmri.ConfigureManager in project JMRI by JMRI.
the class AppConfigBase method saveContents.
public void saveContents() {
// remove old prefs that are registered in ConfigManager
ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
if (cm != null) {
cm.removePrefItems();
}
// put the new GUI managedPreferences on the persistance list
this.getPreferencesPanels().values().stream().forEach((panel) -> {
this.registerWithConfigureManager(panel);
});
if (cm != null) {
cm.storePrefs();
}
}
use of jmri.ConfigureManager in project JMRI by JMRI.
the class SampleMinimalProgram method codeConfig.
protected void codeConfig(String[] args) {
jmri.jmrix.SerialPortAdapter adapter = jmri.jmrix.lenz.li100.LI100Adapter.instance();
//jmri.jmrix.SerialPortAdapter adapter = jmri.jmrix.nce.serialdriver.SerialDriverAdapter.instance();
String portName = "/dev/cu.Bluetooth-PDA-Sync";
String baudRate = "9600";
//String option1Setting = null;
//String option2Setting = null;
adapter.setPort(portName);
adapter.configureBaudRate(baudRate);
//if (option1Setting !=null) adapter.configureOption1(option1Setting);
//if (option2Setting !=null) adapter.configureOption2(option2Setting);
adapter.openPort(portName, "JMRI app");
adapter.configure();
ConfigureManager cm = new JmriConfigurationManager();
// not setting preference file location!
InstanceManager.setConfigureManager(cm);
// needs an error handler that doesn't invoke swing; send to log4j?
// start web server
final int port = 12080;
WebServerPreferences.getDefault().setPort(port);
try {
WebServer.getDefault().start();
} catch (Exception ex) {
log.error("Unable to start web server.", ex);
}
log.info("Up!");
}
use of jmri.ConfigureManager in project JMRI by JMRI.
the class GuiLafConfigPaneXml method load.
@Override
public boolean load(Element shared, Element perNode) {
boolean result = true;
UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels();
java.util.Hashtable<String, String> installedLAFs = new java.util.Hashtable<String, String>(plafs.length);
for (int i = 0; i < plafs.length; i++) {
installedLAFs.put(plafs[i].getName(), plafs[i].getClassName());
}
String name = shared.getAttribute("LAFclass").getValue();
String className = installedLAFs.get(name);
log.debug("GUI selection: " + name + " class name: " + className);
// set the GUI
if (className != null) {
InstanceManager.getDefault(GuiLafPreferencesManager.class).setLookAndFeel(name);
try {
if (!className.equals(UIManager.getLookAndFeel().getClass().getName())) {
log.debug("set GUI to " + name + "," + className);
updateLookAndFeel(name, className);
} else {
log.debug("skip updateLAF as already has className==" + className);
}
} catch (Exception ex) {
log.error("Exception while setting GUI look & feel: " + ex);
result = false;
}
}
Attribute langAttr = shared.getAttribute("LocaleLanguage");
Attribute countryAttr = shared.getAttribute("LocaleCountry");
Attribute varAttr = shared.getAttribute("LocaleVariant");
if (countryAttr != null && langAttr != null && varAttr != null) {
Locale locale = new Locale(langAttr.getValue(), countryAttr.getValue(), varAttr.getValue());
Locale.setDefault(locale);
InstanceManager.getDefault(GuiLafPreferencesManager.class).setLocale(locale);
}
Attribute clickAttr = shared.getAttribute("nonStandardMouseEvent");
if (clickAttr != null) {
boolean nonStandardMouseEvent = clickAttr.getValue().equals("yes");
jmri.util.swing.SwingSettings.setNonStandardMouseEvent(nonStandardMouseEvent);
InstanceManager.getDefault(GuiLafPreferencesManager.class).setNonStandardMouseEvent(nonStandardMouseEvent);
}
Attribute graphicAttr = shared.getAttribute("graphicTableState");
if (graphicAttr != null) {
boolean graphicTableState = graphicAttr.getValue().equals("yes");
InstanceManager.getDefault(GuiLafPreferencesManager.class).setGraphicTableState(graphicTableState);
}
GuiLafConfigPane g = new GuiLafConfigPane();
ConfigureManager cm = jmri.InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
if (cm != null) {
cm.registerPref(g);
}
Attribute fontsize = shared.getAttribute("fontsize");
if (fontsize != null) {
int size = Integer.parseInt(fontsize.getValue());
InstanceManager.getDefault(GuiLafPreferencesManager.class).setFontSize(size);
this.setUIFontSize(size);
}
return result;
}
Aggregations