use of jmri.jmrix.ConnectionConfig in project JMRI by JMRI.
the class RosterFrame method updateProgrammerStatus.
/*
* Handle setting up and updating the GUI for the types of progDebugger
* available.
*/
protected void updateProgrammerStatus() {
log.debug("Updating Programmer Status");
ConnectionConfig oldServMode = serModeProCon;
ConnectionConfig oldOpsMode = opsModeProCon;
// Find the connection that goes with the global programmer
GlobalProgrammerManager gpm = InstanceManager.getNullableDefault(GlobalProgrammerManager.class);
if (gpm != null) {
String serviceModeProgrammerName = gpm.getUserName();
log.debug("GlobalProgrammerManager found of class {} name {} ", gpm.getClass(), serviceModeProgrammerName);
for (ConnectionConfig connection : InstanceManager.getDefault(ConnectionConfigManager.class)) {
log.debug("Checking connection name {}", connection.getConnectionName());
if (connection.getConnectionName() != null && connection.getConnectionName().equals(serviceModeProgrammerName)) {
log.debug("Connection found for GlobalProgrammermanager");
serModeProCon = connection;
}
}
}
// Find the connection that goes with the addressed programmer
AddressedProgrammerManager apm = InstanceManager.getNullableDefault(AddressedProgrammerManager.class);
if (apm != null) {
String opsModeProgrammerName = apm.getUserName();
log.debug("AddressedProgrammerManager found of class {} name {} ", apm.getClass(), opsModeProgrammerName);
for (ConnectionConfig connection : InstanceManager.getDefault(ConnectionConfigManager.class)) {
log.debug("Checking connection name {}", connection.getConnectionName());
if (connection.getConnectionName() != null && connection.getConnectionName().equals(opsModeProgrammerName)) {
log.debug("Connection found for AddressedProgrammermanager");
opsModeProCon = connection;
}
}
}
if (serModeProCon != null && gpm.isGlobalProgrammerAvailable()) {
if (ConnectionStatus.instance().isConnectionOk(serModeProCon.getConnectionName(), serModeProCon.getInfo())) {
log.debug("GPM Connection online");
serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOnline", serModeProCon.getConnectionName()));
serviceModeProgrammerLabel.setForeground(new Color(0, 128, 0));
} else {
log.debug("GPM Connection onffline");
serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOffline", serModeProCon.getConnectionName()));
serviceModeProgrammerLabel.setForeground(Color.red);
}
if (oldServMode == null) {
contextService.setEnabled(true);
contextService.setVisible(true);
service.setEnabled(true);
service.setVisible(true);
firePropertyChange("setprogservice", "setEnabled", true);
}
} else if (gpm != null && gpm.isGlobalProgrammerAvailable()) {
if (ConnectionStatus.instance().isSystemOk(gpm.getUserName())) {
log.debug("GPM Connection online");
serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOnline", gpm.getUserName()));
serviceModeProgrammerLabel.setForeground(new Color(0, 128, 0));
} else {
log.debug("GPM Connection onffline");
serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOffline", gpm.getUserName()));
serviceModeProgrammerLabel.setForeground(Color.red);
}
if (oldServMode == null) {
contextService.setEnabled(true);
contextService.setVisible(true);
service.setEnabled(true);
service.setVisible(true);
firePropertyChange("setprogservice", "setEnabled", true);
}
} else {
// No service programmer available, disable interface sections not available
serviceModeProgrammerLabel.setText(Bundle.getMessage("NoServiceProgrammerAvailable"));
serviceModeProgrammerLabel.setForeground(Color.red);
if (oldServMode != null) {
contextService.setEnabled(false);
contextService.setVisible(false);
service.setEnabled(false);
service.setVisible(false);
firePropertyChange("setprogservice", "setEnabled", false);
}
// Disable Identify in toolBar
// This relies on it being the 2nd item in the tool bar, as defined in xml//config/parts/jmri/jmrit/roster/swing/RosterFrameToolBar.xml
// Because of I18N, we don't look for a particular Action name here
getToolBar().getComponents()[1].setEnabled(false);
}
if (opsModeProCon != null && apm.isAddressedModePossible()) {
if (ConnectionStatus.instance().isConnectionOk(opsModeProCon.getConnectionName(), opsModeProCon.getInfo())) {
log.debug("Ops Mode Connection online");
operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOnline", opsModeProCon.getConnectionName()));
operationsModeProgrammerLabel.setForeground(new Color(0, 128, 0));
} else {
log.debug("Ops Mode Connection offline");
operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOffline", opsModeProCon.getConnectionName()));
operationsModeProgrammerLabel.setForeground(Color.red);
}
if (oldOpsMode == null) {
contextOps.setEnabled(true);
contextOps.setVisible(true);
ops.setEnabled(true);
ops.setVisible(true);
firePropertyChange("setprogops", "setEnabled", true);
}
} else if (apm != null && apm.isAddressedModePossible()) {
if (ConnectionStatus.instance().isSystemOk(apm.getUserName())) {
log.debug("Ops Mode Connection online");
operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOnline", apm.getUserName()));
operationsModeProgrammerLabel.setForeground(new Color(0, 128, 0));
} else {
log.debug("Ops Mode Connection offline");
operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOffline", apm.getUserName()));
operationsModeProgrammerLabel.setForeground(Color.red);
}
if (oldOpsMode == null) {
contextOps.setEnabled(true);
contextOps.setVisible(true);
ops.setEnabled(true);
ops.setVisible(true);
firePropertyChange("setprogops", "setEnabled", true);
}
} else {
operationsModeProgrammerLabel.setText(Bundle.getMessage("NoOpsProgrammerAvailable"));
operationsModeProgrammerLabel.setForeground(Color.red);
if (oldOpsMode != null) {
contextOps.setEnabled(false);
contextOps.setVisible(false);
ops.setEnabled(false);
ops.setVisible(false);
firePropertyChange("setprogops", "setEnabled", false);
}
}
String strProgMode;
if (service.isEnabled()) {
contextService.setSelected(true);
service.setSelected(true);
strProgMode = "setprogservice";
modePanel.setVisible(true);
} else if (ops.isEnabled()) {
contextOps.setSelected(true);
ops.setSelected(true);
strProgMode = "setprogops";
modePanel.setVisible(false);
} else {
contextEdit.setSelected(true);
edit.setSelected(true);
modePanel.setVisible(false);
strProgMode = "setprogedit";
}
firePropertyChange(strProgMode, "setSelected", true);
}
Aggregations