1 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 35 public class ComponentsListBean extends OmniaWebBean 36 implements ComponentContainer 37 { 38 41 protected int dataID = ComponentConstants.COMPONENT_NULL_DATAID; 42 43 46 protected String uri = null; 47 48 51 protected boolean openMultipleComponents = false; 52 53 57 protected Hashtable components = null; 58 59 60 protected Vector orderOfComponents=null; 61 62 63 66 protected boolean componentdatachanged=false; 67 68 69 72 protected String initvmid=null; 73 74 75 79 protected boolean leftComponentOpen=true; 80 81 82 83 86 public int getDataID() { return dataID; } 87 88 91 public void setDataID(int id) { this.dataID = id; } 92 93 96 public boolean getOpenMultiple() { return openMultipleComponents; } 97 98 101 public void setOpenMultiple(boolean omc) { this.openMultipleComponents = omc; } 102 103 106 public String getURI() { return uri; } 107 108 111 public void setURI(String uri) { this.uri = uri; } 112 113 116 public Hashtable getComponents() { return components; } 117 118 119 120 123 public boolean getLeftComponentOpen() { return leftComponentOpen; } 124 125 128 public void setLeftComponentOpen(boolean b) { leftComponentOpen=b; } 129 130 131 132 133 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 )orderOfComponents.elementAt(i)); 143 pair.setObjectTwo( getComponent((String )orderOfComponents.elementAt(i)) ); 144 ret.add( pair ); 145 } 146 return ret; 147 } 148 149 152 public boolean addComponent(String 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 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 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 204 public ComponentBean getComponent(String id) 205 { 206 if(components != null) 207 return (ComponentBean) components.get(id); 208 209 return null; 210 } 211 212 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 226 public void setInitVmodule(String vmid) { 227 228 initvmid=vmid; 229 } 230 231 237 public String getInitVModule() { 238 return initvmid; 239 } 240 241 245 public void removeAllComponents() { 246 components=null; 247 orderOfComponents=null; 248 } 249 250 251 } 252 253 254 | Popular Tags |