|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.gui.dock.layout.DockSituation
public class DockSituation
A DockSituation
is a converter: the relationship of DockStation
s and Dockable
s,
the position of Dockable
s and other information are converted into a
stream of bytes. The other direction, read a stream and create Dockable
s and DockStation
s, is also possible.
Field Summary | |
---|---|
static Path |
ADJACENT_DOCK_FACTORY_EXTENSION
Name for an ExtensionName to load additional AdjacentDockFactory s |
static Path |
DOCK_FACTORY_EXTENSION
Name for an ExtensionName to load additional DockFactory s |
static String |
EXTENSION_PARAM
Name of a parameter of an ExtensionName pointing to this |
Constructor Summary | |
---|---|
DockSituation(DockController controller)
Constructs a new DockSituation. |
|
DockSituation(DockFactory<?,?,?>... factories)
Constructs a new DockSituation and sets some factories which are used to create new DockElements . |
Method Summary | |
---|---|
void |
add(DockFactory<?,?,?> factory)
Adds a factory |
void |
addAdjacent(AdjacentDockFactory<?> factory)
Adds an adjacent factory |
DockLayoutComposition |
convert(DockElement element)
Converts the layout of element and all its children into a
DockLayoutComposition . |
DockElement |
convert(DockLayoutComposition composition)
Reads the contents of composition and tries to create a
DockElement that matches the composition. |
String |
convertFactoryId(DockFactory<?,?,?> factory)
Tells what identifier is used for factory in the
DockLayoutComposition .This method just calls getID(DockFactory) , but
getID(DockFactory) is intended for internal use while this
method is intended to be used by clients which read out a DockLayoutComposition . |
String |
convertFactoryId(String id)
Tells what identifier the DockFactory has, for which the
identifier id is used within a DockLayoutComposition .This method just calls getFactoryID(String) , but while
getFactoryID(String) is intended for internal use, this method
is intended for clients. |
Perspective |
createPerspective()
Creates a new Perspective that uses the settings made on this DockSituation . |
protected void |
estimateLocations(DefaultLocationEstimationMap map)
Recursively tries to estimate the locations of all DockLayoutInfo s that can
be found in map .Note: this method does not call DefaultLocationEstimationMap.finish() . |
void |
estimateLocations(DockLayoutComposition composition)
Tries to guess the location of the elements stored in the tree below composition . |
void |
estimateLocations(DockLayoutComposition composition,
DockableProperty location)
Tries to guess the location of the elements stored in the tree below composition , assuming that composition itself
is at location location . |
DockLayoutComposition |
fillMissing(DockLayoutComposition composition)
Using the factories currently known to this DockSituation , this
method tries to fill gaps in composition . |
protected DockLayoutInfo |
fillMissing(DockLayoutInfo info)
Called by fillMissing(DockLayoutComposition) only for
DockLayoutInfo s which contain a DockLayout . |
AdjacentDockFactory<?> |
getAdjacentFactory(String id)
Gets the adjacent factory which has the given id . |
protected String |
getAdjacentFactoryID(String id)
Transforms an id read from a stream to the id of the adjacent factory which would be used. |
Map<String,AdjacentDockFactory<?>> |
getAdjacentFactorys()
Gets all the adjacent factories that are currently registered at this DockSituation ,
the returned Map is unmodifiable. |
protected String |
getAdjacentID(AdjacentDockFactory<?> factory)
Gets the id of factory . |
DockFactory<? extends DockElement,?,?> |
getFactory(String id)
Gets the factory which has the given id . |
protected String |
getFactoryID(DockLayoutInfo info)
Reads the id of the factory which was used to create info . |
protected String |
getFactoryID(String id)
Transforms an id read from a stream to the id of the factory which would be used. |
protected String |
getID(DockElement element)
Gets the id of the factory which is needed to write (and later read) element |
protected String |
getID(DockFactory<?,?,?> factory)
Gets the id of factory . |
protected String |
getID(PerspectiveElement element)
Gets the id of the factory which is needed to write (and later read) element |
String |
getIdentifier(DockLayoutComposition composition)
Tells what identifier was associated with composition when it was
stored by a DockSituation of this type. |
DockSituationIgnore |
getIgnore()
Gets the filter which decides, which elements are stored. |
PlaceholderStrategy |
getIntermediatePlaceholders()
Gets the strategy for deleting invalid placeholders in the intermediate format. |
MissingDockFactory |
getMissingAdjacentFactory()
Gets the factory which is used when another AdjacentDockFactory
is missing. |
MissingDockFactory |
getMissingFactory()
Gets the factory which is used when another factory is missing. |
protected Path |
getPlaceholder(DockElement element)
Gets a placeholder for element using the current PlaceholderStrategy . |
PlaceholderStrategy |
getPlaceholderStrategy()
Gets the current strategy for removing invalid placeholders. |
protected boolean |
ignoreChildren(DockStation station)
Tells whether to ignore the children of the station when saving or not. |
protected boolean |
ignoreElement(DockElement element)
Tells whether to ignore this element when saving. |
Map<String,DockStation> |
read(byte[] data)
Reads data as stream and returns the roots of the
DockElements which were found. |
Map<String,DockStation> |
read(DataInputStream in)
Reads in and returns the roots of the
DockElements which were found. |
DockLayoutComposition |
readComposition(DataInputStream in)
Reads one DockLayoutComposition and all its children. |
Map<String,DockLayoutComposition> |
readCompositions(DataInputStream in)
Reads in and returns the map of DockLayoutComposition s that was
stored. |
Map<String,DockLayoutComposition> |
readCompositionsXML(XElement root)
Reads a set of DockLayoutComposition s that were stored earlier. |
DockLayoutComposition |
readCompositionXML(XElement element)
Reads a DockLayoutComposition from an xml element. |
Map<String,DockStation> |
readXML(XElement root)
Reads a set of DockStation s that were stored earlier. |
void |
setIgnore(DockSituationIgnore ignore)
Sets a filter which decides, which elements (stations and dockables) are stored. |
void |
setIntermediatePlaceholders(PlaceholderStrategy intermediatePlaceholders)
Sets the strategy for deleting invalid placeholders in the intermediate format |
void |
setMissingAdjacentFactory(MissingDockFactory missingAdjacent)
Sets a factory which is used when a AdjacentDockFactory is missing. |
void |
setMissingFactory(MissingDockFactory missingFactory)
Sets a factory which is used whenever no ordinary DockFactory
can be found to read something. |
void |
setPlaceholderStrategy(PlaceholderStrategy placeholders)
Sets a strategy for deleting invalid placeholders. |
byte[] |
write(Map<String,DockStation> stations)
Writes all locations and relationships of the DockStations
stations and their children into an array of bytes. |
void |
write(Map<String,DockStation> stations,
DataOutputStream out)
Writes all locations and relationships of the DockStations
stations and their children into the stream out . |
void |
writeComposition(DockLayoutComposition composition,
DataOutputStream out)
Writes the contents of composition and all its children
to out . |
void |
writeCompositions(Map<String,DockLayoutComposition> stations,
DataOutputStream out)
Writes all information stored in stations to out . |
void |
writeCompositionsXML(Map<String,DockLayoutComposition> stations,
XElement element)
Writes the contents of station into element . |
void |
writeCompositionXML(DockLayoutComposition composition,
XElement element)
Writes the contents of composition into element without
changing the attributes of element . |
void |
writeXML(Map<String,DockStation> stations,
XElement element)
Writes all locations and relationships of the DockStation s
stations and their children as xml. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Path DOCK_FACTORY_EXTENSION
ExtensionName
to load additional DockFactory
s
public static final Path ADJACENT_DOCK_FACTORY_EXTENSION
ExtensionName
to load additional AdjacentDockFactory
s
public static final String EXTENSION_PARAM
ExtensionName
pointing to this
Constructor Detail |
---|
public DockSituation(DockFactory<?,?,?>... factories)
DockElements
. Please note that this
constructor does not add the default factories, hence it should be used with care.
factories
- the factoriespublic DockSituation(DockController controller)
DefaultDockable
,
SplitDockStation
, StackDockStation
and
FlapDockStation
will be preinstalled.
controller
- DockController
in whose realm this DockSituation
will be used, the
controller is used to access the ExtensionManager
and load additional factoriesMethod Detail |
---|
public Perspective createPerspective()
Perspective
that uses the settings made on this DockSituation
. Changes on the
properties of this DockSituation
will be noticed and used by the created Perspective
. However
changes on the properties of the Perspective
will not influence this DockSituation
.Perspective
s that need the client to make additional settings before
it can be used.
public void setIgnore(DockSituationIgnore ignore)
ignore
- the filter or null
public DockSituationIgnore getIgnore()
null
public void setPlaceholderStrategy(PlaceholderStrategy placeholders)
placeholders
- the strategy, null
for keeping all placeholderspublic PlaceholderStrategy getPlaceholderStrategy()
null
public void setIntermediatePlaceholders(PlaceholderStrategy intermediatePlaceholders)
intermediatePlaceholders
- the strategy, can be null
public PlaceholderStrategy getIntermediatePlaceholders()
null
protected Path getPlaceholder(DockElement element)
element
using the current PlaceholderStrategy
.
element
- some element, not null
null
public void add(DockFactory<?,?,?> factory)
factory
- the additional factorypublic void addAdjacent(AdjacentDockFactory<?> factory)
factory
- the new factorypublic void setMissingFactory(MissingDockFactory missingFactory)
DockFactory
can be found to read something. The missingFactory
can convert
the input to any Object
it likes, but if a missing factory
is later added to this situation, then that object needs to be casted
into the object used by the original factory. So when working with
a MissingDockFactory
handling different types of layout-data
needs to be done very carefully. Note that this factory is only used to convert
byte-stream or xml data to the intermediate format. It cannot create any Dockable
or
DockElement
nor store any data.
missingFactory
- the factory, can be null
public MissingDockFactory getMissingFactory()
null
setMissingFactory(MissingDockFactory)
public void setMissingAdjacentFactory(MissingDockFactory missingAdjacent)
AdjacentDockFactory
is missing.
There are the same issues with this factory than with the one used
by setMissingFactory(MissingDockFactory)
.
missingAdjacent
- the new factory, can be null
setMissingFactory(MissingDockFactory)
public MissingDockFactory getMissingAdjacentFactory()
AdjacentDockFactory
is missing.
null
setMissingAdjacentFactory(MissingDockFactory)
public DockLayoutComposition convert(DockElement element)
element
and all its children into a
DockLayoutComposition
.
element
- the element to convert
null
if the element is ignored
IllegalArgumentException
- if one element has an unknown id of
a DockFactory
.
ClassCastException
- if an element does not specify the correct
DockFactory
.public DockElement convert(DockLayoutComposition composition)
composition
and tries to create a
DockElement
that matches the composition.
composition
- the composition to analyze
DockElement
if the factory for composition
was not foundpublic void writeComposition(DockLayoutComposition composition, DataOutputStream out) throws IOException
composition
and all its children
to out
.
composition
- the composition to write, should be created by
this
DockSituation
or a DockSituation
with
similar properties.out
- the stream to write into
IOException
- if an I/O-error occurspublic DockLayoutComposition readComposition(DataInputStream in) throws IOException
DockLayoutComposition
and all its children.
in
- the stream to read from
null
if the factory was missing
IOException
- if an I/O-error occurspublic byte[] write(Map<String,DockStation> stations) throws IOException
DockStations
stations
and their children into an array of bytes.
stations
- The stations to store, a call to read(byte[])
would return the same map. Only the roots are needed.
IOException
- if the information can't be writtenpublic void write(Map<String,DockStation> stations, DataOutputStream out) throws IOException
DockStations
stations
and their children into the stream out
.
stations
- The stations to store, only the roots are needed.out
- the stream to write in
IOException
- if the stream throws an exceptionpublic void writeCompositions(Map<String,DockLayoutComposition> stations, DataOutputStream out) throws IOException
stations
to out
.
stations
- Representations of the root-stations.out
- the stream to write in
IOException
- if the stream throws an exceptionpublic Map<String,DockStation> read(byte[] data) throws IOException
data
as stream and returns the roots of the
DockElements
which were found.
data
- the array to read
IOException
- if data
can't be readpublic Map<String,DockStation> read(DataInputStream in) throws IOException
in
and returns the roots of the
DockElements
which were found.
in
- the stream to read
IOException
- if the stream can't be readpublic Map<String,DockLayoutComposition> readCompositions(DataInputStream in) throws IOException
in
and returns the map of DockLayoutComposition
s that was
stored.
in
- the stream to read from
IOException
- if an I/O-error occurspublic void writeCompositionXML(DockLayoutComposition composition, XElement element)
composition
into element
without
changing the attributes of element
.
composition
- the composition to writeelement
- the element to write into
IllegalArgumentException
- if a factory is missingpublic DockLayoutComposition readCompositionXML(XElement element)
DockLayoutComposition
from an xml element.
element
- the element to read
XException
- if something is missing or malformed in element
public void writeXML(Map<String,DockStation> stations, XElement element)
DockStation
s
stations
and their children as xml.
stations
- The stations to store, only the roots are needed.element
- the element to write into, attributes of element
will
not be changedpublic void writeCompositionsXML(Map<String,DockLayoutComposition> stations, XElement element)
station
into element
.
stations
- the items to writeelement
- the element to write into, the attributes of element
will not be changedpublic Map<String,DockStation> readXML(XElement root)
DockStation
s that were stored earlier.
root
- the xml element from which to read
public Map<String,DockLayoutComposition> readCompositionsXML(XElement root)
DockLayoutComposition
s that were stored earlier.
root
- the xml element from which to read
public DockLayoutComposition fillMissing(DockLayoutComposition composition) throws IOException, XException
DockSituation
, this
method tries to fill gaps in composition
. It checks
all the DockLayoutInfo
s, if an info contains a byte array or
an XElement
, then this method tries to use a factory to
read the element. If a missing factory
is present, then this factory is used as well.
composition
- the composition to read
composition
or a new composition if this
method changed something
IOException
- if some stream was opened but cannot be read
XException
- if some xml element was found but cannot be readprotected DockLayoutInfo fillMissing(DockLayoutInfo info)
fillMissing(DockLayoutComposition)
only for
DockLayoutInfo
s which contain a DockLayout
. This method
can apply further updates to info
if necessary. The default
implementation just returns info
.DockFactory
s
and use a DockLayout
even for incomplete data.
info
- the info to update
info
if nothing changed or a new
DockLayoutInfo
if additional information could be retrievedpublic void estimateLocations(DockLayoutComposition composition)
composition
. Invoking this method is the same as calling
guessLocation( composition, composition.getLayout().getLocation() );
.
composition
- the composition whose location will be determinedpublic void estimateLocations(DockLayoutComposition composition, DockableProperty location)
composition
, assuming that composition
itself
is at location location
. This method reads out the
DockLayoutInfo
through DockLayoutComposition.getLayout()
and then calls DockLayoutInfo.setLocation(DockableProperty)
, so
composition
gets modified by this method. This method stops
its recursion if the location of a child of composition
was not found.composition
does not have childrencomposition
does not carry a DockLayout
DockFactory
registered for the factory-id found
in composition
fillMissing(DockLayoutComposition)
before invoking this method.
composition
- the composition whose children should be analyzedlocation
- the location of composition
, can be null
protected void estimateLocations(DefaultLocationEstimationMap map)
DockLayoutInfo
s that can
be found in map
.DefaultLocationEstimationMap.finish()
.
map
- the root of the tree for which locations need to be estimatedprotected boolean ignoreElement(DockElement element)
DockSituationIgnore
of this situation.
element
- the element which might not be saved
true
if the element should not be savedprotected boolean ignoreChildren(DockStation station)
DockSituationIgnore
of this situation.
station
- the station whose children might be ignored
true
if the station is saved as having no childrenprotected String getID(PerspectiveElement element)
element
element
- the element to read
getID(DockFactory)
,
getFactory(String)
protected String getID(DockElement element)
element
element
- the element to read
getID(DockFactory)
,
getFactory(String)
protected String getID(DockFactory<?,?,?> factory)
factory
. The default behavior is just to
return DockConverter.getID()
. Note that this method should be
a bijection to getFactory(String)
.
factory
- the factory whose id is needed
protected String getFactoryID(DockLayoutInfo info)
info
.
This returns the id of the factory as it is used internally by this
DockSituation
.
info
- the info to check
null
if info does not contain
data
IllegalArgumentException
- if the data of info
is in the wrong format
XException
- if the data of info
is in the wrong formatpublic String convertFactoryId(DockFactory<?,?,?> factory)
factory
in the
DockLayoutComposition
.getID(DockFactory)
, but
getID(DockFactory)
is intended for internal use while this
method is intended to be used by clients which read out a DockLayoutComposition
.
factory
- the factory which might be used
getID(DockFactory)
public String convertFactoryId(String id)
DockFactory
has, for which the
identifier id
is used within a DockLayoutComposition
.getFactoryID(String)
, but while
getFactoryID(String)
is intended for internal use, this method
is intended for clients.
id
- an identifier found in a DockLayoutComposition
DockFactory
protected String getFactoryID(String id)
DockFactory factory = ...
factory.getID().equals( getFactoryID( getID( factory )));
id
- the id read from a stream
protected String getAdjacentID(AdjacentDockFactory<?> factory)
factory
. The default behavior is just to
return DockConverter.getID()
. Note that this method should be
a bijection to getAdjacentFactory(String)
.
factory
- the factory whose id is needed
protected String getAdjacentFactoryID(String id)
AdjacentDockFactory factory = ...
factory.getID().equals( getFactoryID( getAdjacentID( factory )));
id
- the id read from a stream
@Todo(compatibility=BREAK_MINOR, priority=MAJOR, target=VERSION_1_1_3, description="remove the legacy code that filters out identifiers that look like \'secure ...\'. Instead \'result\' can be returned directly.") public DockFactory<? extends DockElement,?,?> getFactory(String id)
id
. Note that this
method should be a bijection to getID(DockFactory)
. The
default behavior compares id
with the
getID(DockFactory)
.
id
- the name of the factory
null
if no factory has this idpublic AdjacentDockFactory<?> getAdjacentFactory(String id)
id
. Note that this
method should be a bijection to getID(DockFactory)
. The
default behavior compares id
with the
getID(DockFactory)
.
id
- the name of the factory
null
if no factory has this idpublic Map<String,AdjacentDockFactory<?>> getAdjacentFactorys()
DockSituation
,
the returned Map
is unmodifiable.
AdjacentDockFactory
s.public String getIdentifier(DockLayoutComposition composition)
composition
when it was
stored by a DockSituation
of this type. The default implementation always
returns null
.
composition
- some element that was created by this or a similar DockSituation
composition
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |