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_commentprotected java.lang.String_dateUpdatedprotected java.lang.String_dccAddressprotected java.lang.String_decoderCommentprotected java.lang.String_decoderFamilyprotected java.lang.String_decoderModelprotected java.lang.String_developerIDprotected java.lang.String_fileNameprotected java.lang.String_iconFilePathprotected java.lang.String_idprotected java.lang.String_imageFilePathprotected java.lang.String_isShuntingOnprotected java.lang.String_manufacturerIDprotected java.lang.String_maxFnNumprotected int_maxSpeedPCTprotected java.lang.String_mfgprotected java.lang.String_modelprotected java.lang.String_ownerprotected java.lang.String_productIDprotected java.lang.String_programmingModesprotected LocoAddress.Protocol_protocolprotected java.lang.String_roadNameprotected java.lang.String_roadNumberprotected RosterSpeedProfile_spprotected java.lang.String_URLstatic java.lang.StringATTRIBUTE_DELETEDstatic java.lang.StringATTRIBUTE_LAST_OPERATEDstatic java.lang.StringATTRIBUTE_OPERATING_DURATIONstatic java.lang.StringATTRIBUTE_UPDATEDprotected java.util.TreeMap<java.lang.String,java.lang.String>attributePairsstatic java.lang.StringCOMMENTstatic java.lang.StringDATE_UPDATEDprotected java.util.DatedateModifiedstatic java.lang.StringDCC_ADDRESSstatic java.lang.StringDECODER_COMMENTstatic java.lang.StringDECODER_DEVELOPERIDstatic java.lang.StringDECODER_FAMILYstatic java.lang.StringDECODER_MANUFACTURERIDstatic java.lang.StringDECODER_MAXFNNUMstatic java.lang.StringDECODER_MODELstatic java.lang.StringDECODER_MODESstatic java.lang.StringDECODER_PRODUCTIDstatic java.lang.StringDEFAULT_MAXFNNUMstatic java.lang.StringFILENAMEstatic java.lang.StringFUNCTION_IMAGEstatic java.lang.StringFUNCTION_LABELstatic java.lang.StringFUNCTION_LOCKABLEstatic java.lang.StringFUNCTION_SELECTED_IMAGEprotected java.util.Map<java.lang.Integer,java.lang.String>functionImagesprotected java.util.Map<java.lang.Integer,java.lang.String>functionLabelsprotected java.util.Map<java.lang.Integer,java.lang.Boolean>functionLockablesprotected java.util.Map<java.lang.Integer,java.lang.String>functionSelectedImagesprotected java.util.Map<java.lang.Integer,java.lang.Boolean>functionVisiblesstatic java.lang.StringICON_FILE_PATHstatic java.lang.StringIDstatic java.lang.StringIMAGE_FILE_PATH(package private) java.lang.Stringindent(package private) intindentWidth(package private) booleanloadedOncestatic java.lang.StringLONG_ADDRESSstatic java.lang.StringMAX_SPEEDstatic java.lang.StringMFGstatic java.lang.StringMODEL(package private) java.lang.StringnewLine(package private) intopenCounterstatic java.lang.StringOWNERstatic java.lang.StringPROGRAMMINGstatic java.lang.StringPROTOCOLstatic java.lang.StringROADNAMEstatic java.lang.StringSHUNTING_FUNCTIONstatic java.lang.StringSOUND_LABELprotected java.util.Map<java.lang.Integer,java.lang.String>soundLabelsstatic java.lang.StringSPEED_PROFILEstatic java.lang.StringURL-
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 voidchangeDateUpdated()Mark the date updated, e.g. from storing this roster entry.voiddeleteAttribute(java.lang.String key)voidensureFilenameExists()Ensure the entry has a valid filename.static RosterEntryfromFile(java.io.File file)Create a RosterEntry from a file.java.lang.StringgetAttribute(java.lang.String key)java.lang.String[]getAttributeList()java.util.Set<java.lang.String>getAttributes()Provide access to the set of attributes.java.lang.StringgetComment()java.util.DategetDateModified()java.lang.StringgetDateUpdated()Get the date this entry was last modified.java.lang.StringgetDccAddress()DccLocoAddressgetDccLocoAddress()java.lang.StringgetDecoderComment()java.lang.StringgetDecoderFamily()java.lang.StringgetDecoderModel()java.lang.StringgetDeveloperID()java.lang.StringgetDisplayName()Get the formatted single-line String for displaying the object.java.lang.StringgetFileName()java.lang.StringgetFunctionImage(int fn)java.lang.StringgetFunctionLabel(int fn)If a label has been defined for a specific function, return it, otherwise return null.booleangetFunctionLockable(int fn)Return the lockable/latchable state of a specific function.java.lang.StringgetFunctionSelectedImage(int fn)booleangetFunctionVisible(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 existingRosterGroups from the defaultRosterif they exist.java.util.List<RosterGroup>getGroups(Roster roster)List the roster groups this entry is a member of, returning existingRosterGroups from the specifiedRosterif they exist.java.lang.StringgetIconPath()java.lang.StringgetId()java.lang.StringgetImagePath()java.lang.StringgetManufacturerID()java.lang.StringgetMaxFnNum()intgetMaxFnNumAsInt()Get the highest valid Fn key number for this roster entry.intgetMaxSpeedPCT()java.lang.StringgetMfg()java.lang.StringgetModel()java.lang.StringgetOwner()java.lang.StringgetPathName()java.lang.StringgetProductID()java.lang.StringgetProgrammingModes()Get the modes as defined in a roster entry's decoder definition.LocoAddress.ProtocolgetProtocol()java.lang.StringgetProtocolAsString()java.lang.StringgetRoadName()java.lang.StringgetRoadNumber()java.lang.StringgetShuntingFunction()java.lang.StringgetSoundLabel(int fn)If a label has been defined for a specific sound, return it, otherwise return null.RosterSpeedProfilegetSpeedProfile()java.lang.StringgetURL()booleanisLongAddress()booleanisOpen()voidloadAttributes(org.jdom2.Element e3)Load attribute key/value pairs from a JDOM element.voidloadCvModel(VariableTableModel varModel, CvTableModel cvModel)Load pre-existing Variable and CvTableModel object with the contents of this entry.voidloadFunctions(org.jdom2.Element e3)Load function names from a JDOM element.voidloadFunctions(org.jdom2.Element e3, java.lang.String source)Loads function names from a JDOM element.voidloadSounds(org.jdom2.Element e3, java.lang.String source)Loads sound names from a JDOM element.voidprintEntry(HardcopyWriter w)voidprintEntryDetails(java.io.Writer w)Print the roster entry information.voidprintEntryLine(HardcopyWriter w)Ultra-compact list view of roster entries.voidputAttribute(java.lang.String key, java.lang.String value)voidreadFile()Read a file containing the contents of this RosterEntry.voidsetComment(java.lang.String s)voidsetDateModified(java.lang.String date)Set the date modified given a string representing a date.voidsetDateModified(java.util.Date date)protected voidsetDateUpdated(java.lang.String s)Set the date last updated.voidsetDccAddress(java.lang.String s)voidsetDecoderComment(java.lang.String s)voidsetDecoderFamily(java.lang.String s)voidsetDecoderModel(java.lang.String s)voidsetDeveloperID(java.lang.String s)voidsetFileName(java.lang.String s)Set the file name for this roster entry.voidsetFunctionImage(int fn, java.lang.String s)voidsetFunctionLabel(int fn, java.lang.String label)Set the label for a specific function.voidsetFunctionLockable(int fn, boolean lockable)Define whether a specific function is lockable.voidsetFunctionSelectedImage(int fn, java.lang.String s)voidsetFunctionVisible(int fn, boolean visible)Define whether a specific function button is visible.voidsetIconPath(java.lang.String s)voidsetId(java.lang.String s)Set the roster ID for this roster entry.voidsetImagePath(java.lang.String s)voidsetLongAddress(boolean b)voidsetManufacturerID(java.lang.String s)voidsetMaxFnNum(java.lang.String s)voidsetMaxSpeedPCT(int maxSpeedPCT)voidsetMfg(java.lang.String s)voidsetModel(java.lang.String s)voidsetOpen(boolean boo)voidsetOwner(java.lang.String s)voidsetProductID(java.lang.String s)voidsetProgrammingModes(java.lang.String s)Set programming modes as defined in a roster entry's decoder definition.voidsetProtocol(LocoAddress.Protocol protocol)voidsetRoadName(java.lang.String s)voidsetRoadNumber(java.lang.String s)voidsetShuntingFunction(java.lang.String fn)voidsetSoundLabel(int fn, java.lang.String label)Define label for a specific sound.voidsetSpeedProfile(RosterSpeedProfile sp)voidsetURL(java.lang.String s)org.jdom2.Elementstore()Create an XML element to represent this Entry.java.lang.StringtitleString()java.lang.StringtoString()voidupdateFile()Write the contents of this RosterEntry back to a file, preserving all existing decoder CV content.protected voidwarnShortLong(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.voidwriteFile(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
-
PROGRAMMING
public static final java.lang.String PROGRAMMING
- See Also:
- Constant Field Values
-
DECODER_FAMILY
public static final java.lang.String DECODER_FAMILY
- See Also:
- Constant Field Values
-
DECODER_MODES
public static final java.lang.String DECODER_MODES
- 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
-
_programmingModes
protected java.lang.String _programmingModes
-
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:
getIdin 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:
getDccAddressin interfaceBasicRosterEntry
-
setLongAddress
public void setLongAddress(boolean b)
-
getSpeedProfile
public RosterSpeedProfile getSpeedProfile()
-
setSpeedProfile
public void setSpeedProfile(RosterSpeedProfile sp)
-
isLongAddress
public boolean isLongAddress()
- Specified by:
isLongAddressin 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()
-
setProgrammingModes
public void setProgrammingModes(@CheckForNull java.lang.String s)
Set programming modes as defined in a roster entry's decoder definition.- Parameters:
s- a comma separated string of predefined mode elements
-
getProgrammingModes
public java.lang.String getProgrammingModes()
Get the modes as defined in a roster entry's decoder definition.- Returns:
- a comma separated string of predefined mode elements
-
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:
getDccLocoAddressin 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:
getShuntingFunctionin 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:
setOpenin interfaceBasicRosterEntry
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin 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:
putAttributein interfaceBasicRosterEntry
-
getAttribute
public java.lang.String getAttribute(java.lang.String key)
- Specified by:
getAttributein interfaceBasicRosterEntry
-
deleteAttribute
public void deleteAttribute(java.lang.String key)
- Specified by:
deleteAttributein 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:
getAttributeListin interfaceBasicRosterEntry
-
getGroups
public java.util.List<RosterGroup> getGroups()
List the roster groups this entry is a member of, returning existingRosterGroups from the defaultRosterif 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 existingRosterGroups from the specifiedRosterif they exist.- Parameters:
roster- the roster to get matching groups from- Returns:
- list of roster groups
-
getMaxSpeedPCT
public int getMaxSpeedPCT()
- Specified by:
getMaxSpeedPCTin 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:
storein interfaceBasicRosterEntry- Returns:
- Contents in a JDOM Element
-
titleString
public java.lang.String titleString()
- Specified by:
titleStringin interfaceBasicRosterEntry
-
toString
public java.lang.String toString()
- Specified by:
toStringin interfaceBasicRosterEntry- Overrides:
toStringin 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 entry 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:RosterObjectGet the formatted single-line String for displaying the object.- Specified by:
getDisplayNamein interfaceRosterObject- Returns:
- a formatted name
-
-