All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.as400.ui.framework.java.ContextMenuManager
java.lang.Object
|
+----com.ibm.as400.ui.framework.java.MenuManager
|
+----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:
- Parses the PDML document containing the context menu definition, or alternatively,
loads a serialized menu definition file from disk.
- Creates the menu items specified in the PDML and adds them to the menu.
- Associates the application-defined
ActionHandler
s
specified in the PDML with the appropriate menu items.
- Displays the context menu on the screen.
To locate a menu definition, ContextMenuManager
needs three pieces of information:
- The fully-qualified resource name of the PDML document/resource bundle combination
which defines the menu specification.
- The locale that should be used to display menu strings and other
locale-dependent resources. This may be the default locale, or a locale
specified by the application.
- The name of the menu, as specified on the
MENU
tag in the PDML.
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 code>_<variant>]
<resource name>
<context menu name>
Options:
- -locale <language code>_<country 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 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
- See Also:
- DisplayManagerException
-
ContextMenuManager(String, Locale, String, PaneManager)
- Constructs a
ContextMenuManager
for the specified menu.
-
ContextMenuManager(String, String, PaneManager)
- Constructs a
ContextMenuManager
for the specified menu.
-
getLocation()
- Returns the location of this context menu.
-
isVisible()
- Determines whether this context menu is visible.
-
main(String[])
- Provides a command line interface to
ContextMenuManager
.
-
setLocation(Point)
- Sets the location of this context menu.
-
setVisible(boolean)
- Shows or hides this context menu based on the value of parameter
visible
.
-
show(Component, int, int)
- Displays this context menu at the position x,y in the coordinate space of the specified invoker.
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
- 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
- See Also:
- PaneManager, DisplayManagerException
main
public static void main(String args[])
- Provides a command line interface to
ContextMenuManager
. See the class description.
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
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
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.
isVisible
public boolean isVisible()
- Determines whether this context menu is visible.
- Returns:
-
true
if the context menu is visible; false
otherwise.
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.
All Packages Class Hierarchy This Package Previous Next Index