bibliothek.gui.dock
Class DefaultDockable

java.lang.Object
  extended by bibliothek.gui.dock.dockable.AbstractDockable
      extended by bibliothek.gui.dock.DefaultDockable
All Implemented Interfaces:
DockElement, DockElementRepresentative, PlaceholderListItem<Dockable>, Dockable
Direct Known Subclasses:
DefaultCommonDockable

public class DefaultDockable
extends AbstractDockable

A Dockable which consists only of one Component called "content pane". It's possible to add or remove components from the content pane at any time.

Author:
Benjamin Sigg

Constructor Summary
DefaultDockable()
          Constructs a new DefaultDockable
DefaultDockable(Component component)
          Constructs a new DefaultDockable and places one component onto the content pane.
DefaultDockable(Component component, Icon icon)
          Constructs a new DefaultDockable, sets an icon and places one component.
DefaultDockable(Component component, String title)
          Constructs a new DefaultDockable, sets the title and places one component.
DefaultDockable(Component component, String title, Icon icon)
          Constructs a new DefaultDockable, sets the icon and the title, and places a component.
DefaultDockable(Component component, String title, Icon icon, IconHandling handling)
          Constructs a new DefaultDockable, sets the icon and the title, and places a component.
DefaultDockable(Icon icon)
          Constructs a new DefaultDockable and sets the icon.
DefaultDockable(String title)
          Constructs a new DefaultDockable and sets the title.
 
Method Summary
 void add(Component component)
          Adds component to the content pane.
 void add(Component component, Object constraints)
          Adds component to the content pane.
 DockStation asDockStation()
          Returns this if this is an instance of DockStation.
protected  DockIcon createTitleIcon()
          Creates the DockIcon which represents this Dockable or this DockStation.
 Component getClientComponent()
          Gets the Component which was given to this DefaultDockable through the constructor.
 Component getComponent()
          Gets the Component which represents the element.
 Component getComponent(int index)
          Gets the index'th child of this Dockable, this is equivalent of calling getContentPane().getComponent( index ).
 int getComponentCount()
          Gets the number of Components on this dockable, this is equivalent of calling getContentPane().getComponentCount().
 Container getContentPane()
          Gets a panel for children of this Dockable.
 String getFactoryID()
          Gets the unique name of the DockFactory which can read and write elements of this type.
 void remove(Component component)
          Removes component from the content pane.
 void setController(DockController controller)
          Sets the controller in whose realm this Dockable is.
 void setFactoryID(String factoryId)
          Sets the id for the DockFactory which will be used to store and load this dockable.
 void setLayout(LayoutManager layout)
          Sets the layout of the content pane.
 
Methods inherited from class bibliothek.gui.dock.dockable.AbstractDockable
accept, accept, addDockableListener, addDockableStateListener, addDockHierarchyListener, addKeyListener, addMouseInputListener, asDockable, bind, configureDisplayerHints, fireTitleBound, fireTitleExchanged, fireTitleExchanged, fireTitleIconChanged, fireTitleTextChanged, fireTitleTooltipChanged, fireTitleUnbound, getConfigurableDisplayerHints, getController, getDockableStateListeners, getDockElementObserver, getDockParent, getElement, getGlobalActionOffers, getLocalActionOffers, getPopupLocation, getTitleIcon, getTitleIconHandling, getTitleText, getTitleToolTip, isDockableShowing, isDockableVisible, isUsedAsTitle, listBoundTitles, removeDockableListener, removeDockableStateListener, removeDockHierarchyListener, removeKeyListener, removeMouseInputListener, requestDisplayer, requestDockTitle, resetTitleIcon, setActionOffers, setDockParent, setTitleIcon, setTitleIconHandling, setTitleText, setTitleToolTip, shouldFocus, shouldTransfersFocus, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDockable

public DefaultDockable()
Constructs a new DefaultDockable


DefaultDockable

public DefaultDockable(Icon icon)
Constructs a new DefaultDockable and sets the icon.

Parameters:
icon - the icon, to be shown at various places

DefaultDockable

public DefaultDockable(String title)
Constructs a new DefaultDockable and sets the title.

Parameters:
title - the title, to be shown at various places

DefaultDockable

public DefaultDockable(Component component)
Constructs a new DefaultDockable and places one component onto the content pane.

Parameters:
component - the only child of the content pane

DefaultDockable

public DefaultDockable(Component component,
                       Icon icon)
Constructs a new DefaultDockable, sets an icon and places one component.

Parameters:
component - the only child of the content pane
icon - the icon, to be shown at various places

DefaultDockable

public DefaultDockable(Component component,
                       String title)
Constructs a new DefaultDockable, sets the title and places one component.

Parameters:
component - the only child of the content pane
title - the title, to be shown at various places

DefaultDockable

public DefaultDockable(Component component,
                       String title,
                       Icon icon)
Constructs a new DefaultDockable, sets the icon and the title, and places a component.

Parameters:
component - the only child of the content pane
title - the title, to be shown at various places
icon - the icon, to be shown at various places

DefaultDockable

public DefaultDockable(Component component,
                       String title,
                       Icon icon,
                       IconHandling handling)
Constructs a new DefaultDockable, sets the icon and the title, and places a component.

Parameters:
component - the only child of the content pane
title - the title, to be shown at various places
icon - the icon, to be shown at various places
handling - how to understand the icon parameter
Method Detail

createTitleIcon

protected DockIcon createTitleIcon()
Description copied from class: AbstractDockable
Creates the DockIcon which represents this Dockable or this DockStation. The icon must call AbstractDockable.fireTitleIconChanged(Icon, Icon) if the icon changes.

Specified by:
createTitleIcon in class AbstractDockable
Returns:
the default icon for this element

getFactoryID

public String getFactoryID()
Description copied from interface: DockElement
Gets the unique name of the DockFactory which can read and write elements of this type.

Returns:
the id of the factory

setFactoryID

public void setFactoryID(String factoryId)
Sets the id for the DockFactory which will be used to store and load this dockable.

Parameters:
factoryId - the id of the factory

getComponent

public Component getComponent()
Description copied from interface: DockElementRepresentative
Gets the Component which represents the element. The result of this method must not change.

Returns:
the component, never null

asDockStation

public DockStation asDockStation()
Description copied from interface: DockElement
Returns this if this is an instance of DockStation. Otherwise null is returned.

Returns:
this or null. Must not return null if DockElement.asDockable() already returns null

getComponentCount

public int getComponentCount()
Gets the number of Components on this dockable, this is equivalent of calling getContentPane().getComponentCount().

Returns:
the number of components
See Also:
getContentPane(), Container.getComponentCount()

getComponent

public Component getComponent(int index)
Gets the index'th child of this Dockable, this is equivalent of calling getContentPane().getComponent( index ).

Parameters:
index - the index of the child
Returns:
the component
See Also:
getContentPane(), Container.getComponent(int)

getClientComponent

public Component getClientComponent()
Gets the Component which was given to this DefaultDockable through the constructor. If the client ever removes and the client component from the content-pane, and then adds the component again, then the result of this method gets unspecified.
Please note: the implementation of how the client component is stored does not prevent the garbage collector from deleting the client component.

Returns:
the component that was given to this dockable through the constructor or null if that component was removed from the content-pane

getContentPane

public Container getContentPane()
Gets a panel for children of this Dockable. Clients can do whatever they like, except removing the content pane from its parent.

Returns:
the representation of this dockable

add

public void add(Component component)
Adds component to the content pane.

Parameters:
component - the new child

add

public void add(Component component,
                Object constraints)
Adds component to the content pane.

Parameters:
component - the new child
constraints - information for th LayoutManager

remove

public void remove(Component component)
Removes component from the content pane.

Parameters:
component - the child to remove

setLayout

public void setLayout(LayoutManager layout)
Sets the layout of the content pane. The layout is normaly a FlowLayout, except the constructor has added a component to the layout. In that case, the layout is a GridLayout.

Parameters:
layout - the new layout of the content pane

setController

public void setController(DockController controller)
Description copied from interface: Dockable
Sets the controller in whose realm this Dockable is. A value of null means that this Dockable is not managed by a controller.
Note: this method has to inform all DockHierarchyListeners about the change.
Note: when using a DockHierarchyObserver, invoke DockHierarchyObserver.controllerChanged(DockController)

Specified by:
setController in interface Dockable
Overrides:
setController in class AbstractDockable
Parameters:
controller - the owner, may be null