bibliothek.gui.dock.station.toolbar.menu
Class CustomizationToolbarButton

java.lang.Object
  extended by bibliothek.gui.dock.station.toolbar.menu.CustomizationToolbarButton
All Implemented Interfaces:
CustomizationMenuContent
Direct Known Subclasses:
EagerCustomizationToolbarButton

public abstract class CustomizationToolbarButton
extends Object
implements CustomizationMenuContent

The CustomizationToolbarButton is a button that allows to add one Dockable to a DockStation. This button also offers an indication telling whether the Dockable is already shown on another station.

Author:
Benjamin Sigg

Nested Class Summary
static class CustomizationToolbarButton.ItemLocation
          The different locations where a Dockable can be in respect to this button
 
Constructor Summary
CustomizationToolbarButton()
           
 
Method Summary
 void bind(CustomizationMenuCallback callback)
          Informs this item that is going to be used.
protected abstract  bibliothek.gui.Dockable getDockable()
          Gets the element that is put onto a toolbar.
protected  CustomizationToolbarButton.ItemLocation getItemLocation()
          Gets the current location of the Dockable that is described by this button.
 Component getView()
          Gets a Component which represents this item.
protected abstract  boolean hasDockable()
          Tells whether the Dockable of this button, accessible by calling getDockable(), is already present.
 void setController(bibliothek.gui.DockController controller)
          Informs this content about the DockController in whose realm it is used.
 void setDescription(String description)
          Sets a text which describes the meaning of the button.
 void setIcon(Icon icon)
          Sets the icon which should be shown on the button.
protected  void setItemVisible(boolean visible)
          Removes the Dockable from its current parent and maybe appends it to the owner of this button.
 void setText(String text)
          Sets the text which should be shown on the button.
 void unbind()
          Informs this item that it is no longer used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomizationToolbarButton

public CustomizationToolbarButton()
Method Detail

setController

public void setController(bibliothek.gui.DockController controller)
Description copied from interface: CustomizationMenuContent
Informs this content about the DockController in whose realm it is used.

Specified by:
setController in interface CustomizationMenuContent
Parameters:
controller - the controller, can be null

getView

public Component getView()
Description copied from interface: CustomizationMenuContent
Gets a Component which represents this item. If #bind() has not yet been called, or CustomizationMenuContent.unbind() has been called, then a result of null is valid.

Specified by:
getView in interface CustomizationMenuContent
Returns:
the view or null if this item is not bound.

bind

public void bind(CustomizationMenuCallback callback)
Description copied from interface: CustomizationMenuContent
Informs this item that is going to be used. This method must not be called twice in a row.

Specified by:
bind in interface CustomizationMenuContent
Parameters:
callback - access to more detailed information about the DockStation that is showing the menu

getItemLocation

protected CustomizationToolbarButton.ItemLocation getItemLocation()
Gets the current location of the Dockable that is described by this button.

Returns:
the current location
Throws:
IllegalStateExceptione - if bind(CustomizationMenuCallback) was not called

setItemVisible

protected void setItemVisible(boolean visible)
Removes the Dockable from its current parent and maybe appends it to the owner of this button.

Parameters:
visible - whether the item should be visible or not

unbind

public void unbind()
Description copied from interface: CustomizationMenuContent
Informs this item that it is no longer used. This method must not be called twive in a row, it must be called after a call to #bind().

Specified by:
unbind in interface CustomizationMenuContent

setIcon

public void setIcon(Icon icon)
Sets the icon which should be shown on the button.

Parameters:
icon - the new icon, can be null

setText

public void setText(String text)
Sets the text which should be shown on the button.

Parameters:
icon - the new text, can be null

setDescription

public void setDescription(String description)
Sets a text which describes the meaning of the button.

Parameters:
description - the description, can be null

hasDockable

protected abstract boolean hasDockable()
Tells whether the Dockable of this button, accessible by calling getDockable(), is already present. If the item is not yet present, then it cannot be visible or selected at this time.

Returns:
whether the Dockable already exists

getDockable

protected abstract bibliothek.gui.Dockable getDockable()
Gets the element that is put onto a toolbar. This method may create the Dockable lazily in the very moment it is used the first time.

Returns:
the item to show on the toolbar