use of jmri.Transit in project JMRI by JMRI.
the class DispatcherFrame method createActiveTrain.
/**
* Creates a new ActiveTrain, and registers it with Dispatcher.
*
* @param transitID system or user name of a Transit
* in the Transit Table
* @param trainID any text that identifies the train
* @param tSource either ROSTER, OPERATIONS, or USER
* (see ActiveTrain.java)
* @param startBlockName system or user name of Block where
* train currently resides
* @param startBlockSectionSequenceNumber sequence number in the Transit of
* the Section containing the
* startBlock (if the startBlock is
* within the Transit), or of the
* Section the train will enter from
* the startBlock (if the startBlock
* is outside the Transit)
* @param endBlockName system or user name of Block where
* train will end up after its
* transit
* @param endBlockSectionSequenceNumber sequence number in the Transit of
* the Section containing the
* endBlock.
* @param autoRun set to "true" if computer is to
* run the train automatically,
* otherwise "false"
* @param dccAddress required if "autoRun" is "true",
* set to null otherwise
* @param priority any integer, higher number is
* higher priority. Used to arbitrate
* allocation request conflicts
* @param resetWhenDone set to "true" if the Active Train
* is capable of continuous running
* and the user has requested that it
* be automatically reset for another
* run thru its Transit each time it
* completes running through its
* Transit.
* @param reverseAtEnd true if train should automatically
* reverse at end of transit; false
* otherwise
* @param allocateAllTheWay set to "true" to allow Auto
* Allocate to allocate as many
* sections as possible between the
* start section and the end section.
* Set to false Auto Allocate
* allocates no more than three
* sections ahead.
* @param showErrorMessages "true" if error message dialogs
* are to be displayed for detected
* errors Set to "false" to suppress
* error message dialogs from this
* method.
* @param frame window request is from, or "null"
* if not from a window
* <P>
* @return a new ActiveTrain or null on failure
*/
public ActiveTrain createActiveTrain(String transitID, String trainID, int tSource, String startBlockName, int startBlockSectionSequenceNumber, String endBlockName, int endBlockSectionSequenceNumber, boolean autoRun, String dccAddress, int priority, boolean resetWhenDone, boolean reverseAtEnd, boolean allocateAllTheWay, boolean showErrorMessages, JmriJFrame frame) {
// log.debug("trainID:{}, tSource:{}, startBlockName:{}, startBlockSectionSequenceNumber:{}, endBlockName:{}, endBlockSectionSequenceNumber:{}",
// trainID,tSource,startBlockName,startBlockSectionSequenceNumber,endBlockName,endBlockSectionSequenceNumber);
// validate input
Transit t = transitManager.getTransit(transitID);
if (t == null) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error1"), new Object[] { transitID }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Bad Transit name '" + transitID + "' when attempting to create an Active Train");
return null;
}
if (t.getState() != Transit.IDLE) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error2"), new Object[] { transitID }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Transit '" + transitID + "' not IDLE, cannot create an Active Train");
return null;
}
if ((trainID == null) || trainID.equals("")) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, Bundle.getMessage("Error3"), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("TrainID string not provided, cannot create an Active Train");
return null;
}
if ((tSource != ActiveTrain.ROSTER) && (tSource != ActiveTrain.OPERATIONS) && (tSource != ActiveTrain.USER)) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, Bundle.getMessage("Error21"), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Train source is invalid - " + tSource + " - cannot create an Active Train");
return null;
}
Block startBlock = InstanceManager.getDefault(jmri.BlockManager.class).getBlock(startBlockName);
if (startBlock == null) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error4"), new Object[] { startBlockName }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Bad startBlockName '" + startBlockName + "' when attempting to create an Active Train");
return null;
}
if (isInAllocatedSection(startBlock)) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error5"), new Object[] { startBlock.getDisplayName() }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Start block '" + startBlockName + "' in allocated Section, cannot create an Active Train");
return null;
}
if (_HasOccupancyDetection && (!(startBlock.getState() == Block.OCCUPIED))) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error6"), new Object[] { startBlock.getDisplayName() }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("No train in start block '" + startBlockName + "', cannot create an Active Train");
return null;
}
if (startBlockSectionSequenceNumber <= 0) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, Bundle.getMessage("Error12"), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
} else if (startBlockSectionSequenceNumber > t.getMaxSequence()) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error13"), new Object[] { "" + startBlockSectionSequenceNumber }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Invalid sequence number '" + startBlockSectionSequenceNumber + "' when attempting to create an Active Train");
return null;
}
Block endBlock = InstanceManager.getDefault(jmri.BlockManager.class).getBlock(endBlockName);
if ((endBlock == null) || (!t.containsBlock(endBlock))) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error7"), new Object[] { endBlockName }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Bad endBlockName '" + endBlockName + "' when attempting to create an Active Train");
return null;
}
if ((endBlockSectionSequenceNumber <= 0) && (t.getBlockCount(endBlock) > 1)) {
JOptionPane.showMessageDialog(frame, Bundle.getMessage("Error8"), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
} else if (endBlockSectionSequenceNumber > t.getMaxSequence()) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error9"), new Object[] { "" + endBlockSectionSequenceNumber }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Invalid sequence number '" + endBlockSectionSequenceNumber + "' when attempting to create an Active Train");
return null;
}
if ((!reverseAtEnd) && resetWhenDone && (!t.canBeResetWhenDone())) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error26"), new Object[] { (t.getSystemName() + "(" + t.getUserName() + ")") }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("Incompatible Transit set up and request to Reset When Done when attempting to create an Active Train");
return null;
}
if (autoRun && ((dccAddress == null) || dccAddress.equals(""))) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, Bundle.getMessage("Error10"), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
log.error("AutoRun requested without a dccAddress when attempting to create an Active Train");
return null;
}
if (autoRun) {
if (_autoTrainsFrame == null) {
// for automatic running. First check for layout editor panel
if (!_UseConnectivity || (_LE == null)) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, Bundle.getMessage("Error33"), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
log.error("AutoRun requested without a LayoutEditor panel for connectivity.");
return null;
}
}
if (!_HasOccupancyDetection) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, Bundle.getMessage("Error35"), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
log.error("AutoRun requested without occupancy detection.");
return null;
}
}
}
// check/set Transit specific items for automatic running
// validate connectivity for all Sections in this transit
int numErrors = t.validateConnectivity(_LE);
if (numErrors != 0) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error34"), new Object[] { ("" + numErrors) }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
return null;
}
// check/set direction sensors in signal logic for all Sections in this Transit.
if (getSignalType() == SIGNALHEAD) {
numErrors = t.checkSignals(_LE);
if (numErrors == 0) {
t.initializeBlockingSensors();
}
if (numErrors != 0) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error36"), new Object[] { ("" + numErrors) }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
return null;
}
}
// this train is OK, activate the AutoTrains window, if needed
if (_autoTrainsFrame == null) {
_autoTrainsFrame = new AutoTrainsFrame(_instance);
} else {
_autoTrainsFrame.setVisible(true);
}
} else if (_UseConnectivity && (_LE != null)) {
// not auto run, set up direction sensors in signals since use connectivity was requested
if (getSignalType() == SIGNALHEAD) {
int numErrors = t.checkSignals(_LE);
if (numErrors == 0) {
t.initializeBlockingSensors();
}
if (numErrors != 0) {
if (showErrorMessages) {
JOptionPane.showMessageDialog(frame, java.text.MessageFormat.format(Bundle.getMessage("Error36"), new Object[] { ("" + numErrors) }), Bundle.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
return null;
}
}
}
// all information checks out - create
ActiveTrain at = new ActiveTrain(t, trainID, tSource);
//if (at==null) {
// if (showErrorMessages) {
// JOptionPane.showMessageDialog(frame,java.text.MessageFormat.format(Bundle.getMessage(
// "Error11"),new Object[] { transitID, trainID }), Bundle.getMessage("ErrorTitle"),
// JOptionPane.ERROR_MESSAGE);
// }
// log.error("Creating Active Train failed, Transit - "+transitID+", train - "+trainID);
// return null;
//}
activeTrainsList.add(at);
java.beans.PropertyChangeListener listener = null;
at.addPropertyChangeListener(listener = new java.beans.PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
handleActiveTrainChange(e);
}
});
_atListeners.add(listener);
t.setState(Transit.ASSIGNED);
at.setStartBlock(startBlock);
at.setStartBlockSectionSequenceNumber(startBlockSectionSequenceNumber);
at.setEndBlock(endBlock);
at.setEndBlockSection(t.getSectionFromBlockAndSeq(endBlock, endBlockSectionSequenceNumber));
at.setEndBlockSectionSequenceNumber(endBlockSectionSequenceNumber);
at.setResetWhenDone(resetWhenDone);
if (resetWhenDone) {
restartingTrainsList.add(at);
}
at.setReverseAtEnd(reverseAtEnd);
at.setAllocateAllTheWay(allocateAllTheWay);
at.setPriority(priority);
at.setDccAddress(dccAddress);
at.setAutoRun(autoRun);
return at;
}
use of jmri.Transit in project JMRI by JMRI.
the class SignalMastIcon method addTransitPopup.
private void addTransitPopup(JPopupMenu popup) {
if ((InstanceManager.getDefault(jmri.SectionManager.class).getSystemNameList().size()) > 0 && jmri.InstanceManager.getDefault(jmri.jmrit.display.layoutEditor.LayoutBlockManager.class).isAdvancedRoutingEnabled()) {
if (tct == null) {
tct = new jmri.jmrit.display.layoutEditor.TransitCreationTool();
}
popup.addSeparator();
String addString = Bundle.getMessage("MenuTransitCreate");
if (tct.isToolInUse()) {
addString = Bundle.getMessage("MenuTransitAddTo");
}
popup.add(new AbstractAction(addString) {
@Override
public void actionPerformed(ActionEvent e) {
try {
tct.addNamedBean(getSignalMast());
} catch (jmri.JmriException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage(), Bundle.getMessage("TransitErrorTitle"), JOptionPane.ERROR_MESSAGE);
}
}
});
if (tct.isToolInUse()) {
popup.add(new AbstractAction(Bundle.getMessage("MenuTransitAddComplete")) {
@Override
public void actionPerformed(ActionEvent e) {
Transit created;
try {
tct.addNamedBean(getSignalMast());
created = tct.createTransit();
JOptionPane.showMessageDialog(null, Bundle.getMessage("TransitCreatedMessage", created.getDisplayName()), Bundle.getMessage("TransitCreatedTitle"), JOptionPane.INFORMATION_MESSAGE);
} catch (jmri.JmriException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage(), Bundle.getMessage("TransitErrorTitle"), JOptionPane.ERROR_MESSAGE);
return;
}
}
});
popup.add(new AbstractAction(Bundle.getMessage("MenuTransitCancel")) {
@Override
public void actionPerformed(ActionEvent e) {
tct.cancelTransitCreate();
}
});
}
popup.addSeparator();
}
}
use of jmri.Transit in project JMRI by JMRI.
the class TransitTableAction method createModel.
/**
* Create the JTable DataModel, along with the changes for the specific case
* of Transit objects
*/
@Override
protected void createModel() {
m = new BeanTableDataModel() {
public static final int EDITCOL = NUMCOLUMN;
public static final int DUPLICATECOL = EDITCOL + 1;
@Override
public String getValue(String name) {
if (name == null) {
log.warn("requested getValue(null)");
return "(no name)";
}
Transit z = InstanceManager.getDefault(jmri.TransitManager.class).getBySystemName(name);
if (z == null) {
log.debug("requested getValue(\"" + name + "\"), Transit doesn't exist");
return "(no Transit)";
}
return "Transit";
}
@Override
public Manager getManager() {
return InstanceManager.getDefault(jmri.TransitManager.class);
}
@Override
public NamedBean getBySystemName(String name) {
return InstanceManager.getDefault(jmri.TransitManager.class).getBySystemName(name);
}
@Override
public NamedBean getByUserName(String name) {
return InstanceManager.getDefault(jmri.TransitManager.class).getByUserName(name);
}
@Override
protected String getMasterClassName() {
return getClassName();
}
@Override
public void clickOn(NamedBean t) {
}
@Override
public int getColumnCount() {
return DUPLICATECOL + 1;
}
@Override
public Object getValueAt(int row, int col) {
if (col == VALUECOL) {
// some error checking
if (row >= sysNameList.size()) {
log.debug("row is greater than name list");
return "";
}
Transit z = (Transit) getBySystemName(sysNameList.get(row));
if (z == null) {
return "";
} else {
int state = z.getState();
if (state == Transit.IDLE) {
return (rbx.getString("TransitIdle"));
} else if (state == Transit.ASSIGNED) {
return (rbx.getString("TransitAssigned"));
}
}
} else if (col == EDITCOL) {
return Bundle.getMessage("ButtonEdit");
} else if (col == DUPLICATECOL) {
return rbx.getString("ButtonDuplicate");
} else {
return super.getValueAt(row, col);
}
return null;
}
@Override
public void setValueAt(Object value, int row, int col) {
if (col == EDITCOL) {
class WindowMaker implements Runnable {
int row;
WindowMaker(int r) {
row = r;
}
@Override
public void run() {
String sName = (String) getValueAt(row, SYSNAMECOL);
editPressed(sName);
}
}
WindowMaker t = new WindowMaker(row);
javax.swing.SwingUtilities.invokeLater(t);
} else if (col == DUPLICATECOL) {
// set up to duplicate
class WindowMaker implements Runnable {
int row;
WindowMaker(int r) {
row = r;
}
@Override
public void run() {
String sName = (String) getValueAt(row, SYSNAMECOL);
duplicatePressed(sName);
}
}
WindowMaker t = new WindowMaker(row);
javax.swing.SwingUtilities.invokeLater(t);
} else {
super.setValueAt(value, row, col);
}
}
@Override
public String getColumnName(int col) {
if (col == EDITCOL) {
// no namne on Edit column
return "";
}
if (col == DUPLICATECOL) {
// no namne on Duplicate column
return "";
}
return super.getColumnName(col);
}
@Override
public Class<?> getColumnClass(int col) {
if (col == VALUECOL) {
// not a button
return String.class;
}
if (col == EDITCOL) {
return JButton.class;
}
if (col == DUPLICATECOL) {
return JButton.class;
} else {
return super.getColumnClass(col);
}
}
@Override
public boolean isCellEditable(int row, int col) {
if (col == VALUECOL) {
return false;
}
if (col == EDITCOL) {
return true;
}
if (col == DUPLICATECOL) {
return true;
} else {
return super.isCellEditable(row, col);
}
}
@Override
public int getPreferredWidth(int col) {
// override default value for SystemName and UserName columns
if (col == SYSNAMECOL) {
return new JTextField(9).getPreferredSize().width;
}
if (col == USERNAMECOL) {
return new JTextField(17).getPreferredSize().width;
}
if (col == VALUECOL) {
return new JTextField(6).getPreferredSize().width;
}
// new columns
if (col == EDITCOL) {
return new JTextField(6).getPreferredSize().width;
}
if (col == DUPLICATECOL) {
return new JTextField(10).getPreferredSize().width;
} else {
return super.getPreferredWidth(col);
}
}
@Override
public void configValueColumn(JTable table) {
// value column isn't button, so config is null
}
@Override
protected boolean matchPropertyName(java.beans.PropertyChangeEvent e) {
return true;
// return (e.getPropertyName().indexOf("alue")=0);
}
@Override
public JButton configureButton() {
log.error("configureButton should not have been called");
return null;
}
@Override
protected String getBeanType() {
return "Transit";
}
};
}
use of jmri.Transit in project JMRI by JMRI.
the class ActivateTrainFrame method initiateTrain.
/**
* Displays a window that allows a new ActiveTrain to be activated.
*
* Called by Dispatcher in response to the dispatcher clicking the New Train
* button.
* @param e the action event triggering the window display
*/
protected void initiateTrain(ActionEvent e) {
// set Dispatcher defaults
_TrainsFromRoster = _dispatcher.getTrainsFromRoster();
_TrainsFromTrains = _dispatcher.getTrainsFromTrains();
_TrainsFromUser = _dispatcher.getTrainsFromUser();
_ActiveTrainsList = _dispatcher.getActiveTrainsList();
// create window if needed
if (initiateFrame == null) {
initiateFrame = new JmriJFrame(Bundle.getMessage("AddTrainTitle"), false, true);
initiateFrame.addHelpMenu("package.jmri.jmrit.dispatcher.NewTrain", true);
initiatePane = initiateFrame.getContentPane();
initiatePane.setLayout(new BoxLayout(initiateFrame.getContentPane(), BoxLayout.Y_AXIS));
// add buttons to load and save train information
JPanel p0 = new JPanel();
p0.setLayout(new FlowLayout());
p0.add(loadButton = new JButton(Bundle.getMessage("LoadButton")));
loadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
loadTrainInfo(e);
}
});
loadButton.setToolTipText(Bundle.getMessage("LoadButtonHint"));
p0.add(saveButton = new JButton(Bundle.getMessage("SaveButton")));
saveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
saveTrainInfo(e);
}
});
saveButton.setToolTipText(Bundle.getMessage("SaveButtonHint"));
p0.add(deleteButton = new JButton(Bundle.getMessage("ButtonDelete")));
deleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteTrainInfo(e);
}
});
deleteButton.setToolTipText(Bundle.getMessage("DeleteButtonHint"));
initiatePane.add(p0);
initiatePane.add(new JSeparator());
// add items relating to both manually run and automatic trains.
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(new JLabel(Bundle.getMessage("TransitBoxLabel") + " :"));
p1.add(transitSelectBox);
transitSelectBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleTransitSelectionChanged(e);
}
});
transitSelectBox.setToolTipText(Bundle.getMessage("TransitBoxHint"));
p1.add(trainBoxLabel);
p1.add(trainSelectBox);
trainSelectBox.setToolTipText(Bundle.getMessage("TrainBoxHint"));
initiatePane.add(p1);
JPanel p1a = new JPanel();
p1a.setLayout(new FlowLayout());
p1a.add(trainFieldLabel);
p1a.add(trainNameField);
trainNameField.setToolTipText(Bundle.getMessage("TrainFieldHint"));
p1a.add(dccAddressFieldLabel);
p1a.add(dccAddressField);
dccAddressField.setToolTipText(Bundle.getMessage("DccAddressFieldHint"));
initiatePane.add(p1a);
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.add(inTransitBox);
inTransitBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleInTransitClick(e);
}
});
inTransitBox.setToolTipText(Bundle.getMessage("InTransitBoxHint"));
initiatePane.add(p2);
JPanel p3 = new JPanel();
p3.setLayout(new FlowLayout());
p3.add(new JLabel(Bundle.getMessage("StartingBlockBoxLabel") + " :"));
p3.add(startingBlockBox);
startingBlockBox.setToolTipText(Bundle.getMessage("StartingBlockBoxHint"));
startingBlockBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleStartingBlockSelectionChanged(e);
}
});
initiatePane.add(p3);
JPanel p4 = new JPanel();
p4.setLayout(new FlowLayout());
p4.add(new JLabel(Bundle.getMessage("DestinationBlockBoxLabel") + ":"));
p4.add(destinationBlockBox);
destinationBlockBox.setToolTipText(Bundle.getMessage("DestinationBlockBoxHint"));
initiatePane.add(p4);
JPanel p4a = new JPanel();
p4a.setLayout(new FlowLayout());
p4a.add(allocateAllTheWayBox);
allocateAllTheWayBox.setToolTipText(Bundle.getMessage("AllocateAllTheWayBoxHint"));
initiatePane.add(p4a);
JPanel p6 = new JPanel();
p6.setLayout(new FlowLayout());
p6.add(resetWhenDoneBox);
resetWhenDoneBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleResetWhenDoneClick(e);
}
});
resetWhenDoneBox.setToolTipText(Bundle.getMessage("ResetWhenDoneBoxHint"));
initiatePane.add(p6);
JPanel p6a = new JPanel();
p6a.setLayout(new FlowLayout());
((FlowLayout) p6a.getLayout()).setVgap(1);
p6a.add(delayedReStartLabel);
p6a.add(delayedReStartBox);
delayedReStartBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleResetWhenDoneClick(e);
}
});
delayedReStartBox.setToolTipText(Bundle.getMessage("DelayedReStartHint"));
initiatePane.add(p6a);
JPanel p6b = new JPanel();
p6b.setLayout(new FlowLayout());
((FlowLayout) p6b.getLayout()).setVgap(1);
p6b.add(delayMinLabel);
p6b.add(delayMinField);
delayMinField.setText("0");
delayMinField.setToolTipText(Bundle.getMessage("RestartTimedHint"));
p6b.add(delayReStartSensorLabel);
p6b.add(delayReStartSensor);
delayReStartSensor.setFirstItemBlank(true);
handleResetWhenDoneClick(null);
initiatePane.add(p6b);
JPanel p10 = new JPanel();
p10.setLayout(new FlowLayout());
p10.add(reverseAtEndBox);
reverseAtEndBox.setToolTipText(Bundle.getMessage("ReverseAtEndBoxHint"));
initiatePane.add(p10);
reverseAtEndBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleReverseAtEndBoxClick(e);
}
});
JPanel p10a = new JPanel();
p10a.setLayout(new FlowLayout());
p10a.add(terminateWhenDoneBox);
initiatePane.add(p10a);
JPanel p8 = new JPanel();
p8.setLayout(new FlowLayout());
p8.add(new JLabel(Bundle.getMessage("PriorityLabel") + " :"));
p8.add(priorityField);
priorityField.setToolTipText(Bundle.getMessage("PriorityHint"));
priorityField.setText("5");
p8.add(new JLabel(" "));
p8.add(new JLabel(Bundle.getMessage("TrainTypeBoxLabel")));
initializeTrainTypeBox();
p8.add(trainTypeBox);
trainTypeBox.setSelectedIndex(1);
trainTypeBox.setToolTipText(Bundle.getMessage("TrainTypeBoxHint"));
initiatePane.add(p8);
JPanel p9 = new JPanel();
p9.setLayout(new FlowLayout());
p9.add(new JLabel(Bundle.getMessage("DelayedStart")));
p9.add(delayedStartBox);
delayedStartBox.setToolTipText(Bundle.getMessage("DelayedStartHint"));
delayedStartBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleDelayStartClick(e);
}
});
p9.add(departureTimeLabel);
p9.add(departureHrField);
departureHrField.setText("08");
departureHrField.setToolTipText(Bundle.getMessage("DepartureTimeHrHint"));
p9.add(departureSepLabel);
p9.add(departureMinField);
departureMinField.setText("00");
departureMinField.setToolTipText(Bundle.getMessage("DepartureTimeMinHint"));
p9.add(delaySensor);
delaySensor.setFirstItemBlank(true);
handleDelayStartClick(null);
initiatePane.add(p9);
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(loadAtStartupBox);
loadAtStartupBox.setToolTipText(Bundle.getMessage("LoadAtStartupBoxHint"));
loadAtStartupBox.setSelected(false);
initiatePane.add(p11);
initiatePane.add(new JSeparator());
JPanel p5 = new JPanel();
p5.setLayout(new FlowLayout());
p5.add(autoRunBox);
autoRunBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleAutoRunClick(e);
}
});
autoRunBox.setToolTipText(Bundle.getMessage("AutoRunBoxHint"));
autoRunBox.setSelected(false);
initiatePane.add(p5);
initializeAutoRunItems();
initiatePane.add(new JSeparator());
JPanel p7 = new JPanel();
p7.setLayout(new FlowLayout());
JButton cancelButton = null;
p7.add(cancelButton = new JButton(Bundle.getMessage("ButtonCancel")));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelInitiateTrain(e);
}
});
cancelButton.setToolTipText(Bundle.getMessage("CancelButtonHint"));
p7.add(addNewTrainButton = new JButton(Bundle.getMessage("AddNewTrainButton")));
addNewTrainButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addNewTrain(e);
}
});
addNewTrainButton.setToolTipText(Bundle.getMessage("AddNewTrainButtonHint"));
initiatePane.add(p7);
}
if (_TrainsFromRoster || _TrainsFromTrains) {
trainBoxLabel.setVisible(true);
trainSelectBox.setVisible(true);
trainFieldLabel.setVisible(false);
trainNameField.setVisible(false);
dccAddressFieldLabel.setVisible(false);
dccAddressField.setVisible(false);
} else if (_TrainsFromUser) {
trainNameField.setText("");
trainBoxLabel.setVisible(false);
trainSelectBox.setVisible(false);
trainFieldLabel.setVisible(true);
trainNameField.setVisible(true);
dccAddressFieldLabel.setVisible(true);
dccAddressField.setVisible(true);
}
setAutoRunDefaults();
autoRunBox.setSelected(false);
loadAtStartupBox.setSelected(false);
allocateAllTheWayBox.setSelected(false);
initializeFreeTransitsCombo(new ArrayList<Transit>());
initializeFreeTrainsCombo();
initiateFrame.pack();
initiateFrame.setVisible(true);
}
Aggregations