jmri.jmrit.operations.trains
Class TrainScheduleManager

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

public class TrainScheduleManager
extends Object
implements PropertyChangeListener

Manages train schedules.

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

Field Summary
protected  Hashtable<String,TrainSchedule> _scheduleHashTable
           
static String LISTLENGTH_CHANGED_PROPERTY
           
 
Constructor Summary
TrainScheduleManager()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void deregister(TrainSchedule 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.
 TrainSchedule getScheduleById(String id)
           
 TrainSchedule getScheduleByName(String name)
           
 List<String> getSchedulesByIdList()
          Sort by schedule number
 List<String> getSchedulesByNameList()
          Sort by schedule name
 JComboBox getSelectComboBox()
          Gets a JComboBox loaded with schedules starting with an empty string.
static TrainScheduleManager instance()
           
 void load(Element values)
           
 TrainSchedule newSchedule(String name)
          Finds an existing 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)
           
 void register(TrainSchedule schedule)
          Remember a NamedBean Object created outside the manager.
 void removePropertyChangeListener(PropertyChangeListener l)
           
 Element store()
          Create an XML element to represent this Entry.
 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,TrainSchedule> _scheduleHashTable
Constructor Detail

TrainScheduleManager

public TrainScheduleManager()
Method Detail

instance

public static TrainScheduleManager instance()

dispose

public void dispose()

numEntries

public int numEntries()
Returns:
Number of schedules

getScheduleByName

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

getScheduleById

public TrainSchedule getScheduleById(String id)

newSchedule

public TrainSchedule newSchedule(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 -
Returns:
new TrainSchedule or existing TrainSchedule

register

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


deregister

public void deregister(TrainSchedule 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.

getSelectComboBox

public JComboBox getSelectComboBox()
Gets a JComboBox loaded with schedules starting with an empty string.

Returns:
JComboBox with a list of schedules starting with an empty string.

updateComboBox

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

Parameters:
box - the JComboBox needing an update.

store

public Element store()
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-trains.dtd.

Returns:
Contents in a JDOM Element

load

public void load(Element values)

propertyChange

public void propertyChange(PropertyChangeEvent e)
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