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

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

public class MenuMenuHandler
extends AbstractMenuHandler<javax.swing.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

Nested Class Summary
private  class MenuMenuHandler.JMenuWrapper
          A wrapper JMenu to Menu.
private  class MenuMenuHandler.JPopupMenuWrapper
          A Wrapper JPopupMenu to Menu.
private  class MenuMenuHandler.Listener
          A listener to the source of the enclosing handler.
private static interface MenuMenuHandler.Menu
          A representation of a menu.
 
Field Summary
private  java.util.List<DockAction> actions
          the actions currently known to this menu
private  java.util.Map<DockAction,ViewItem<javax.swing.JComponent>> handlers
          the current handlers of the menu
private  MenuMenuHandler.Listener listener
          a listener to the source
private  MenuMenuHandler.Menu menu
          the menu to add or remove children
private  DockActionSource source
          the observed source
 
Fields inherited from class bibliothek.gui.dock.themes.basic.action.menu.AbstractMenuHandler
action, dockable, item
 
Constructor Summary
MenuMenuHandler(DockActionSource source, Dockable dockable, javax.swing.JPopupMenu menu)
          Creates a new handler
MenuMenuHandler(MenuDockAction action, Dockable dockable)
          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.
 void bind()
          Connects this handler to its action.
private  ViewItem<javax.swing.JComponent> handlerFor(DockAction action)
          Creates a new AbstractMenuHandler for action.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes a listener from this view.
private  void setup(DockActionSource source, MenuMenuHandler.Menu menu)
          Sets up 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
 

Field Detail

source

private DockActionSource source
the observed source


menu

private MenuMenuHandler.Menu menu
the menu to add or remove children


handlers

private java.util.Map<DockAction,ViewItem<javax.swing.JComponent>> handlers
the current handlers of the menu


actions

private java.util.List<DockAction> actions
the actions currently known to this menu


listener

private MenuMenuHandler.Listener listener
a listener to the source

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(DockActionSource source,
                       Dockable dockable,
                       javax.swing.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

setup

private void setup(DockActionSource source,
                   MenuMenuHandler.Menu menu)
Sets up this handler

Parameters:
source - the observed source
menu - the menu whose values will be changed

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<javax.swing.JMenu,MenuDockAction>

handlerFor

private ViewItem<javax.swing.JComponent> handlerFor(DockAction action)
Creates a new AbstractMenuHandler for action.

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

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<javax.swing.JMenu,MenuDockAction>