|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.gui.dock.station.support.PlaceholderList<D,S,P>
D
- the kind of object that should be treated as Dockable
S
- the kind of object that should be treated as DockStation
P
- the type of item which represents a Dockable
public abstract class PlaceholderList<D,S,P extends PlaceholderListItem<D>>
A list consisting of Dockable
s and sets of Path
s as placeholder.
Uses a PlaceholderStrategy
to automatically create and dispose
of placeholders.
Clients should call bind()
and unbind()
to manage the
lifecycle of this list.
A PlaceholderList
is not thread-safe.
Nested Class Summary | |
---|---|
static interface |
PlaceholderList.Filter<M>
A sublist of a PlaceholderList , the elements in this
list are filtered by a strategy that is defined by the
PlaceholderList . |
class |
PlaceholderList.Item
A single item in a PlaceholderList |
static class |
PlaceholderList.Level
identifiers for the various sublists this list consists of |
Constructor Summary | |
---|---|
PlaceholderList()
Creates a new and empty list. |
|
PlaceholderList(PlaceholderMap map,
PlaceholderListItemConverter<D,P> converter)
Creates a new list reading all the data that is stored in map . |
Method Summary | |
---|---|
int |
baseToLevel(int index,
PlaceholderList.Level level)
Searches the base entry at index and returns
its location in sublist level . |
void |
bind()
Connects this list with its strategy. |
PlaceholderList.Filter<P> |
dockables()
Gets a mutable view of all Dockable s of this list. |
protected abstract D[] |
getChildren(S station)
Gets all the children of station . |
P |
getDockableAt(Path placeholder)
Searches the first occurrence of placeholder and returns the Dockable
that is stored at that location. |
int |
getDockableIndex(Path placeholder)
Emulates the insertion of a Dockable at location placeholder and
returns the index that the inserted dockable would have in the dockable-list. |
int |
getListIndex(Path placeholder)
Searches the first occurance of placeholder in a placeholder-set and returns
return the index of that entry on the BASE level . |
PlaceholderMap |
getMap(Path placeholder)
Gets the PlaceholderMap that was used for a station at location placeholder . |
PlaceholderMetaMap |
getMetaMap(Path placeholder)
Gets the meta-map that is associated with the set of placeholders that include placeholder . |
protected abstract Path |
getPlaceholder(D dockable)
Gets the placeholder which matches dockable . |
protected abstract PlaceholderMap |
getPlaceholders(S station)
Gets all the placeholders that are used by station . |
PlaceholderStrategy |
getStrategy()
Gets the current strategy of this list. |
boolean |
hasPlaceholder(Path placeholder)
Tells whether this list contains a reference to placeholder . |
void |
insertAllPlaceholders()
Inserts a placeholder for all Dockable s that are stored in this list. |
int |
levelToBase(int index,
PlaceholderList.Level level)
Searches the base entry at index in the sublist level and returns
its location in the base list. |
PlaceholderList.Filter<PlaceholderList.Item> |
list()
Gets a mutable view of all elements of this list. |
PlaceholderList.Filter<java.util.Set<Path>> |
listPlaceholders()
Gets a mutable view of all elements of this list. |
PlaceholderList.Filter<java.util.Set<Path>> |
purePlaceholders()
Gets a mutable view of all pure placeholders of this list. |
int |
put(Path placeholder,
P dockable)
Searches for the first occurrence of placeholder and replaces
it with dockable . |
boolean |
put(P dockable,
Path placeholder)
Searches for the entry containing dockable and adds placeholder to the
placeholder set. |
void |
read(PlaceholderMap map,
PlaceholderListItemConverter<D,P> converter)
Reads the contents of map and adds them at the end of this list. |
protected void |
read(PlaceholderMap map,
PlaceholderListItemConverter<D,P> converter,
boolean simulate)
Reads the contenst of map . |
Path |
remove(int index)
Removes the index 'th Dockable from this list were
index is an index used in dockables() . |
Path |
remove(P dockable)
Searches for dockable and replaces it by a placeholder. |
void |
removeAll(Path placeholder)
Checks all entries of this list and removes all occurrences of all placeholder . |
void |
removeAll(java.util.Set<Path> placeholders)
Checks all entries of this list and removes all occurrences of all paths stored in placeholders . |
protected abstract void |
setPlaceholders(S station,
PlaceholderMap map)
Sets all the placeholders that should be used by station . |
void |
setStrategy(PlaceholderStrategy strategy)
Sets the new strategy of this list. |
PlaceholderMap |
toMap(PlaceholderListItemConverter<?,? super P> converter)
Converts this list into a PlaceholderMap , any remaining Dockable or
DockStation will be converted using converter . |
protected abstract S |
toStation(D dockable)
Converts dockable to the representation of a DockStation . |
java.lang.String |
toString()
|
protected abstract java.lang.String |
toString(D dockable)
Gets a representation of dockable as string. |
void |
unbind()
Disconnects this list from its strategy. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PlaceholderList()
public PlaceholderList(PlaceholderMap map, PlaceholderListItemConverter<D,P> converter)
map
. This
constructor stores all placeholders that are described in map
, obsolete
placeholders may be deleted as soon as a PlaceholderStrategy
is set.
map
- the map to read, not null
converter
- used to convert items back to dockables, not null
java.lang.IllegalArgumentException
- if map
was not written by a PlaceholderList
Method Detail |
---|
protected abstract Path getPlaceholder(D dockable)
dockable
.
dockable
- some random dockable
dockable
, can be null
protected abstract java.lang.String toString(D dockable)
dockable
as string.
dockable
- some random dockable, not null
protected abstract S toStation(D dockable)
dockable
to the representation of a DockStation
.
dockable
- some random dockable
dockable
as station, can be null
protected abstract PlaceholderMap getPlaceholders(S station)
station
.
station
- some random representation of a DockStation
null
protected abstract void setPlaceholders(S station, PlaceholderMap map)
station
.
station
- a representation of a DockStation
map
- the map of placeholders, not null
protected abstract D[] getChildren(S station)
station
.
station
- some station whose children are searched
public void read(PlaceholderMap map, PlaceholderListItemConverter<D,P> converter)
map
and adds them at the end of this list.
map
- the map to readconverter
- used to convert items back to dockables, not null
java.lang.IllegalArgumentException
- if the map is in the wrong formatprotected void read(PlaceholderMap map, PlaceholderListItemConverter<D,P> converter, boolean simulate)
map
. This method can either add the contents at
the end of this list, or just simulate a read. If a read is simulated, then the methods
of converter
are called just as if this would be an actual read, but
in reality no data is changed in this list.
map
- the data to readconverter
- used to convert items back to dockables, not null
simulate
- whether this list should actually be changed or not
java.lang.IllegalArgumentException
- if the map is in the wrong formatpublic PlaceholderMap toMap(PlaceholderListItemConverter<?,? super P> converter)
PlaceholderMap
, any remaining Dockable
or
DockStation
will be converted using converter
.
converter
- converter to translate dockables into persistent data, not null
null
public void bind()
public void unbind()
public PlaceholderStrategy getStrategy()
public void setStrategy(PlaceholderStrategy strategy)
null
,
then all current placeholders are checked and the invalid placeholders
are removed.
strategy
- the new strategypublic void insertAllPlaceholders()
Dockable
s that are stored in this list.
public PlaceholderList.Filter<P> dockables()
Dockable
s of this list.
public PlaceholderList.Filter<java.util.Set<Path>> purePlaceholders()
null
public PlaceholderList.Filter<PlaceholderList.Item> list()
public PlaceholderList.Filter<java.util.Set<Path>> listPlaceholders()
public void removeAll(java.util.Set<Path> placeholders)
placeholders
. If an entry remains with
0 placeholders and no Dockable
it is removed.
placeholders
- the placeholders to removepublic void removeAll(Path placeholder)
placeholder
. If an entry remains with 0 placeholders
and no Dockable
it is removed.
placeholder
- the placeholder to removepublic Path remove(int index)
index
'th Dockable
from this list were
index
is an index used in dockables()
.
index
- the index of the element to remove
null
public Path remove(P dockable)
dockable
and replaces it by a placeholder. If dockable
is a DockStation
, then its PlaceholderMap
is stored.
dockable
- the element to remove
null
if the current strategy does
not assign a placeholder to dockable
or if dockable
was not found in this listpublic int put(Path placeholder, P dockable)
placeholder
and replaces
it with dockable
. If there is already another dockable stored at that
location, then the other dockable is replaced silently. If dockable
is a
DockStation
and a PlaceholderMap
is set, then this map is transfered to
dockable
and removed from this list.placeholder
and the placeholder that is assigned
by the current PlaceholderStrategy
from this list.
placeholder
- the placeholder to search, not null
dockable
- the element which will replace placeholder
, not null
dockables()
where dockable
was inserted or -1 if
placeholder
was not foundpublic int getDockableIndex(Path placeholder)
Dockable
at location placeholder
and
returns the index that the inserted dockable would have in the dockable-list.
placeholder
- the placeholder of the element to insert
placeholder
was not foundpublic int getListIndex(Path placeholder)
placeholder
in a placeholder-set and returns
return the index of that entry on the BASE level
.
placeholder
- the placeholder to search
public boolean hasPlaceholder(Path placeholder)
placeholder
.
placeholder
- the placeholder to search
public boolean put(P dockable, Path placeholder)
dockable
and adds placeholder
to the
placeholder set. This method removes placeholder
from all the other entries.
dockable
- the keyplaceholder
- the placeholder to insert
true
if dockable
was found, false
otherwisepublic P getDockableAt(Path placeholder)
placeholder
and returns the Dockable
that is stored at that location.
placeholder
- the placeholder to search
null
if there is no dockable stored or
placeholder
is not foundpublic PlaceholderMetaMap getMetaMap(Path placeholder)
placeholder
.
placeholder
- some placeholder to search
placeholder
, can be null
public PlaceholderMap getMap(Path placeholder)
PlaceholderMap
that was used for a station at location placeholder
.
placeholder
- some placeholder to search
PlaceholderMap
that was stored at the place where placeholder
was found,
can be null
public int baseToLevel(int index, PlaceholderList.Level level)
index
and returns
its location in sublist level
.
index
- the index of some entrylevel
- the sublist
level
java.lang.IndexOutOfBoundsException
- if index
is illegalpublic int levelToBase(int index, PlaceholderList.Level level)
index
in the sublist level
and returns
its location in the base list.
index
- the index of some entrylevel
- the sublist
java.lang.IndexOutOfBoundsException
- if index
is illegalpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |