bibliothek.gui.dock.support.action
Class ModeTransitionSetting<A,B>

java.lang.Object
  extended by bibliothek.gui.dock.support.action.ModeTransitionSetting<A,B>
Direct Known Subclasses:
StateManager.StateManagerSetting

public class ModeTransitionSetting<A,B>
extends Object

A storage device used to store a specific set of modes from a ModeTransitionManager. This setting can be used later to load the set of modes again.

Author:
Benjamin Sigg

Constructor Summary
ModeTransitionSetting(ModeTransitionConverter<A,B> converter)
          Creates a new setting
 
Method Summary
 void add(String id, String current, Map<String,A> properties, Collection<String> history)
          Adds a new set of properties to this setting.
 ModeTransitionConverter<A,B> getConverter()
          Gets the converter that is used to transform internal and external properties.
 String getCurrent(int index)
          Gets the current mode of the index'th set.
 String[] 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<String,A> getProperties(int index)
          Gets the converted properties of the index'th set.
 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModeTransitionSetting

public ModeTransitionSetting(ModeTransitionConverter<A,B> converter)
Creates a new setting

Parameters:
converter - the converter to read and write properties
Method Detail

getConverter

public ModeTransitionConverter<A,B> getConverter()
Gets the converter that is used to transform internal and external properties.

Returns:
the converter, never null

add

public void add(String id,
                String current,
                Map<String,A> properties,
                Collection<String> history)
Adds a new set of properties to this setting.

Parameters:
id - the unique identifier of this set of properties
current - the current mode of the set, can be null
properties - the properties, will be copied by this method
history - older modes of the setting, will be copied by this method

size

public int size()
Gets the number of sets this setting stores.

Returns:
the number of sets

getId

public String getId(int index)
Gets the unique id of the index'th set.

Parameters:
index - the index of the set
Returns:
the unique id

getCurrent

public String getCurrent(int index)
Gets the current mode of the index'th set.

Parameters:
index - the index of the set
Returns:
the current mode

getHistory

public String[] getHistory(int index)
Gets the history of the index'th set.

Parameters:
index - the index of the set
Returns:
the history

getProperties

public Map<String,A> getProperties(int index)
Gets the converted properties of the index'th set.

Parameters:
index - the index of the set
Returns:
a new map of freshly converted properties

write

public void write(DataOutputStream out)
           throws IOException
Writes all properties of this setting into out.

Parameters:
out - the stream to write into
Throws:
IOException - if an I/O-error occurs

read

public void read(DataInputStream in)
          throws IOException
Clears all properties of this setting and then reads new properties from in.

Parameters:
in - the stream to read from
Throws:
IOException - if an I/O-error occurs

writeXML

public void writeXML(XElement element)
Writes the contents of this setting in xml format.

Parameters:
element - the elemnt to write into, the attributes of element will not be changed.
See Also:
readXML(XElement)

readXML

public void readXML(XElement element)
Clears all properties of this setting and then reads new properties from element.

Parameters:
element - the element from which the properties should be read
See Also:
writeXML(XElement)