com.ibm.as400.ui.framework.java
Class ContextMenuManager

java.lang.Object
  extended by com.ibm.as400.ui.framework.java.MenuManager
      extended by com.ibm.as400.ui.framework.java.ContextMenuManager

public class ContextMenuManager
extends MenuManager

Creates a context menu defined using the Panel Definition Markup Language (PDML).

ContextMenuManager performs the following processing on behalf of the application:

To locate a menu definition, ContextMenuManager needs three pieces of information:

The framework first searches the specified location for a file with a name matching the menu name, and an extension of .pdml.ser. If the serialized menu definition is not found, an attempt will be made to load a ResourceBundle and a PDML file which correspond to the specified resource name. If the resources cannot be located a DisplayManagerException will be thrown.

Examples

Assume that the context menu MyMenu is defined in the file TestMenus.pdml, and that a properties file TestMenus.properties is associated with the menu definition. Both files reside in the directory com/ourCompany/ourPackage, which is accessible from a directory defined in the classpath, or from a ZIP or JAR file defined in the classpath. The following code creates the context menu and displays it:

 import com.ibm.as400.ui.framework.java.*;
  
 // Create the context menu manager. Parameters:
 // 1. Resource name of the menu definition
 // 2. Name of menu
 // 3. PaneManager managing the window currently displayed (may be null)
  
 MenuManager mm = null;
 try {
 mm = new MenuManager("com.ourCompany.ourPackage.TestMenus",
                      "Mymenu",
                      null);
 }
 catch (DisplayManagerException e) {
 e.displayUserMessage(null);
 System.exit(-1);
 }
 ...
 // Display the context menu (normally done when handling a mouse event).
 MouseEvent e;
 mm.show(e.getComponent(), e.getX(), e.getY());
 

Command Line Interface

The command line interface may be used to display newly-defined menus.
 java com.ibm.as400.ui.framework.java.MenuManager
     [-locale <language code>_<country or region code>_<variant>]
     <resource name>
     <context menu name>
 
Options:

-locale <language code>_<country or region code>_<variant>
Identifies the locale which should be used to locate the menu definition. The locale string should consist of a two-letter lowercase ISO Language Code, a two-letter uppercase ISO country or region code, and an optional variant string, each delimited by an underscore ("_") character. If this parameter is omitted the default locale will be used. If resources for the default locale cannot be found, an attempt will be made to use the base resources for the menu.

<resource name>
The fully-qualified resource name of the PDML document/resource bundle combination which defines the menu specification.

<context menu name>
The name of the menu, as specified on the menu tag in the PDML document.

Examples:

Test a base sample menu:

java com.ibm.as400.ui.framework.java.MenuManager com.ourCompany.ourPackage.Testmenus Mymenu

Test the UK version:

java com.ibm.as400.ui.framework.java.MenuManager -locale en_UK com.ourCompany.ourPackage.Testmenus Mymenu

Since:
v4r5m0
Version:
1.0, 03/05/99
Author:
D. Petty
See Also:
DisplayManagerException

Constructor Summary
Constructor and Description
ContextMenuManager(String baseName, Locale locale, String menuName, PaneManager pm)
          Constructs a ContextMenuManager for the specified menu.
ContextMenuManager(String baseName, String menuName, PaneManager pm)
          Constructs a ContextMenuManager for the specified menu.
 
Method Summary
Modifier and Type Method and Description
 Point getLocation()
          Returns the location of this context menu.
 boolean isVisible()
          Determines whether this context menu is visible.
static void main(String[] args)
          Provides a command line interface to ContextMenuManager.
 void setLocation(Point pt)
          Sets the location of this context menu.
 void setVisible(boolean visible)
          Shows or hides this context menu based on the value of parameter visible.
 void show(Component invoker, int x, int y)
          Displays this context menu at the position x,y in the coordinate space of the specified invoker.
 
Methods inherited from class com.ibm.as400.ui.framework.java.MenuManager
addMenuItem, addSeparator, enableAllMenuItems, enableMenuItem, getActions, getMenu, getMenuItem, getName, getPaneManager, removeMenuItem, serialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextMenuManager

public ContextMenuManager(String baseName,
                          String menuName,
                          PaneManager pm)
                   throws DisplayManagerException
Constructs a ContextMenuManager for the specified menu.

The default locale will be used to load the menu definition.

Parameters:
baseName - the resource name of the PDML document/resource bundle combination which defines the menu specification
menuName - the name of the menu, as specified on the MENU tag in the PDML
pm - the PaneManager managing the window on which the context menu will be displayed (may be null)
Throws:
DisplayManagerException - if an error was encountered accessing the menu definition
Since:
v4r5m0
See Also:
PaneManager, DisplayManagerException

ContextMenuManager

public ContextMenuManager(String baseName,
                          Locale locale,
                          String menuName,
                          PaneManager pm)
                   throws DisplayManagerException
Constructs a ContextMenuManager for the specified menu.

Parameters:
baseName - the resource name of the PDML document/resource bundle combination which defines the menu specification
locale - the desired locale to be used to load the menu definition
menuName - the name of the menu, as specified on the MENU tag in the PDML
pm - the PaneManager managing the window on which the context menu will be displayed (may be null)
Throws:
DisplayManagerException - if an error was encountered accessing the menu definition
Since:
v4r5m0
See Also:
PaneManager, DisplayManagerException
Method Detail

main

public static void main(String[] args)
Provides a command line interface to ContextMenuManager. See the class description.

Since:
v4r5m0

setLocation

public void setLocation(Point pt)
Sets the location of this context menu.

Parameters:
pt - a Point identifying the location of the top left corner of the context menu
Since:
v4r5m0

getLocation

public Point getLocation()
Returns the location of this context menu.

Returns:
pt a Point identifying the location of the top left corner of the context menu
Since:
v4r5m0

setVisible

public void setVisible(boolean visible)
Shows or hides this context menu based on the value of parameter visible.

Parameters:
visible - If true, shows this context menu; otherwise, hides this context menu.
Since:
v4r5m0

isVisible

public boolean isVisible()
Determines whether this context menu is visible.

Returns:
true if the context menu is visible; false otherwise.
Since:
v4r5m0

show

public void show(Component invoker,
                 int x,
                 int y)
Displays this context menu at the position x,y in the coordinate space of the specified invoker.

Parameters:
invoker - The component in whose space the context menu is to appear.
x - The x coordinate in the invoker's coordinate space at which the context menu is to be displayed.
y - The y coordinate in the invoker's coordinate space at which the context menu is to be displayed.
Since:
v4r5m0