Skip to content
Permalink
Browse files

Remove hyphen location name in conductor

  • Loading branch information...
DanielBoudreau committed Jun 11, 2019
1 parent 710b2ec commit 40c61c37fbb37ddf8d79cc6b36b6d848d64a3b05
@@ -2,11 +2,16 @@

import java.awt.Dimension;
import java.awt.GridBagLayout;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jmri.jmrit.operations.CommonConductorYardmasterPanel;
import jmri.jmrit.operations.locations.Location;
import jmri.jmrit.operations.rollingstock.RollingStock;
@@ -15,8 +20,6 @@
import jmri.jmrit.operations.routes.RouteLocation;
import jmri.jmrit.operations.setup.Control;
import jmri.jmrit.operations.setup.Setup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Conductor Panel. Shows work for a train one location at a time.
@@ -120,8 +123,8 @@ public TrainConductorPanel(Train train) {
}
// show route comment box only if there's a route comment
if (_train.getRoute() != null) {
textTrainRouteCommentPane.setVisible(!_train.getRoute().getComment().equals(Route.NONE)
&& Setup.isPrintRouteCommentsEnabled());
textTrainRouteCommentPane.setVisible(
!_train.getRoute().getComment().equals(Route.NONE) && Setup.isPrintRouteCommentsEnabled());
textTrainRouteCommentPane.setText(_train.getRoute().getComment());
}

@@ -149,7 +152,7 @@ public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
}
super.buttonActionPerformed(ae);
}

private boolean queued = false;

@Override
@@ -172,14 +175,16 @@ public void run() {
if (rl != null) {
textTrainRouteLocationCommentPane.setVisible(!rl.getComment().equals(RouteLocation.NONE));
textTrainRouteLocationCommentPane.setText(rl.getComment());
textLocationName.setText(rl.getLocation().getName());
pTrainDepartureTime.setVisible(_train.isShowArrivalAndDepartureTimesEnabled()
&& !rl.getDepartureTime().equals(RouteLocation.NONE));
textLocationName.setText(trainManager.isShowLocationHyphenNameEnabled()
? rl.getLocation().getName() : TrainCommon.splitString(rl.getLocation().getName()));
pTrainDepartureTime.setVisible(_train.isShowArrivalAndDepartureTimesEnabled() &&
!rl.getDepartureTime().equals(RouteLocation.NONE));
textTrainDepartureTime.setText(rl.getFormatedDepartureTime());
textLocationCommentPane.setVisible(!rl.getLocation().getComment().equals(Location.NONE)
&& Setup.isPrintLocationCommentsEnabled());
textLocationCommentPane.setVisible(!rl.getLocation().getComment().equals(Location.NONE) &&
Setup.isPrintLocationCommentsEnabled());
textLocationCommentPane.setText(rl.getLocation().getComment());
textNextLocationName.setText(_train.getNextLocationName());
textNextLocationName.setText(trainManager.isShowLocationHyphenNameEnabled()
? _train.getNextLocationName() : TrainCommon.splitString(_train.getNextLocationName()));

// check for locos
updateLocoPanes(rl);
@@ -191,17 +196,17 @@ public void run() {
moveButton.setEnabled(false);
modifyButton.setEnabled(false);
}

textStatus.setText(getStatus(rl, IS_MANIFEST));

// adjust move button text
if (rl == _train.getTrainTerminatesRouteLocation()) {
moveButton.setText(Bundle.getMessage("Terminate"));
} else {
moveButton.setText(Bundle.getMessage("Move"));
}
updateComplete();

}
}
});
@@ -222,15 +227,16 @@ public void propertyChange(java.beans.PropertyChangeEvent e) {
e.getPropertyName(), e.getSource().toString(),
e.getOldValue(), e.getNewValue());
}
if (e.getPropertyName().equals(Train.TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY)
|| e.getPropertyName().equals(Train.BUILT_CHANGED_PROPERTY)) {
if (e.getPropertyName().equals(Train.TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY) ||
e.getPropertyName().equals(Train.BUILT_CHANGED_PROPERTY)) {
clearAndUpdate();
}
if ((e.getPropertyName().equals(RollingStock.ROUTE_LOCATION_CHANGED_PROPERTY) && e.getNewValue() == null)
|| (e.getPropertyName().equals(RollingStock.ROUTE_DESTINATION_CHANGED_PROPERTY) && e
.getNewValue() == null)
|| e.getPropertyName().equals(RollingStock.TRAIN_CHANGED_PROPERTY)
|| e.getPropertyName().equals(Train.TRAIN_MODIFIED_CHANGED_PROPERTY)) {
if ((e.getPropertyName().equals(RollingStock.ROUTE_LOCATION_CHANGED_PROPERTY) && e.getNewValue() == null) ||
(e.getPropertyName().equals(RollingStock.ROUTE_DESTINATION_CHANGED_PROPERTY) &&
e
.getNewValue() == null) ||
e.getPropertyName().equals(RollingStock.TRAIN_CHANGED_PROPERTY) ||
e.getPropertyName().equals(Train.TRAIN_MODIFIED_CHANGED_PROPERTY)) {
// remove car from list
if (e.getSource().getClass().equals(Car.class)) {
Car car = (Car) e.getSource();
@@ -8,8 +8,15 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JOptionPane;

import org.jdom2.Attribute;
import org.jdom2.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jmri.InstanceManager;
import jmri.InstanceManagerAutoDefault;
import jmri.InstanceManagerAutoInitialize;
@@ -25,10 +32,6 @@
import jmri.jmrit.operations.trains.schedules.TrainScheduleManager;
import jmri.script.JmriScriptEngineManager;
import jmri.util.ColorUtil;
import org.jdom2.Attribute;
import org.jdom2.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Manages trains.
@@ -48,6 +51,9 @@
private boolean _printPreview = false; // when true, preview train manifest
private boolean _openFile = false; // when true, open CSV file manifest
private boolean _runFile = false; // when true, run CSV file manifest

// Conductor attributes
private boolean _showLocationHyphenName = false;

// Trains window row colors
private boolean _rowColorManual = true; // when true train colors are manually assigned
@@ -169,6 +175,14 @@ public void setPrintPreviewEnabled(boolean enable) {
setDirtyAndFirePropertyChange(PRINTPREVIEW_CHANGED_PROPERTY, old ? "Preview" : "Print", // NOI18N
enable ? "Preview" : "Print"); // NOI18N
}

/**
* When true show entire location name including hyphen
* @return true when showing entire location name
*/
public boolean isShowLocationHyphenNameEnabled() {
return _showLocationHyphenName;
}

public String getTrainsFrameTrainAction() {
return _trainAction;
@@ -1020,6 +1034,14 @@ public void load(Element root) {
_trainAction = a.getValue();
}
}

// Conductor options
Element eConductorOptions = options.getChild(Xml.CONDUCTOR_OPTIONS);
if (eConductorOptions != null) {
if ((a = eConductorOptions.getAttribute(Xml.SHOW_HYPHEN_NAME)) != null) {
_showLocationHyphenName = a.getValue().equals(Xml.TRUE);
}
}

// Row color options
Element eRowColorOptions = options.getChild(Xml.ROW_COLOR_OPTIONS);
@@ -1090,6 +1112,11 @@ public void store(Element root) {
e.setAttribute(Xml.RUN_FILE, isRunFileEnabled() ? Xml.TRUE : Xml.FALSE);
e.setAttribute(Xml.TRAIN_ACTION, getTrainsFrameTrainAction());
options.addContent(e);

// Conductor options
e = new Element(Xml.CONDUCTOR_OPTIONS);
e.setAttribute(Xml.SHOW_HYPHEN_NAME, isShowLocationHyphenNameEnabled() ? Xml.TRUE : Xml.FALSE);
options.addContent(e);

// Trains table row color options
e = new Element(Xml.ROW_COLOR_OPTIONS);
@@ -120,6 +120,9 @@
// static final String ACTIVE_ID = "activeId"; // NOI18N
static final String START_UP = "startUp"; // NOI18N
static final String SHUT_DOWN = "shutDown"; // NOI18N

static final String CONDUCTOR_OPTIONS = "conductorOptions"; // NOI18N
static final String SHOW_HYPHEN_NAME = "showHyphenName"; // NOI18N

static final String ROW_COLOR_OPTIONS = "rowColorOptions"; // NOI18N
static final String ROW_COLOR_MANUAL = "rowColorManual"; // NOI18N
@@ -15,9 +15,10 @@

<!ELEMENT operations-config (trains | options | schedules | trainScheduleOptions | automations)*>

<!ELEMENT options (trainOptions | rowColorOptions | trainEditOptions | scripts | manifestCreator
<!ELEMENT options (trainOptions | conductorOptions | rowColorOptions | trainEditOptions | scripts | manifestCreator
| switchlistCreator)*>
<!ELEMENT trainOptions EMPTY>
<!ELEMENT conductorOptions EMPTY>
<!ELEMENT rowColorOptions EMPTY>
<!ELEMENT trainEditOptions EMPTY>
<!ELEMENT trainScheduleOptions EMPTY>
@@ -29,6 +30,8 @@
<!ATTLIST trainOptions runFile (true | false) "false">
<!ATTLIST trainOptions trainAction CDATA #IMPLIED>

<!ATTLIST conductorOptions showHyphenName (true | false) "false">

<!ATTLIST rowColorOptions rowColorManual (true | false) "false">
<!ATTLIST rowColorOptions rowColorBuidFailed CDATA #IMPLIED>
<!ATTLIST rowColorOptions rowColorBuilt CDATA #IMPLIED>
@@ -194,6 +197,7 @@
<!ATTLIST item routeLocationId CDATA #IMPLIED>
<!ATTLIST item automationId CDATA #IMPLIED>
<!ATTLIST item gotoAutomationId CDATA #IMPLIED>
<!ATTLIST item gotoBranched CDATA #IMPLIED>
<!ATTLIST item trainScheduleId CDATA #IMPLIED>
<!ATTLIST item haltFail (true | false) "true">
<!ATTLIST item actionRan (true | false) "false">

0 comments on commit 40c61c3

Please sign in to comment.
You can’t perform that action at this time.