Skip to content

Commit

Permalink
fix: Get Logix system prefix on demand
Browse files Browse the repository at this point in the history
Don't force non-users of Logix to load the entire Logix subsystem.
  • Loading branch information
rhwood committed May 17, 2020
1 parent 6604685 commit 2d2f449
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions java/src/jmri/jmrit/beantable/RouteTableAction.java
Expand Up @@ -37,6 +37,7 @@
import jmri.ConditionalVariable;
import jmri.InstanceManager;
import jmri.Logix;
import jmri.LogixManager;
import jmri.Route;
import jmri.RouteManager;
import jmri.Sensor;
Expand Down Expand Up @@ -1359,6 +1360,15 @@ void clearPage() {
}

/////////////////////// Export to Logix ////////////////////////////

private String getLogixSystemPrefix() {
return InstanceManager.getDefault(LogixManager.class).getSystemPrefix() + ":RTX:";
}

private String getConditionalSystemPrefix() {
return getLogixSystemPrefix() + "C";
}

/**
* Respond to the Export button - export to Logix.
*
Expand All @@ -1371,7 +1381,7 @@ void exportPressed(ActionEvent e) {
sName = fixedSystemName.getText();
}
String uName = _userName.getText();
String logixSystemName = LOGIX_SYS_NAME + sName;
String logixSystemName = getLogixSystemPrefix() + sName;
Logix logix = InstanceManager.getDefault(jmri.LogixManager.class).getBySystemName(logixSystemName);
if (logix == null) {
logix = InstanceManager.getDefault(jmri.LogixManager.class).createNewLogix(logixSystemName, uName);
Expand Down Expand Up @@ -1442,13 +1452,13 @@ void exportPressed(ActionEvent e) {
for (int i = 0; i < ch.length; i++) {
hash += ch[i];
}
String cSystemName = CONDITIONAL_SYS_PREFIX + "T" + hash;
String cSystemName = getConditionalSystemPrefix() + "T" + hash;
removeConditionals(cSystemName, logix);
cSystemName = CONDITIONAL_SYS_PREFIX + "F" + hash;
cSystemName = getConditionalSystemPrefix() + "F" + hash;
removeConditionals(cSystemName, logix);
cSystemName = CONDITIONAL_SYS_PREFIX + "A" + hash;
cSystemName = getConditionalSystemPrefix() + "A" + hash;
removeConditionals(cSystemName, logix);
cSystemName = CONDITIONAL_SYS_PREFIX + "L" + hash;
cSystemName = getConditionalSystemPrefix() + "L" + hash;
removeConditionals(cSystemName, logix);

int n = 0;
Expand Down Expand Up @@ -2089,16 +2099,8 @@ public void setValueAt(Object type, int r, int c) {

private boolean showAll = true; // false indicates show only included Turnouts

public final static String LOGIX_SYS_NAME;
public final static String CONDITIONAL_SYS_PREFIX;
private static int ROW_HEIGHT;

static {
String logixPrefix = InstanceManager.getDefault(jmri.LogixManager.class).getSystemNamePrefix();
LOGIX_SYS_NAME = logixPrefix + ":RTX:";
CONDITIONAL_SYS_PREFIX = LOGIX_SYS_NAME + "C";
}

private static String[] COLUMN_NAMES = {Bundle.getMessage("ColumnSystemName"),
Bundle.getMessage("ColumnUserName"),
Bundle.getMessage("Include"),
Expand Down

0 comments on commit 2d2f449

Please sign in to comment.