Class TrainScheduleManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.trains.schedules.TrainScheduleManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
,InstanceManagerAutoDefault
,InstanceManagerAutoInitialize
public class TrainScheduleManager extends PropertyChangeSupport implements InstanceManagerAutoDefault, InstanceManagerAutoInitialize, java.beans.PropertyChangeListener
Manages train schedules. The default is the days of the week, but can be anything the user wants when defining when trains will run.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Hashtable<java.lang.String,TrainSchedule>
_scheduleHashTable
static java.lang.String
LISTLENGTH_CHANGED_PROPERTY
static java.lang.String
NONE
static java.lang.String
SCHEDULE_ID_CHANGED_PROPERTY
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description TrainScheduleManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildSwitchLists()
void
createDefaultSchedules()
void
deregister(TrainSchedule schedule)
Forget a NamedBean Object created outside the manager.void
dispose()
TrainSchedule
getActiveSchedule()
javax.swing.JComboBox<TrainSchedule>
getComboBox()
Gets a JComboBox loaded with schedules starting with null.TrainSchedule
getScheduleById(java.lang.String id)
TrainSchedule
getScheduleByName(java.lang.String name)
java.util.List<TrainSchedule>
getSchedulesByIdList()
Sort by train schedule id numbersjava.util.List<TrainSchedule>
getSchedulesByNameList()
Sort by train schedule namejavax.swing.JComboBox<TrainSchedule>
getSelectComboBox()
Gets a JComboBox loaded with schedules starting with null.java.lang.String
getTrainScheduleActiveId()
void
initialize()
Perform any initialization that occurs after this object has been constructed and made available by the InstanceManager.void
load(org.jdom2.Element root)
TrainSchedule
newSchedule(java.lang.String name)
Finds an existing schedule or creates a new schedule if needed requires schedule's name creates a unique id for this scheduleint
numEntries()
void
propertyChange(java.beans.PropertyChangeEvent e)
void
register(TrainSchedule schedule)
Remember a NamedBean Object created outside the manager.protected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setTrainScheduleActiveId(java.lang.String id)
Sets the selected schedule idvoid
store(org.jdom2.Element root)
Create an XML element to represent this Entry.void
updateComboBox(javax.swing.JComboBox<TrainSchedule> box)
Update a JComboBox with the latest schedules.-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
NONE
public static final java.lang.String NONE
- See Also:
- Constant Field Values
-
LISTLENGTH_CHANGED_PROPERTY
public static final java.lang.String LISTLENGTH_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
SCHEDULE_ID_CHANGED_PROPERTY
public static final java.lang.String SCHEDULE_ID_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
_scheduleHashTable
protected java.util.Hashtable<java.lang.String,TrainSchedule> _scheduleHashTable
-
-
Constructor Detail
-
TrainScheduleManager
public TrainScheduleManager()
-
-
Method Detail
-
dispose
public void dispose()
-
numEntries
public int numEntries()
- Returns:
- Number of schedules
-
setTrainScheduleActiveId
public void setTrainScheduleActiveId(java.lang.String id)
Sets the selected schedule id- Parameters:
id
- Selected schedule id
-
getTrainScheduleActiveId
public java.lang.String getTrainScheduleActiveId()
-
getActiveSchedule
public TrainSchedule getActiveSchedule()
-
getScheduleByName
public TrainSchedule getScheduleByName(java.lang.String name)
- Parameters:
name
- The schedule string name to search for.- Returns:
- requested TrainSchedule object or null if none exists
-
getScheduleById
public TrainSchedule getScheduleById(java.lang.String id)
-
newSchedule
public TrainSchedule newSchedule(java.lang.String name)
Finds an existing schedule or creates a new schedule if needed requires schedule's name creates a unique id for this schedule- Parameters:
name
- The string name of the schedule.- Returns:
- new TrainSchedule or existing TrainSchedule
-
register
public void register(TrainSchedule schedule)
Remember a NamedBean Object created outside the manager.- Parameters:
schedule
- The TrainSchedule to add.
-
deregister
public void deregister(TrainSchedule schedule)
Forget a NamedBean Object created outside the manager.- Parameters:
schedule
- The TrainSchedule to delete.
-
getSchedulesByNameList
public java.util.List<TrainSchedule> getSchedulesByNameList()
Sort by train schedule name- Returns:
- list of train schedules ordered by name
-
getSchedulesByIdList
public java.util.List<TrainSchedule> getSchedulesByIdList()
Sort by train schedule id numbers- Returns:
- list of train schedules ordered by id numbers
-
getComboBox
public javax.swing.JComboBox<TrainSchedule> getComboBox()
Gets a JComboBox loaded with schedules starting with null.- Returns:
- JComboBox with a list of schedules.
-
getSelectComboBox
public javax.swing.JComboBox<TrainSchedule> getSelectComboBox()
Gets a JComboBox loaded with schedules starting with null.- Returns:
- JComboBox with a list of schedules starting with null.
-
updateComboBox
public void updateComboBox(javax.swing.JComboBox<TrainSchedule> box)
Update a JComboBox with the latest schedules.- Parameters:
box
- the JComboBox needing an update.- Throws:
java.lang.IllegalArgumentException
- if box is null
-
buildSwitchLists
public void buildSwitchLists()
-
store
public void store(org.jdom2.Element root)
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-trains.dtd.- Parameters:
root
- The common Element for operations-trains.dtd.
-
load
public void load(org.jdom2.Element root)
-
createDefaultSchedules
public void createDefaultSchedules()
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
setDirtyAndFirePropertyChange
protected void setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
-
initialize
public void initialize()
Description copied from interface:InstanceManagerAutoInitialize
Perform any initialization that occurs after this object has been constructed and made available by the InstanceManager.- Specified by:
initialize
in interfaceInstanceManagerAutoInitialize
-
-