Horus Doc || Java GUI Reference || Doxygen's quick Index  

ExtMenuBar Class Reference

Representation of an (extended) menu bar. More...

Inheritance diagram for ExtMenuBar::

CorbaExtMenuBar List of all members.

Public Methods

 ExtMenuBar (Object user)
 Construct an ExtMenuBar. More...

JMenu addMenu (String menuName)
 Add a new menu to the bar. More...

void addSubMenu (String menuName, String subMenuName)
 Add a sub menu to the given menu. More...

void addGroupMenu (String menuName, String[] options, String funcName, String selected)
 Add an group of items (RadioButtons) to the given menu. More...

void addCheckBoxItem (String menuName, String itemName, String funcName, boolean checked)
 Add a check-box menu item to the given menu. More...

void addColorsMenu (String menuName, String funcName)
 Add color items to the given menu. More...

void addMenuItem (String menuName, JMenuItem item)
void addMenuItem (String menuName, Action ac)
void addMenuItem (String menuName, String itemName, Action ac)
void addMenuItem (String menuName, String itemName, String funcName)
 Add an item to the given menu. More...

void addMenuItem (String menuName, String itemName, CallableMethod method)
 Add an item to the given menu. More...

void addMenuItem (String menuName, String itemName, Object target, CallableMethod method)
 Add an item to the given menu. More...

void addMenuItem (String menuName, String itemName, Object target, CallableMethod targetMethod, Object user, String userMethodName)
 Add an item to the given menu. More...

void addSeparator (String menuName)
 Add a separator to the given menu. More...

void addSaMethodMenu ()
 Add the default SaMethodMenu to the bar. More...

void addSaMethodMenu (String saClassName)
 Add the SaMethodMenu with the given name. More...

void addSaMethodMenu (String saClassName, String prefixKey)
 Add the SaMethodMenu with the given name and prefixKey. More...

void actionPerformed (ActionEvent event)
 Implementation of ActionListener. More...


Static Public Methods

JMenuItem colorMenuItem (int i)
JMenuItem colorMenuItem (Color c)

Static Public Attributes

final Color[] colors = listColors()

Protected Attributes

Object _user

Detailed Description

Representation of an (extended) menu bar.


Constructor & Destructor Documentation

ExtMenuBar::ExtMenuBar Object    user [inline]
 

Construct an ExtMenuBar.

The user object will be called whenever a menu item is selected.

00037 {
00038     _user = user;
00039     _map = new HashMap();
00040 }


Member Function Documentation

JMenu ExtMenuBar::addMenu String    menuName [inline]
 

Add a new menu to the bar.

00046 {
00047     JMenu menu = new JMenu(menuName);
00048     add(menu);
00049     _map.put(menuName, menu);
00050 
00051     return menu;
00052 }

void ExtMenuBar::addSubMenu String    menuName,
String    subMenuName
[inline]
 

Add a sub menu to the given menu.

00058 {
00059     JMenu menu = (JMenu) _map.get(menuName);
00060     if (menu == null) {
00061         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00062         return;
00063     }
00064     JMenu subMenu = new JMenu(subMenuName);
00065     menu.add(subMenu);
00066     _map.put(subMenuName, subMenu);
00067 }

void ExtMenuBar::addGroupMenu String    menuName,
String    options[],
String    funcName,
String    selected
[inline]
 

Add an group of items (RadioButtons) to the given menu.

The member function "funcName" of the user should have the following signature: public void "funcName"(String option)

"option" is the option selected from the group

00078 {
00079     JMenu menu = (JMenu) _map.get(menuName);
00080     if (menu == null) {
00081         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00082         return;
00083     }
00084 
00085     ButtonGroup group = new ButtonGroup();
00086     JRadioButtonMenuItem rbmi;
00087     CallableMethod meth = new CallableMethod(funcName, "String", "", "");
00088     for(int i=0; i<options.length; i++) {
00089         rbmi = new JRadioButtonMenuItem(options[i], options[i].equals(selected));
00090         rbmi.addActionListener(
00091                 new JavaFuncAction("", _user, meth, new Object[] { options[i] }));
00092         group.add(rbmi);
00093         menu.add(rbmi);
00094     }
00095 }

void ExtMenuBar::addCheckBoxItem String    menuName,
String    itemName,
String    funcName,
boolean    checked
[inline]
 

Add a check-box menu item to the given menu.

The member function "funcName" of the user should have the following signature: public void "funcName"(boolean val)

00103 {
00104     JMenu menu = (JMenu) _map.get(menuName);
00105     if (menu == null) {
00106         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00107         return;
00108     }
00109 
00110     final JCheckBoxMenuItem check = new JCheckBoxMenuItem(itemName, checked);
00111     CallableMethod meth = new CallableMethod(funcName, "boolean", "", "");
00112     final JavaFuncAction ac = new JavaFuncAction("", _user, meth);
00113 
00114     check.addActionListener(new ActionListener() {
00115         public void actionPerformed(ActionEvent e) {
00116             ac.invoke(new Object[] { new Boolean(check.getState()) });
00117         }});
00118 
00119     menu.add(check);
00120 }

void ExtMenuBar::addColorsMenu String    menuName,
String    funcName
[inline]
 

Add color items to the given menu.

The member function "funcName" of the user should have the following signature: public void "funcName"(Color color)

"color" is the color selected

00129 {
00130     JMenu menu = (JMenu) _map.get(menuName);
00131     if (menu == null) {
00132         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00133         return;
00134     }
00135 
00136     CallableMethod meth = new CallableMethod(funcName, "Color", "", "");
00137     for(int i=0; i<colors.length; i++) {
00138         JMenuItem mi = colorMenuItem(colors[i]);
00139         mi.addActionListener(
00140                 new JavaFuncAction("", _user, meth, new Color[] { colors[i] }));
00141         menu.add(mi);
00142     }
00143 }

JMenuItem ExtMenuBar::colorMenuItem int    i [inline, static]
 

00146 {
00147     return new JMenuItem(createIcon(colors[i]));
00148 }

JMenuItem ExtMenuBar::colorMenuItem Color    c [inline, static]
 

00151 {
00152     return new JMenuItem(createIcon(c));
00153 }

void ExtMenuBar::addMenuItem String    menuName,
JMenuItem    item
[inline]
 

00156 {
00157     JMenu menu = (JMenu) _map.get(menuName);
00158     if (menu == null) {
00159         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00160         return;
00161     }
00162     menu.add(item);
00163 }

void ExtMenuBar::addMenuItem String    menuName,
Action    ac
[inline]
 

00166 {
00167     JMenu menu = (JMenu) _map.get(menuName);
00168     if (menu == null) {
00169         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00170         return;
00171     }
00172     menu.add(ac);
00173 }

void ExtMenuBar::addMenuItem String    menuName,
String    itemName,
Action    ac
[inline]
 

00176 {
00177     JMenu menu = (JMenu) _map.get(menuName);
00178     if (menu == null) {
00179         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00180         return;
00181     }
00182     JMenuItem mi = new JMenuItem(itemName);
00183     if(ac == null) mi.setEnabled(false);
00184     else mi.addActionListener(ac);
00185     menu.add(mi);
00186 }

void ExtMenuBar::addMenuItem String    menuName,
String    itemName,
String    funcName
[inline]
 

Add an item to the given menu.

Upon selection, the bar will call \_user.funcName (without arguments).

00192 {
00193     if(funcName == null)
00194         addMenuItem(menuName, itemName, (Action)null);
00195     else
00196         addMenuItem(menuName,
00197             new JavaFuncAction(itemName, _user, new CallableMethod(funcName)));
00198 }

void ExtMenuBar::addMenuItem String    menuName,
String    itemName,
CallableMethod    method
[inline]
 

Add an item to the given menu.

Upon selection, the bar will invoke the given method on the \_user object. Method invocation is direct in case the method has no arguments, otherwise the bar will first pop a JavaFuncDialog.

00207 {
00208     if(method == null) addMenuItem(menuName, itemName, (Action)null);
00209     else
00210         addMenuItem(menuName, new JavaFuncAction(itemName, _user, method));
00211 }

void ExtMenuBar::addMenuItem String    menuName,
String    itemName,
Object    target,
CallableMethod    method
[inline]
 

Add an item to the given menu.

Upon selection, the bar will invoke the given method on the target object. Method invocation is direct in case the method has no arguments, otherwise the bar will first pop a JavaFuncDialog.

00221 {
00222     addMenuItem(menuName,
00223         new JavaFuncAction(itemName, target, method));
00224 }

void ExtMenuBar::addMenuItem String    menuName,
String    itemName,
Object    target,
CallableMethod    targetMethod,
Object    user,
String    userMethodName
[inline]
 

Add an item to the given menu.

This method provides method invocation via an intermediate call to a user. The intermediate user is necessary in case the target object is not known at menu construction time.

The member function "userMethodName" of this user will be called (either directly or via a JavaFuncDialog) upon selection of the menu item. The function should have the following signature: public void "userMethodName"(Object target, CallableMethod method, Object[] argVals) "target" is the target specified at menu construction time "method" is the method to be invoked on target "argVals" are the arguments of the method entered via the dialog box

"userMethodName" is resposible for invoking the callable method on the given target or (more likely) an object of its own choice, e.g. method.invoke(mytarget, argVals);

00248 {
00249     addMenuItem(menuName,
00250         new JavaFuncAction(itemName, target, targetMethod, user, userMethodName));
00251 }

void ExtMenuBar::addSeparator String    menuName [inline]
 

Add a separator to the given menu.

00257 {
00258     JMenu menu = (JMenu) _map.get(menuName);
00259     if (menu == null) {
00260         ErrorStreamArea.println("ExtMenuBar: no menu " + menuName);
00261         return;
00262     }
00263     menu.addSeparator();
00264 }

void ExtMenuBar::addSaMethodMenu   [inline]
 

Add the default SaMethodMenu to the bar.

00270 {
00271     JMenu saMM = new SaMethodMenu(this);
00272     add(saMM);
00273 }

void ExtMenuBar::addSaMethodMenu String    saClassName [inline]
 

Add the SaMethodMenu with the given name.

00279 {
00280     JMenu saMM = new SaMethodMenu(saClassName, this);
00281     add(saMM);
00282 }

void ExtMenuBar::addSaMethodMenu String    saClassName,
String    prefixKey
[inline]
 

Add the SaMethodMenu with the given name and prefixKey.

00288 {
00289     JMenu saMM = new SaMethodMenu(saClassName, prefixKey, this);
00290     add(saMM);
00291 }

void ExtMenuBar::actionPerformed ActionEvent    event [inline]
 

Implementation of ActionListener.

00297 {
00298     String command = event.getActionCommand();
00299     int i = command.indexOf("::");
00300     if (i != -1) { // It is an SaMethodMenu item
00301 //      menuName = command.substring(0, i);
00302         SaMethodDescription desc = new SaMethodDescription(command);
00303         if (desc.valid()) {
00304             SaMethodDialog saMethodDialog = new SaMethodDialog(desc, _user,
00305                                                 "handleSaMethodDialogResult");
00306         }
00307         return;
00308     }
00309 }


Member Data Documentation

final Color [] ExtMenuBar::colors = listColors() [static]
 

Object ExtMenuBar::_user [protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:19 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001