bibliothek.gui.dock.station.split
Class SplitDockPerspective

java.lang.Object
  extended by bibliothek.gui.dock.station.split.SplitDockPerspective
All Implemented Interfaces:
PerspectiveDockable, PerspectiveElement, PerspectiveStation, PlaceholderListItem<PerspectiveDockable>
Direct Known Subclasses:
CGridPerspective.CommonSplitDockPerspective

public class SplitDockPerspective
extends Object
implements PerspectiveDockable, PerspectiveStation

Represents a SplitDockStation in a Perspective.

Author:
Benjamin Sigg

Nested Class Summary
static class SplitDockPerspective.Entry
          An entry in a tree, either a node or a leaf.
static interface SplitDockPerspective.EntryListener
          A listener that can be added to a SplitDockPerspective and that will receive events whenever the tree of the perspective changes.
static class SplitDockPerspective.Leaf
          A leaf in a tree, describes one Dockable.
static class SplitDockPerspective.Node
          A node in a tree.
 class SplitDockPerspective.Root
          A root in a tree.
 
Constructor Summary
SplitDockPerspective()
          Creates a new perspective
 
Method Summary
 void addListener(SplitDockPerspective.EntryListener listener)
          Adds a listener to this perspective.
 void addPlaceholder(SplitDockPerspective.Entry destination, Path placeholder)
          Adds a placeholder to destination and makes sure at the same time that placeholder is not used by any other node.
 PerspectiveDockable asDockable()
          Returns the representation of this as PerspectiveDockable.
 PerspectiveStation asStation()
          Returns the representation of this as PerspectiveStation
protected  PerspectiveDockable combine(PerspectiveDockable[] dockables, PerspectiveDockable selection)
          Combines several dockables to one dockable.
protected  void fireAdded(SplitDockPerspective.Entry parent, SplitDockPerspective.Entry child)
          Calls SplitDockPerspective.EntryListener.added(SplitDockPerspective.Entry, SplitDockPerspective.Entry) on all listeners that are currently known to this perspective
protected  void fireRemoved(SplitDockPerspective.Entry parent, SplitDockPerspective.Entry child)
          Calls SplitDockPerspective.EntryListener.removed(SplitDockPerspective.Entry, SplitDockPerspective.Entry) on all listeners that are currently known to this perspective
 PerspectiveDockable getDockable(int index)
          Gets the index'th child of this station.
 int getDockableCount()
          Gets the number of children this station has.
 SplitDockPathProperty getDockablePathProperty(PerspectiveDockable child)
          Creates the location information for child that directly describes the path through the tree to the element.
 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.
 PerspectiveDockable getFullscreen()
          Gets the element which is in fullscreen-mode
 SplitDockPerspective.Leaf getLeaf(PerspectiveDockable child)
          Searches and returns the leaf that shows child.
 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.
 SplitDockPerspective.Root getRoot()
          Gets the root of the tree that is the layout of this station.
 boolean hasFullscreenAction()
          Tells whether the SplitDockStation will attempt to create a fullscreen-action.
protected  SplitDockPerspective.EntryListener[] listeners()
          Gets an array containing all the listeners of this perspective
 void read(PerspectiveSplitDockTree tree, PerspectiveDockable fullscreen)
          Reads the contents of tree and replaces any content of this perspective
 boolean remove(PerspectiveDockable dockable)
          Removes a child of this station, can leave behind a placeholder.
 void removeListener(SplitDockPerspective.EntryListener listener)
          Removes listener from this perspective
 void replace(PerspectiveDockable oldDockable, PerspectiveDockable newDockable)
          Replaces oldDockable by newDockable.
 void setFullscreen(PerspectiveDockable fullscreen)
          Sets the element which is in fullscreen-mode, must be a child of this perspective
 void setHasFullscreenAction(boolean hasFullscreenAction)
          Sets whether the SplitDockStation should create a fullscreen-action.
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitDockPerspective

public SplitDockPerspective()
Creates a new perspective

Method Detail

addListener

public void addListener(SplitDockPerspective.EntryListener listener)
Adds a listener to this perspective.

Parameters:
listener - the new listener, not null

removeListener

public void removeListener(SplitDockPerspective.EntryListener listener)
Removes listener from this perspective

Parameters:
listener - the listener to remove

listeners

protected SplitDockPerspective.EntryListener[] listeners()
Gets an array containing all the listeners of this perspective

Returns:
all the listeners

fireRemoved

protected void fireRemoved(SplitDockPerspective.Entry parent,
                           SplitDockPerspective.Entry child)
Calls SplitDockPerspective.EntryListener.removed(SplitDockPerspective.Entry, SplitDockPerspective.Entry) on all listeners that are currently known to this perspective

Parameters:
parent - the parent from which child was removed
child - the child which was removed

fireAdded

protected void fireAdded(SplitDockPerspective.Entry parent,
                         SplitDockPerspective.Entry child)
Calls SplitDockPerspective.EntryListener.added(SplitDockPerspective.Entry, SplitDockPerspective.Entry) on all listeners that are currently known to this perspective

Parameters:
parent - the parent of the new element
child - the child that was added

read

public void read(PerspectiveSplitDockTree tree,
                 PerspectiveDockable fullscreen)
Reads the contents of tree and replaces any content of this perspective

Parameters:
tree - the tree that represents this perspective
fullscreen - the one child that is currently in fullscreen-mode, can be null

setHasFullscreenAction

public void setHasFullscreenAction(boolean hasFullscreenAction)
Sets whether the SplitDockStation should create a fullscreen-action.

Parameters:
hasFullscreenAction - whether to show a fullscreen action

hasFullscreenAction

public boolean hasFullscreenAction()
Tells whether the SplitDockStation will attempt to create a fullscreen-action.

Returns:
whether to create a fullscreen action

combine

protected PerspectiveDockable combine(PerspectiveDockable[] dockables,
                                      PerspectiveDockable selection)
Combines several dockables to one dockable.

Parameters:
dockables - the element to combine
selection - the selected element, can be null
Returns:
the combination

getFullscreen

public PerspectiveDockable getFullscreen()
Gets the element which is in fullscreen-mode

Returns:
the maximized element, can be null

setFullscreen

public void setFullscreen(PerspectiveDockable fullscreen)
Sets the element which is in fullscreen-mode, must be a child of this perspective

Parameters:
fullscreen - the element in fullscreen

getRoot

public SplitDockPerspective.Root getRoot()
Gets the root of the tree that is the layout of this station.

Returns:
the root of the tree, not 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

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

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

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

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

getDockablePathProperty

public SplitDockPathProperty getDockablePathProperty(PerspectiveDockable child)
Creates the location information for child that directly describes the path through the tree to the element.

Parameters:
child - the element whose location is searched
Returns:
the location or null if child was not found

remove

public boolean remove(PerspectiveDockable dockable)
Description copied from interface: PerspectiveStation
Removes a child of this station, can leave behind a placeholder.

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

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

getLeaf

public SplitDockPerspective.Leaf getLeaf(PerspectiveDockable child)
Searches and returns the leaf that shows child.

Parameters:
child - some child of this station
Returns:
the leaf showing child or null if not found

addPlaceholder

public void addPlaceholder(SplitDockPerspective.Entry destination,
                           Path placeholder)
Adds a placeholder to destination and makes sure at the same time that placeholder is not used by any other node.

Parameters:
destination - a child of this perspective
placeholder - the placeholder to insert