jmri.jmrit.operations.locations
Class ScheduleManager

java.lang.Object
  extended by jmri.jmrit.operations.locations.ScheduleManager
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class ScheduleManager
extends Object
implements PropertyChangeListener

Manages schedules.

Author:
Bob Jacobsen Copyright (C) 2003, Daniel Boudreau Copyright (C) 2008

Field Summary
protected  Hashtable<String,Schedule> _scheduleHashTable
           
static String LISTLENGTH_CHANGED_PROPERTY
           
 
Constructor Summary
ScheduleManager()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void deregister(Schedule schedule)
          Forget a NamedBean Object created outside the manager.
 void dispose()
           
protected  void firePropertyChange(String p, Object old, Object n)
           
 JComboBox getComboBox()
          Gets a JComboBox loaded with schedules.
 Schedule getScheduleById(String id)
           
 Schedule getScheduleByName(String name)
           
 List<String> getSchedulesByIdList()
          Sort by schedule number
 List<String> getSchedulesByNameList()
          Sort by schedule name
 JComboBox getSidingsByScheduleComboBox(Schedule schedule)
          Gets a JComboBox with a list of spurs that use this schedule.
static ScheduleManager instance()
           
 Schedule newSchedule(String name)
          Finds an exsisting schedule or creates a new schedule if needed requires schedule's name creates a unique id for this schedule
 int numEntries()
           
 void propertyChange(PropertyChangeEvent e)
          Check for car type and road name changes.
 void register(Schedule schedule)
          Remember a NamedBean Object created outside the manager.
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void replaceLoad(String type, String oldLoad, String newLoad)
          Replaces car loads in all schedules with specific car type.
 void replaceRoad(String oldRoad, String newRoad)
          Replaces car roads in all schedules.
 void replaceType(String oldType, String newType)
          Replaces car type in all schedules.
 void updateComboBox(JComboBox box)
          Update a JComboBox with the latest schedules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LISTLENGTH_CHANGED_PROPERTY

public static final String LISTLENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

_scheduleHashTable

protected Hashtable<String,Schedule> _scheduleHashTable
Constructor Detail

ScheduleManager

public ScheduleManager()
Method Detail

instance

public static ScheduleManager instance()

dispose

public void dispose()

numEntries

public int numEntries()
Returns:
Number of schedules

getScheduleByName

public Schedule getScheduleByName(String name)
Returns:
requested Schedule object or null if none exists

getScheduleById

public Schedule getScheduleById(String id)

newSchedule

public Schedule newSchedule(String name)
Finds an exsisting schedule or creates a new schedule if needed requires schedule's name creates a unique id for this schedule

Parameters:
name -
Returns:
new schedule or existing schedule

register

public void register(Schedule schedule)
Remember a NamedBean Object created outside the manager.


deregister

public void deregister(Schedule schedule)
Forget a NamedBean Object created outside the manager.


getSchedulesByNameList

public List<String> getSchedulesByNameList()
Sort by schedule name

Returns:
list of schedule ids ordered by name

getSchedulesByIdList

public List<String> getSchedulesByIdList()
Sort by schedule number

Returns:
list of schedule ids ordered by number

getComboBox

public JComboBox getComboBox()
Gets a JComboBox loaded with schedules.

Returns:
JComboBox with a list of schedules.

updateComboBox

public void updateComboBox(JComboBox box)
Update a JComboBox with the latest schedules.

Parameters:
box - the JComboBox needing an update.

replaceType

public void replaceType(String oldType,
                        String newType)
Replaces car type in all schedules.

Parameters:
oldType - car type to be replaced.
newType - replacement car type.

replaceRoad

public void replaceRoad(String oldRoad,
                        String newRoad)
Replaces car roads in all schedules.

Parameters:
oldRoad - car road to be replaced.
newRoad - replacement car road.

replaceLoad

public void replaceLoad(String type,
                        String oldLoad,
                        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.

getSidingsByScheduleComboBox

public JComboBox getSidingsByScheduleComboBox(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.

propertyChange

public void propertyChange(PropertyChangeEvent e)
Check for car type and road name changes.

Specified by:
propertyChange in interface PropertyChangeListener

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads