Package jmri.jmrit.operations.automation
Class AutomationManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.automation.AutomationManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
,InstanceManagerAutoDefault
public class AutomationManager extends PropertyChangeSupport implements InstanceManagerAutoDefault, java.beans.PropertyChangeListener
Manages automations.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Hashtable<java.lang.String,Automation>
_automationHashTable
protected Automation
_startupAutomation
static java.lang.String
LISTLENGTH_CHANGED_PROPERTY
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description AutomationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Automation
copyAutomation(Automation automation, java.lang.String newName)
Makes a new copy of automationvoid
deregister(Automation automation)
Forget a NamedBean Object created outside the manager.void
dispose()
Automation
getAutomationById(java.lang.String id)
Automation
getAutomationByName(java.lang.String name)
java.util.List<Automation>
getAutomationsByIdList()
Sort by automation id numberjava.util.List<Automation>
getAutomationsByNameList()
Sort by automation namejavax.swing.JComboBox<Automation>
getComboBox()
Gets a JComboBox loaded with automations.int
getSize()
Automation
getStartupAutomation()
protected java.lang.String
getStartupAutomationId()
void
load(org.jdom2.Element root)
Construct this Entry from XML.Automation
newAutomation(java.lang.String name)
Finds an existing automation or creates a new automation if needed requires automation's name creates a unique id for this automationvoid
propertyChange(java.beans.PropertyChangeEvent e)
void
register(Automation automation)
Remember a NamedBean Object created outside the manager.void
resumeAutomations()
Restarts all automations that were running when the operations program was last saved.void
runStartupAutomation()
protected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setStartupAutomation(Automation automation)
void
store(org.jdom2.Element root)
Create an XML element to represent this Entry.void
updateComboBox(javax.swing.JComboBox<Automation> box)
Update a JComboBox with the latest automations.-
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
-
_automationHashTable
protected java.util.Hashtable<java.lang.String,Automation> _automationHashTable
-
_startupAutomation
protected Automation _startupAutomation
-
-
Constructor Detail
-
AutomationManager
public AutomationManager()
-
-
Method Detail
-
getSize
public int getSize()
- Returns:
- Number of automations
-
getAutomationByName
public Automation getAutomationByName(java.lang.String name)
- Parameters:
name
- The string name of the automation to be returned.- Returns:
- requested Automation object or null if none exists
-
getAutomationById
public Automation getAutomationById(java.lang.String id)
-
newAutomation
public Automation newAutomation(java.lang.String name)
Finds an existing automation or creates a new automation if needed requires automation's name creates a unique id for this automation- Parameters:
name
- The string name of the automation.- Returns:
- new automation or existing automation
-
register
public void register(Automation automation)
Remember a NamedBean Object created outside the manager.- Parameters:
automation
- The automation that is being registered.
-
deregister
public void deregister(Automation automation)
Forget a NamedBean Object created outside the manager.- Parameters:
automation
- The automation to be deleted.
-
getAutomationsByNameList
public java.util.List<Automation> getAutomationsByNameList()
Sort by automation name- Returns:
- list of automations ordered by name
-
getAutomationsByIdList
public java.util.List<Automation> getAutomationsByIdList()
Sort by automation id number- Returns:
- list of automations ordered by id number
-
getComboBox
public javax.swing.JComboBox<Automation> getComboBox()
Gets a JComboBox loaded with automations.- Returns:
- JComboBox with a list of automations.
-
updateComboBox
public void updateComboBox(javax.swing.JComboBox<Automation> box)
Update a JComboBox with the latest automations.- Parameters:
box
- the JComboBox needing an update.
-
resumeAutomations
public void resumeAutomations()
Restarts all automations that were running when the operations program was last saved.
-
copyAutomation
public Automation copyAutomation(Automation automation, java.lang.String newName)
Makes a new copy of automation- Parameters:
automation
- the automation to copynewName
- name for the copy of automation- Returns:
- new copy of automation
-
getStartupAutomation
public Automation getStartupAutomation()
-
getStartupAutomationId
protected java.lang.String getStartupAutomationId()
-
setStartupAutomation
public void setStartupAutomation(Automation automation)
-
runStartupAutomation
public void runStartupAutomation()
-
dispose
public void dispose()
-
load
public void load(org.jdom2.Element root)
Construct this Entry from XML. This member has to remain synchronized with the detailed DTD in operations-trains.dtd- Parameters:
root
- Consist XML element
-
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
- Contents in a JDOM Element
-
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)
-
-