bibliothek.gui.dock.station.flap
Class FlapDockPerspective

java.lang.Object
  extended by bibliothek.gui.dock.station.flap.FlapDockPerspective
All Implemented Interfaces:
PerspectiveDockable, PerspectiveElement, PerspectiveStation, PlaceholderListItem<PerspectiveDockable>
Direct Known Subclasses:
CMinimizePerspective.CommonFlapDockPerspective

public class FlapDockPerspective
extends Object
implements PerspectiveDockable, PerspectiveStation

A representation of a FlapDockStation in a Perspective.
Note: while this perspective allows to set the hold and size property of a dockable, the final decision of how these properties look like are made by the FlapLayoutManager that is installed on the FlapDockStation which shows the real Dockables.

Author:
Benjamin Sigg

Constructor Summary
FlapDockPerspective()
           
 
Method Summary
 void add(PerspectiveDockable dockable)
          Adds dockable at the end of the list of children.
 void add(PerspectiveDockable dockable, boolean hold, int size)
          Adds dockable at the end of the list of children.
 void addPlaceholder(Path placeholder)
          Adds placeholder at the end of the list of items.
 void addPlaceholder(PerspectiveDockable dockable)
          Adds a placeholder for dockable and all its children to 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
 int getDefaultSize()
          Gets the default size of the window of newly added Dockables.
 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.
 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.
 int getSize(PerspectiveDockable dockable)
          Gets the preferred size of the window that shows dockable.
 int indexOf(PerspectiveDockable dockable)
          Gets the current index of dockable.
 void insert(int index, PerspectiveDockable dockable)
          Adds a Dockable to this station.
 void insert(int index, PerspectiveDockable dockable, boolean hold, int size)
          Adds dockable to this station.
 void insertPlaceholder(int index, Path placeholder)
          Adds placeholder at location index in the list of items.
 void insertPlaceholder(int index, PerspectiveDockable dockable)
          Adds a placeholder for dockable and all its children at location index to the list of dockables.
 boolean isDefaultHold()
          Tells whether newly added Dockables normally remain open even if they loose the focus.
 boolean isHold(PerspectiveDockable dockable)
          Tells whether dockable should stay open even if it lost focus.
 void read(PlaceholderMap map, Map<Integer,PerspectiveDockable> children)
          Updates the content of this perspective by reading the contents of map.
 PerspectiveDockable remove(int index)
          Removes the index'th element of this perspective.
 boolean remove(PerspectiveDockable dockable)
          Removes a child of this station, can leave behind a placeholder.
 void replace(PerspectiveDockable oldDockable, PerspectiveDockable newDockable)
          Replaces oldDockable by newDockable.
 void setDefaultHold(boolean defaultHold)
          Sets whether newly added Dockables remain open even if they lost the focus.
 void setDefaultSize(int defaultSize)
          Sets the default size of the window of newly added Dockables.
 void setHold(PerspectiveDockable dockable, boolean hold)
          Sets whether dockable should stay open even if it lost focus.
 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 setSize(PerspectiveDockable dockable, int size)
          Sets the preferred size of the window that shows dockable.
 PlaceholderMap toMap(Map<PerspectiveDockable,Integer> children)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlapDockPerspective

public FlapDockPerspective()
Method Detail

read

public void read(PlaceholderMap map,
                 Map<Integer,PerspectiveDockable> children)
Updates the content of this perspective by reading the contents of map.

Parameters:
map - the placeholders
children - the possible children of this perspective

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)

getDefaultSize

public int getDefaultSize()
Gets the default size of the window of newly added Dockables.

Returns:
the default size

setDefaultSize

public void setDefaultSize(int defaultSize)
Sets the default size of the window of newly added Dockables. Changing this property has no effect on Dockables that were already added to this station.

Parameters:
defaultSize - the default size, at least 0

isDefaultHold

public boolean isDefaultHold()
Tells whether newly added Dockables normally remain open even if they loose the focus.

Returns:
true if the elements remain open

setDefaultHold

public void setDefaultHold(boolean defaultHold)
Sets whether newly added Dockables remain open even if they lost the focus.

Parameters:
defaultHold - true if the elements should remain open

insertPlaceholder

public void insertPlaceholder(int index,
                              PerspectiveDockable dockable)
Adds a placeholder for dockable and all its children at location index to the list of dockables.

Parameters:
index - the location of dockable
dockable - the element which is stored as placeholder

insertPlaceholder

public void insertPlaceholder(int index,
                              Path placeholder)
Adds placeholder at location index in the list of items.

Parameters:
index - the location of placeholder
placeholder - the placeholder to add, not null

addPlaceholder

public void addPlaceholder(PerspectiveDockable dockable)
Adds a placeholder for dockable and all its children to the end of the list of dockables.

Parameters:
dockable - the element which is stored as placeholder

addPlaceholder

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

Parameters:
placeholder - the placeholder to add, not null

add

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

Parameters:
dockable - the new element

add

public void add(PerspectiveDockable dockable,
                boolean hold,
                int size)
Adds dockable at the end of the list of children.

Parameters:
dockable - the new element
hold - whether dockable should remain open even if the focus is lost
size - the preferred size of dockable

insert

public void insert(int index,
                   PerspectiveDockable dockable)
Adds a Dockable to this station.

Parameters:
index - the location of the new child
dockable - the new child, not null, must not have a parent

insert

public void insert(int index,
                   PerspectiveDockable dockable,
                   boolean hold,
                   int size)
Adds dockable to this station.

Parameters:
index - the location of dockable
dockable - the new element
hold - whether dockable should remain open even if the focus is lost
size - the preferred size of dockable

remove

public PerspectiveDockable remove(int index)
Removes the index'th element of this perspective.

Parameters:
index - the location of the element to remove
Returns:
the element that was removed

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

indexOf

public int indexOf(PerspectiveDockable dockable)
Gets the current index of dockable.

Parameters:
dockable - some dockable to search
Returns:
the index or -1 if not found

setHold

public void setHold(PerspectiveDockable dockable,
                    boolean hold)
Sets whether dockable should stay open even if it lost focus.

Parameters:
dockable - the element whose state changes
hold - whether to keep dockable open
Throws:
IllegalArgumentException - if dockable is not known to this station

isHold

public boolean isHold(PerspectiveDockable dockable)
Tells whether dockable should stay open even if it lost focus.

Parameters:
dockable - the element whose state is requested
Returns:
true if dockable should remain open
Throws:
IllegalArgumentException - if dockable is not known to this station

setSize

public void setSize(PerspectiveDockable dockable,
                    int size)
Sets the preferred size of the window that shows dockable.

Parameters:
dockable - some child of this station
size - the preferred size, at least 0
Throws:
IllegalArgumentException - if either dockable is not a child of this station or if size is less than 0

getSize

public int getSize(PerspectiveDockable dockable)
Gets the preferred size of the window that shows dockable.

Parameters:
dockable - some child of this station
Returns:
the preferred size
Throws:
IllegalArgumentException - if dockable is not known to 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

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