Changeset 8783 for trunk/gli/src/org/greenstone/gatherer/collection
- Timestamp:
- 2004-12-13T12:01:25+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/collection
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/Collection.java
r8652 r8783 47 47 import org.greenstone.gatherer.cdm.CollectionMeta; 48 48 import org.greenstone.gatherer.cdm.CollectionMetaManager; 49 import org.greenstone.gatherer.file.FileNode;50 49 import org.greenstone.gatherer.util.StaticStrings; 51 50 import org.greenstone.gatherer.util.Utility; … … 302 301 private int getCount(TreeNode node, boolean count_folders, boolean count_files) { 303 302 int count = 0; 304 File file = (( FileNode)node).getFile();303 File file = ((CollectionTreeNode)node).getFile(); 305 304 if(file.isFile() && count_files) { 306 305 count++; -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r8652 r8783 38 38 39 39 import java.io.*; 40 import java.lang.Class;41 40 import java.util.*; 42 41 import javax.swing.*; … … 54 53 import org.greenstone.gatherer.cdm.CollectionMetaManager; 55 54 import org.greenstone.gatherer.cdm.CommandTokenizer; 56 import org.greenstone.gatherer.file.FileNode; 57 import org.greenstone.gatherer.file.FileQueue; 58 import org.greenstone.gatherer.file.FileSystemModel; 55 import org.greenstone.gatherer.file.WorkspaceTree; // !!! Don't like this here 59 56 import org.greenstone.gatherer.gui.LockFileDialog; 60 57 import org.greenstone.gatherer.gui.NewCollectionMetadataPrompt; 61 58 import org.greenstone.gatherer.gui.ExternalCollectionPrompt; 62 59 import org.greenstone.gatherer.gui.WarningDialog; 63 import org.greenstone.gatherer.gui.tree.WorkspaceTree;64 60 import org.greenstone.gatherer.metadata.DocXMLFileManager; 65 61 import org.greenstone.gatherer.metadata.MetadataSet; … … 94 90 static private Collection collection = null; 95 91 /** The collection_model. */ 96 private FileSystemModel collection_model = null;92 private CollectionTreeModel collection_model = null; 97 93 /** An inner class listener responsible for noting tree changes and resetting saved when they occur. */ 98 94 private FMTreeModelListener fm_tree_model_listener = null; … … 126 122 { 127 123 collection_contents_changed_listeners.add(listener); 128 }129 130 131 /** Add a special directory mapping.132 * @param name The name for this directory mapping as a <strong>String</strong>.133 * @param file The directory this mapping maps to as a <strong>File</strong>.134 */135 public void addDirectoryMapping(String name, File file)136 {137 // Update the information stored in the Gatherer config138 Configuration.addDirectoryMapping(name, file);139 // Now update the tree140 Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.FOLDER_SHORTCUTS_CHANGED);141 124 } 142 125 … … 291 274 } 292 275 DebugStream.println("Copying images and macros dirs from the base collection"); 293 FileQueue fq = Gatherer.f_man.getQueue();294 276 try { 295 277 // do the images dir … … 301 283 302 284 // copy the contents over 303 fq.copyDirectoryContents(base_coll_images, new_coll_images, null); 304 } 305 } catch (Exception e) { 285 Gatherer.f_man.getQueue().copyDirectoryContents(base_coll_images, new_coll_images, null); 286 } 287 } 288 catch (Exception e) { 306 289 DebugStream.println("Couldn't copy over the images dir from the base collection: "+e.toString()); 307 290 } … … 315 298 316 299 // copy the contents over 317 fq.copyDirectoryContents(base_coll_macros, new_coll_macros, null);300 Gatherer.f_man.getQueue().copyDirectoryContents(base_coll_macros, new_coll_macros, null); 318 301 } 319 } catch (Exception e) { 302 } 303 catch (Exception e) { 320 304 DebugStream.println("Couldn't copy over the macros dir from the base collection: "+e.toString()); 321 305 } … … 529 513 530 514 515 public boolean deleteCollection(String collection_name) 516 { 517 File collection_directory = null; 518 if (Gatherer.GS3) { 519 collection_directory = new File(Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection_name)); 520 } 521 else { 522 collection_directory = new File(Utility.getCollectionDir(Configuration.gsdl_path, collection_name)); 523 } 524 525 if (Utility.delete(collection_directory)) { 526 // Refresh the collections shown in the workspace tree 527 Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED); 528 return true; 529 } 530 531 return false; 532 } 533 534 531 535 public void fireFileAddedToCollection(File file) 532 536 { … … 706 710 /** Retrieve the record set (tree model) associated with the current collection. */ 707 711 public TreeModel getRecordSet() { 708 if (collection_model == null && collection != null) {709 // Use the import directory to generate a new FileSystemModel710 collection_model = new FileSystemModel(new FileNode(new File(getCollectionImport()), false));712 if (collection_model == null && collection != null) { 713 // Use the import directory to generate a new CollectionTreeModel 714 collection_model = new CollectionTreeModel(new CollectionTreeNode(new File(getCollectionImport()))); 711 715 // Ensure that the manager is a change listener for the tree. 712 if (fm_tree_model_listener == null) {716 if (fm_tree_model_listener == null) { 713 717 fm_tree_model_listener = new FMTreeModelListener(); 714 718 } … … 716 720 } 717 721 return collection_model; 718 }719 720 721 static public FileNode getGreenstoneCollectionsMapping()722 {723 FileNode greenstone_collections_node = new FileNode(Dictionary.get("Tree.World"));724 greenstone_collections_node.unmap();725 return greenstone_collections_node;726 }727 728 729 static public FileNode[] getFolderShortcuts()730 {731 // Return any predefined special directories732 HashMap mappings = Configuration.getDirectoryMappings();733 FileNode[] mapping_nodes = new FileNode[mappings.size()];734 Iterator mappings_iterator = mappings.keySet().iterator();735 for (int i = 0; mappings_iterator.hasNext(); i++) {736 String mapping_name = (String) mappings_iterator.next();737 File mapping_file = (File) mappings.get(mapping_name);738 mapping_nodes[i] = new FileNode(mapping_file, mapping_name);739 }740 return mapping_nodes;741 722 } 742 723 … … 1204 1185 public void registerImportMonitor(GShellProgressMonitor monitor) { 1205 1186 import_monitor = monitor; 1206 }1207 /** Remove a previously assigned special directory mapping.1208 * @param target The <string>FileNode</strong> representing the special directory mapping to remove as a <strong>String</strong>.1209 * @return The <strong>File</strong> of the mapping removed.1210 * @see org.greenstone.gatherer.file.FileNode1211 */1212 public File removeDirectoryMapping(FileNode target) {1213 // Remove from config, remembering file1214 File file = Configuration.removeDirectoryMapping(target.toString());1215 // Update tree.1216 Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.FOLDER_SHORTCUTS_CHANGED);1217 return file;1218 1187 } 1219 1188 -
trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java
r8620 r8783 51 51 import org.greenstone.gatherer.gui.ModalDialog; 52 52 import org.greenstone.gatherer.gui.SimpleMenuBar; 53 import org.greenstone.gatherer.gui.tree.WorkspaceTree;54 53 import org.greenstone.gatherer.util.ArrayTools; 55 54 import org.greenstone.gatherer.util.StaticStrings; … … 351 350 } 352 351 353 File delete_me; 354 if (Gatherer.GS3) { 355 delete_me = new File(Utility.getCollectionDir(Configuration.gsdl3_path, Configuration.site_name, collection.getShortName())); 356 } else { 357 delete_me = new File(Utility.getCollectionDir(Configuration.gsdl_path, collection.getShortName())); 358 } 359 if (Utility.delete(delete_me)) { 352 if (Gatherer.c_man.deleteCollection(collection.getShortName())) { 360 353 if (Gatherer.c_man.getCollection() != null && collection.getShortName().equals(Gatherer.c_man.getCollection().getName())) { 361 354 current_coll_deleted = true; 362 355 } 363 356 list_model.removeElement(collection); 364 365 // Refresh the collections shown in the workspace tree366 Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED);367 357 368 358 resultPrompt(true); -
trunk/gli/src/org/greenstone/gatherer/collection/DownloadJob.java
r8782 r8783 47 47 import org.greenstone.gatherer.Gatherer; 48 48 import org.greenstone.gatherer.WGet; 49 import org.greenstone.gatherer.file.WorkspaceTree; 49 50 import org.greenstone.gatherer.gui.DownloadProgressBar; 50 import org.greenstone.gatherer.gui.tree.WorkspaceTree;51 51 import org.greenstone.gatherer.util.AppendLineOnlyFileDocument; 52 52 import org.greenstone.gatherer.util.GURL; … … 486 486 } 487 487 488 public void downloadComplete(String current_file_downloading) { 488 489 public void downloadComplete(String current_file_downloading) 490 { 489 491 progress.downloadComplete(); 490 DebugStream.println("Current File: " + current_file_downloading); 491 // !! TEMPORARILY DISABLED !! 492 //WorkspaceTreeModel.refreshWebCacheMappings(); 493 // if(Gatherer.g_man.gather_pane.workspace_tree != null) { 494 // FileSystemModel tree_model = (FileSystemModel) Gatherer.g_man.gather_pane.workspace_tree.getModel(); 495 // File new_file = new File(current_file_downloading); 496 // File parent_file = new_file.getParentFile(); 497 // String download_cache = Utility.getCacheDir().getAbsolutePath(); 498 // ArrayList raw_path = new ArrayList(); 499 // while(parent_file != null && !parent_file.getAbsolutePath().equals(download_cache)) { 500 // raw_path.add(0, parent_file.getName()); 501 // parent_file = parent_file.getParentFile(); 502 // } 503 // download_cache = null; 504 // // Add download cache name 505 // /** @todo - add to dictionary */ 506 // raw_path.add(0, "Mirroring.Mirror_Cache"); 507 // // And the root node 508 // raw_path.add(0, tree_model.getRoot()); 509 // TreePath destination_path = new TreePath(raw_path.toArray()); 510 // raw_path = null; 511 // // Retrieve the destination node 512 // FileNode destination_node = (FileNode) tree_model.getNode(destination_path); 513 // // destination_path = null; 514 // //FileNode new_file_node = new FileNode(new_file); 515 516 // // It suddenly occurs to me that by retrieving the destination path, we are causing the potential destination node to map its children which includes the file which I am about to add. Hence I was ending up with two copies. 517 // ///atherer.println("Ready to insert new FileNode."); 518 // DebugStream.println("Model: " + tree_model); 519 // DebugStream.println("Destination path: " + destination_path); 520 // destination_node.unmap(); 521 // ///atherer.println("Destination node: " + destination_node); 522 // ///atherer.println("New node: " + new_file_node); 523 // //SynchronizedTreeModelTools.insertNodeInto(tree_model, destination_node, new_file_node); 524 525 // //new_file_node = null; 526 // destination_node = null; 527 // tree_model = null; 528 // } 529 // url = null; 530 // current_url = null; 531 } 492 DebugStream.println("Download complete: " + current_file_downloading); 493 } 494 532 495 533 496 /** Called by the WGet native code when the requested download returns … … 535 498 */ 536 499 public void downloadFailed() { 537 ///ystem.out.println("downloadFailed("+current_url+")"); 538 failed_urls.add(current_url); // Its the current url thats failed. 500 failed_urls.add(current_url); // It is the current url that failed 539 501 progress.downloadFailed(); 502 DebugStream.println("Download failed: " + current_url); 540 503 } 541 504 … … 546 509 } 547 510 548 /**549 * @return A String representing the currently downloading url.550 */551 /* private String getCurrent() {552 return current_url;553 } */554 511 555 512 /**
Note:
See TracChangeset
for help on using the changeset viewer.