Class ScheduleManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.locations.schedules.ScheduleManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
,InstanceManagerAutoDefault
,InstanceManagerAutoInitialize
public class ScheduleManager extends PropertyChangeSupport implements InstanceManagerAutoDefault, InstanceManagerAutoInitialize, java.beans.PropertyChangeListener
Manages schedules.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Hashtable<java.lang.String,Schedule>
_scheduleHashTable
static java.lang.String
LISTLENGTH_CHANGED_PROPERTY
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description ScheduleManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Schedule
copySchedule(Schedule schedule, java.lang.String newScheduleName)
void
deregister(Schedule schedule)
Forget a NamedBean Object created outside the manager.void
dispose()
javax.swing.JComboBox<Schedule>
getComboBox()
Gets a JComboBox loaded with schedules.Schedule
getScheduleById(java.lang.String id)
Schedule
getScheduleByName(java.lang.String name)
java.util.List<Schedule>
getSchedulesByIdList()
Sort by schedule id numberjava.util.List<Schedule>
getSchedulesByNameList()
Sort by schedule namejavax.swing.JComboBox<LocationTrackPair>
getSpursByScheduleComboBox(Schedule schedule)
Gets a JComboBox with a list of spurs that use this schedule.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)
Schedule
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)
Check for car type and road name changes.void
register(Schedule schedule)
Remember a NamedBean Object created outside the manager.void
replaceLoad(java.lang.String type, java.lang.String oldLoad, java.lang.String newLoad)
Replaces car loads in all schedules with specific car type.void
replaceRoad(java.lang.String oldRoad, java.lang.String newRoad)
Replaces car roads in all schedules.void
replaceTrack(Track oldTrack, Track newTrack)
void
replaceType(java.lang.String oldType, java.lang.String newType)
Replaces car type in all schedules.void
resetHitCounts()
protected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
store(org.jdom2.Element root)
void
updateComboBox(javax.swing.JComboBox<Schedule> 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
-
LISTLENGTH_CHANGED_PROPERTY
public static final java.lang.String LISTLENGTH_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
_scheduleHashTable
protected java.util.Hashtable<java.lang.String,Schedule> _scheduleHashTable
-
-
Constructor Detail
-
ScheduleManager
public ScheduleManager()
-
-
Method Detail
-
dispose
public void dispose()
-
numEntries
public int numEntries()
- Returns:
- Number of schedules
-
getScheduleByName
public Schedule getScheduleByName(java.lang.String name)
- Parameters:
name
- The string name for the schedule- Returns:
- requested Schedule object or null if none exists
-
getScheduleById
public Schedule getScheduleById(java.lang.String id)
-
newSchedule
public Schedule 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 for this schedule- Returns:
- new schedule or existing schedule
-
register
public void register(Schedule schedule)
Remember a NamedBean Object created outside the manager.- Parameters:
schedule
- The Schedule to add.
-
deregister
public void deregister(Schedule schedule)
Forget a NamedBean Object created outside the manager.- Parameters:
schedule
- The Schedule to delete.
-
getSchedulesByNameList
public java.util.List<Schedule> getSchedulesByNameList()
Sort by schedule name- Returns:
- list of schedules ordered by name
-
getSchedulesByIdList
public java.util.List<Schedule> getSchedulesByIdList()
Sort by schedule id number- Returns:
- list of schedules ordered by id number
-
copySchedule
public Schedule copySchedule(Schedule schedule, java.lang.String newScheduleName)
-
resetHitCounts
public void resetHitCounts()
-
getComboBox
public javax.swing.JComboBox<Schedule> getComboBox()
Gets a JComboBox loaded with schedules.- Returns:
- JComboBox with a list of schedules.
-
updateComboBox
public void updateComboBox(javax.swing.JComboBox<Schedule> box)
Update a JComboBox with the latest schedules.- Parameters:
box
- the JComboBox needing an update.
-
replaceType
public void replaceType(java.lang.String oldType, java.lang.String newType)
Replaces car type in all schedules.- Parameters:
oldType
- car type to be replaced.newType
- replacement car type.
-
replaceRoad
public void replaceRoad(java.lang.String oldRoad, java.lang.String newRoad)
Replaces car roads in all schedules.- Parameters:
oldRoad
- car road to be replaced.newRoad
- replacement car road.
-
replaceLoad
public void replaceLoad(java.lang.String type, java.lang.String oldLoad, java.lang.String newLoad)
Replaces car loads in all schedules with specific car type.- Parameters:
type
- car type.oldLoad
- car load to be replaced.newLoad
- replacement car load.
-
replaceTrack
public void replaceTrack(Track oldTrack, Track newTrack)
-
getSpursByScheduleComboBox
public javax.swing.JComboBox<LocationTrackPair> getSpursByScheduleComboBox(Schedule schedule)
Gets a JComboBox with a list of spurs that use this schedule.- Parameters:
schedule
- The schedule for this JComboBox.- Returns:
- JComboBox with a list of spurs using schedule.
-
load
public void load(org.jdom2.Element root)
-
store
public void store(org.jdom2.Element root)
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
Check for car type and road name changes.- 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
-
-