com.tensegrity.skeleton.swing
Class SwingGraphPanelPopupMenuSource

java.lang.Object
  extended bycom.tensegrity.skeleton.swing.SwingGraphPanelPopupMenuSource
All Implemented Interfaces:
JPopupMenuSource, JPopupMenuSourceWithUpdateUI

public class SwingGraphPanelPopupMenuSource
extends java.lang.Object
implements JPopupMenuSourceWithUpdateUI

This class provides the popup menus for the drawing areas. Note that since the application frame only holds one instance of popup menu source shared among all the GraphPanels the destroy method overridden in this class does nothing. Override the destroyBeforeCreating() method instead in order to ensure that the UIMap does not get overloaded when doing Look And Feel switches. This class also provides several addToMenu() utility methods to be used in order to add items to the popup menu.

Version:
$Id: SwingGraphPanelPopupMenuSource.java,v 1.14 2005/06/03 11:00:43 SebastienGuyon Exp $
Author:
S�bastien Guyon

Field Summary
protected  ApplicationFrame applicationFrame
          applicationFrame reference
protected  PopupMenu popupmenu
          popupmenu reference
 
Constructor Summary
SwingGraphPanelPopupMenuSource(ApplicationFrame applicationFrame)
          Initializes the SwingGraphPanelPopupMenuSource instance.
 
Method Summary
protected  void addToMenu(PopupMenu popupmenu, java.util.HashMap uiMap, java.lang.String id, javax.swing.KeyStroke stroke, java.lang.String iconurl, java.lang.Class referenceClass)
          The method addToMenu adds a new command to the given menu and stores the icons, required for a smooth switch as properties of the action.
protected  void addToMenu(PopupMenu popupmenu, java.util.HashMap uiMap, java.lang.String id, javax.swing.KeyStroke stroke, java.lang.String iconurl, java.lang.String defaulticon)
          The method addToMenu adds a new command to the given menu and stores the icons, required for a smooth switch as properties of the action.
protected  void addToMenu(PopupMenu popupmenu, java.util.HashMap uiMap, java.lang.String id, javax.swing.KeyStroke stroke, java.lang.String iconurl, java.lang.String defaulticon, java.lang.Class referenceClass)
          The method addToMenu adds a new command to the given menu and stores the icons, required for a smooth switch as properties of the action.
protected  void addToMenu(PopupMenu popupmenu, java.util.HashMap uiMap, java.lang.String id, java.lang.String iconurl, java.lang.String defaulticon)
          Adds a new Item to the parameter Menu.
protected  void addToMenu(PopupMenu popupmenu, java.util.HashMap uiMap, java.lang.String id, java.lang.String iconurl, java.lang.String defaulticon, java.lang.Class referenceClass)
          Adds a new Item to the parameter Menu.
 void create()
          This callback triggers a (re)creation of the popup menu.
 SwingMenu createMenu(java.lang.String idText)
          Utility method creating and returning a SwingMenu
 void destroy()
          Does nothing.
protected  void destroyBeforeCreating()
          This method method has to be called has a first thing in the create() method before the popup menu creation in order to ensure that the UIMap is not overloaded.
 PopupMenuMarkup getPopupMenu(java.lang.Object eventObject)
          Returns the internal JPopupMenu instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

applicationFrame

protected final ApplicationFrame applicationFrame
applicationFrame reference


popupmenu

protected PopupMenu popupmenu
popupmenu reference

Constructor Detail

SwingGraphPanelPopupMenuSource

public SwingGraphPanelPopupMenuSource(ApplicationFrame applicationFrame)
Initializes the SwingGraphPanelPopupMenuSource instance.

Parameters:
applicationFrame - Application context for this MenuSource.
Method Detail

getPopupMenu

public PopupMenuMarkup getPopupMenu(java.lang.Object eventObject)
Returns the internal JPopupMenu instance of this class.

Specified by:
getPopupMenu in interface JPopupMenuSource
Parameters:
eventObject - an optional instance of MouseEvent.
Returns:
the internal JPopupMenu instance of this class.
See Also:
JPopupMenuSource.getPopupMenu(Object), popupmenu

createMenu

public SwingMenu createMenu(java.lang.String idText)
Utility method creating and returning a SwingMenu

Parameters:
idText - the ID for the UIManager as used for the text of the resulting SwingMenu.
Returns:
a new instance of SwingMenu.

create

public void create()
Description copied from interface: JPopupMenuSourceWithUpdateUI
This callback triggers a (re)creation of the popup menu.

Specified by:
create in interface JPopupMenuSourceWithUpdateUI

destroy

public void destroy()
Does nothing. Since there is only one popup menusource instance for the all application frame we do not want to unregister the popupmenu in here. Instead the destroyBeforeCreating() private method will be called before the creation, thus ensuring that the UIMap is not overloaded.

Specified by:
destroy in interface JPopupMenuSourceWithUpdateUI
See Also:
JPopupMenuSourceWithUpdateUI.destroy()

destroyBeforeCreating

protected void destroyBeforeCreating()
This method method has to be called has a first thing in the create() method before the popup menu creation in order to ensure that the UIMap is not overloaded.


addToMenu

protected final void addToMenu(PopupMenu popupmenu,
                               java.util.HashMap uiMap,
                               java.lang.String id,
                               java.lang.String iconurl,
                               java.lang.String defaulticon)
Adds a new Item to the parameter Menu. The class used as a reference in order to retrieve the images is com.tensegrity.skeleton.Skeleton.

Parameters:
popupmenu - target SwingPopupMenu to add a new item to.
uiMap - map to add the resulting menu item to (required for language switch)
id - ID of the text for the new item.
iconurl - url of the icon.
defaulticon - url to the default icon used in windows LNF.

addToMenu

protected final void addToMenu(PopupMenu popupmenu,
                               java.util.HashMap uiMap,
                               java.lang.String id,
                               java.lang.String iconurl,
                               java.lang.String defaulticon,
                               java.lang.Class referenceClass)
Adds a new Item to the parameter Menu.

Parameters:
popupmenu - target SwingPopupMenu to add a new item to.
uiMap - map to add the resulting menu item to (required for language switch)
id - ID of the text for the new item.
iconurl - url of the icon.
defaulticon - url to the default icon used in windows LNF.
referenceClass - Class used as reference in order to retrieve the images.

addToMenu

protected final void addToMenu(PopupMenu popupmenu,
                               java.util.HashMap uiMap,
                               java.lang.String id,
                               javax.swing.KeyStroke stroke,
                               java.lang.String iconurl,
                               java.lang.Class referenceClass)
The method addToMenu adds a new command to the given menu and stores the icons, required for a smooth switch as properties of the action.

Parameters:
popupmenu - target SwingPopupMenu to add a new item to.
uiMap - map to add the resulting menu item to (required for language switch)
id - ID of the text for the new item.
stroke - KeyStroke for the new item.
iconurl - url of the icon.
referenceClass - Class used as reference in order to retrieve the images

addToMenu

protected final void addToMenu(PopupMenu popupmenu,
                               java.util.HashMap uiMap,
                               java.lang.String id,
                               javax.swing.KeyStroke stroke,
                               java.lang.String iconurl,
                               java.lang.String defaulticon,
                               java.lang.Class referenceClass)
The method addToMenu adds a new command to the given menu and stores the icons, required for a smooth switch as properties of the action.

Parameters:
popupmenu - target SwingPopupMenu to add a new item to.
uiMap - map to add the resulting menu item to (required for language switch)
id - ID of the text for the new item.
stroke - KeyStroke for the new item.
iconurl - url of the icon.
defaulticon - url to the default icon used in windows LNF.
referenceClass - Class used as reference in order to retrieve the images

addToMenu

protected final void addToMenu(PopupMenu popupmenu,
                               java.util.HashMap uiMap,
                               java.lang.String id,
                               javax.swing.KeyStroke stroke,
                               java.lang.String iconurl,
                               java.lang.String defaulticon)
The method addToMenu adds a new command to the given menu and stores the icons, required for a smooth switch as properties of the action. The class used as a reference in order to retrieve the images is com.tensegrity.skeleton.Skeleton.

Parameters:
popupmenu - target SwingPopupMenu to add a new item to.
uiMap - map to add the resulting menu item to (required for language switch)
id - ID of the text for the new item.
stroke - KeyStroke for the new item.
iconurl - url of the icon.
defaulticon - url to the default icon used in windows LNF.


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