KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > components > ComponentsListBean


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

5
6 package com.raptus.owxv3.api.components;
7
8 import java.util.*;
9
10 import com.raptus.owxv3.*;
11 import com.raptus.owxv3.api.OmniaWebBean;
12
13 /**
14  *
15  * <hr>
16  * <table width="100%" border="0">
17  * <tr>
18  * <td width="24%"><b>Filename</b></td><td width="76%">ComponentsListBean.java</td>
19  * </tr>
20  * <tr>
21  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
22  * </tr>
23  * <tr>
24  * <td width="24%"><b>Date</b></td><td width="76%">28th of June 2001</td>
25  * </tr>
26  * </table>
27  * <hr>
28  * <table width="100%" border="0">
29  * <tr>
30  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
31  * </tr>
32  * </table>
33  * <hr>
34  */

35 public class ComponentsListBean extends OmniaWebBean
36                                 implements ComponentContainer
37 {
38     /**
39      *
40      */

41     protected int dataID = ComponentConstants.COMPONENT_NULL_DATAID;
42
43     /**
44      *
45      */

46     protected String JavaDoc uri = null;
47
48     /**
49      *
50      */

51     protected boolean openMultipleComponents = false;
52
53     /**
54      *Since the hashtable doesn't KEEP the order of the
55      *entries added we need more methods
56      */

57     protected Hashtable components = null;
58
59
60     protected Vector orderOfComponents=null;
61
62
63     /**
64      *
65      */

66     protected boolean componentdatachanged=false;
67
68
69     /**
70      *
71      */

72     protected String JavaDoc initvmid=null;
73     
74     
75     /**
76      *Boolean showing that left component is open or not,
77      * default is open
78      */

79     protected boolean leftComponentOpen=true;
80
81
82
83     /**
84      *
85      */

86     public int getDataID() { return dataID; }
87
88     /**
89      *
90      */

91     public void setDataID(int id) { this.dataID = id; }
92
93     /**
94      *
95      */

96     public boolean getOpenMultiple() { return openMultipleComponents; }
97
98     /**
99      *
100      */

101     public void setOpenMultiple(boolean omc) { this.openMultipleComponents = omc; }
102
103     /**
104      *
105      */

106     public String JavaDoc getURI() { return uri; }
107
108     /**
109      *
110      */

111     public void setURI(String JavaDoc uri) { this.uri = uri; }
112
113     /**
114      *
115      */

116     public Hashtable getComponents() { return components; }
117     
118     
119     
120     /**
121      *
122      */

123     public boolean getLeftComponentOpen() { return leftComponentOpen; }
124     
125     /**
126      *
127      */

128     public void setLeftComponentOpen(boolean b) { leftComponentOpen=b; }
129     
130     
131     
132
133     /**
134      *
135      */

136     public Vector getComponentsInOrder()
137     {
138         Vector ret=new Vector();
139         for(int i=0;i<orderOfComponents.size();i++)
140         {
141             PairOfObjects pair=new PairOfObjects();
142             pair.setObjectOne((String JavaDoc)orderOfComponents.elementAt(i));
143             pair.setObjectTwo( getComponent((String JavaDoc)orderOfComponents.elementAt(i)) );
144             ret.add( pair );
145         }
146         return ret;
147     }
148
149     /**
150      *
151      */

152     public boolean addComponent(String JavaDoc id)
153     {
154         ComponentsRegistry cr = new ComponentsRegistry();
155         ComponentData cd = cr.getComponentData(id);
156
157         if(cd == null)
158             return false;
159
160         ComponentBean bean = null;
161
162         try
163         {
164             Class JavaDoc classObj = Class.forName(cd.getBeanClass());
165             if(classObj == null)
166             {
167                 LoggingManager.log("Can't load component " + cd.getBeanClass() + "!", this);
168                 return false;
169             }
170
171             bean = (ComponentBean) classObj.newInstance();
172             if(bean == null)
173             {
174                 LoggingManager.log("Can't instantiate component " + cd.getBeanClass() + "!", this);
175                 return false;
176             }
177         }
178         catch(Exception JavaDoc e)
179         {
180             LoggingManager.log("Exception while instantiating component " + cd.getBeanClass(), this);
181             LoggingManager.log(e.toString(), this);
182             return false;
183         }
184
185         bean.setContainer(this);
186         bean.setData(cd);
187         
188         bean.setComponentId(id);
189
190         if(components == null)
191             components = new Hashtable();
192         if(orderOfComponents == null)
193             orderOfComponents = new Vector();
194
195
196         components.put(id, bean);
197         orderOfComponents.add(id);
198         return true;
199     }
200
201     /**
202      *
203      */

204     public ComponentBean getComponent(String JavaDoc id)
205     {
206         if(components != null)
207             return (ComponentBean) components.get(id);
208
209         return null;
210     }
211
212     /**
213      *
214      */

215     public void closeAllComponents()
216     {
217         if(components==null) return;
218         Enumeration enuCmps = components.elements();
219         while(enuCmps.hasMoreElements())
220             ((ComponentBean) enuCmps.nextElement()).setOpen(false);
221     }
222
223     /**
224      *
225      */

226     public void setInitVmodule(String JavaDoc vmid) {
227
228         initvmid=vmid;
229     }
230
231     /**
232      * The component container is initialized
233      * by one vmodule (ex. news) but other virtual modules
234      * has other setting they need to to reinitiazlize
235      *the container
236      */

237     public String JavaDoc getInitVModule() {
238         return initvmid;
239     }
240
241     /**
242      * WE need to remove all components to add other compnonents
243      * of different vmodule
244      */

245     public void removeAllComponents() {
246         components=null;
247         orderOfComponents=null;
248     }
249
250
251 }
252
253 /* end class ComponentsListBean */
254
Popular Tags