Package jmri.jmrit.operations.trains
Class TrainManager
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.jmrit.operations.trains.TrainManager
- All Implemented Interfaces:
PropertyChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,InstanceManagerAutoDefault,InstanceManagerAutoInitialize
public class TrainManager
extends PropertyChangeSupport
implements InstanceManagerAutoDefault, InstanceManagerAutoInitialize, PropertyChangeListener
Manages trains.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) intstatic final String(package private) static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddShutDownScript(String pathname) Add a script to run at shutdownvoidaddStartUpScript(String pathname) Add a script to run after trains have been loadedvoidbuildSelectedTrains(List<Train> trains) Makes a copy of an existing train.voiddeleteShutDownScript(String pathname) voiddeleteStartUpScript(String pathname) voidderegister(Train train) Forget a NamedBean Object created outside the manager.voiddispose()getExcludeTrainListForCar(Car car, PrintWriter buildReport) getList()intintGet the number of items in the rosterJColorChooser is not a replacement for getRowColorComboBox as it doesn't support no color as a selection.Gets a list of pathnames to run at shutdownGets a list of pathnames to run after trains have been loadedgetTrainById(String id) getTrainByName(String name) getTrainForCar(Car car, PrintWriter buildReport) getTrainForCar(Car car, List<Train> excludeTrains, PrintWriter buildReport, boolean isExcludeRoutes) getTrainsArrivingThisLocationList(Location location) Provides a list of trains ordered by arrival time to a locationSort by train departure location nameSort by train descriptionSort by train idSort by train nameSort by train route nameSort by train statusSort by train termination location nameSort by train departure timevoidPerform any initialization that occurs after this object has been constructed and made available by the InstanceManager.booleanbooleanbooleanbooleanbooleanUsed to determine if a train has any restrictions with regard to car built dates.booleanUsed to determine if a train has any restrictions with regard to caboose roads.booleanUsed to determine if a train has any restrictions with regard to car roads.booleanUsed to determine if a train has any restrictions with regard to car loads.booleanUsed to determine if a train has any restrictions with regard to Locomotive roads.booleanbooleanUsed to determine if a train has any restrictions with regard to car owners.booleanbooleanbooleanbooleanWhen true show entire location name including hyphenvoidload(org.jdom2.Element root) voidLoads train icons if neededFinds an existing train or creates a new train if needed.booleanprintSelectedTrains(List<Train> trains) voidNot currently used.voidRemember a NamedBean Object created outside the manager.voidreplaceLoad(String type, String oldLoadName, String newLoadName) voidvoidvoidvoidsetBuildMessagesEnabled(boolean enable) voidsetBuildReportEnabled(boolean enable) voidsetOpenFileEnabled(boolean enable) voidsetPrintPreviewEnabled(boolean enable) voidsetRowColorNameForBuildFailed(String colorName) voidsetRowColorNameForBuilt(String colorName) voidsetRowColorNameForReset(String colorName) voidsetRowColorNameForTerminated(String colorName) voidsetRowColorNameForTrainEnRoute(String colorName) voidsetRowColorsManual(boolean manual) voidsetRunFileEnabled(boolean enable) voidsetShowLocationHyphenNameEnabled(boolean enable) voidsetTrainsFrameTrainAction(String action) voidSets all built trains manifests to modified.voidsetTrainsSwitchListStatus(String status) Sets the switch list status for all built trains.voidstore(org.jdom2.Element root) Create an XML element to represent this Entry.booleanterminateSelectedTrains(List<Train> trains) voidvoidupdateTrainComboBox(JComboBox<Train> box, Car car) Update combo box with trains that will service this carMethods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
NONE
- See Also:
-
_startUpScripts
-
_shutDownScripts
-
LISTLENGTH_CHANGED_PROPERTY
- See Also:
-
PRINTPREVIEW_CHANGED_PROPERTY
- See Also:
-
OPEN_FILE_CHANGED_PROPERTY
- See Also:
-
RUN_FILE_CHANGED_PROPERTY
- See Also:
-
TRAIN_ACTION_CHANGED_PROPERTY
- See Also:
-
ROW_COLOR_NAME_CHANGED_PROPERTY
- See Also:
-
TRAINS_BUILT_CHANGED_PROPERTY
- See Also:
-
TRAINS_SHOW_FULL_NAME_PROPERTY
- See Also:
-
TRAINS_SAVED_PROPERTY
- See Also:
-
SEVEN
- See Also:
-
_maxTrainNameLength
-
-
Constructor Details
-
TrainManager
public TrainManager()
-
-
Method Details
-
getNumEntries
Get the number of items in the roster- Returns:
- Number of trains in the roster
-
isBuildMessagesEnabled
- Returns:
- true if build messages are enabled
-
setBuildMessagesEnabled
-
isBuildReportEnabled
- Returns:
- true if build reports are enabled
-
setBuildReportEnabled
-
isOpenFileEnabled
- Returns:
- true if open file is enabled
-
setOpenFileEnabled
-
isRunFileEnabled
- Returns:
- true if open file is enabled
-
setRunFileEnabled
-
isPrintPreviewEnabled
- Returns:
- true if print preview is enabled
-
setPrintPreviewEnabled
-
isShowLocationHyphenNameEnabled
When true show entire location name including hyphen- Returns:
- true when showing entire location name
-
setShowLocationHyphenNameEnabled
-
getTrainsFrameTrainAction
-
setTrainsFrameTrainAction
-
addStartUpScript
Add a script to run after trains have been loaded- Parameters:
pathname- The script's pathname
-
deleteStartUpScript
-
getStartUpScripts
Gets a list of pathnames to run after trains have been loaded- Returns:
- A list of pathnames to run after trains have been loaded
-
runStartUpScripts
-
addShutDownScript
Add a script to run at shutdown- Parameters:
pathname- The script's pathname
-
deleteShutDownScript
-
getShutDownScripts
Gets a list of pathnames to run at shutdown- Returns:
- A list of pathnames to run at shutdown
-
runShutDownScripts
-
isBuiltRestricted
Used to determine if a train has any restrictions with regard to car built dates.- Returns:
- true if there's a restriction
-
isLoadRestricted
Used to determine if a train has any restrictions with regard to car loads.- Returns:
- true if there's a restriction
-
isCarRoadRestricted
Used to determine if a train has any restrictions with regard to car roads.- Returns:
- true if there's a restriction
-
isCabooseRoadRestricted
Used to determine if a train has any restrictions with regard to caboose roads.- Returns:
- true if there's a restriction
-
isLocoRoadRestricted
Used to determine if a train has any restrictions with regard to Locomotive roads.- Returns:
- true if there's a restriction
-
isOwnerRestricted
Used to determine if a train has any restrictions with regard to car owners.- Returns:
- true if there's a restriction
-
dispose
-
getTrainByName
- Parameters:
name- The train's name.- Returns:
- requested Train object or null if none exists
-
getTrainById
-
newTrain
Finds an existing train or creates a new train if needed. Requires train's name and creates a unique id for a new train- Parameters:
name- The train's name.- Returns:
- new train or existing train
-
register
Remember a NamedBean Object created outside the manager.- Parameters:
train- The Train to be added.
-
deregister
Forget a NamedBean Object created outside the manager.- Parameters:
train- The Train to delete.
-
replaceLoad
-
isAnyTrainBuilt
- Returns:
- true if there's a built train
-
isAnyTrainBuilding
- Returns:
- true if there's a train being built
-
getTrainForCar
- Parameters:
car- The car looking for a train.buildReport- The optional build report for logging.- Returns:
- Train that can service car from its current location to the its destination.
-
getTrainForCar
public Train getTrainForCar(Car car, List<Train> excludeTrains, PrintWriter buildReport, boolean isExcludeRoutes) - Parameters:
car- The car looking for a train.excludeTrains- The trains not to try.buildReport- The optional build report for logging.isExcludeRoutes- When true eliminate trains that have the same route in the exclude trains list.- Returns:
- Train that can service car from its current location to the its destination.
-
getExcludeTrainListForCar
-
getTrainsByNameList
Sort by train name- Returns:
- list of trains ordered by name
-
getTrainsByTimeList
Sort by train departure time- Returns:
- list of trains ordered by departure time
-
getTrainsByDepartureList
Sort by train departure location name- Returns:
- list of trains ordered by departure name
-
getTrainsByTerminatesList
Sort by train termination location name- Returns:
- list of trains ordered by termination name
-
getTrainsByRouteList
Sort by train route name- Returns:
- list of trains ordered by route name
-
getTrainsByStatusList
Sort by train status- Returns:
- list of trains ordered by status
-
getTrainsByDescriptionList
Sort by train description- Returns:
- list of trains ordered by train description
-
getTrainsByIdList
Sort by train id- Returns:
- list of trains ordered by id
-
getList
-
getTrainComboBox
-
updateTrainComboBox
-
updateTrainComboBox
Update combo box with trains that will service this car- Parameters:
box- the combo box to updatecar- the car to be serviced
-
isRowColorManual
-
setRowColorsManual
-
getRowColorNameForBuilt
-
setRowColorNameForBuilt
-
getRowColorNameForBuildFailed
-
setRowColorNameForBuildFailed
-
getRowColorNameForTrainEnRoute
-
setRowColorNameForTrainEnRoute
-
getRowColorNameForTerminated
-
setRowColorNameForTerminated
-
getRowColorNameForReset
-
setRowColorNameForReset
-
getRowColorComboBox
JColorChooser is not a replacement for getRowColorComboBox as it doesn't support no color as a selection.- Returns:
- the available colors used highlighting table rows including no color.
-
copyTrain
Makes a copy of an existing train.- Parameters:
train- the train to copytrainName- the name of the new train- Returns:
- a copy of train
-
getTrainsArrivingThisLocationList
Provides a list of trains ordered by arrival time to a location- Parameters:
location- The location- Returns:
- A list of trains ordered by arrival time.
-
loadTrainIcons
Loads train icons if needed -
setTrainsSwitchListStatus
Sets the switch list status for all built trains. Used for switch lists in consolidated mode.- Parameters:
status- Train.PRINTED, Train.UNKNOWN
-
setTrainsModified
Sets all built trains manifests to modified. This causes the train's manifest to be recreated. -
buildSelectedTrains
-
printSelectedTrains
-
terminateSelectedTrains
-
resetBuildFailedTrains
-
getMaxTrainNameLength
-
load
-
store
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-trains.dtd.- Parameters:
root- common Element for operations-trains.dtd.
-
propertyChange
Not currently used.- Specified by:
propertyChangein interfacePropertyChangeListener
-
initialize
Description copied from interface:InstanceManagerAutoInitializePerform any initialization that occurs after this object has been constructed and made available by the InstanceManager.- Specified by:
initializein interfaceInstanceManagerAutoInitialize
-