bibliothek.gui.dock.facile.menu
Class CloseableDockableMenuPiece

java.lang.Object
  extended by bibliothek.gui.dock.support.menu.MenuPiece
      extended by bibliothek.gui.dock.support.menu.BaseMenuPiece
          extended by bibliothek.gui.dock.facile.menu.CloseableDockableMenuPiece
Direct Known Subclasses:
SingleCDockableListMenuPiece

public class CloseableDockableMenuPiece
extends BaseMenuPiece

A piece of a menu allowing to close or reopen some Dockables that are registered in a DockFrontend.

Author:
Benjamin Sigg

Nested Class Summary
protected  class CloseableDockableMenuPiece.Item
          An item showing the visibility state of one Dockable.
 
Constructor Summary
CloseableDockableMenuPiece()
          Creates a new piece
CloseableDockableMenuPiece(DockFrontend frontend)
          Creates a new piece
 
Method Summary
 void bind()
          This method is called if there is a possibility for the user to see this menu.
 void check(Dockable dockable)
          Ensures that dockable has an item if it is included, and does not have otherwise.
protected  CloseableDockableMenuPiece.Item create(Dockable dockable)
          Creates a new item for the menu.
 DockFrontend getFrontend()
          Gets the frontend which is observed by this piece.
protected  void hide(Dockable dockable)
          Ensures that dockable is not visible.
protected  boolean include(Dockable dockable)
          Tells whether an item should be inserted into the menu for the given dockable or not.
protected  void insert(CloseableDockableMenuPiece.Item item)
          Adds an earlier created item into the menu, subclasses might override this method to add the item at a different location.
 void setFrontend(DockFrontend frontend)
          Sets the frontend which will be observed by this piece.
protected  void show(Dockable dockable)
          Ensures that dockable is visible.
 void unbind()
          This method is called if the user has no longer any possibility to see this menu.
 
Methods inherited from class bibliothek.gui.dock.support.menu.BaseMenuPiece
add, addSeparator, fill, getItem, getItemCount, insert, insertSeparator, remove, remove, removeAll
 
Methods inherited from class bibliothek.gui.dock.support.menu.MenuPiece
addListener, fireInsert, fireRemove, getMenu, getParent, isBound, items, removeListener, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CloseableDockableMenuPiece

public CloseableDockableMenuPiece()
Creates a new piece


CloseableDockableMenuPiece

public CloseableDockableMenuPiece(DockFrontend frontend)
Creates a new piece

Parameters:
frontend - the list of Dockables, can be null
Method Detail

getFrontend

public DockFrontend getFrontend()
Gets the frontend which is observed by this piece.

Returns:
the frontend, might be null
See Also:
setFrontend(DockFrontend)

setFrontend

public void setFrontend(DockFrontend frontend)
Sets the frontend which will be observed by this piece. Every Dockable that is registered at the frontend will get an item in the menu of this piece.

Parameters:
frontend - the list of Dockables, can be null

bind

public void bind()
Description copied from class: MenuPiece
This method is called if there is a possibility for the user to see this menu. The menu shoudl register listeners, update its text etc. to be ready for that event. This method must never be called twice in a row.

Overrides:
bind in class MenuPiece
See Also:
MenuPiece.unbind()

unbind

public void unbind()
Description copied from class: MenuPiece
This method is called if the user has no longer any possibility to see this menu. The menu should unregister its listeners. This method must never be called twice in a row.

Overrides:
unbind in class MenuPiece
See Also:
MenuPiece.bind()

create

protected CloseableDockableMenuPiece.Item create(Dockable dockable)
Creates a new item for the menu.

Parameters:
dockable - the element which will be shown/hidden when the user clicks onto the item.
Returns:
the new item

insert

protected void insert(CloseableDockableMenuPiece.Item item)
Adds an earlier created item into the menu, subclasses might override this method to add the item at a different location.

Parameters:
item - the item to insert

show

protected void show(Dockable dockable)
Ensures that dockable is visible.

Parameters:
dockable - the element to show

hide

protected void hide(Dockable dockable)
Ensures that dockable is not visible.

Parameters:
dockable - the element to hide

include

protected boolean include(Dockable dockable)
Tells whether an item should be inserted into the menu for the given dockable or not.

Parameters:
dockable - the element to check
Returns:
true if there should be an item added to the menu

check

public void check(Dockable dockable)
Ensures that dockable has an item if it is included, and does not have otherwise.

Parameters:
dockable - the element whose item is to be checked