Changeset 7326 for trunk/gli/src/org/greenstone/gatherer/file
- Timestamp:
- 2004-05-13T17:08:42+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileNode.java
r7281 r7326 34 34 private MutableTreeNode parent; 35 35 private String title; 36 private boolean gs3_site = false; 36 37 37 38 public FileNode(File file) { … … 267 268 268 269 public void map() { 269 if(children == null) { 270 children = new ArrayList(); 271 // Super Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually be the collect directory of greenstone. 272 if(file == null && title.equals(Dictionary.get("Tree.World"))) { 270 if(children != null) { 271 return; 272 } 273 children = new ArrayList(); 274 // Super Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually be the collect directory of greenstone. 275 if(file == null) { // a special mapping folder 276 if (title.equals(Dictionary.get("Tree.World")) && Gatherer.GS3) { 277 // the Greenstone collections folder for GS3 - this contains a 278 // folder for each site 279 File start = new File(Utility.getSitesDir(Gatherer.config.gsdl3_path)); 280 File sites[] = start.listFiles(); 281 ArrayTools.sort(sites); 282 for (int i=0; sites != null && i < sites.length; i++) { 283 //File site = sites[i]; 284 File collect_dir = new File(sites[i], Utility.COL_DIR); 285 if(!collect_dir.exists()) { 286 continue; 287 } 288 289 FileNode child = new FileNode(sites[i].getName()); 290 child.setGS3Site(true); 291 child.unmap(); 292 child.setParent(this); 293 child.setModel(model); 294 child.map(); 295 children.add(child); 296 } 297 298 } else if (title.equals(Dictionary.get("Tree.World")) || gs3_site) { 299 // the collect dir for gs2 or a site dir for gs3 273 300 ///atherer.println("Map the 'Greenstone Collections' node."); 274 301 // For each of the children directories, which are collections... 275 File start = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 302 File start; 303 if (gs3_site) { 304 start = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, title)); 305 } else { 306 start = new File(Utility.getCollectDir(Gatherer.config.gsdl_path)); 307 } 276 308 File cols[] = start.listFiles(); 277 309 ArrayTools.sort(cols); … … 279 311 for(int i = 0; cols != null && i < cols.length; i++) { 280 312 if (!cols[i].getName().equals(StaticStrings.MODEL_COLLECTION_NAME)) { 281 File dirs[] = cols[i].listFiles();282 ArrayTools.sort(dirs);313 //File dirs[] = cols[i].listFiles(); 314 //ArrayTools.sort(dirs); 283 315 File import_dir = new File(cols[i], StaticStrings.IMPORT_FOLDER); 284 if(import_dir.exists()) { 285 // we don't care if there is no config file 286 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(cols[i], Utility.CONFIG_FILE)); 287 FileNode collection_root = new FileNode(import_dir, collect_cfg.toString(), true); 288 collection_root.setParent(this); 289 collection_root.setModel(model); 290 // One last piece of magic so we can determine the current collection 291 Collection collection = Gatherer.c_man.getCollection(); 292 if(collection != null) { 293 collection_root.setCurrentCollection(cols[i].getName().equals(collection.getName())); 294 } 295 children.add(collection_root); 296 collection_root = null; 316 if(!import_dir.exists()) { 317 continue; 297 318 } 319 // we don't care if there is no config file 320 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(cols[i], Utility.CONFIG_FILE)); 321 FileNode collection_root = new FileNode(import_dir, collect_cfg.toString(), true); 322 collection_root.setParent(this); 323 collection_root.setModel(model); 324 // One last piece of magic so we can determine the current collection 325 Collection collection = Gatherer.c_man.getCollection(); 326 if(collection != null) { 327 collection_root.setCurrentCollection(cols[i].getName().equals(collection.getName())); 328 } 329 children.add(collection_root); 330 collection_root = null; 298 331 import_dir = null; 299 dirs = null;300 } 301 } 332 //dirs = null; 333 } 334 } // for each coll 302 335 cols = null; 303 336 model.nodeStructureChanged(this); 304 337 } 305 // General case: Only map if there are no children. 306 else if(file != null && getAllowsChildren()) { 338 } // if file == null 339 // General case: Only map if there are no children. 340 else { // file !=null 341 if(getAllowsChildren()) { 307 342 File[] files = file.listFiles(); 308 343 if(files != null && files.length > 0) { … … 318 353 raw_children.add(child); 319 354 } 320 355 321 356 // Apply the filters set in the model. 322 357 //if(model != null) { … … 326 361 } 327 362 //} 328 363 329 364 // Now add them to children. 330 365 for(int i = 0; i < files.length; i++) { … … 343 378 } 344 379 } 380 345 381 } 346 382 … … 376 412 public void setFile(File file) { 377 413 this.file = file; 414 } 415 416 public void setGS3Site(boolean is_site) { 417 this.gs3_site = is_site; 378 418 } 379 419 … … 426 466 public void unmap() { 427 467 // You cannot unmap nodes that have no file basis. 428 if(file != null || title.equals(Dictionary.get("Tree.World")) ) {468 if(file != null || title.equals(Dictionary.get("Tree.World")) || gs3_site) { 429 469 ///atherer.println("Unmap: " + this); 430 470 children = null;
Note:
See TracChangeset
for help on using the changeset viewer.