vnas.sm
Class MenuHelper
java.lang.Object
|
+--vnas.sm.MenuHelper
- public class MenuHelper
- extends java.lang.Object
A helper class to connect menu items with methods of an object. To handle menu
(and JButton) events, to deactivate or activate menu items and to check or unckeck checkbox items,
just provide a "server class" and implement one or two methods for each event,
as described below:
The node ID (= the "id" property set in SEditor) of each menu must correspond by name to
a method of the object (the "server object") that handles the menu event. Example:
Assume class FileManager has the methods open() and viewDetails() and a menu has been
defined with items id="open" and id="close". Then, the link between the items
and the FileManager is established by
MenuHelper.connectMenus(sm, new String[]{"open", "viewDetails"}, fileManager);
To disable or enable a menu item, the additional method boolean checkXXX()
should be provided by the server class. For example, add the method boolean checkopen()
to the
FileManager class. The method should return true if it's possible to open a file.
If a menu item is a JCheckBoxMenuItem, the additional method
boolean checkXXX()
or int checkXXX()
must be provided by the
server object. For example, add the method int checkviewDetails()
to the
FileManager class. This method will be called every time before the item becomes
visible. Depending on the return value 0, 1, or 2, the item will be deactivated,
unchecked or checked.
|
Method Summary |
static void |
connectMenus(ISMaker sm,
java.lang.String[] functions,
java.lang.Object server)
Connects menu items to methods of an object (the "server" object). |
static void |
enableMenu(ISMaker sm,
java.lang.String id,
boolean enable)
enables or disables a menu item. |
| Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
MenuHelper
public MenuHelper()
connectMenus
public static void connectMenus(ISMaker sm,
java.lang.String[] functions,
java.lang.Object server)
- Connects menu items to methods of an object (the "server" object).
- Parameters:
sm - the SMaker where the menu items are searchedfunctions - array of item IDsserver - the menu events are connected to methods of this object
enableMenu
public static void enableMenu(ISMaker sm,
java.lang.String id,
boolean enable)
- enables or disables a menu item.
- Parameters:
sm - the SMaker where the menu item is searchedthe - item IDenable - true enables, false disables the menu item