com.tensegrity.gui.swing.document
Class MenuTool

java.lang.Object
  extended byjava.awt.Component
      extended bycom.tensegrity.gui.swing.document.MenuTool
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, Observer, java.io.Serializable
Direct Known Subclasses:
SkeletonSwingMenuTool

public class MenuTool
extends java.awt.Component
implements Observer

The MenuTool is a Tool alike class to add a Window Menu and a View-Tools menu to your application. The Window menu part contains a list of Documents, while the active document is marked selected through the usage of JRadioButtonMenuItem's. NOTE: Documents are added at the beginning of the internal Menu container, A MenuTool instance should be used as Observer to ease the update process for the Window menu. The MenuTool also provides a ToolsMenu. Such a menu contains entries, which can be checked (JCheckBoxMenuItem). This menu will then set the visibility of the associated (Tool-)Document and show or hide these.

Version:
$Id: MenuTool.java,v 1.26 2005/12/16 09:02:54 BurkhardWick Exp $
Author:
Gilles Iachelini, S.Rutz
See Also:
Serialized Form

Nested Class Summary
static class MenuTool.DocumentAction
          The class DocumentAction is a simple Helperclass for Tool menu items wich need to show/hide a document.
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MenuTool()
          Constructs a new MenuTool instance.
MenuTool(GraphApplication graphapplication)
          Deprecated. Pass the MDIComponent instead of the application.
MenuTool(MDIComponent mdiComponent)
          Constructor creates a new MenuTool which initially has no menu and no map.
 
Method Summary
 void add(Container container)
          Adds a container to this instance.
 void add(Document document)
          Method add(Document) adds a new CheckBoxMenuItem to the top of the internal menu.
 javax.swing.JMenuItem add(ToolBar toolbar)
          Adds a ToolBar to this MenuTool.
 ContainerAction getContainerAction(Container container)
          This factory method returns a new ContainerAction instance initialized with the passed Container parameter.
 SwingMenu getDocumentMenu()
          Returns the documentMenu.
 SwingMenu getToolBarsMenu()
          Gets the toolsMenu.
 SwingMenu getToolsMenu()
          Returns the toolsMenu.
 void remove(Document document)
          Removes the specified document from the menuMap and the associated menuitem as well.
 void setDocumentMenu(SwingMenu documentMenu)
          Sets the documentMenu.
 void setMDIComponent(MDIComponent component)
          Sets the MDIComponent that this instance is associated with.
 void setMenuMap(java.util.Map menuMap)
          Sets the menuMap.
 void setToolBarsMenu(SwingMenu toobarsMenu)
          Sets the toolbarsMenu
 void setToolsMenu(SwingMenu toolsMenu)
          Sets the toolsMenu.
 void update(Observable o, java.lang.Object arg)
          Invoked when active document changes.
 void updateContainerNames()
          Updates the names of the containers.
 void updateDocuments()
          Updates the Documents menu by retrieving each items action and changing the name property to the currently name of the associated document.
 void updateTools()
          Updates the tools part of the menu
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MenuTool

public MenuTool()
Constructs a new MenuTool instance.


MenuTool

public MenuTool(GraphApplication graphapplication)
Deprecated. Pass the MDIComponent instead of the application.

Constructor creates a new MenuTool which initially has no menu and no map.

Parameters:
graphapplication - the graphapplication we are associated with.

MenuTool

public MenuTool(MDIComponent mdiComponent)
Constructor creates a new MenuTool which initially has no menu and no map.

Parameters:
mdiComponent - the mdi-component to use.
Method Detail

setMenuMap

public void setMenuMap(java.util.Map menuMap)
Sets the menuMap.

Parameters:
menuMap - The menuMap to set

add

public javax.swing.JMenuItem add(ToolBar toolbar)
Adds a ToolBar to this MenuTool.

Parameters:
toolbar - the ToolBar to add.
Returns:
the newly created CheckBoxMenuItem for the given ToolBar.

add

public void add(Container container)
Adds a container to this instance. Note that the Action set to the created JMenuItem is retrieved from the factory method getContainerAction(Container).

Parameters:
container - the Container to add.

getContainerAction

public ContainerAction getContainerAction(Container container)
This factory method returns a new ContainerAction instance initialized with the passed Container parameter. Note that the returned ContainerAction instance extends the default ContainerAction.actionPerformed() method by doing a MDIComponent.postValidate().

Parameters:
container - the Container to look up.
Returns:
a new ContainerAction instance
See Also:
ContainerAction, Container

add

public void add(Document document)
Method add(Document) adds a new CheckBoxMenuItem to the top of the internal menu. This methods adds a separator if the first document is added, to separate user commands from document entries. This allows users of this class to combine a document menu with a custom (general) window menu.

Parameters:
document - the Document to add.

updateContainerNames

public void updateContainerNames()
Updates the names of the containers.


updateTools

public void updateTools()
Updates the tools part of the menu


updateDocuments

public void updateDocuments()
Updates the Documents menu by retrieving each items action and changing the name property to the currently name of the associated document.


remove

public void remove(Document document)
Removes the specified document from the menuMap and the associated menuitem as well.

Parameters:
document - the Document to remove.

update

public void update(Observable o,
                   java.lang.Object arg)
Invoked when active document changes. MenuTool sets the associated menu item as checked. Indication through menu about active document.

Specified by:
update in interface Observer
Parameters:
o - the observable that triggered the call.
arg - an object carrying additional information.

getDocumentMenu

public SwingMenu getDocumentMenu()
Returns the documentMenu.

Returns:
the documentMenu that is used.

getToolsMenu

public SwingMenu getToolsMenu()
Returns the toolsMenu.

Returns:
the currently used tools-menu.

getToolBarsMenu

public SwingMenu getToolBarsMenu()
Gets the toolsMenu.

Returns:
the toolsMenu.

setDocumentMenu

public void setDocumentMenu(SwingMenu documentMenu)
Sets the documentMenu.

Parameters:
documentMenu - The documentMenu to set

setToolsMenu

public void setToolsMenu(SwingMenu toolsMenu)
Sets the toolsMenu. This is the menu, which will contain the toggle menu items for all the Tool Windows, which appear in this application (Like navigator, outliner, AttributeEditor, etc.).

Parameters:
toolsMenu - The toolsMenu to set

setToolBarsMenu

public void setToolBarsMenu(SwingMenu toobarsMenu)
Sets the toolbarsMenu

Parameters:
toobarsMenu - the toolbarsMenu to set.

setMDIComponent

public void setMDIComponent(MDIComponent component)
Sets the MDIComponent that this instance is associated with.

Parameters:
component - the MDIComponent that this instance is associated with.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.