Class RosterEntry
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.beans.ArbitraryBean
-
- jmri.jmrit.roster.RosterEntry
-
- All Implemented Interfaces:
BasicRosterEntry
,BeanInterface
,PropertyChangeFirer
,PropertyChangeProvider
,RosterObject
public class RosterEntry extends ArbitraryBean implements RosterObject, BasicRosterEntry
RosterEntry represents a single element in a locomotive roster, including information on how to locate it from decoder information.The RosterEntry is the central place to find information about a locomotive's configuration, including CV and "programming variable" information. RosterEntry handles persistence through the LocoFile class. Creating a RosterEntry does not necessarily read the corresponding file (which might not even exist), please see readFile(), writeFile() member functions.
All the data attributes have a content, not null. FileName, however, is special. A null value for it indicates that no physical file is (yet) associated with this entry.
When the filePath attribute is non-null, the user has decided to organize the roster into directories.
Each entry can have one or more "Attributes" associated with it. These are (key, value) pairs. The key has to be unique, and currently both objects have to be Strings.
All properties, including the "Attributes", are bound.
- See Also:
LocoFile
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_comment
protected java.lang.String
_dateUpdated
protected java.lang.String
_dccAddress
protected java.lang.String
_decoderComment
protected java.lang.String
_decoderFamily
protected java.lang.String
_decoderModel
protected java.lang.String
_developerID
protected java.lang.String
_fileName
protected java.lang.String
_iconFilePath
protected java.lang.String
_id
protected java.lang.String
_imageFilePath
protected java.lang.String
_isShuntingOn
protected java.lang.String
_manufacturerID
protected java.lang.String
_maxFnNum
protected int
_maxSpeedPCT
protected java.lang.String
_mfg
protected java.lang.String
_model
protected java.lang.String
_owner
protected java.lang.String
_productID
protected LocoAddress.Protocol
_protocol
protected java.lang.String
_roadName
protected java.lang.String
_roadNumber
protected RosterSpeedProfile
_sp
protected java.lang.String
_URL
static java.lang.String
ATTRIBUTE_DELETED
static java.lang.String
ATTRIBUTE_LAST_OPERATED
static java.lang.String
ATTRIBUTE_OPERATING_DURATION
static java.lang.String
ATTRIBUTE_UPDATED
protected java.util.TreeMap<java.lang.String,java.lang.String>
attributePairs
static java.lang.String
COMMENT
static java.lang.String
DATE_UPDATED
protected java.util.Date
dateModified
static java.lang.String
DCC_ADDRESS
static java.lang.String
DECODER_COMMENT
static java.lang.String
DECODER_DEVELOPERID
static java.lang.String
DECODER_FAMILY
static java.lang.String
DECODER_MANUFACTURERID
static java.lang.String
DECODER_MAXFNNUM
static java.lang.String
DECODER_MODEL
static java.lang.String
DECODER_PRODUCTID
static java.lang.String
DEFAULT_MAXFNNUM
static java.lang.String
FILENAME
static java.lang.String
FUNCTION_IMAGE
static java.lang.String
FUNCTION_LABEL
static java.lang.String
FUNCTION_LOCKABLE
static java.lang.String
FUNCTION_SELECTED_IMAGE
protected java.util.Map<java.lang.Integer,java.lang.String>
functionImages
protected java.util.Map<java.lang.Integer,java.lang.String>
functionLabels
protected java.util.Map<java.lang.Integer,java.lang.Boolean>
functionLockables
protected java.util.Map<java.lang.Integer,java.lang.String>
functionSelectedImages
protected java.util.Map<java.lang.Integer,java.lang.Boolean>
functionVisibles
static java.lang.String
ICON_FILE_PATH
static java.lang.String
ID
static java.lang.String
IMAGE_FILE_PATH
(package private) java.lang.String
indent
(package private) int
indentWidth
(package private) boolean
loadedOnce
static java.lang.String
LONG_ADDRESS
static java.lang.String
MAX_SPEED
static java.lang.String
MFG
static java.lang.String
MODEL
(package private) java.lang.String
newLine
(package private) int
openCounter
static java.lang.String
OWNER
static java.lang.String
PROTOCOL
static java.lang.String
ROADNAME
static java.lang.String
SHUNTING_FUNCTION
static java.lang.String
SOUND_LABEL
protected java.util.Map<java.lang.Integer,java.lang.String>
soundLabels
static java.lang.String
SPEED_PROFILE
static java.lang.String
URL
-
Fields inherited from class jmri.beans.ArbitraryBean
arbitraryPropertySupport
-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description RosterEntry()
Construct a blank object.RosterEntry(java.lang.String fileName)
Constructor based on a given file name.RosterEntry(RosterEntry pEntry, java.lang.String pID)
Constructor based on a given RosterEntry object and name/ID.RosterEntry(org.jdom2.Element e)
Construct this Entry from XML.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeDateUpdated()
Mark the date updated, e.g. from storing this roster entry.void
deleteAttribute(java.lang.String key)
void
ensureFilenameExists()
Ensure the entry has a valid filename.static RosterEntry
fromFile(java.io.File file)
Create a RosterEntry from a file.java.lang.String
getAttribute(java.lang.String key)
java.lang.String[]
getAttributeList()
java.util.Set<java.lang.String>
getAttributes()
Provide access to the set of attributes.java.lang.String
getComment()
java.util.Date
getDateModified()
java.lang.String
getDateUpdated()
Get the date this entry was last modified.java.lang.String
getDccAddress()
DccLocoAddress
getDccLocoAddress()
java.lang.String
getDecoderComment()
java.lang.String
getDecoderFamily()
java.lang.String
getDecoderModel()
java.lang.String
getDeveloperID()
java.lang.String
getDisplayName()
Get the formatted single-line String for displaying the object.java.lang.String
getFileName()
java.lang.String
getFunctionImage(int fn)
java.lang.String
getFunctionLabel(int fn)
If a label has been defined for a specific function, return it, otherwise return null.boolean
getFunctionLockable(int fn)
Return the lockable/latchable state of a specific function.java.lang.String
getFunctionSelectedImage(int fn)
boolean
getFunctionVisible(int fn)
Return the UI visibility of a specific function button.java.util.List<RosterGroup>
getGroups()
List the roster groups this entry is a member of, returning existingRosterGroup
s from the defaultRoster
if they exist.java.util.List<RosterGroup>
getGroups(Roster roster)
List the roster groups this entry is a member of, returning existingRosterGroup
s from the specifiedRoster
if they exist.java.lang.String
getIconPath()
java.lang.String
getId()
java.lang.String
getImagePath()
java.lang.String
getManufacturerID()
java.lang.String
getMaxFnNum()
int
getMaxFnNumAsInt()
Get the highest valid Fn key number for this roster entry.int
getMaxSpeedPCT()
java.lang.String
getMfg()
java.lang.String
getModel()
java.lang.String
getOwner()
java.lang.String
getPathName()
java.lang.String
getProductID()
LocoAddress.Protocol
getProtocol()
java.lang.String
getProtocolAsString()
java.lang.String
getRoadName()
java.lang.String
getRoadNumber()
java.lang.String
getShuntingFunction()
java.lang.String
getSoundLabel(int fn)
If a label has been defined for a specific sound, return it, otherwise return null.RosterSpeedProfile
getSpeedProfile()
java.lang.String
getURL()
boolean
isLongAddress()
boolean
isOpen()
void
loadAttributes(org.jdom2.Element e3)
Load attribute key/value pairs from a JDOM element.void
loadCvModel(VariableTableModel varModel, CvTableModel cvModel)
Load pre-existing Variable and CvTableModel object with the contents of this entry.void
loadFunctions(org.jdom2.Element e3)
Load function names from a JDOM element.void
loadFunctions(org.jdom2.Element e3, java.lang.String source)
Loads function names from a JDOM element.void
loadSounds(org.jdom2.Element e3, java.lang.String source)
Loads sound names from a JDOM element.void
printEntry(HardcopyWriter w)
void
printEntryDetails(java.io.Writer w)
Print the roster information.void
printEntryLine(HardcopyWriter w)
Ultra compact list view of roster entries.void
putAttribute(java.lang.String key, java.lang.String value)
void
readFile()
Read a file containing the contents of this RosterEntry.void
setComment(java.lang.String s)
void
setDateModified(java.lang.String date)
Set the date modified given a string representing a date.void
setDateModified(java.util.Date date)
protected void
setDateUpdated(java.lang.String s)
Set the date last updated.void
setDccAddress(java.lang.String s)
void
setDecoderComment(java.lang.String s)
void
setDecoderFamily(java.lang.String s)
void
setDecoderModel(java.lang.String s)
void
setDeveloperID(java.lang.String s)
void
setFileName(java.lang.String s)
Set the file name for this roster entry.void
setFunctionImage(int fn, java.lang.String s)
void
setFunctionLabel(int fn, java.lang.String label)
Set the label for a specific function.void
setFunctionLockable(int fn, boolean lockable)
Define whether a specific function is lockable.void
setFunctionSelectedImage(int fn, java.lang.String s)
void
setFunctionVisible(int fn, boolean visible)
Define whether a specific function button is visible.void
setIconPath(java.lang.String s)
void
setId(java.lang.String s)
Set the roster ID for this roster entry.void
setImagePath(java.lang.String s)
void
setLongAddress(boolean b)
void
setManufacturerID(java.lang.String s)
void
setMaxFnNum(java.lang.String s)
void
setMaxSpeedPCT(int maxSpeedPCT)
void
setMfg(java.lang.String s)
void
setModel(java.lang.String s)
void
setOpen(boolean boo)
void
setOwner(java.lang.String s)
void
setProductID(java.lang.String s)
void
setProtocol(LocoAddress.Protocol protocol)
void
setRoadName(java.lang.String s)
void
setRoadNumber(java.lang.String s)
void
setShuntingFunction(java.lang.String fn)
void
setSoundLabel(int fn, java.lang.String label)
Define label for a specific sound.void
setSpeedProfile(RosterSpeedProfile sp)
void
setURL(java.lang.String s)
org.jdom2.Element
store()
Create an XML element to represent this Entry.java.lang.String
titleString()
java.lang.String
toString()
void
updateFile()
Write the contents of this RosterEntry back to a file, preserving all existing decoder CV content.protected void
warnShortLong(java.lang.String id)
Warn user that the roster entry needs to be resaved.java.util.Vector<java.lang.String>
wrapComment(java.lang.String comment, int textSpace)
Line wrap a comment.void
writeFile(CvTableModel cvModel, VariableTableModel variableModel)
Write the contents of this RosterEntry to a file.-
Methods inherited from class jmri.beans.ArbitraryBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.BasicRosterEntry
addPropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.beans.BeanInterface
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
Field Detail
-
ID
public static final java.lang.String ID
- See Also:
- Constant Field Values
-
FILENAME
public static final java.lang.String FILENAME
- See Also:
- Constant Field Values
-
ROADNAME
public static final java.lang.String ROADNAME
- See Also:
- Constant Field Values
-
MFG
public static final java.lang.String MFG
- See Also:
- Constant Field Values
-
MODEL
public static final java.lang.String MODEL
- See Also:
- Constant Field Values
-
OWNER
public static final java.lang.String OWNER
- See Also:
- Constant Field Values
-
DCC_ADDRESS
public static final java.lang.String DCC_ADDRESS
- See Also:
- Constant Field Values
-
LONG_ADDRESS
public static final java.lang.String LONG_ADDRESS
- See Also:
- Constant Field Values
-
PROTOCOL
public static final java.lang.String PROTOCOL
- See Also:
- Constant Field Values
-
COMMENT
public static final java.lang.String COMMENT
- See Also:
- Constant Field Values
-
DECODER_MODEL
public static final java.lang.String DECODER_MODEL
- See Also:
- Constant Field Values
-
DECODER_DEVELOPERID
public static final java.lang.String DECODER_DEVELOPERID
- See Also:
- Constant Field Values
-
DECODER_MANUFACTURERID
public static final java.lang.String DECODER_MANUFACTURERID
- See Also:
- Constant Field Values
-
DECODER_PRODUCTID
public static final java.lang.String DECODER_PRODUCTID
- See Also:
- Constant Field Values
-
DECODER_FAMILY
public static final java.lang.String DECODER_FAMILY
- See Also:
- Constant Field Values
-
DECODER_COMMENT
public static final java.lang.String DECODER_COMMENT
- See Also:
- Constant Field Values
-
DECODER_MAXFNNUM
public static final java.lang.String DECODER_MAXFNNUM
- See Also:
- Constant Field Values
-
DEFAULT_MAXFNNUM
public static final java.lang.String DEFAULT_MAXFNNUM
- See Also:
- Constant Field Values
-
IMAGE_FILE_PATH
public static final java.lang.String IMAGE_FILE_PATH
- See Also:
- Constant Field Values
-
ICON_FILE_PATH
public static final java.lang.String ICON_FILE_PATH
- See Also:
- Constant Field Values
-
URL
public static final java.lang.String URL
- See Also:
- Constant Field Values
-
DATE_UPDATED
public static final java.lang.String DATE_UPDATED
- See Also:
- Constant Field Values
-
FUNCTION_IMAGE
public static final java.lang.String FUNCTION_IMAGE
- See Also:
- Constant Field Values
-
FUNCTION_LABEL
public static final java.lang.String FUNCTION_LABEL
- See Also:
- Constant Field Values
-
FUNCTION_LOCKABLE
public static final java.lang.String FUNCTION_LOCKABLE
- See Also:
- Constant Field Values
-
FUNCTION_SELECTED_IMAGE
public static final java.lang.String FUNCTION_SELECTED_IMAGE
- See Also:
- Constant Field Values
-
ATTRIBUTE_UPDATED
public static final java.lang.String ATTRIBUTE_UPDATED
- See Also:
- Constant Field Values
-
ATTRIBUTE_DELETED
public static final java.lang.String ATTRIBUTE_DELETED
- See Also:
- Constant Field Values
-
MAX_SPEED
public static final java.lang.String MAX_SPEED
- See Also:
- Constant Field Values
-
SHUNTING_FUNCTION
public static final java.lang.String SHUNTING_FUNCTION
- See Also:
- Constant Field Values
-
SPEED_PROFILE
public static final java.lang.String SPEED_PROFILE
- See Also:
- Constant Field Values
-
SOUND_LABEL
public static final java.lang.String SOUND_LABEL
- See Also:
- Constant Field Values
-
ATTRIBUTE_OPERATING_DURATION
public static final java.lang.String ATTRIBUTE_OPERATING_DURATION
- See Also:
- Constant Field Values
-
ATTRIBUTE_LAST_OPERATED
public static final java.lang.String ATTRIBUTE_LAST_OPERATED
- See Also:
- Constant Field Values
-
_fileName
protected java.lang.String _fileName
-
_id
protected java.lang.String _id
-
_roadName
protected java.lang.String _roadName
-
_roadNumber
protected java.lang.String _roadNumber
-
_mfg
protected java.lang.String _mfg
-
_owner
protected java.lang.String _owner
-
_model
protected java.lang.String _model
-
_dccAddress
protected java.lang.String _dccAddress
-
_protocol
protected LocoAddress.Protocol _protocol
-
_comment
protected java.lang.String _comment
-
_decoderModel
protected java.lang.String _decoderModel
-
_decoderFamily
protected java.lang.String _decoderFamily
-
_decoderComment
protected java.lang.String _decoderComment
-
_maxFnNum
protected java.lang.String _maxFnNum
-
_dateUpdated
protected java.lang.String _dateUpdated
-
dateModified
protected java.util.Date dateModified
-
_maxSpeedPCT
protected int _maxSpeedPCT
-
_developerID
protected java.lang.String _developerID
-
_manufacturerID
protected java.lang.String _manufacturerID
-
_productID
protected java.lang.String _productID
-
functionLabels
protected java.util.Map<java.lang.Integer,java.lang.String> functionLabels
-
soundLabels
protected java.util.Map<java.lang.Integer,java.lang.String> soundLabels
-
functionSelectedImages
protected java.util.Map<java.lang.Integer,java.lang.String> functionSelectedImages
-
functionImages
protected java.util.Map<java.lang.Integer,java.lang.String> functionImages
-
functionLockables
protected java.util.Map<java.lang.Integer,java.lang.Boolean> functionLockables
-
functionVisibles
protected java.util.Map<java.lang.Integer,java.lang.Boolean> functionVisibles
-
_isShuntingOn
protected java.lang.String _isShuntingOn
-
attributePairs
protected final java.util.TreeMap<java.lang.String,java.lang.String> attributePairs
-
_imageFilePath
protected java.lang.String _imageFilePath
-
_iconFilePath
protected java.lang.String _iconFilePath
-
_URL
protected java.lang.String _URL
-
_sp
protected RosterSpeedProfile _sp
-
openCounter
int openCounter
-
loadedOnce
boolean loadedOnce
-
indent
java.lang.String indent
-
indentWidth
int indentWidth
-
newLine
java.lang.String newLine
-
-
Constructor Detail
-
RosterEntry
public RosterEntry()
Construct a blank object.
-
RosterEntry
public RosterEntry(java.lang.String fileName)
Constructor based on a given file name.- Parameters:
fileName
- xml file name for the user's Roster entry
-
RosterEntry
public RosterEntry(RosterEntry pEntry, java.lang.String pID)
Constructor based on a given RosterEntry object and name/ID.- Parameters:
pEntry
- RosterEntry objectpID
- unique name/ID for the roster entry
-
RosterEntry
public RosterEntry(org.jdom2.Element e)
Construct this Entry from XML.This member has to remain synchronized with the detailed schema in xml/schema/locomotive-config.xsd.
- Parameters:
e
- Locomotive XML element
-
-
Method Detail
-
getMaxFnNumAsInt
public int getMaxFnNumAsInt()
Get the highest valid Fn key number for this roster entry.- The default value (28) can be overridden by a "maxFnNum" attribute in the "model" element of a decoder definition file
- A European standard (RCN-212) extends NMRA S9.2.1 up to F68.
- ESU LokSound 5 already uses up to F31.
- Returns:
- the highest function number (Fn) supported by this roster entry.
- See Also:
- "http://normen.railcommunity.de/RCN-212.pdf"
-
setId
public void setId(java.lang.String s)
Set the roster ID for this roster entry.- Parameters:
s
- new ID
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceBasicRosterEntry
-
setFileName
public void setFileName(java.lang.String s)
Set the file name for this roster entry.- Parameters:
s
- the new roster entry file name
-
getFileName
public java.lang.String getFileName()
-
getPathName
public java.lang.String getPathName()
-
ensureFilenameExists
public void ensureFilenameExists()
Ensure the entry has a valid filename.If none exists, create one based on the ID string. Does _not_ enforce any particular naming; you have to check separately for "<none>" or whatever your convention is for indicating an invalid name. Does replace the space, period, colon, slash and backslash characters so that the filename will be generally usable.
-
setRoadName
public void setRoadName(java.lang.String s)
-
getRoadName
public java.lang.String getRoadName()
-
setRoadNumber
public void setRoadNumber(java.lang.String s)
-
getRoadNumber
public java.lang.String getRoadNumber()
-
setMfg
public void setMfg(java.lang.String s)
-
getMfg
public java.lang.String getMfg()
-
setModel
public void setModel(java.lang.String s)
-
getModel
public java.lang.String getModel()
-
setOwner
public void setOwner(java.lang.String s)
-
getOwner
public java.lang.String getOwner()
-
setDccAddress
public void setDccAddress(java.lang.String s)
-
getDccAddress
public java.lang.String getDccAddress()
- Specified by:
getDccAddress
in interfaceBasicRosterEntry
-
setLongAddress
public void setLongAddress(boolean b)
-
getSpeedProfile
public RosterSpeedProfile getSpeedProfile()
-
setSpeedProfile
public void setSpeedProfile(RosterSpeedProfile sp)
-
isLongAddress
public boolean isLongAddress()
- Specified by:
isLongAddress
in interfaceBasicRosterEntry
-
setProtocol
public void setProtocol(LocoAddress.Protocol protocol)
-
getProtocol
public LocoAddress.Protocol getProtocol()
-
getProtocolAsString
public java.lang.String getProtocolAsString()
-
setComment
public void setComment(java.lang.String s)
-
getComment
public java.lang.String getComment()
-
setDecoderModel
public void setDecoderModel(java.lang.String s)
-
getDecoderModel
public java.lang.String getDecoderModel()
-
setDeveloperID
public void setDeveloperID(java.lang.String s)
-
getDeveloperID
public java.lang.String getDeveloperID()
-
setManufacturerID
public void setManufacturerID(java.lang.String s)
-
getManufacturerID
public java.lang.String getManufacturerID()
-
setProductID
public void setProductID(@CheckForNull java.lang.String s)
-
getProductID
public java.lang.String getProductID()
-
setDecoderFamily
public void setDecoderFamily(java.lang.String s)
-
getDecoderFamily
public java.lang.String getDecoderFamily()
-
setDecoderComment
public void setDecoderComment(java.lang.String s)
-
getDecoderComment
public java.lang.String getDecoderComment()
-
setMaxFnNum
public void setMaxFnNum(java.lang.String s)
-
getMaxFnNum
public java.lang.String getMaxFnNum()
-
getDccLocoAddress
public DccLocoAddress getDccLocoAddress()
- Specified by:
getDccLocoAddress
in interfaceBasicRosterEntry
-
setImagePath
public void setImagePath(java.lang.String s)
-
getImagePath
public java.lang.String getImagePath()
-
setIconPath
public void setIconPath(java.lang.String s)
-
getIconPath
public java.lang.String getIconPath()
-
setShuntingFunction
public void setShuntingFunction(java.lang.String fn)
-
getShuntingFunction
public java.lang.String getShuntingFunction()
- Specified by:
getShuntingFunction
in interfaceBasicRosterEntry
-
setURL
public void setURL(java.lang.String s)
-
getURL
public java.lang.String getURL()
-
setDateModified
public void setDateModified(@Nonnull java.util.Date date)
-
setDateModified
public void setDateModified(@Nonnull java.lang.String date) throws java.text.ParseException
Set the date modified given a string representing a date.Tries ISO 8601 and the current Java defaults as formats for parsing a date.
- Parameters:
date
- the string to parse into a date- Throws:
java.text.ParseException
- if the date cannot be parsed
-
getDateModified
@CheckForNull public java.util.Date getDateModified()
-
setDateUpdated
protected void setDateUpdated(java.lang.String s)
Set the date last updated.- Parameters:
s
- the string to parse into a date
-
getDateUpdated
public java.lang.String getDateUpdated()
Get the date this entry was last modified. Returns the value ofgetDateModified()
in ISO 8601 format if that is not null, otherwise returns the raw value for the last modified date from the XML file for the roster entry.Use getDateModified() if control over formatting is required
- Returns:
- the string representation of the date last modified
-
setOpen
public void setOpen(boolean boo)
- Specified by:
setOpen
in interfaceBasicRosterEntry
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceBasicRosterEntry
-
loadFunctions
public void loadFunctions(org.jdom2.Element e3)
Load function names from a JDOM element.Does not change values that are already present!
- Parameters:
e3
- the XML element containing functions
-
loadFunctions
public void loadFunctions(org.jdom2.Element e3, java.lang.String source)
Loads function names from a JDOM element. Does not change values that are already present!- Parameters:
e3
- the XML element containing the functionssource
- "family" if source is the decoder definition, or "model" if source is the roster entry itself
-
loadSounds
public void loadSounds(org.jdom2.Element e3, java.lang.String source)
Loads sound names from a JDOM element. Does not change values that are already present!- Parameters:
e3
- the XML element containing sound namessource
- "family" if source is the decoder definition, or "model" if source is the roster entry itself
-
loadAttributes
public void loadAttributes(org.jdom2.Element e3)
Load attribute key/value pairs from a JDOM element.- Parameters:
e3
- XML element containing roster entry attributes
-
setFunctionLabel
public void setFunctionLabel(int fn, java.lang.String label)
Set the label for a specific function.- Parameters:
fn
- function number, starting with 0label
- the label to use
-
getFunctionLabel
public java.lang.String getFunctionLabel(int fn)
If a label has been defined for a specific function, return it, otherwise return null.- Parameters:
fn
- function number, starting with 0- Returns:
- function label or null if not defined
-
setSoundLabel
public void setSoundLabel(int fn, java.lang.String label)
Define label for a specific sound.- Parameters:
fn
- sound number, starting with 0label
- display label for the sound function
-
getSoundLabel
public java.lang.String getSoundLabel(int fn)
If a label has been defined for a specific sound, return it, otherwise return null.- Parameters:
fn
- sound number, starting with 0- Returns:
- sound label or null
-
setFunctionImage
public void setFunctionImage(int fn, java.lang.String s)
-
getFunctionImage
public java.lang.String getFunctionImage(int fn)
-
setFunctionSelectedImage
public void setFunctionSelectedImage(int fn, java.lang.String s)
-
getFunctionSelectedImage
public java.lang.String getFunctionSelectedImage(int fn)
-
setFunctionLockable
public void setFunctionLockable(int fn, boolean lockable)
Define whether a specific function is lockable.- Parameters:
fn
- function number, starting with 0lockable
- true if function is continuous; false if momentary
-
getFunctionLockable
public boolean getFunctionLockable(int fn)
Return the lockable/latchable state of a specific function. Defaults to true.- Parameters:
fn
- function number, starting with 0- Returns:
- true if function is lockable/latchable
-
setFunctionVisible
public void setFunctionVisible(int fn, boolean visible)
Define whether a specific function button is visible.- Parameters:
fn
- function number, starting with 0visible
- true if function button is visible; false to hide
-
getFunctionVisible
public boolean getFunctionVisible(int fn)
Return the UI visibility of a specific function button. Defaults to true.- Parameters:
fn
- function number, starting with 0- Returns:
- true if function button is visible
-
putAttribute
public void putAttribute(java.lang.String key, java.lang.String value)
- Specified by:
putAttribute
in interfaceBasicRosterEntry
-
getAttribute
public java.lang.String getAttribute(java.lang.String key)
- Specified by:
getAttribute
in interfaceBasicRosterEntry
-
deleteAttribute
public void deleteAttribute(java.lang.String key)
- Specified by:
deleteAttribute
in interfaceBasicRosterEntry
-
getAttributes
public java.util.Set<java.lang.String> getAttributes()
Provide access to the set of attributes.This is directly backed access, so e.g. removing an item from this Set removes it from the RosterEntry too.
- Returns:
- a set of attribute keys
-
getAttributeList
public java.lang.String[] getAttributeList()
- Specified by:
getAttributeList
in interfaceBasicRosterEntry
-
getGroups
public java.util.List<RosterGroup> getGroups()
List the roster groups this entry is a member of, returning existingRosterGroup
s from the defaultRoster
if they exist.- Returns:
- list of roster groups
-
getGroups
public java.util.List<RosterGroup> getGroups(Roster roster)
List the roster groups this entry is a member of, returning existingRosterGroup
s from the specifiedRoster
if they exist.- Parameters:
roster
- the roster to get matching groups from- Returns:
- list of roster groups
-
getMaxSpeedPCT
public int getMaxSpeedPCT()
- Specified by:
getMaxSpeedPCT
in interfaceBasicRosterEntry
-
setMaxSpeedPCT
public void setMaxSpeedPCT(int maxSpeedPCT)
-
warnShortLong
protected void warnShortLong(java.lang.String id)
Warn user that the roster entry needs to be resaved.- Parameters:
id
- roster ID to warn about
-
store
public org.jdom2.Element store()
Create an XML element to represent this Entry.This member has to remain synchronized with the detailed schema in xml/schema/locomotive-config.xsd.
- Specified by:
store
in interfaceBasicRosterEntry
- Returns:
- Contents in a JDOM Element
-
titleString
public java.lang.String titleString()
- Specified by:
titleString
in interfaceBasicRosterEntry
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceBasicRosterEntry
- Overrides:
toString
in classjava.lang.Object
-
updateFile
public void updateFile()
Write the contents of this RosterEntry back to a file, preserving all existing decoder CV content.This writes the file back in place, with the same decoder-specific content.
-
writeFile
public void writeFile(CvTableModel cvModel, VariableTableModel variableModel)
Write the contents of this RosterEntry to a file.Information on the contents is passed through the parameters, as the actual XML creation is done in the LocoFile class.
- Parameters:
cvModel
- CV contents to include in filevariableModel
- Variable contents to include in file
-
changeDateUpdated
public void changeDateUpdated()
Mark the date updated, e.g. from storing this roster entry.
-
loadCvModel
public void loadCvModel(VariableTableModel varModel, CvTableModel cvModel)
Load pre-existing Variable and CvTableModel object with the contents of this entry.- Parameters:
varModel
- the variable model to loadcvModel
- CV contents to load
-
printEntryLine
public void printEntryLine(HardcopyWriter w)
Ultra compact list view of roster entries. Shows text from fields as initially visible in the Roster frame table.Header is created in
PrintListAction.actionPerformed(java.awt.event.ActionEvent)
so keep column widths identical with values of colWidth below.- Parameters:
w
- writer providing output
-
printEntry
public void printEntry(HardcopyWriter w)
-
printEntryDetails
public void printEntryDetails(java.io.Writer w)
Print the roster information.Updated to allow for multiline comment and decoder comment fields. Separate write statements for text and line feeds to work around the HardcopyWriter bug that misplaces borders.
- Parameters:
w
- the HardcopyWriter used to print
-
wrapComment
public java.util.Vector<java.lang.String> wrapComment(java.lang.String comment, int textSpace)
Line wrap a comment.- Parameters:
comment
- the comment to wrap at word boundariestextSpace
- the width of the space to print- Returns:
- comment wrapped to fit given width
-
readFile
public void readFile()
Read a file containing the contents of this RosterEntry.This has to be done before a call to loadCvModel, for example.
-
fromFile
public static RosterEntry fromFile(@Nonnull java.io.File file) throws org.jdom2.JDOMException, java.io.IOException
Create a RosterEntry from a file.- Parameters:
file
- The file containing the RosterEntry- Returns:
- a new RosterEntry
- Throws:
org.jdom2.JDOMException
- if unable to parse filejava.io.IOException
- if unable to read file
-
getDisplayName
public java.lang.String getDisplayName()
Description copied from interface:RosterObject
Get the formatted single-line String for displaying the object.- Specified by:
getDisplayName
in interfaceRosterObject
- Returns:
- a formatted name
-
-