bibliothek.gui.dock.station.stack
Class CombinedStackDockComponent<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>

java.lang.Object
  extended by bibliothek.gui.dock.station.stack.tab.AbstractTabPane<T,M,I>
      extended by bibliothek.gui.dock.station.stack.CombinedStackDockComponent<T,M,I>
Type Parameters:
T - the type of the tabs
M - the type of the menus
I - the type of the additinal info panel
All Implemented Interfaces:
StackDockComponent, TabPane
Direct Known Subclasses:
BubbleStackDockComponent, EclipseTabPane, FlatTabPane

public abstract class CombinedStackDockComponent<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>
extends AbstractTabPane<T,M,I>
implements StackDockComponent

A StackDockComponent which is a combination of other components.
This class also implements TabPane and thus supports the TabLayoutManager.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from interface bibliothek.gui.dock.station.stack.tab.TabPane
LAYOUT_MANAGER
 
Constructor Summary
CombinedStackDockComponent()
          Constructs a new component.
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Adds a ChangeListener to this component.
 void addTab(String title, Icon icon, Component comp, Dockable dockable)
          Adds a new child at an unspecified location.
protected  void addToMenu(M menu, Dockable dockable)
          Adds dockable somewhere to menu
protected  CombinedStackDockContentPane createContentPane(CombinedStackDockComponent<T,M,I> self)
          Creates the content pane for this component.
 DockElementRepresentative createDefaultRepresentation(DockElement target)
          Creates and returns a new DockElementRepresentative representing target, the new representation is to be used to cover all the empty areas on this StackDockComponent.
protected  Component createLayerAt(Component component, Dockable dockable)
          Creates a layer between component and this panel.
 Rectangle getAvailableArea()
          Gets the area in which all the Tabs, TabMenus and the visible Dockable (TabPane.setSelectedBounds(Rectangle)) must find their place.
 Rectangle getBoundsAt(int index)
          Gets the location and size of the graphical element that allows the user to select the index'th child.
 JComponent getComponent()
          Gets a Component on which the children of this StackDockComponent will be displayed.
 Dockable getDockableAt(int index)
          Gets the Dockable which was placed at the index'th position.
 CombinedHandler<AbstractTabPaneComponent> getInfoHandler()
          Gets a handler for info components.
 Component getLayerAt(int index)
          Gets the index'th Component on this tab.
 CombinedHandler<CombinedMenu> getMenuHandler()
          Gets a handler for menus.
 Rectangle getSelectedBounds()
          Gets the boundaries the selected Dockable has (independent of whether such a Dockable exists).
 int getSelectedIndex()
          Gets the index of the currently selected dockable
 int getTabCount()
          Gets the number of children that are added to this StackDockComponent.
 CombinedHandler<CombinedTab> getTabHandler()
          Gets a handler for tabs.
protected  int getZOrder(Component component)
          Gets the z order of component.
 void insertTab(String title, Icon icon, Component comp, Dockable dockable, int index)
          Adds a new child at the location index.
 void moveTab(int source, int destination)
          Moves the tab at source to location destination.
 T putOnTab(Dockable dockable)
          Informs this pane that its child dockable should have a tab-button.
 void remove(int index)
          Removes the index'th element of this pane.
 void removeAll()
          Removes all elements from this pane.
 void removeChangeListener(ChangeListener listener)
          Removes a ChangeListener which was added earlier.
protected  void removeFromMenu(M menu, Dockable dockable)
          Removes dockable from menu.
 void repaint()
          Repaints the contents of this component.
 void revalidate()
          Called when the layout of this pane has become invalid, the default behavior is to call AbstractTabPane.doLayout().
 void setComponentAt(int index, Component component)
          Sets the component which should be shown at tab index.
 void setController(DockController controller)
          Connects this pane with controller.
 void setIconAt(int index, Icon newIcon)
          Sets the icon of the child at location index.
 void setSelectedBounds(Rectangle bounds)
          Sets the boundaries of the selected Dockable.
 void setSelectedDockable(Dockable dockable)
          Selects the child dockable of this pane as the one visible element.
 void setSelectedIndex(int index)
          Selects the component at location index.
 void setTitleAt(int index, String newTitle)
          Sets the title of the child at location index.
 void setTooltipAt(int index, String newTooltip)
          Sets the tooltip of the child at location index.
protected  void setZOrder(Component component, int order)
          Sets the z order of component, as higher the z order as later the component is painted, as more components it can overlap.
 
Methods inherited from class bibliothek.gui.dock.station.stack.tab.AbstractTabPane
addTabPaneListener, createMenu, destroyMenu, discardComponentsAndRebuild, doLayout, fireAdded, fireInfoComponentChanged, fireRemoved, fireSelectionChanged, getController, getDockable, getDockableCount, getDockables, getInfoComponent, getLayoutManager, getMenu, getMenuList, getMenus, getMinimumSize, getOnTab, getPreferredSize, getSelectedDockable, getTab, getTabPlacement, getTabs, getTabsList, getVisibleTab, getVisibleTabCount, indexOf, indexOfVisible, insert, listeners, menuRemoved, move, newMenu, newTab, putInMenu, removeTabPaneListener, setInfoComponent, setLayoutManager, setTabPlacement, tabRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.station.stack.StackDockComponent
hasBorder, isSingleTabComponent, setTabPlacement
 

Constructor Detail

CombinedStackDockComponent

public CombinedStackDockComponent()
Constructs a new component.

Method Detail

createContentPane

protected CombinedStackDockContentPane createContentPane(CombinedStackDockComponent<T,M,I> self)
Creates the content pane for this component. This method may be called by the constructor.

Parameters:
self - this
Returns:
a new panel, not null

revalidate

public void revalidate()
Description copied from class: AbstractTabPane
Called when the layout of this pane has become invalid, the default behavior is to call AbstractTabPane.doLayout(). Subclasses may override to update the layout lazily.

Overrides:
revalidate in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>

repaint

public void repaint()
Repaints the contents of this component.


addChangeListener

public void addChangeListener(ChangeListener listener)
Description copied from interface: StackDockComponent
Adds a ChangeListener to this component. The listener will be called when the selected component changes.

Specified by:
addChangeListener in interface StackDockComponent
Parameters:
listener - the new listener

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Description copied from interface: StackDockComponent
Removes a ChangeListener which was added earlier.

Specified by:
removeChangeListener in interface StackDockComponent
Parameters:
listener - the listener to remove

setController

public void setController(DockController controller)
Description copied from class: AbstractTabPane
Connects this pane with controller.

Specified by:
setController in interface StackDockComponent
Overrides:
setController in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>
Parameters:
controller - the realm in which this pane works, may be null

getTabHandler

public CombinedHandler<CombinedTab> getTabHandler()
Gets a handler for tabs. This handler adds or removes CombinedTabs from this component in order to change their visibility.

Returns:
the handler

getMenuHandler

public CombinedHandler<CombinedMenu> getMenuHandler()
Gets a handler for menus. This handler adds or removes CombinedMenus from this component in order to change their visibility.

Returns:
the handler

getInfoHandler

public CombinedHandler<AbstractTabPaneComponent> getInfoHandler()
Gets a handler for info components. This handler adds or removes AbstractTabPaneComponents from this component in order to change their visibility.

Returns:
the handler

getAvailableArea

public Rectangle getAvailableArea()
Description copied from interface: TabPane
Gets the area in which all the Tabs, TabMenus and the visible Dockable (TabPane.setSelectedBounds(Rectangle)) must find their place.

Specified by:
getAvailableArea in interface TabPane
Returns:
the available space, has at least width and height 1.

getSelectedBounds

public Rectangle getSelectedBounds()
Description copied from interface: TabPane
Gets the boundaries the selected Dockable has (independent of whether such a Dockable exists).

Specified by:
getSelectedBounds in interface TabPane
Returns:
the boundaries of the selected child, not null

setSelectedBounds

public void setSelectedBounds(Rectangle bounds)
Description copied from interface: TabPane
Sets the boundaries of the selected Dockable.

Specified by:
setSelectedBounds in interface TabPane
Parameters:
bounds - the boundaries of the selected child

getSelectedIndex

public int getSelectedIndex()
Description copied from interface: StackDockComponent
Gets the index of the currently selected dockable

Specified by:
getSelectedIndex in interface StackDockComponent
Returns:
the index

setSelectedIndex

public void setSelectedIndex(int index)
Description copied from interface: StackDockComponent
Selects the component at location index.

Specified by:
setSelectedIndex in interface StackDockComponent
Parameters:
index - the index of the selected component

setSelectedDockable

public void setSelectedDockable(Dockable dockable)
Description copied from class: AbstractTabPane
Selects the child dockable of this pane as the one visible element.

Overrides:
setSelectedDockable in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>
Parameters:
dockable - the newly selected element, can be null

getBoundsAt

public Rectangle getBoundsAt(int index)
Description copied from interface: StackDockComponent
Gets the location and size of the graphical element that allows the user to select the index'th child.

Specified by:
getBoundsAt in interface StackDockComponent
Parameters:
index - the index of the child
Returns:
the bounds of the graphical selection-element, null if the element is not directly visible

getTabCount

public int getTabCount()
Description copied from interface: StackDockComponent
Gets the number of children that are added to this StackDockComponent.

Specified by:
getTabCount in interface StackDockComponent
Returns:
the number of children

addTab

public void addTab(String title,
                   Icon icon,
                   Component comp,
                   Dockable dockable)
Description copied from interface: StackDockComponent
Adds a new child at an unspecified location.

Specified by:
addTab in interface StackDockComponent
Parameters:
title - the title of the child
icon - an icon to display for the child or null
comp - the new child to display
dockable - the Dockable for which the tab is used

insertTab

public void insertTab(String title,
                      Icon icon,
                      Component comp,
                      Dockable dockable,
                      int index)
Description copied from interface: StackDockComponent
Adds a new child at the location index.

Specified by:
insertTab in interface StackDockComponent
Parameters:
title - the title of the child
icon - an icon to display for the child or null
comp - the new child to display
dockable - the Dockable for which the tab is used
index - the index that the new child should have

getDockableAt

public Dockable getDockableAt(int index)
Description copied from interface: StackDockComponent
Gets the Dockable which was placed at the index'th position.

Specified by:
getDockableAt in interface StackDockComponent
Parameters:
index - the position of the element
Returns:
the element

moveTab

public void moveTab(int source,
                    int destination)
Description copied from interface: StackDockComponent
Moves the tab at source to location destination.

Specified by:
moveTab in interface StackDockComponent
Parameters:
source - the item to move
destination - the target destination

remove

public void remove(int index)
Description copied from class: AbstractTabPane
Removes the index'th element of this pane.

Specified by:
remove in interface StackDockComponent
Overrides:
remove in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>
Parameters:
index - the index of the element to remove

removeAll

public void removeAll()
Description copied from class: AbstractTabPane
Removes all elements from this pane.

Specified by:
removeAll in interface StackDockComponent
Overrides:
removeAll in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>

putOnTab

public T putOnTab(Dockable dockable)
Description copied from interface: TabPane
Informs this pane that its child dockable should have a tab-button. This TabPane may create a new Tab or reuse an existing Tab. Reusing an existing tab is recommended. If dockable was part of a TabMenu, then it should be removed from that menu.
If dockable already is on a tab then this tab should be reused.

Specified by:
putOnTab in interface TabPane
Overrides:
putOnTab in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>
Parameters:
dockable - the element which needs a tab-button
Returns:
a Tab that is only used for dockable

addToMenu

protected void addToMenu(M menu,
                         Dockable dockable)
Description copied from class: AbstractTabPane
Adds dockable somewhere to menu

Specified by:
addToMenu in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>
Parameters:
menu - a menu of this pane
dockable - a new child of menu

removeFromMenu

protected void removeFromMenu(M menu,
                              Dockable dockable)
Description copied from class: AbstractTabPane
Removes dockable from menu.

Specified by:
removeFromMenu in class AbstractTabPane<T extends CombinedTab,M extends CombinedMenu,I extends CombinedInfoComponent>
Parameters:
menu - some menu of this pane
dockable - a child of menu

createLayerAt

protected Component createLayerAt(Component component,
                                  Dockable dockable)
Creates a layer between component and this panel. The object component is a representation of dockable but not necessarily dockable itself. The default behavior of this method is to return component.

Parameters:
component - the representation of dockable
dockable - the element for which a new layer is created
Returns:
the new layer which must be a parent of component or component

getLayerAt

public Component getLayerAt(int index)
Gets the index'th Component on this tab. This Component is not a Dockable but a layer between dockable and this panel.

Parameters:
index - the index of a tab.
Returns:
the layer between tab and dockable

setTitleAt

public void setTitleAt(int index,
                       String newTitle)
Description copied from interface: StackDockComponent
Sets the title of the child at location index.

Specified by:
setTitleAt in interface StackDockComponent
Parameters:
index - the index of the child
newTitle - the new title

setTooltipAt

public void setTooltipAt(int index,
                         String newTooltip)
Description copied from interface: StackDockComponent
Sets the tooltip of the child at location index.

Specified by:
setTooltipAt in interface StackDockComponent
Parameters:
index - the index of the child
newTooltip - the new tooltip, can be null

setIconAt

public void setIconAt(int index,
                      Icon newIcon)
Description copied from interface: StackDockComponent
Sets the icon of the child at location index.

Specified by:
setIconAt in interface StackDockComponent
Parameters:
index - the index of the child
newIcon - the new icon, null if no icon should be displayed

setComponentAt

public void setComponentAt(int index,
                           Component component)
Description copied from interface: StackDockComponent
Sets the component which should be shown at tab index.

Specified by:
setComponentAt in interface StackDockComponent
Parameters:
index - the index where to show component
component - the new content, not null

getComponent

public JComponent getComponent()
Description copied from interface: StackDockComponent
Gets a Component on which the children of this StackDockComponent will be displayed.

Specified by:
getComponent in interface StackDockComponent
Returns:
the Component

setZOrder

protected void setZOrder(Component component,
                         int order)
Sets the z order of component, as higher the z order as later the component is painted, as more components it can overlap.

Parameters:
component - some child of this pane
order - the order

getZOrder

protected int getZOrder(Component component)
Gets the z order of component.

Parameters:
component - some child of this pane
Returns:
the order

createDefaultRepresentation

public DockElementRepresentative createDefaultRepresentation(DockElement target)
Description copied from interface: StackDockComponent
Creates and returns a new DockElementRepresentative representing target, the new representation is to be used to cover all the empty areas on this StackDockComponent.

Specified by:
createDefaultRepresentation in interface StackDockComponent
Parameters:
target - the target for the new representative, may or may not be a child of this component, not null
Returns:
the new representation, can be null if this StackDockComponent does not allow to use its free spaces