A - the objects used by ModeManager to store informationB - the independent objects used by this ModeSettings to store informationpublic class ModeSettings<A,B> extends Object
ModeManager and its Modes. The properties
can be stored persistently and do not depend on any existing object (like for example the Modes).| Constructor and Description |
|---|
ModeSettings(ModeSettingsConverter<A,B> converter)
Creates a new setting
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Mode<A> mode)
Adds the settings of
mode to this. |
void |
add(ModeSetting<A> mode)
Adds the settings
mode to this. |
void |
add(String id,
Path current,
Map<Path,A> properties,
Collection<Path> history)
Adds a new set of properties to this setting.
|
void |
addFactory(ModeSettingFactory<A> factory)
Adds a factory to this setting.
|
ModeSettingsConverter<A,B> |
getConverter()
Gets the converter that is used to transform internal and external
properties.
|
Path |
getCurrent(int index)
Gets the current mode of the index'th set.
|
Path[] |
getHistory(int index)
Gets the history of the index'th set.
|
String |
getId(int index)
Gets the unique id of the index'th set.
|
Map<Path,A> |
getProperties(int index)
Gets the converted properties of the index'th set.
|
ModeSetting<A> |
getSettings(Path modeId)
Gets the settings which belong to a
Mode with unique
identifier modeId. |
int |
indexOf(String id)
Gets the index of the entry with identifier
id. |
void |
read(DataInputStream in)
Clears all properties of this setting and then reads new properties
from
in. |
void |
readXML(XElement element)
Clears all properties of this setting and then reads new properties
from
element. |
protected void |
rescueSettings(DataInputStream in,
Version version)
Called if some setting with version < 1.0.8 is found.
|
protected void |
rescueSettings(XElement element)
Called if some setting does not have the "modes" entry, the assumption is that
only old settings are missing this entry.
|
protected Path |
resuceMode(String identifier)
Called if a single identifier of a mode is found as was used in
version 1.0.7 and below.
|
int |
size()
Gets the number of sets this setting stores.
|
void |
write(DataOutputStream out)
Writes all properties of this setting into
out. |
void |
writeXML(XElement element)
Writes the contents of this setting in xml format.
|
public ModeSettings(ModeSettingsConverter<A,B> converter)
converter - the converter to read and write propertiespublic ModeSettingsConverter<A,B> getConverter()
nullpublic void addFactory(ModeSettingFactory<A> factory)
ModeSettings.factory - the new factory, not nullpublic void add(String id, Path current, Map<Path,A> properties, Collection<Path> history)
id - the unique identifier of this set of propertiescurrent - the current mode of the set, can be nullproperties - the properties, will be copied by this methodhistory - older modes of the setting, will be copied by this methodpublic void add(Mode<A> mode)
mode to this.mode - the mode whose settings are to be storedpublic void add(ModeSetting<A> mode)
mode to this.mode - the properties to storepublic int size()
public int indexOf(String id)
id.id - the identifier of a dockablepublic String getId(int index)
index - the index of the setpublic Path getCurrent(int index)
index - the index of the setpublic Path[] getHistory(int index)
index - the index of the setpublic Map<Path,A> getProperties(int index)
index - the index of the setpublic ModeSetting<A> getSettings(Path modeId)
Mode with unique
identifier modeId.modeId - the unique identifier of some modenull if not foundpublic void write(DataOutputStream out) throws IOException
out.out - the stream to write intoIOException - if an I/O-error occursprotected void rescueSettings(DataInputStream in, Version version) throws IOException
in - the stream to read fromversion - the version that was foundIOException - in case of an errorprotected void rescueSettings(XElement element)
element - the entry that has to be rescuedXException - in case of an error related to a wrongly read attributeprotected Path resuceMode(String identifier)
identifier - the single identifiernullpublic void read(DataInputStream in) throws IOException
in.in - the stream to read fromIOException - if an I/O-error occurspublic void writeXML(XElement element)
element - the element to write into, the attributes of
element will not be changed.readXML(XElement)public void readXML(XElement element)
element.element - the element from which the properties should be readwriteXML(XElement)Copyright © 2018. All rights reserved.