bibliothek.gui.dock.common.menu
Class CPreferenceMenuPiece

java.lang.Object
  extended by bibliothek.gui.dock.support.menu.MenuPiece
      extended by bibliothek.gui.dock.support.menu.BaseMenuPiece
          extended by bibliothek.gui.dock.common.menu.CPreferenceMenuPiece

public class CPreferenceMenuPiece
extends BaseMenuPiece

A menu piece that shows an entry for opening the preferences-dialog. The model to show on the dialog can either be set explicitly using setModel(PreferenceModel), or else will be read from CControl.getPreferenceModel().
Note: clients can use setup(CControl) to ensure that the CControl has a model.

Author:
Benjamin Sigg

Constructor Summary
CPreferenceMenuPiece(CControl control)
          Creates a new menu piece.
 
Method Summary
protected  void action()
          Opens a dialog with the current PreferenceModel.
 void bind()
          This method is called if there is a possibility for the user to see this menu.
 PreferenceModel getModel()
          Gets the model which was explicitly set.
 void setModel(PreferenceModel model)
          Explicitly sets the model which will be shown on the dialog.
static CPreferenceMenuPiece setup(CControl control)
          Creates a new CPreferenceMenuPiece.
 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

CPreferenceMenuPiece

public CPreferenceMenuPiece(CControl control)
Creates a new menu piece.

Parameters:
control - the control for which this piece works, not null
Method Detail

setup

public static CPreferenceMenuPiece setup(CControl control)
Creates a new CPreferenceMenuPiece. Reads the model of control, if control has no model then a new PreferenceModel will be created and set.

Parameters:
control - the control whose model will be shown
Returns:
a new menu piece
See Also:
CControl.getPreferenceModel(), CControl.setPreferenceModel(PreferenceModel)

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()

setModel

public void setModel(PreferenceModel model)
Explicitly sets the model which will be shown on the dialog. If null is set, then this menu will try to show CControl.getPreferenceModel().

Parameters:
model - the model to use or null

getModel

public PreferenceModel getModel()
Gets the model which was explicitly set.

Returns:
the model or null
See Also:
setModel(PreferenceModel)

action

protected void action()
Opens a dialog with the current PreferenceModel.