Source code: org/mitre/cvw/UserMenuControl.java
1 /*
2 * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/).
3 * All rights reserved.
4 * CVW comes with ABSOLUTELY NO WARRANTY. See license for details.
5 */
6
7 package org.mitre.cvw;
8
9 import java.awt.*;
10 import java.util.Hashtable;
11
12 /** User Popup menu controller
13 * This class will control the various user menus that may exist.
14 * Upon initialization, this class will create the different menus
15 * and save them in a hashtable. When requested a menu, the class
16 * will lookup the appropriate menu and activate its show() method.
17 *
18 * @author Stephen Jones, The MITRE Corporation
19 * @version 1
20 */
21
22 public class UserMenuControl extends Object implements ObjectValues {
23
24 Hashtable menu_table;
25 int menu_types[] = {USER, PROXY, ONLINEUSER, CURRONLINEUSER, CURRUSER, DISCONNECTED, REMOTEUSER, PROXYWIN};
26
27 /** constructor
28 * @param cont The container that will hold the menu
29 * @param client The class that will handle the callback.
30 */
31 public UserMenuControl(Container cont, UserClient client) {
32 this(cont, client, 0);
33 }
34
35 /** constructor
36 * @param cont The container that will hold the menu
37 * @param client The class that will handle the callback.
38 * @param admit_mod either <code>0</code> for allow admit menu item or
39 * <code>IMAGEMENU</code> to remove it.
40 */
41 public UserMenuControl(Container cont, UserClient client, int admit_mod) {
42 menu_table = new Hashtable();
43 if (admit_mod != IMAGEMENU)
44 admit_mod = 0;
45
46 for (int i=0; i < menu_types.length; i++) {
47 UserMenu menu = new UserMenu((admit_mod | menu_types[i]), client);
48 menu_table.put(new Integer(menu_types[i]), menu);
49 cont.add(menu);
50 }
51 }
52
53 /** Get the proper menu for the selected object
54 * @param menu_type One of the possible menu types as defined in ObjectValues
55 * @return A specialized UserMenu, or null if the menu_type is not in the Hashtable
56 */
57 public UserMenu getMenu(int menu_type) {
58 return ((UserMenu)menu_table.get(new Integer(menu_type)));
59 }
60 }