KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > MenuManager


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.api;
7
8 import com.raptus.owxv3.*;
9
10 /**
11  * The menu manager provides access to the various virtual module configurations
12  * available.
13  *
14  * <hr>
15  * <table width="100%" border="0">
16  * <tr>
17  * <td width="24%"><b>Filename</b></td><td width="76%">MenuManager.java</td>
18  * </tr>
19  * <tr>
20  * <td width="24%"><b>Author</b></td><td width="76%">Guy Z�rcher (gzuercher@raptus.com)</td>
21  * </tr>
22  * <tr>
23  * <td width="24%"><b>Date</b></td><td width="76%">16th of April 2001</td>
24  * </tr>
25  * </table>
26  * <hr>
27  * <table width="100%" border="0">
28  * <tr>
29  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
30  * </tr>
31  * </table>
32  * <hr>
33  */

34 public class MenuManager extends Object JavaDoc
35 {
36     /**
37      *
38      */

39     protected com.raptus.owxv3.api.usermgr.User user;
40
41     /**
42      *
43      */

44     protected String JavaDoc locale;
45
46     /**
47      *
48      */

49     protected String JavaDoc section;
50
51     /**
52      *
53      */

54     protected String JavaDoc[] vmodules;
55
56     /**
57      *
58      */

59     //protected Configuration cfg;
60

61     /**
62      *
63      */

64     public MenuManager(com.raptus.owxv3.api.usermgr.User user, String JavaDoc section)
65     {
66         VModuleManager vmm = VModuleManager.getInstance();
67         vmodules=vmm.getVModules();
68         //this.vmodules = user.getAllowedVModules();
69

70         this.locale = user.getLocale().toString();
71         this.section = section;
72         this.user = user;
73
74         //ConfigManager cm = ConfigManager.getInstance();
75
//cfg = cm.getConfiguration();
76
}
77
78     /**
79      *
80      */

81     public MenuManager(String JavaDoc section)
82     {
83         this.vmodules = null;
84         this.locale = null;
85         this.section = section;
86
87         //ConfigManager cm = ConfigManager.getInstance();
88
//cfg = cm.getConfiguration();
89
}
90
91     /**
92      *
93      */

94     public void prepareMenuBean(MenuBean bean)
95     {
96         fillupVModules(bean
97         //, cfg
98
);
99         //bean.setUserDisplayname(user.getDisplayname());
100
bean.setUserDisplayname(user.getName());
101     }
102
103     /**
104      *
105      */

106     protected void fillupVModules(MenuBean bean
107                                     //, Configuration cfg
108
)
109     {
110         VModuleManager vmm = VModuleManager.getInstance();
111         vmodules=vmm.getVModules();
112         for(int i = 0; i < vmodules.length; i ++)
113         {
114             VModule vm = vmm.getVModule(vmodules[i]);
115             if(vm == null)
116                 continue;
117             VModuleSection vms = vm.getSection(section);
118             if(vms == null)
119                 continue;
120             String JavaDoc[] elements = vms.getElements();
121             for(int n = 0; n < elements.length; n ++)
122             {
123                 VModuleSectionElement vmselement = vms.getElement(elements[n]);
124                 if(vmselement == null)
125                     continue;
126                 // first element of section is used as "index"
127
if(n == 0)
128                 {
129                     bean.addVModule(vmodules[i],
130                                     vmselement.getDisplayname(locale),
131                                     vmselement.getURI());
132                 }
133                 else
134                 {
135                     bean.addFunction(vmodules[i],
136                                     vmselement.getDisplayname(locale),
137                                     vmselement.getURI());
138                 }
139             }
140         }
141     }
142
143 }
144
145 /* eof */
146
Popular Tags