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 PlaceholderToolbarGrid<D,S,P extends bibliothek.gui.dock.station.support.PlaceholderListItem<D>>
extends java.lang.Object
PlaceholderToolbarGrid
behaves like a list of PlaceholderList
s.Constructor and Description |
---|
PlaceholderToolbarGrid() |
Modifier and Type | Method and Description |
---|---|
void |
addPlaceholder(int column,
int line,
bibliothek.util.Path placeholder)
Stores the placeholder
placeholder in the designated column. |
protected java.util.Iterator<bibliothek.gui.dock.station.support.PlaceholderList<D,S,P>> |
allColumns()
Gets an iterator over all columns, including the columns with no content.
|
void |
bind()
Informs this grid that it is actually used and that it should be allowed
to add observers to various resources.
|
void |
clear()
Removes all content from this grid.
|
protected java.util.Iterator<bibliothek.gui.dock.station.support.PlaceholderList<D,S,P>> |
columns()
Gets an iterator over all non-empty columns.
|
protected abstract bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> |
createColumn()
Creates one column.
|
protected abstract GridPlaceholderList<D,S,P> |
createGrid()
Creates a new
GridPlaceholderList . |
protected abstract void |
fill(D dockable,
bibliothek.gui.dock.station.support.ConvertedPlaceholderListItem item)
Called by
toMap(Map) , this method should read persistent data
from dockable and write that data into item . |
void |
fromMap(bibliothek.gui.dock.station.support.PlaceholderMap map)
Replaces the content of this grid by a map that was written earlier using
toMap() or toMap(Map) . |
void |
fromMap(bibliothek.gui.dock.station.support.PlaceholderMap map,
java.util.Map<java.lang.Integer,D> identifiers,
PlaceholderToolbarGridConverter<D,P> converter) |
P |
get(D dockable)
Gets the item that represents
dockable |
P |
get(int index)
Gets the
index 'th item of this grid. |
P |
get(bibliothek.util.Path placeholder)
Searches the item which is at the location of
placeholder . |
int |
getColumn(D dockable)
Tells in which non-empty column
dockable is. |
protected bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> |
getColumn(int index)
Gets the non-empty column with index
index . |
int |
getColumn(bibliothek.util.Path placeholder)
Gets the index of the first column that contains
placeholder
. |
java.util.Iterator<P> |
getColumnContent(int index)
Gets an iterator over the contents of the
index 'th non-empty
column. |
int |
getColumnCount()
Gets the number of columns that are currently stored in this grid.
|
int |
getLine(D dockable)
Tells at which position
dockable is within its column. |
int |
getLine(int column,
D dockable)
Tells at which position
dockable is within the column
column |
int |
getLine(int column,
bibliothek.util.Path placeholder)
Tells at which line
placeholder appears in the column
column . |
int |
getLine(bibliothek.util.Path placeholder)
Tells at which line
placeholder appears in the first column
that contains placeholder . |
int |
getLineCount(int column)
Tells how many items are currently stored at the non-empty column with
index
column . |
protected abstract java.util.Set<bibliothek.util.Path> |
getPlaceholders(D dockable)
Gets all placeholders that are associated with
dockable . |
bibliothek.gui.dock.station.support.PlaceholderStrategy |
getStrategy()
Gets the
PlaceholderStrategy that is currently used by this grid. |
int |
getTotalColumnCount()
Gets the total number of columns, this includes empty columns.
|
boolean |
hasPlaceholder(bibliothek.util.Path placeholder)
Tells whether this
PlaceholderToolbarGrid knows a column which
contains the placeholder placeholder , this includes empty
columns. |
protected void |
init()
Initializes all fields of this object.
|
void |
insert(int column,
int line,
P item)
Adds the item
item to the non-empty column
column into position line . |
void |
insert(int columnIndex,
P item)
Adds the item
item to a new column, the new column will have
the index columnIndex . |
void |
insert(int columnIndex,
P item,
boolean reuse)
Adds the item
item to a new column, the new column will have
the index columnIndex . |
void |
insertPlaceholder(int column,
int line,
bibliothek.util.Path placeholder)
Inserts
placeholder into column column at line . |
java.util.Iterator<P> |
items()
Gets an iterator that visits all items of this grid.
|
void |
move(int sourceColumn,
int sourceLine,
int destinationColumn,
int destinationLine,
bibliothek.gui.dock.station.support.PlaceholderList.Level destinationLevel)
Moves the item at
sourceColumn/sourceLine to
destinationColumn/destinationLine . |
protected abstract void |
onInserted()
Called if all columns were inserted at the same time.
|
protected abstract void |
onInserted(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column,
int index)
Called if a new column
column was added to this grid. |
protected abstract void |
onInserted(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column,
int columnIndex,
P item,
int itemIndex)
Called if
item was added to the column column . |
protected abstract void |
onRemoved()
Called if all columns were removed from this grid
|
protected abstract void |
onRemoved(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column,
int index)
Called if the column
column was removed from this grid. |
protected abstract void |
onRemoved(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column,
int columnIndex,
P item,
int itemIndex)
Called if
item was removed to the column column . |
boolean |
put(bibliothek.util.Path placeholder,
P item)
Tries to put
item into this list at location
placeholder . |
boolean |
remove(P item)
Removes
item from this grid, but leaves a placeholder for
the item. |
void |
removePlaceholder(bibliothek.util.Path placeholder)
Removes all occurences of
placeholder . |
void |
setStrategy(bibliothek.gui.dock.station.support.PlaceholderStrategy strategy)
Sets the
PlaceholderStrategy which is to be used by this grid. |
int |
size()
Gets the total count of items stored in this grid.
|
bibliothek.gui.dock.station.support.PlaceholderMap |
toMap()
Converts this grid into a
PlaceholderMap , if possible any
Dockable is converted into a placeholder. |
bibliothek.gui.dock.station.support.PlaceholderMap |
toMap(java.util.Map<D,java.lang.Integer> identifiers)
Converts this grid into a
PlaceholderMap using
identifiers to remember which Dockable was a which
position. |
void |
unbind()
Informs this grid that it is no longer used and that is should remove any
observers.
|
protected void init()
protected abstract bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> createColumn()
protected abstract GridPlaceholderList<D,S,P> createGrid()
GridPlaceholderList
.protected abstract java.util.Set<bibliothek.util.Path> getPlaceholders(D dockable)
dockable
.dockable
- some element used by this gridprotected abstract void onInserted(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column, int columnIndex, P item, int itemIndex)
item
was added to the column column
.column
- a visible columncolumnIndex
- the index of the columnitem
- a new item of column
itemIndex
- the index of the new itemprotected abstract void onRemoved(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column, int columnIndex, P item, int itemIndex)
item
was removed to the column column
.column
- a visible columncolumnIndex
- the index of the columnitem
- the removed item of column
itemIndex
- the index the item had before removingprotected abstract void onInserted(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column, int index)
column
was added to this grid. The column may not contain any elements when
this method is called.column
- the new columnindex
- the index of the new columnprotected abstract void onRemoved(bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> column, int index)
column
was removed from this grid. The column may still contain elements when it
is removed.column
- the removed columnindex
- the index the column had before it was removedprotected abstract void onInserted()
protected abstract void onRemoved()
public void clear()
public void insert(int column, int line, P item)
item
to the non-empty column
column
into position line
. This method may add
a new column in order to store item
.column
- the column in which to store item
line
- the index within column
item
- the item to store, not null
java.lang.IllegalArgumentException
- if item
is null
java.lang.IllegalStateException
- if there is no PlaceholderStrategy
setpublic void insert(int columnIndex, P item)
item
to a new column, the new column will have
the index columnIndex
. If columnIndex
is out of
bounds, then the new column will be added as near as possible to the
preferred position. This method will try to reuse an empty column, if one
is available at the desired location.columnIndex
- the column to additem
- the item to store, not null
public void insert(int columnIndex, P item, boolean reuse)
item
to a new column, the new column will have
the index columnIndex
. If columnIndex
is out of
bounds, then the new column will be added as near as possible to the
preferred position.columnIndex
- the column to additem
- the item to store, not null
reuse
- if false
then a new column will be built in any
case, if true
then this grid tries to reuse an
existing yet empty column if possiblepublic void move(int sourceColumn, int sourceLine, int destinationColumn, int destinationLine, bibliothek.gui.dock.station.support.PlaceholderList.Level destinationLevel)
sourceColumn/sourceLine
to
destinationColumn/destinationLine
. The operation behaves as
if the item would first be removed from the source position, and
afterwards inserted at the destination position.sourceColumn
- the column in which to find the item, only includes non-empty
columnssourceLine
- the line in the column in which to find the itemdestinationColumn
- the column in which to insert the itemdestinationLine
- the line at which to insert the itemdestinationLevel
- the level at which to find destinationColumn
,
will be converted to an index from PlaceholderList.Level.BASE
java.lang.IllegalArgumentException
- if any index is out of boundspublic boolean put(bibliothek.util.Path placeholder, P item)
item
into this list at location
placeholder
. If there is already an element at
placeholder
, then the old item is silently removed and the
new item inserted. This method may create a new non-empty column if
necessary.placeholder
- the name of the itemitem
- the item to inserttrue
if insertion was a success, false
otherwisepublic void addPlaceholder(int column, int line, bibliothek.util.Path placeholder)
placeholder
in the designated column.column
- the column in which to add placeholder
, only
includes non-empty columnsline
- the line in which to add placeholder
placeholder
- the placeholder to storepublic void insertPlaceholder(int column, int line, bibliothek.util.Path placeholder)
placeholder
into column column
at line
. This
method may create a new column if column
is as big as the grid.column
- the column into which to insert placeholder
, includes
empty columns.line
- the line into which to insert placeholder
placeholder
- the new placeholder, not null
public boolean remove(P item)
item
from this grid, but leaves a placeholder for
the item.item
- the item to removetrue
if item
was found and removedpublic void removePlaceholder(bibliothek.util.Path placeholder)
placeholder
.placeholder
- the placeholder to removepublic int getColumn(D dockable)
dockable
is.dockable
- the item to search-1
if not foundpublic int getColumn(bibliothek.util.Path placeholder)
placeholder
.placeholder
- the placeholder to searchplaceholder
or -1 if not
found, this includes empty columnspublic int getLine(D dockable)
dockable
is within its column.dockable
- the item to searchdockable
public int getLine(int column, D dockable)
dockable
is within the column
column
column
- the index of the non-empty column to searchdockable
- the item to searchdockable
public int getLine(bibliothek.util.Path placeholder)
placeholder
appears in the first column
that contains placeholder
. This includes empty columns.placeholder
- the placeholder to searchplaceholder
was foundpublic int getLine(int column, bibliothek.util.Path placeholder)
placeholder
appears in the column
column
.column
- the index of the column, this includes empty columnsplaceholder
- the placeholder to searchplaceholder
was not foundpublic boolean hasPlaceholder(bibliothek.util.Path placeholder)
PlaceholderToolbarGrid
knows a column which
contains the placeholder placeholder
, this includes empty
columns.placeholder
- the placeholder to searchtrue
if placeholder
was foundpublic int size()
public P get(int index)
index
'th item of this grid.index
- the index of the itemjava.lang.IllegalArgumentException
- if index
is not validpublic P get(D dockable)
dockable
dockable
- the dockable to searchdockable
or
null
if not foundpublic P get(bibliothek.util.Path placeholder)
placeholder
.placeholder
- some placeholder that may or may not be known to this gridplaceholder
or null
either
if placeholder
was not found or if there is no item
storedprotected java.util.Iterator<bibliothek.gui.dock.station.support.PlaceholderList<D,S,P>> allColumns()
protected java.util.Iterator<bibliothek.gui.dock.station.support.PlaceholderList<D,S,P>> columns()
public java.util.Iterator<P> items()
public int getColumnCount()
public int getLineCount(int column)
column
.column
- the index of a non-empty columnpublic int getTotalColumnCount()
public java.util.Iterator<P> getColumnContent(int index)
index
'th non-empty
column.index
- the index of the non-empty columnprotected bibliothek.gui.dock.station.support.PlaceholderList<D,S,P> getColumn(int index)
index
. Subclasses should not modify the returned list.index
- the index of the columnnull
if no such column
existspublic void bind()
public void unbind()
public void setStrategy(bibliothek.gui.dock.station.support.PlaceholderStrategy strategy)
PlaceholderStrategy
which is to be used by this grid.strategy
- the new strategy, can be null
public bibliothek.gui.dock.station.support.PlaceholderStrategy getStrategy()
PlaceholderStrategy
that is currently used by this grid.null
protected abstract void fill(D dockable, bibliothek.gui.dock.station.support.ConvertedPlaceholderListItem item)
toMap(Map)
, this method should read persistent data
from dockable
and write that data into item
.dockable
- the dockable to readitem
- the item to write intopublic bibliothek.gui.dock.station.support.PlaceholderMap toMap(java.util.Map<D,java.lang.Integer> identifiers)
PlaceholderMap
using
identifiers
to remember which Dockable
was a which
position.identifiers
- identifiers for all children of the DockStation
using
this gridpublic void fromMap(bibliothek.gui.dock.station.support.PlaceholderMap map, java.util.Map<java.lang.Integer,D> identifiers, PlaceholderToolbarGridConverter<D,P> converter)
public bibliothek.gui.dock.station.support.PlaceholderMap toMap()
PlaceholderMap
, if possible any
Dockable
is converted into a placeholder.public void fromMap(bibliothek.gui.dock.station.support.PlaceholderMap map)
toMap()
or toMap(Map)
.map
- the map to read, not null