ilog.views.swing
Class IlvPopupMenuManager

java.lang.Object
  extended by ilog.views.swing.IlvPopupMenuManager
All Implemented Interfaces:
SwingConstants

public class IlvPopupMenuManager
extends Object
implements SwingConstants

This class enables Swing popup menus on graphic objects in a manager view.

Each graphic object contained in the manager associated with the view can have its own popup menu. There are three ways to implement Swing popup menus on graphic objects.

If a popup menu is triggered in a manager view at a position where a graphic object is located, the popup menu of the graphic object is displayed if available. If no graphic object is located at that position, the popup menu of the manager of the view is displayed if available.

To enable Swing popup menus in a view, call the static method registerView(ilog.views.IlvManagerView). To disable tooltips in a view, call unregisterView(ilog.views.IlvManagerView).

The popup menu manager can also be used to enable popups on arbitrary Swing component, via setPopupMenu(JComponent, JPopupMenu).

Since:
JViews 7.5
See Also:
IlvGraphic, IlvManagerView

Field Summary
static String JCOMPONENT_POPUP_MENU_CONTEXT_KEY
          The key of the client property of a JPopupMenu used to store the popup menu context via JComponent.setClientProperty.
static String JCOMPONENT_POPUP_MENU_KEY
          The key of the client property of Swing components used to store a Swing popup menu or its name via JComponent.setClientProperty.
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Method Summary
static JPopupMenu getPopupMenu(JComponent component)
          Returns a Swing popup menu of a Swing component.
static IlvPopupMenuContext getPopupMenuContext(MenuElement element)
          Returns the popup menu context of a popup menu element (for instance, the popup menu itself or a menu item or a submenu).
static JPopupMenu getRegisteredMenu(String name)
          Returns the Swing popup menu registered for a given name.
static void registerMenu(String name, JPopupMenu popupMenu)
          Registers a Swing popup menus with a given name.
static void registerView(IlvManagerView view)
          Enables the Swing popup menus of graphic objects in a manager view.
static void setPopupMenu(JComponent component, JPopupMenu popupMenu)
          Stores a Swing popup menu of a Swing component.
static void setPopupMenuContext(MenuElement element, IlvPopupMenuContext context)
          Stores the popup menu context of a popup menu element (for instance, the popup menu itself or a menu item or a submenu).
static void setPopupMenuName(JComponent component, String popupMenuName)
          Stores the name of a Swing popup menu of a Swing component.
static void unregisterMenu(String name)
          Removes the name of a Swing popup menus from the register.
static void unregisterView(IlvManagerView view)
          Disables the Swing popup menus of graphic objects in a manager view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JCOMPONENT_POPUP_MENU_KEY

public static final String JCOMPONENT_POPUP_MENU_KEY
The key of the client property of Swing components used to store a Swing popup menu or its name via JComponent.setClientProperty.

See Also:
setPopupMenu(javax.swing.JComponent, javax.swing.JPopupMenu)

JCOMPONENT_POPUP_MENU_CONTEXT_KEY

public static final String JCOMPONENT_POPUP_MENU_CONTEXT_KEY
The key of the client property of a JPopupMenu used to store the popup menu context via JComponent.setClientProperty.

See Also:
setPopupMenuContext(javax.swing.MenuElement, ilog.views.swing.IlvPopupMenuContext)
Method Detail

registerView

public static void registerView(IlvManagerView view)
Enables the Swing popup menus of graphic objects in a manager view.

Parameters:
view - The manager view.
See Also:
IlvGraphic.setPopupMenu(javax.swing.JPopupMenu), unregisterView(ilog.views.IlvManagerView)

unregisterView

public static void unregisterView(IlvManagerView view)
Disables the Swing popup menus of graphic objects in a manager view.

Parameters:
view - The manager view.
See Also:
registerView(ilog.views.IlvManagerView)

registerMenu

public static void registerMenu(String name,
                                JPopupMenu popupMenu)
Registers a Swing popup menus with a given name. This allows to specify Swing popup menus for graphic objects by name using IlvGraphic.setPopupMenuName(java.lang.String).

Parameters:
name - The name of the popup menu.
popupMenu - The popup menu.
See Also:
IlvGraphic.setPopupMenuName(java.lang.String)., unregisterMenu(java.lang.String)

unregisterMenu

public static void unregisterMenu(String name)
Removes the name of a Swing popup menus from the register. A graphic object that uses this name to identify the Swing popup menus will not anymore have any popup menu enabled.

Parameters:
name - The name of the popup menu.
See Also:
IlvGraphic.setPopupMenuName(java.lang.String)., registerMenu(java.lang.String, javax.swing.JPopupMenu)

getRegisteredMenu

public static JPopupMenu getRegisteredMenu(String name)
Returns the Swing popup menu registered for a given name.

See Also:
registerMenu(java.lang.String, javax.swing.JPopupMenu)

setPopupMenu

public static void setPopupMenu(JComponent component,
                                JPopupMenu popupMenu)
Stores a Swing popup menu of a Swing component. This can be used to enable popup menus in swing components that don't contain a manager view.

Parameters:
component - The Swing component
popupMenu - The popup menu. If null, the popup menu will be removed from the component.
See Also:
getPopupMenu(javax.swing.JComponent)

setPopupMenuName

public static void setPopupMenuName(JComponent component,
                                    String popupMenuName)
Stores the name of a Swing popup menu of a Swing component. This is an alternative way to set the popup menu of this object. You need to register a Swing popup menu for the name via registerMenu(String name, javax.swing.JPopupMenu) and use the name to specify the popup menu of the input component. This can be used to enable popup menus in swing components that don't contain a manager view.

Parameters:
component - The Swing component
popupMenuName - The name of the registered Swing popup menu to be used for the input component. If popupName is null, the popup menu will be removed from the component.
See Also:
getPopupMenu(javax.swing.JComponent)

getPopupMenu

public static JPopupMenu getPopupMenu(JComponent component)
Returns a Swing popup menu of a Swing component.

See Also:
setPopupMenu(javax.swing.JComponent, javax.swing.JPopupMenu)

setPopupMenuContext

public static void setPopupMenuContext(MenuElement element,
                                       IlvPopupMenuContext context)
Stores the popup menu context of a popup menu element (for instance, the popup menu itself or a menu item or a submenu). This is called when the display of the popup menu is triggered. The context can be used inside the action listener of the popup menu to decide how the action must be performed.

See Also:
getPopupMenuContext(javax.swing.MenuElement)

getPopupMenuContext

public static IlvPopupMenuContext getPopupMenuContext(MenuElement element)
Returns the popup menu context of a popup menu element (for instance, the popup menu itself or a menu item or a submenu). The action listener of a menu element can retrieve the context of the popup menu in order to decide how the action must be performed.

See Also:
setPopupMenuContext(javax.swing.MenuElement, ilog.views.swing.IlvPopupMenuContext)


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.