Package jmri.jmrit.operations.locations
Class LocationManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.locations.LocationManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
,InstanceManagerAutoDefault
,InstanceManagerAutoInitialize
public class LocationManager extends PropertyChangeSupport implements InstanceManagerAutoDefault, InstanceManagerAutoInitialize, java.beans.PropertyChangeListener
Manages locations.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Hashtable<java.lang.String,Location>
_locationHashTable
protected int
_maxLocationAndTrackNameLength
protected int
_maxLocationNameLength
protected int
_maxTrackNameLength
protected boolean
_showId
static java.lang.String
LISTLENGTH_CHANGED_PROPERTY
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description LocationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deregister(Location location)
Forget a NamedBean Object created outside the manager.void
dispose()
javax.swing.JComboBox<Location>
getComboBox()
Returns a JComboBox with locations sorted alphabetically.java.util.List<Location>
getList()
Gets an unsorted list of all locations.Location
getLocationById(java.lang.String id)
Location
getLocationByName(java.lang.String name)
Location
getLocationByReporter(Reporter r)
Request a location associated with a given reporter.java.util.List<Location>
getLocationsByIdList()
Sort by location number, number can alpha numericjava.util.List<Location>
getLocationsByNameList()
Sort by location nameint
getMaxLocationAndTrackNameLength()
int
getMaxLocationNameLength()
int
getMaxTrackNameLength()
int
getNumberOfLocations()
Track
getTrackByReporter(Reporter r)
Request a track associated with a given reporter.java.util.List<Track>
getTracks(java.lang.String type)
Returns all tracks of typejava.util.List<Track>
getTracksByMoves(java.lang.String type)
Returns all tracks of type sorted by use.java.util.List<Location>
getUniqueLocationsByNameList()
Get unique locations list by location name.boolean
hasDivisions()
Used to determine if a division name has been assigned to a locationboolean
hasReporters()
Used to determine if a reporter has been assigned to a locationboolean
hasWork()
void
initialize()
Perform any initialization that occurs after this object has been constructed and made available by the InstanceManager.boolean
isShowIdEnabled()
void
load(org.jdom2.Element root)
Load the locations from a xml file.Location
newLocation(java.lang.String name)
Finds an existing location or creates a new location if needed requires location's name creates a unique id for this locationvoid
propertyChange(java.beans.PropertyChangeEvent e)
There aren't any current property changes being monitored.void
register(Location location)
Remember a NamedBean Object created outside the manager.void
replaceLoad(java.lang.String type, java.lang.String oldLoadName, java.lang.String newLoadName)
Replace all track car load names for a given type of carvoid
resetMoves()
Sets move count to 0 for all tracksvoid
resetNameLengths()
protected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setShowIdEnabled(boolean showId)
void
store(org.jdom2.Element root)
void
updateComboBox(javax.swing.JComboBox<Location> box)
Updates JComboBox alphabetically with a list of locations.-
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
-
_showId
protected boolean _showId
-
_locationHashTable
protected java.util.Hashtable<java.lang.String,Location> _locationHashTable
-
_maxLocationNameLength
protected int _maxLocationNameLength
-
_maxTrackNameLength
protected int _maxTrackNameLength
-
_maxLocationAndTrackNameLength
protected int _maxLocationAndTrackNameLength
-
-
Constructor Detail
-
LocationManager
public LocationManager()
-
-
Method Detail
-
dispose
public void dispose()
-
getNumberOfLocations
public int getNumberOfLocations()
- Returns:
- Number of locations
-
getLocationByName
public Location getLocationByName(java.lang.String name)
- Parameters:
name
- The string name of the Location to get.- Returns:
- requested Location object or null if none exists
-
getLocationById
public Location getLocationById(java.lang.String id)
-
hasDivisions
public boolean hasDivisions()
Used to determine if a division name has been assigned to a location- Returns:
- true if a location has a division name
-
hasWork
public boolean hasWork()
-
hasReporters
public boolean hasReporters()
Used to determine if a reporter has been assigned to a location- Returns:
- true if a location has a RFID reporter
-
setShowIdEnabled
public void setShowIdEnabled(boolean showId)
-
isShowIdEnabled
public boolean isShowIdEnabled()
-
getLocationByReporter
public Location getLocationByReporter(Reporter r)
Request a location associated with a given reporter.- Parameters:
r
- Reporter object associated with desired location.- Returns:
- requested Location object or null if none exists
-
getTrackByReporter
public Track getTrackByReporter(Reporter r)
Request a track associated with a given reporter.- Parameters:
r
- Reporter object associated with desired location.- Returns:
- requested Location object or null if none exists
-
newLocation
public Location newLocation(java.lang.String name)
Finds an existing location or creates a new location if needed requires location's name creates a unique id for this location- Parameters:
name
- The string name for a new Location.- Returns:
- new location or existing location
-
register
public void register(Location location)
Remember a NamedBean Object created outside the manager.- Parameters:
location
- The Location to add.
-
deregister
public void deregister(Location location)
Forget a NamedBean Object created outside the manager.- Parameters:
location
- The Location to delete.
-
getLocationsByNameList
public java.util.List<Location> getLocationsByNameList()
Sort by location name- Returns:
- list of locations ordered by name
-
getUniqueLocationsByNameList
public java.util.List<Location> getUniqueLocationsByNameList()
Get unique locations list by location name.- Returns:
- list of locations ordered by name. Locations with "similar" names to the primary location are not returned. Also checks and updates the primary location for any changes to the other "similar" locations.
-
getLocationsByIdList
public java.util.List<Location> getLocationsByIdList()
Sort by location number, number can alpha numeric- Returns:
- list of locations ordered by id numbers
-
getList
public java.util.List<Location> getList()
Gets an unsorted list of all locations.- Returns:
- All locations.
-
getTracks
public java.util.List<Track> getTracks(java.lang.String type)
Returns all tracks of type- Parameters:
type
- Spur (Track.SPUR), Yard (Track.YARD), Interchange (Track.INTERCHANGE), Staging (Track.STAGING), or null (returns all track types)- Returns:
- List of tracks
-
getTracksByMoves
public java.util.List<Track> getTracksByMoves(java.lang.String type)
Returns all tracks of type sorted by use. Alternate tracks are not included.- Parameters:
type
- Spur (Track.SPUR), Yard (Track.YARD), Interchange (Track.INTERCHANGE), Staging (Track.STAGING), or null (returns all track types)- Returns:
- List of tracks ordered by use
-
resetMoves
public void resetMoves()
Sets move count to 0 for all tracks
-
getComboBox
public javax.swing.JComboBox<Location> getComboBox()
Returns a JComboBox with locations sorted alphabetically.- Returns:
- locations for this railroad
-
updateComboBox
public void updateComboBox(javax.swing.JComboBox<Location> box)
Updates JComboBox alphabetically with a list of locations.- Parameters:
box
- The JComboBox to update.
-
replaceLoad
public void replaceLoad(java.lang.String type, java.lang.String oldLoadName, java.lang.String newLoadName)
Replace all track car load names for a given type of car- Parameters:
type
- type of caroldLoadName
- load name to replacenewLoadName
- new load name
-
resetNameLengths
public void resetNameLengths()
-
getMaxLocationNameLength
public int getMaxLocationNameLength()
-
getMaxTrackNameLength
public int getMaxTrackNameLength()
-
getMaxLocationAndTrackNameLength
public int getMaxLocationAndTrackNameLength()
-
load
public void load(org.jdom2.Element root)
Load the locations from a xml file.- Parameters:
root
- xml file
-
store
public void store(org.jdom2.Element root)
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
There aren't any current property changes being monitored.- 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
-
-