bibliothek.gui.dock.themes.basic.action.menu
Class MenuMenuHandler

java.lang.Object
  extended by bibliothek.gui.dock.themes.basic.action.menu.AbstractMenuHandler<JMenu,MenuDockAction>
      extended by bibliothek.gui.dock.themes.basic.action.menu.MenuMenuHandler
All Implemented Interfaces:
ViewItem<JComponent>, MenuViewItem<JComponent>

public class MenuMenuHandler
extends AbstractMenuHandler<JMenu,MenuDockAction>

A handler that manages a menu. The menu can either be toplevel (like a popup-menu) or a submenu of another menu.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from class bibliothek.gui.dock.themes.basic.action.menu.AbstractMenuHandler
action, dockable, item
 
Constructor Summary
MenuMenuHandler(DockActionSource source, Dockable dockable, JPopupMenu menu)
          Creates a new handler
MenuMenuHandler(MenuDockAction action, Dockable dockable)
          Creates a new handler
MenuMenuHandler(MenuDockAction action, Dockable dockable, ViewTarget<? extends MenuViewItem<JComponent>> target)
          Creates a new handler
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds a listener which will be called if this view is triggered.
 void addChildrenActionListener(ActionListener listener)
          Adds a listener to this handler, the listener will be invoked if one of the children of this handler fires an action.
 void bind()
          Connects this handler to its action.
protected  void fireActionEvent(ActionEvent event)
          Fires event to all ActionListeners currently known to this handler.
 MenuViewItem<JComponent> getViewFor(DockAction action)
          Searches for the first view which is used for action.
protected  MenuViewItem<JComponent> handlerFor(DockAction action)
          Creates a new view for action.
 void removeActionListener(ActionListener listener)
          Removes a listener from this view.
 void removeChildrenActionListener(ActionListener listener)
          Removes listener from this handler.
 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
 

Constructor Detail

MenuMenuHandler

public MenuMenuHandler(MenuDockAction action,
                       Dockable dockable)
Creates a new handler

Parameters:
action - the observed action
dockable - the dockable for which items are inserted into the menu

MenuMenuHandler

public MenuMenuHandler(MenuDockAction action,
                       Dockable dockable,
                       ViewTarget<? extends MenuViewItem<JComponent>> target)
Creates a new handler

Parameters:
action - the observed action
dockable - the dockable for which items are inserted into the menu
target - what kind of view to use on the menu

MenuMenuHandler

public MenuMenuHandler(DockActionSource source,
                       Dockable dockable,
                       JPopupMenu menu)
Creates a new handler

Parameters:
source - the observed source
dockable - the dockable for which actions are dispatched
menu - the menu where items will be inserted
Method Detail

addActionListener

public void addActionListener(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(ActionListener listener)
Description copied from interface: MenuViewItem
Removes a listener from this view.

Parameters:
listener - the listener to remove

addChildrenActionListener

public void addChildrenActionListener(ActionListener listener)
Adds a listener to this handler, the listener will be invoked if one of the children of this handler fires an action. The source of the ActionEvent will be the DockAction which fired the event.

Parameters:
listener - a new listener

removeChildrenActionListener

public void removeChildrenActionListener(ActionListener listener)
Removes listener from this handler.

Parameters:
listener - the listener to remove
See Also:
addChildrenActionListener(ActionListener)

fireActionEvent

protected void fireActionEvent(ActionEvent event)
Fires event to all ActionListeners currently known to this handler.

Parameters:
event - the event to fire

bind

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

Specified by:
bind in interface ViewItem<JComponent>
Overrides:
bind in class AbstractMenuHandler<JMenu,MenuDockAction>

handlerFor

protected MenuViewItem<JComponent> handlerFor(DockAction action)
Creates a new view for action. The default implementation uses the ActionViewConverter and sets the ViewTarget to ViewTarget.MENU.

Parameters:
action - an action
Returns:
a handler ready to work with action.

getViewFor

public MenuViewItem<JComponent> getViewFor(DockAction action)
Searches for the first view which is used for action.

Parameters:
action - some child of this handler
Returns:
the view used for action, null if action is not found or if this handler is not bound

unbind

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

Specified by:
unbind in interface ViewItem<JComponent>
Overrides:
unbind in class AbstractMenuHandler<JMenu,MenuDockAction>