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.
 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.
 
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, 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)

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.