bibliothek.gui.dock.station.toolbar.group
Class AbstractToolbarGroupActions<P,C extends AbstractToolbarGroupActions.Column>

java.lang.Object
  extended by bibliothek.gui.dock.station.toolbar.group.AbstractToolbarGroupActions<P,C>
Type Parameters:
P - the type of object that represents a Dockable
C - the type of this sublcass
All Implemented Interfaces:
ColumnDockActionSource
Direct Known Subclasses:
ExpandToolbarGroupActions

public abstract class AbstractToolbarGroupActions<P,C extends AbstractToolbarGroupActions.Column>
extends Object
implements ColumnDockActionSource

A class that can create one DockActionSource for each ToolbarColumn a ToolbarGroupDockStation has. This class is built such that sublcasses can easily access or modify the DockActionSources.

Author:
Benjamin Sigg

Nested Class Summary
protected  class AbstractToolbarGroupActions.Column
          Represents one column of the ToolbarGroupDockStation.
 
Constructor Summary
AbstractToolbarGroupActions(ToolbarGroupDockStation station)
          Creates a new object
 
Method Summary
 void addListener(ColumnDockActionSourceListener listener)
          Adds the observer listener to this source.
protected abstract  C createColumn(ToolbarColumn<P> column)
          Creates a new, empty AbstractToolbarGroupActions.Column which will be filled with content later.
protected abstract  Rectangle getBoundaries(P item)
          Gets the bounds of the Component item.
protected  C getColumn(bibliothek.gui.Dockable dockable)
          Searches the column which contains dockable.
 C getColumn(int index)
          Gets the index'th column.
 int getColumnCount()
          Gets the current number of columns.
protected  List<C> getColumns()
          Gets all the column that are currently known to this object.
 ToolbarColumnModel<P> getModel()
          Gets the model which is currently observed by this object
 Orientation getOrientation()
          Gets the orientation of this source.
 bibliothek.gui.dock.action.DockActionSource getSource(int index)
          Gets the index'th source of this ColumnDockActionSource.
 int getSourceCount()
          Gets the total number of DockActionSources that are currently available.
 int getSourceLength(int index)
          Gets the available length in pixel for the index'th source.
 int getSourceOffset(int index)
          Gets the offset of the index'th source in pixel.
protected abstract  void installListener(P item, ComponentListener listener)
          Installs the ComponentListener listener such that changes on item that lead to columns shifting position or size are recognized.
protected  ColumnDockActionSourceListener[] listeners()
          Gets all the listeners that are currently registered.
 void removeListener(ColumnDockActionSourceListener listener)
          Removes the observer listener from this source.
 void setModel(ToolbarColumnModel<P> model)
          Sets the model which should be observed by this AbstractToolbarGroupActions, all existing columns will be removed by this method.
protected abstract  void uninstallListener(P item, ComponentListener listener)
          Removes the listener listener from item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractToolbarGroupActions

public AbstractToolbarGroupActions(ToolbarGroupDockStation station)
Creates a new object

Parameters:
station - the station which uses this set of actions
Method Detail

addListener

public void addListener(ColumnDockActionSourceListener listener)
Description copied from interface: ColumnDockActionSource
Adds the observer listener to this source.

Specified by:
addListener in interface ColumnDockActionSource
Parameters:
listener - the new observer

removeListener

public void removeListener(ColumnDockActionSourceListener listener)
Description copied from interface: ColumnDockActionSource
Removes the observer listener from this source.

Specified by:
removeListener in interface ColumnDockActionSource
Parameters:
listener - the observer to remove

listeners

protected ColumnDockActionSourceListener[] listeners()
Gets all the listeners that are currently registered.

Returns:
all the listeners

setModel

public void setModel(ToolbarColumnModel<P> model)
Sets the model which should be observed by this AbstractToolbarGroupActions, all existing columns will be removed by this method.

Parameters:
model - the new model or null

getModel

public ToolbarColumnModel<P> getModel()
Gets the model which is currently observed by this object

Returns:
the mode, can be null

getColumns

protected List<C> getColumns()
Gets all the column that are currently known to this object.

Returns:
all the columns, the list is not modifiable

getColumnCount

public int getColumnCount()
Gets the current number of columns.

Returns:
the number of columns

getSourceCount

public int getSourceCount()
Description copied from interface: ColumnDockActionSource
Gets the total number of DockActionSources that are currently available.

Specified by:
getSourceCount in interface ColumnDockActionSource
Returns:
the total number of sources

getSource

public bibliothek.gui.dock.action.DockActionSource getSource(int index)
Description copied from interface: ColumnDockActionSource
Gets the index'th source of this ColumnDockActionSource.

Specified by:
getSource in interface ColumnDockActionSource
Parameters:
index - the index of the source
Returns:
the DockActionSource, must not be null but may be empty

getOrientation

public Orientation getOrientation()
Description copied from interface: ColumnDockActionSource
Gets the orientation of this source. The orientation tells in which direction ColumnDockActionSource.getSourceOffset(int) points: either along the x, or along the y axis.

Specified by:
getOrientation in interface ColumnDockActionSource
Returns:
the orientation, must not be null

getColumn

public C getColumn(int index)
Gets the index'th column.

Parameters:
index - the location of the column
Returns:
the column, never null

getColumn

protected C getColumn(bibliothek.gui.Dockable dockable)
Searches the column which contains dockable.

Parameters:
dockable - the element to search
Returns:
the column with dockable or null if not found

getSourceOffset

public int getSourceOffset(int index)
Description copied from interface: ColumnDockActionSource
Gets the offset of the index'th source in pixel. The offset is relative to the Dockable to which this ColumnDockActionSource belongs.

Specified by:
getSourceOffset in interface ColumnDockActionSource
Parameters:
index - the index of the source
Returns:
the offset of the source in pixels

getSourceLength

public int getSourceLength(int index)
Description copied from interface: ColumnDockActionSource
Gets the available length in pixel for the index'th source.

Specified by:
getSourceLength in interface ColumnDockActionSource
Parameters:
index - the index of the source
Returns:
the maximum amount of space in pixel

createColumn

protected abstract C createColumn(ToolbarColumn<P> column)
Creates a new, empty AbstractToolbarGroupActions.Column which will be filled with content later.

Parameters:
column - the column that is represented by the new object
Returns:
the new column, must not be null

getBoundaries

protected abstract Rectangle getBoundaries(P item)
Gets the bounds of the Component item.

Parameters:
item - the item whose boundaries are required
Returns:
the boundaries

installListener

protected abstract void installListener(P item,
                                        ComponentListener listener)
Installs the ComponentListener listener such that changes on item that lead to columns shifting position or size are recognized.

Parameters:
item - the item which gets a new listener
listener - the new listener

uninstallListener

protected abstract void uninstallListener(P item,
                                          ComponentListener listener)
Removes the listener listener from item.

Parameters:
item - the item where the listener is to be removed
listener - the listener to remove