1 5 6 package com.raptus.owxv3.modules.categories; 7 8 import com.raptus.owxv3.api.*; 9 import java.util.*; 10 11 public class PubStyleTreeBean extends Object 12 { 13 16 com.raptus.owxv3.api.GlobalResources gres = new com.raptus.owxv3.api.GlobalResources(); 17 18 21 java.util.Vector categories = new Vector(); 22 23 26 String owner; 27 28 31 Locale locale; 32 33 36 Vector categoryNames = new Vector(); 37 38 41 Vector folderStats = new Vector(); 42 43 46 Hashtable isOpened = new Hashtable(); 47 48 54 public boolean isOpen(int id) 55 { 56 int i; 57 58 String v = (String )isOpened.get(""+id); 59 if(v!= null) 60 { 61 if(v.equals("true")) 62 { 63 return true; 64 } 65 else 66 { 67 return false; 68 } 69 } 70 else 71 { 72 return false; 73 } 74 } 75 76 81 public void setLocale(Locale l) 82 { 83 this.locale = l; 84 } 85 86 91 public Locale getLocale() 92 { 93 return locale; 94 } 95 96 101 public String getOwner() 102 { 103 return owner; 104 } 105 106 111 public void setOwner(String owner) 112 { 113 this.owner = owner; 114 } 115 116 121 public Vector getCategories() 122 { 123 return categories; 124 } 125 126 129 public void Update() 130 { 131 gres = new com.raptus.owxv3.api.GlobalResources(); 132 categories = new Vector(); 133 categoryNames = new Vector(); 134 try 135 { 136 loadCategories(); 137 loadCategoryNames(); 138 } 139 catch(java.sql.SQLException ex) 140 {} 141 } 142 143 148 public Vector getCategoryNames() 149 { 150 return categoryNames; 151 } 152 153 156 public void loadCategories() throws java.sql.SQLException 157 { 158 java.util.Vector v=gres.loadCategories(0,owner); 159 for (int i=0;i<v.size();i++) 160 { 161 GResCategory grcat=(GResCategory)v.elementAt(i); 162 163 categories.add(grcat); 164 if(i<v.size()-1) 165 { 166 { 172 folderStats.addElement(new String ("folder_close")); 173 } 174 loadChildCategories(grcat.getRowID(), false); 175 } 176 else 177 { 178 { 184 folderStats.addElement(new String ("folder_close_last")); 185 } 186 loadChildCategories(grcat.getRowID(), true); 187 } 188 } 189 } 190 191 197 protected void loadChildCategories(int id, boolean abslast) throws java.sql.SQLException 198 { 199 java.util.Vector child=gres.loadChildCategories(id,owner); 200 for (int i=0;i<child.size();i++) 201 { 202 com.raptus.owxv3.api.GResCategory grcat=(com.raptus.owxv3.api.GResCategory)child.elementAt(i); 203 204 categories.add(grcat); 205 if(i<child.size()-1) 206 { 207 { 213 folderStats.addElement(new String ("folder_close")); 214 } 215 } 216 else 217 { 218 if(abslast) 219 { 220 { 226 folderStats.addElement(new String ("folder_close_last_end")); 227 } 228 } 229 else 230 { 231 { 237 folderStats.addElement(new String ("folder_close_last")); 238 } 239 } 240 } 241 loadChildCategories(grcat.getRowID(), abslast); 242 } } 245 246 251 public Vector getFolderStatus() 252 { 253 Vector folderStatsr = new Vector(); 254 for(int i=0;i<categories.size();i++) 255 { 256 com.raptus.owxv3.api.GResCategory grcat=(com.raptus.owxv3.api.GResCategory)categories.elementAt(i); 257 String stat = (String )folderStats.elementAt(i); 258 if(this.isOpen(grcat.getRowID())) 259 { 260 if(stat.equals("folder_close")) 261 { 262 folderStatsr.addElement("folder_open"); 263 } 264 265 if(stat.equals("folder_close_last")) 266 { 267 folderStatsr.addElement("folder_open_last"); 268 } 269 270 if(stat.equals("folder_close_last_end")) 271 { 272 folderStatsr.addElement("folder_open_last_end"); 273 } 274 } 275 else 276 { 277 folderStatsr.addElement(stat); 278 } 279 } 280 return folderStatsr; 281 } 282 283 286 protected void loadCategoryNames() throws java.sql.SQLException 287 { 288 com.raptus.owxv3.api.GResCategory grcat=null; 289 int i; 290 for (i=0;i<categories.size();i++) 291 { 292 grcat=(com.raptus.owxv3.api.GResCategory)categories.elementAt(i); 293 294 if(grcat!=null) 295 { 296 String catnames; 297 catnames = gres.loadMessage(gres.getCategoryTableName(),grcat.getRowID(), CategoryConstants.RESCATFIELD_NAME,locale); 298 categoryNames.add(catnames); 299 } 300 else 301 { 302 categoryNames.add("This cat=null"); 303 } 304 } 305 } 307 312 public void togleFolder(int id) 313 { 314 int i; 315 316 if(isOpen(id)) 317 { 318 isOpened.put(""+id, "false"); 319 } 320 else 321 { 322 isOpened.put(""+id, "true"); 323 } 324 } 325 326 332 public Vector getTree(GResCategory cat) 333 { 334 GlobalResources res = new GlobalResources(); 335 try 336 { 337 return res.getTree(cat, new Locale("en","GB")); 338 } 339 catch(java.sql.SQLException ex) 340 { 341 return new Vector(); 342 } 343 } 344 345 346 } 347 | Popular Tags |