bibliothek.gui.dock.station.stack.menu
Class AbstractCombinedMenu

java.lang.Object
  extended by bibliothek.gui.dock.station.stack.tab.AbstractTabPaneComponent
      extended by bibliothek.gui.dock.station.stack.menu.AbstractCombinedMenu
All Implemented Interfaces:
CombinedMenu, TabMenu, TabPaneComponent
Direct Known Subclasses:
BubbleTabMenu, EclipseMenu, FlatMenu

public abstract class AbstractCombinedMenu
extends AbstractTabPaneComponent
implements CombinedMenu

An abstract implementation of CombinedMenu, this menu delegates creation and management of its Component to its subclasses and uses a CombinedMenuContent to show its content.

Author:
Benjamin Sigg

Constructor Summary
AbstractCombinedMenu(TabPane parent, CombinedHandler<? super AbstractCombinedMenu> handler)
          Creates a new menu.
 
Method Summary
protected  void closed()
          Called once the menu is closed, the default implementation does nothing.
protected abstract  Component createComponent()
          Creates the button which will always be visible.
protected  void ensureComponent()
          Ensures that createComponent() is called and its result stored.
 Component getComponent()
          Gets the Component which is wrapped into this AbstractTabPaneComponent.
 DockController getController()
          Gets the controller in whose realm this menu is used.
 Dockable getDockable(int index)
          Gets the index'th Dockable of this menu.
 int getDockableCount()
          Gets the number of Dockables shown on this menu.
 Dockable[] getDockables()
          Gets all the Dockables that are shown in this menu.
 int getZOrder()
          Gets the value of the z order.
 void insert(int index, Dockable dockable)
          Inserts a new item at index in this menu.
 boolean isPaneVisible()
          Tells whether this component is visible or not.
 void open()
          Opens a menu where the user can select a Dockable.
 void remove(Dockable dockable)
          Removes the item dockable from this menu
protected abstract  void selected(Dockable dockable)
          Called if this menu was open, an element was selected and the menu closed.
 void setController(DockController controller)
          Sets the controller in whose realm this menu is used.
 void setIcon(int index, Icon icon)
          Sets the image of this menu at index.
 void setPaneVisible(boolean visible)
          Changes the visibility state of this component.
 void setText(int index, String text)
          Sets the text of this menu at index.
 void setTooltip(int index, String tooltip)
          Sets the tooltip of this menu at index.
 void setZOrder(int order)
          Sets the z order of this component.
 
Methods inherited from class bibliothek.gui.dock.station.stack.tab.AbstractTabPaneComponent
getBounds, getMaximumSize, getMinimumSize, getOrientation, getOverlap, getPreferredSize, getTabParent, setBounds, setOrientation
 
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.tab.TabPaneComponent
getBounds, getMaximumSize, getMinimumSize, getOverlap, getPreferredSize, getTabParent, setBounds, setOrientation
 

Constructor Detail

AbstractCombinedMenu

public AbstractCombinedMenu(TabPane parent,
                            CombinedHandler<? super AbstractCombinedMenu> handler)
Creates a new menu.

Parameters:
parent - the owner of this menu, must not be null
handler - handler for making this menu visible or invisible and change the z order
Method Detail

ensureComponent

protected void ensureComponent()
Ensures that createComponent() is called and its result stored.


createComponent

protected abstract Component createComponent()
Creates the button which will always be visible. The user needs to click onto that button in order to show the content of this menu. This method will be called only once and not from a constructor of AbstractCombinedMenu.

Returns:
the new button

open

public void open()
Opens a menu where the user can select a Dockable.


closed

protected void closed()
Called once the menu is closed, the default implementation does nothing.


setController

public void setController(DockController controller)
Description copied from interface: CombinedMenu
Sets the controller in whose realm this menu is used.

Specified by:
setController in interface CombinedMenu
Parameters:
controller - the realm

getController

public DockController getController()
Gets the controller in whose realm this menu is used.

Returns:
the controller, might be null

setPaneVisible

public void setPaneVisible(boolean visible)
Description copied from interface: TabPaneComponent
Changes the visibility state of this component. Invisible components should be removed from any parent.

Specified by:
setPaneVisible in interface TabPaneComponent
Parameters:
visible - the new state

isPaneVisible

public boolean isPaneVisible()
Description copied from interface: TabPaneComponent
Tells whether this component is visible or not.

Specified by:
isPaneVisible in interface TabPaneComponent
Returns:
true if visible, false otherwise

setZOrder

public void setZOrder(int order)
Description copied from interface: TabPaneComponent
Sets the z order of this component. The z order tells which component to paint first, as lower the order as earlier a component is to be painted. If two components overlap, then the one with the higher z order appears in front of the one with the lower z order. If two components have the same z order, then it is unspecified which component is painted first.
A z-order is at least 0 and must not exceed the number of TabPaneComponents on the parent TabPane. The implementation may increase or decrease z-orders to prevent collisions between components with the same order.

Specified by:
setZOrder in interface TabPaneComponent
Parameters:
order - the order, can be any integer.

getZOrder

public int getZOrder()
Description copied from interface: TabPaneComponent
Gets the value of the z order.

Specified by:
getZOrder in interface TabPaneComponent
Returns:
the z order
See Also:
TabPaneComponent.setZOrder(int)

selected

protected abstract void selected(Dockable dockable)
Called if this menu was open, an element was selected and the menu closed.

Parameters:
dockable - the selected element

getComponent

public Component getComponent()
Description copied from class: AbstractTabPaneComponent
Gets the Component which is wrapped into this AbstractTabPaneComponent. This method is not called from the constructor.

Specified by:
getComponent in interface CombinedMenu
Specified by:
getComponent in class AbstractTabPaneComponent
Returns:
the wrapped Component, not null

setIcon

public void setIcon(int index,
                    Icon icon)
Description copied from interface: CombinedMenu
Sets the image of this menu at index.

Specified by:
setIcon in interface CombinedMenu
Parameters:
index - the entry that should be modified
icon - an icon that should be shown, can be null

setText

public void setText(int index,
                    String text)
Description copied from interface: CombinedMenu
Sets the text of this menu at index.

Specified by:
setText in interface CombinedMenu
Parameters:
index - the entry that should be modified
text - the text to display

setTooltip

public void setTooltip(int index,
                       String tooltip)
Description copied from interface: CombinedMenu
Sets the tooltip of this menu at index.

Specified by:
setTooltip in interface CombinedMenu
Parameters:
index - the entry that should be modified
tooltip - the tooltip text, can be null

insert

public void insert(int index,
                   Dockable dockable)
Description copied from interface: CombinedMenu
Inserts a new item at index in this menu.

Specified by:
insert in interface CombinedMenu
Parameters:
index - the location of the new item
dockable - the new item

remove

public void remove(Dockable dockable)
Description copied from interface: CombinedMenu
Removes the item dockable from this menu

Specified by:
remove in interface CombinedMenu
Parameters:
dockable - the item to remove

getDockables

public Dockable[] getDockables()
Description copied from interface: TabMenu
Gets all the Dockables that are shown in this menu.

Specified by:
getDockables in interface TabMenu
Returns:
the list of elements in this menu

getDockableCount

public int getDockableCount()
Description copied from interface: TabMenu
Gets the number of Dockables shown on this menu.

Specified by:
getDockableCount in interface TabMenu
Returns:
the number of items

getDockable

public Dockable getDockable(int index)
Description copied from interface: TabMenu
Gets the index'th Dockable of this menu.

Specified by:
getDockable in interface TabMenu
Parameters:
index - the index of an item
Returns:
the item