bibliothek.gui.dock.themes.basic.action.menu
Class SelectableMenuHandler<M extends javax.swing.JMenuItem>

java.lang.Object
  extended by bibliothek.gui.dock.themes.basic.action.menu.AbstractMenuHandler<M,SelectableDockAction>
      extended by bibliothek.gui.dock.themes.basic.action.menu.SelectableMenuHandler<M>
Type Parameters:
M - the type of menu-item handled by this handler
All Implemented Interfaces:
ViewItem<javax.swing.JComponent>, MenuViewItem<javax.swing.JComponent>
Direct Known Subclasses:
SelectableMenuHandler.Check, SelectableMenuHandler.Radio

public abstract class SelectableMenuHandler<M extends javax.swing.JMenuItem>
extends AbstractMenuHandler<M,SelectableDockAction>

A handler which ensures that the selected-state of a JMenuItem and a SelectableDockAction are always the same.

Author:
Benjamin Sigg

Nested Class Summary
static class SelectableMenuHandler.Check
          A handler designed to handle actions of type ActionType.CHECK.
private  class SelectableMenuHandler.Listener
          A listener added
static class SelectableMenuHandler.Radio
          A handler designed to handle actions of type ActionType.RADIO.
 
Field Summary
private  SelectableMenuHandler.Listener listener
          a listener intended to ensure the selection-state on the view and in the action are the same
 
Fields inherited from class bibliothek.gui.dock.themes.basic.action.menu.AbstractMenuHandler
action, dockable, item
 
Constructor Summary
SelectableMenuHandler(SelectableDockAction action, Dockable dockable, M item)
          Creates a new handler
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds a listener which will be called if this view is triggered.
protected abstract  boolean allowChange(boolean newValue)
          Tells whether the new value newValue can be set through the view or not.
 void bind()
          Connects this handler to its action.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes a listener from this view.
 void unbind()
          Disconnects this handler from its action
 
Methods inherited from class bibliothek.gui.dock.themes.basic.action.menu.AbstractMenuHandler
getAction, getDockable, getItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listener

private SelectableMenuHandler.Listener listener
a listener intended to ensure the selection-state on the view and in the action are the same

Constructor Detail

SelectableMenuHandler

public SelectableMenuHandler(SelectableDockAction action,
                             Dockable dockable,
                             M item)
Creates a new handler

Parameters:
action - the action to observe
dockable - the dockable for which actions are dispatched
item - the item to manage
Method Detail

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Description copied from interface: MenuViewItem
Adds a listener which will be called if this view is triggered. The listener should only be called, if the user clicked directly onto this view.

Parameters:
listener - the new listener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Description copied from interface: MenuViewItem
Removes a listener from this view.

Parameters:
listener - the listener to remove

bind

public void bind()
Description copied from class: AbstractMenuHandler
Connects this handler to its action.

Specified by:
bind in interface ViewItem<javax.swing.JComponent>
Overrides:
bind in class AbstractMenuHandler<M extends javax.swing.JMenuItem,SelectableDockAction>

unbind

public void unbind()
Description copied from class: AbstractMenuHandler
Disconnects this handler from its action

Specified by:
unbind in interface ViewItem<javax.swing.JComponent>
Overrides:
unbind in class AbstractMenuHandler<M extends javax.swing.JMenuItem,SelectableDockAction>

allowChange

protected abstract boolean allowChange(boolean newValue)
Tells whether the new value newValue can be set through the view or not.

Parameters:
newValue - the new value for the element
Returns:
true if the value is accepted