bibliothek.gui.dock.station.stack
Class StackDockPerspective

java.lang.Object
  extended by bibliothek.gui.dock.station.stack.StackDockPerspective
All Implemented Interfaces:
PerspectiveDockable, PerspectiveElement, PerspectiveStation, PlaceholderListItem<PerspectiveDockable>
Direct Known Subclasses:
CStackPerspective

public class StackDockPerspective
extends Object
implements PerspectiveDockable, PerspectiveStation

A representation of a StackDockStation in a Perspective.

Author:
Benjamin Sigg

Constructor Summary
StackDockPerspective()
          Creates a new empty StackDockPerspective.
StackDockPerspective(PerspectiveDockable[] children, PerspectiveDockable selection)
          Creates a new perspective.
 
Method Summary
 void add(PerspectiveDockable dockable)
          Adds dockable at the end of the list of dockables.
 void addPlaceholder(Path placeholder)
          Adds placeholder at the end of the list of dockables.
 void addPlaceholder(PerspectiveDockable dockable)
          Adds a placeholder for dockable at the end of the list of dockables.
 PerspectiveDockable asDockable()
          Returns the representation of this as PerspectiveDockable.
 PerspectiveStation asStation()
          Returns the representation of this as PerspectiveStation
 PerspectiveDockable getDockable(int index)
          Gets the index'th child of this station.
 int getDockableCount()
          Gets the number of children this station has.
 DockableProperty getDockableProperty(PerspectiveDockable child, PerspectiveDockable target)
          Gets precise information about the location of a child of this station.
 String getFactoryID()
          Gets the identifier of the DockFactory that will be able to understand the layout information this element generates.
 int getItemCount()
          Gets the number of children, this includes dockables and placeholders.
 PerspectiveStation getParent()
          Gets the parent DockStation of this Dockable.
 Path getPlaceholder()
          Gets the placeholder which is associated with this Dockable.
 PlaceholderMap getPlaceholders()
          Converts the contents of this station into a map of placeholders.
 PerspectiveDockable getSelection()
          Gets the currently selected element.
 int indexOf(Path placeholder)
          Gets the location where placeholder would be found if it were a dockable.
 int indexOf(PerspectiveDockable dockable)
          Gets the location of dockable.
 void insert(int index, PerspectiveDockable dockable)
          Inserts dockable at location index.
 void insertPlaceholder(int index, Path placeholder, PlaceholderList.Level level)
          Adds placeholder at location index.
 void insertPlaceholder(int index, PerspectiveDockable dockable)
          Adds a placeholder for dockable at location index.
 void read(PlaceholderMap placeholders, Map<Integer,PerspectiveDockable> children, int selected)
          Reads the contents of map and replaces any content of this perspective.
 PerspectiveDockable remove(int index)
          Removes the index'th child of this station.
 boolean remove(PerspectiveDockable dockable)
          Removes dockable from this station.
 void replace(PerspectiveDockable oldDockable, PerspectiveDockable newDockable)
          Replaces oldDockable by newDockable.
 void setParent(PerspectiveStation parent)
          Sets the parent DockStation of this Dockable.
 void setPlaceholders(PlaceholderMap placeholders)
          Informs this station of the content that it should show
 void setSelection(PerspectiveDockable dockable)
          Changes the selected element of this station.
 PlaceholderMap toMap(Map<PerspectiveDockable,Integer> children)
          Converts this perspective into a PlaceholderMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackDockPerspective

public StackDockPerspective()
Creates a new empty StackDockPerspective.


StackDockPerspective

public StackDockPerspective(PerspectiveDockable[] children,
                            PerspectiveDockable selection)
Creates a new perspective.

Parameters:
children - the children of the new station
selection - the current selection, may be null
Method Detail

read

public void read(PlaceholderMap placeholders,
                 Map<Integer,PerspectiveDockable> children,
                 int selected)
Reads the contents of map and replaces any content of this perspective.

Parameters:
placeholders - the map to convert
children - the children of this station
selected - the selected child or -1

setPlaceholders

public void setPlaceholders(PlaceholderMap placeholders)
Description copied from interface: PerspectiveStation
Informs this station of the content that it should show

Specified by:
setPlaceholders in interface PerspectiveStation
Parameters:
placeholders - a map that was earlier created by PerspectiveStation.getPlaceholders()

getPlaceholders

public PlaceholderMap getPlaceholders()
Description copied from interface: PerspectiveStation
Converts the contents of this station into a map of placeholders.

Specified by:
getPlaceholders in interface PerspectiveStation
Returns:
a map of placeholders describing the contents of this station

toMap

public PlaceholderMap toMap(Map<PerspectiveDockable,Integer> children)
Converts this perspective into a PlaceholderMap.

Parameters:
children - identifiers for the children of this station
Returns:
the new map

addPlaceholder

public void addPlaceholder(PerspectiveDockable dockable)
Adds a placeholder for dockable at the end of the list of dockables.

Parameters:
dockable - the element for which a placeholder should be added

addPlaceholder

public void addPlaceholder(Path placeholder)
Adds placeholder at the end of the list of dockables.

Parameters:
placeholder - the new placeholder

insertPlaceholder

public void insertPlaceholder(int index,
                              PerspectiveDockable dockable)
Adds a placeholder for dockable at location index.

Parameters:
index - the location where the placeholder goes
dockable - the element for which a placeholder should be left

insertPlaceholder

public void insertPlaceholder(int index,
                              Path placeholder,
                              PlaceholderList.Level level)
Adds placeholder at location index.

Parameters:
index - the location where the placeholder goes
placeholder - the new placeholder
level - at which level index should be evaluated, not null

add

public void add(PerspectiveDockable dockable)
Adds dockable at the end of the list of dockables.

Parameters:
dockable - the element to add

insert

public void insert(int index,
                   PerspectiveDockable dockable)
Inserts dockable at location index.

Parameters:
index - the location
dockable - the new element

indexOf

public int indexOf(PerspectiveDockable dockable)
Gets the location of dockable.

Parameters:
dockable - the dockable whose location is searched
Returns:
the location or -1 if not found

indexOf

public int indexOf(Path placeholder)
Gets the location where placeholder would be found if it were a dockable.

Parameters:
placeholder - the placeholder to search
Returns:
the location of placeholder or -1

remove

public boolean remove(PerspectiveDockable dockable)
Removes dockable from this station.

Specified by:
remove in interface PerspectiveStation
Parameters:
dockable - the element to remove
Returns:
true if dockable was removed, false otherwise

remove

public PerspectiveDockable remove(int index)
Removes the index'th child of this station. If the child is the selected element, then the selected element is set to null.

Parameters:
index - the location of the child
Returns:
the child that was removed

replace

public void replace(PerspectiveDockable oldDockable,
                    PerspectiveDockable newDockable)
Description copied from interface: PerspectiveStation
Replaces oldDockable by newDockable. This method should behave the same way is if oldDockable was removed and newDockable added at the same location.

Specified by:
replace in interface PerspectiveStation
Parameters:
oldDockable - some child of this station
newDockable - the replacement for oldDockable

setSelection

public void setSelection(PerspectiveDockable dockable)
Changes the selected element of this station.

Parameters:
dockable - the selected element, can be null

getSelection

public PerspectiveDockable getSelection()
Gets the currently selected element.

Returns:
the selected child or null

getDockableProperty

public DockableProperty getDockableProperty(PerspectiveDockable child,
                                            PerspectiveDockable target)
Description copied from interface: PerspectiveStation
Gets precise information about the location of a child of this station.

Specified by:
getDockableProperty in interface PerspectiveStation
Parameters:
child - a child of this station, this childs location is asked
target - an optional hint telling for which dockable the location information will be used, can be null. This hint can be used to find a placeholder that should be part of the result.
Returns:
the location

setParent

public void setParent(PerspectiveStation parent)
Description copied from interface: PerspectiveDockable
Sets the parent DockStation of this Dockable.

Specified by:
setParent in interface PerspectiveDockable
Parameters:
parent - the new parent, can be null

getParent

public PerspectiveStation getParent()
Description copied from interface: PerspectiveDockable
Gets the parent DockStation of this Dockable.

Specified by:
getParent in interface PerspectiveDockable
Returns:
the parent, may be null

getPlaceholder

public Path getPlaceholder()
Description copied from interface: PerspectiveDockable
Gets the placeholder which is associated with this Dockable.

Specified by:
getPlaceholder in interface PerspectiveDockable
Returns:
the placeholder, can be null

asDockable

public PerspectiveDockable asDockable()
Description copied from interface: PerspectiveElement
Returns the representation of this as PerspectiveDockable.

Specified by:
asDockable in interface PerspectiveElement
Specified by:
asDockable in interface PlaceholderListItem<PerspectiveDockable>
Returns:
either this, a representation of this or null

asStation

public PerspectiveStation asStation()
Description copied from interface: PerspectiveElement
Returns the representation of this as PerspectiveStation

Specified by:
asStation in interface PerspectiveElement
Returns:
either this, a representation of this or null

getFactoryID

public String getFactoryID()
Description copied from interface: PerspectiveElement
Gets the identifier of the DockFactory that will be able to understand the layout information this element generates.

Specified by:
getFactoryID in interface PerspectiveElement
Returns:
the factories identifier

getDockable

public PerspectiveDockable getDockable(int index)
Description copied from interface: PerspectiveStation
Gets the index'th child of this station.

Specified by:
getDockable in interface PerspectiveStation
Parameters:
index - the index of a child
Returns:
the child, not null

getDockableCount

public int getDockableCount()
Description copied from interface: PerspectiveStation
Gets the number of children this station has.

Specified by:
getDockableCount in interface PerspectiveStation
Returns:
the number of children

getItemCount

public int getItemCount()
Gets the number of children, this includes dockables and placeholders.

Returns:
the total number of children