|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrit.XmlFile
jmri.jmrit.roster.Roster
public class Roster
Roster manages and manipulates a roster of locomotives.
It works with the "roster-config" XML DTD to load and store its information.
This is an in-memory representation of the roster xml file (see below for constants defining name and location). As such, this class is also responsible for the "dirty bit" handling to ensure it gets written. As a temporary reliability enhancement, all changes to this structure are now being written to a backup file, and a copy is made when the file is opened.
Multiple Roster objects don't make sense, so we use an "instance" member to navigate to a single one.
The only bound property is the list of RosterEntrys; a PropertyChangedEvent is fired every time that changes.
The entries are stored in an ArrayList, sorted alphabetically. That sort is done manually each time an entry is added.
The roster is stored in a "Roster Index", which can be read or written. Each individual entry (once stored) contains a filename which can be used to retreive the locomotive information for that roster entry. Note that the RosterEntry information is duplicated in both the Roster (stored in the roster.xml file) and in the specific file for the entry.
RosterEntry| Field Summary | |
|---|---|
protected List<RosterEntry> |
_list
List of contained RosterEntry elements. |
protected ArrayList<String> |
_rosterGroupList
|
| Fields inherited from class jmri.jmrit.XmlFile |
|---|
dtdLocation, xsltLocation |
| Constructor Summary | |
|---|---|
Roster()
|
|
| Method Summary | |
|---|---|
void |
addEntry(RosterEntry e)
Add a RosterEntry object to the in-memory Roster. |
void |
addPropertyChangeListener(PropertyChangeListener l)
|
void |
addRosterGroupList(String str)
|
boolean |
checkEntry(int i,
String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderModel,
String decoderFamily,
String id)
Check if an entry is consistent with specific properties. |
static String |
defaultRosterFilename()
Return the filename String for the default roster file, including location. |
void |
delRosterGroupList(String str)
|
void |
dispose()
|
RosterEntry |
entryFromTitle(String title)
Return RosterEntry from a "title" string, ala selection in matchingComboBox. |
void |
entryIdChanged(RosterEntry r)
Notify that the ID of an entry has changed. |
String |
fileFromTitle(String title)
Return filename from a "title" string, ala selection in matchingComboBox. |
protected void |
firePropertyChange(String p,
Object old,
Object n)
|
JComboBox |
fullRosterComboBox()
Return a JComboBox containing the entire roster, if a roster group has been selected, it will only return the entries relating to that group. |
JComboBox |
fullRosterComboBoxGlobal()
Return a JComboBox containing the entire roster, regardless of what roster group has been selected. |
Set<String> |
getAllAttributeKeys()
|
List<RosterEntry> |
getEntriesWithAttributeKey(String key)
|
List<RosterEntry> |
getEntriesWithAttributeKeyValue(String key,
String value)
|
RosterEntry |
getEntry(int i)
Return a specific entry by index |
static String |
getFileLocation()
Absolute path to roster file location. |
RosterEntry |
getGroupEntry(int i)
|
static String |
getRosterGroup()
|
void |
getRosterGroupList(int i)
|
static String |
getRosterGroupName()
|
String |
getRosterGroupPrefix()
|
static String |
getRosterGroupWP()
|
static void |
installNullInstance()
Provide a null (empty) roster instance |
static Roster |
instance()
Locate the single instance of Roster, loading it if need be. |
static String |
makeValidFilename(String entry)
Name a valid roster entry filename from an entry name. |
JComboBox |
matchingComboBox(String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderMfgID,
String decoderVersionID,
String id)
Get a JComboBox representing the choices that match some information. |
JComboBox |
matchingComboBoxGlobal(String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderMfgID,
String decoderVersionID,
String id)
Get a JComboBox representing the choices that match some information regardless of which roster group has been selected. |
List<RosterEntry> |
matchingList(String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderMfgID,
String decoderVersionID,
String id)
Get a List of RosterEntry objects in Roster matching some information. |
int |
numEntries()
|
int |
numGroupEntries()
|
void |
reloadRosterFile()
Update the in-memory Roster to be consistent with the current roster file. |
void |
removeEntry(RosterEntry e)
Remove a RosterEntry object from the in-memory Roster. |
void |
removePropertyChangeListener(PropertyChangeListener l)
|
static void |
resetInstance()
|
JComboBox |
rosterGroupBox()
|
void |
rosterGroupEntryChanged()
This is here so that when a roster entry is added to a group via the table entry, a propertyChangeEvent is fired off. |
static void |
setFileLocation(String f)
Set the default location for the Roster file, and all individual locomotive files. |
static void |
setRosterFileName(String name)
|
void |
setRosterGroup(String group)
|
void |
updateComboBox(JComboBox box)
|
void |
updateComboBoxGlobal(JComboBox box)
|
void |
updateGroupBox(JComboBox box)
|
static void |
writeRosterFile()
Store the roster in the default place, including making a backup if needed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected List<RosterEntry> _list
RosterEntry elements.
protected ArrayList<String> _rosterGroupList
| Constructor Detail |
|---|
public Roster()
| Method Detail |
|---|
public static void resetInstance()
public static Roster instance()
public static void installNullInstance()
public void addEntry(RosterEntry e)
e - Entry to addpublic void removeEntry(RosterEntry e)
e - Entry to removepublic int numEntries()
public int numGroupEntries()
public JComboBox fullRosterComboBox()
The JComboBox is based on a common model object, so it updates when the roster changes.
public JComboBox fullRosterComboBoxGlobal()
The JComboBox is based on a common model object, so it updates when the roster changes.
public JComboBox matchingComboBox(String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderMfgID,
String decoderVersionID,
String id)
Only entries that exactly match the given parameters will be returned. Null parameters mean to ignore that part of the match.
The JComboBox is based on a common model object, so it updates when the roster changes.
public JComboBox matchingComboBoxGlobal(String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderMfgID,
String decoderVersionID,
String id)
Only entries that exactly match the given parameters will be returned. Null parameters mean to ignore that part of the match.
The JComboBox is based on a common model object, so it updates when the roster changes.
public void updateComboBox(JComboBox box)
public void updateComboBoxGlobal(JComboBox box)
public RosterEntry entryFromTitle(String title)
public RosterEntry getEntry(int i)
public RosterEntry getGroupEntry(int i)
public String fileFromTitle(String title)
public List<RosterEntry> getEntriesWithAttributeKey(String key)
public List<RosterEntry> getEntriesWithAttributeKeyValue(String key,
String value)
public Set<String> getAllAttributeKeys()
public List<RosterEntry> matchingList(String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderMfgID,
String decoderVersionID,
String id)
RosterEntry objects in Roster matching some information.
The list may have
null contents if there are no matches.
public boolean checkEntry(int i,
String roadName,
String roadNumber,
String dccAddress,
String mfg,
String decoderModel,
String decoderFamily,
String id)
A null String entry always matches. Strings are used for convenience in GUI building.
public static String makeValidFilename(String entry)
entry - the getId() entry name from the RosterEntry
IllegalArgumentException - if called with null or empty entry nameRosterEntry.ensureFilenameExists()public void dispose()
public static void writeRosterFile()
Uses writeFile(String), a protected method that can write to a specific location.
public void reloadRosterFile()
public static String defaultRosterFilename()
public static void setFileLocation(String f)
f - Absolute pathname to use. A null or "" argument flags
a return to the original default in prefsdir.public static String getFileLocation()
Default is in the prefsDir, but can be set to anything.
XmlFile.prefsDir()public static void setRosterFileName(String name)
public void addPropertyChangeListener(PropertyChangeListener l)
protected void firePropertyChange(String p,
Object old,
Object n)
public void removePropertyChangeListener(PropertyChangeListener l)
public void entryIdChanged(RosterEntry r)
public void setRosterGroup(String group)
public static String getRosterGroup()
public static String getRosterGroupName()
public static String getRosterGroupWP()
public void rosterGroupEntryChanged()
public String getRosterGroupPrefix()
public void addRosterGroupList(String str)
public void delRosterGroupList(String str)
public void getRosterGroupList(int i)
public JComboBox rosterGroupBox()
public void updateGroupBox(JComboBox box)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||