Package bibliothek.gui.dock.support.mode
Class ModeSettings<A,B>
java.lang.Object
bibliothek.gui.dock.support.mode.ModeSettings<A,B>
- Type Parameters:
A- the objects used byModeManagerto store informationB- the independent objects used by thisModeSettingsto store information
- Direct Known Subclasses:
CLocationModeSettings
A set of properties extracted from a
ModeManager and its Modes. The properties
can be stored persistently and do not depend on any existing object (like for example the Modes).- Author:
- Benjamin Sigg
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the settings ofmodeto this.voidadd(ModeSetting<A> mode) Adds the settingsmodeto this.voidAdds a new set of properties to this setting.voidaddFactory(ModeSettingFactory<A> factory) Adds a factory to this setting.Gets the converter that is used to transform internal and external properties.getCurrent(int index) Gets the current mode of the index'th set.Path[]getHistory(int index) Gets the history of the index'th set.getId(int index) Gets the unique id of the index'th set.getProperties(int index) Gets the converted properties of the index'th set.getSettings(Path modeId) Gets the settings which belong to aModewith unique identifiermodeId.intGets the index of the entry with identifierid.voidread(DataInputStream in) Clears all properties of this setting and then reads new properties fromin.voidClears all properties of this setting and then reads new properties fromelement.protected voidrescueSettings(XElement element) Called if some setting does not have the "modes" entry, the assumption is that only old settings are missing this entry.protected voidrescueSettings(DataInputStream in, Version version) Called if some setting with version < 1.0.8 is found.protected PathresuceMode(String identifier) Called if a single identifier of a mode is found as was used in version 1.0.7 and below.intsize()Gets the number of sets this setting stores.voidwrite(DataOutputStream out) Writes all properties of this setting intoout.voidWrites the contents of this setting in xml format.
-
Constructor Details
-
ModeSettings
Creates a new setting- Parameters:
converter- the converter to read and write properties
-
-
Method Details
-
getConverter
Gets the converter that is used to transform internal and external properties.- Returns:
- the converter, never
null
-
addFactory
Adds a factory to this setting. The factory will be used to create newModeSettings.- Parameters:
factory- the new factory, notnull
-
add
Adds a new set of properties to this setting.- Parameters:
id- the unique identifier of this set of propertiescurrent- the current mode of the set, can benullproperties- the properties, will be copied by this methodhistory- older modes of the setting, will be copied by this method
-
add
Adds the settings ofmodeto this.- Parameters:
mode- the mode whose settings are to be stored
-
add
Adds the settingsmodeto this.- Parameters:
mode- the properties to store
-
size
public int size()Gets the number of sets this setting stores.- Returns:
- the number of sets
-
indexOf
Gets the index of the entry with identifierid.- Parameters:
id- the identifier of a dockable- Returns:
- the entry that represents that dockable, can be -1
-
getId
Gets the unique id of the index'th set.- Parameters:
index- the index of the set- Returns:
- the unique id
-
getCurrent
Gets the current mode of the index'th set.- Parameters:
index- the index of the set- Returns:
- the current mode
-
getHistory
Gets the history of the index'th set.- Parameters:
index- the index of the set- Returns:
- the history
-
getProperties
Gets the converted properties of the index'th set.- Parameters:
index- the index of the set- Returns:
- a new map of freshly converted properties
-
getSettings
Gets the settings which belong to aModewith unique identifiermodeId.- Parameters:
modeId- the unique identifier of some mode- Returns:
- the settings or
nullif not found
-
write
Writes all properties of this setting intoout.- Parameters:
out- the stream to write into- Throws:
IOException- if an I/O-error occurs
-
rescueSettings
Called if some setting with version < 1.0.8 is found. Subclasses may override this method to read and interpret the old settings. The default implementation does nothing.- Parameters:
in- the stream to read fromversion- the version that was found- Throws:
IOException- in case of an error
-
rescueSettings
Called if some setting does not have the "modes" entry, the assumption is that only old settings are missing this entry.- Parameters:
element- the entry that has to be rescued- Throws:
XException- in case of an error related to a wrongly read attribute
-
resuceMode
Called if a single identifier of a mode is found as was used in version 1.0.7 and below.- Parameters:
identifier- the single identifier- Returns:
- the identifier of the matching mode, can be
null
-
read
Clears all properties of this setting and then reads new properties fromin.- Parameters:
in- the stream to read from- Throws:
IOException- if an I/O-error occurs
-
writeXML
Writes the contents of this setting in xml format.- Parameters:
element- the element to write into, the attributes of element will not be changed.- See Also:
-
readXML
Clears all properties of this setting and then reads new properties fromelement.- Parameters:
element- the element from which the properties should be read- See Also:
-