Changeset 5847 for trunk/gli/src/org/greenstone/gatherer/collection
- Timestamp:
- 2003-11-14T15:03:33+13:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/collection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r5836 r5847 55 55 import org.greenstone.gatherer.gui.ExternalCollectionPrompt; 56 56 import org.greenstone.gatherer.gui.NewMetaSetPrompt; 57 import org.greenstone.gatherer.gui.tree.WorkspaceTree; 57 58 import org.greenstone.gatherer.msm.ElementWrapper; 58 59 import org.greenstone.gatherer.msm.GDMManager; … … 92 93 private boolean importing = false; 93 94 /** The collection this manager is managing! */ 94 private Collection collection = null;95 static private Collection collection = null; 95 96 /** The collection_model. */ 96 97 private FileSystemModel collection_model = null; 97 98 /** The workspace model. This becomes invalid on a collection change. */ 98 private FileSystemModel workspace_model = null;99 // private FileSystemModel workspace_model = null; 99 100 /** An inner class listener responsible for noting tree changes and resetting saved when they occur. */ 100 101 private FMTreeModelListener fm_tree_model_listener = null; … … 137 138 collection.addDirectoryMapping(name, file); 138 139 // Now update the tree 139 FileSystemModel model = (FileSystemModel) Gatherer.g_man.collection_pane.getWorkspaceTree().getModel(); 140 FileNode parent = (FileNode) model.getRoot(); 141 FileNode target = new FileNode(file, name); 142 SynchronizedTreeModelTools.insertNodeInto(model, parent, target); 140 Gatherer.g_man.collection_pane.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED); 143 141 } 144 142 } … … 207 205 collection = null; 208 206 collection_model = null; 209 workspace_model = null;207 // workspace_model = null; 210 208 undo.clear(); 211 209 Gatherer.config.setCollectionConfiguration(null); … … 420 418 // Done. 421 419 if(Gatherer.g_man != null) { 422 workspace_model = null;420 // workspace_model = null; 423 421 // set the view to Gather pane 424 422 Gatherer.g_man.setSelectedView(Gatherer.g_man.collection_pane); … … 611 609 return collection_model; 612 610 } 613 /** Create and return the model behind the workspace tree. Quite an extensive method, as it must first map known greenstone collections, then the local file system and finally any public or private download workspaces. */ 614 public TreeModel getWorkspace() { 615 ///ystem.err.println("Get Workspace"); 616 if(workspace_model != null) { 617 return workspace_model; 618 } 619 // Determine the local collection directory if any 620 String current_collection_directory = null; 621 if(collection != null) { 622 current_collection_directory = Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName(); 623 } 624 // Create the workspace tree. 625 FileNode workspace_root = new FileNode("ABS_ROOT"); 626 workspace_model = new FileSystemModel(workspace_root); 627 // Create and add Greenstone collections node. 628 // Starting at the collection directory of gsdl... 629 FileNode world_root = new FileNode(Dictionary.get("Tree.World")); 630 world_root.unmap(); 631 workspace_root.insert(world_root); 632 // Create Local File space. 633 // Get all the available roots mounted on the system. 634 File roots[] = File.listRoots(); 635 // If there is just one root use it as the tree root (linux) 636 if(roots != null) { 637 FileNode file_root; 638 String name = Dictionary.get("Tree.Root"); 639 if(roots.length == 1) { 640 file_root = new FileNode(roots[0], name); 641 workspace_root.insert(file_root); 642 } 643 // Otherwise build a dummy node which has these nodes as children. 644 else { 645 file_root = new FileNode(name); 646 workspace_root.insert(file_root); 647 // Hopefully this does an alphabetic sort. 648 ArrayTools.sort(roots); 649 for(int i = 0; i < roots.length; i++) { 650 // Only add root if it isn't a floppy drive. 651 if(!FileSystemView.getFileSystemView().isFloppyDrive(roots[i])) { 652 FileNode child_root = new FileNode(roots[i]); 653 file_root.insert(child_root); 654 child_root = null; 655 } 656 } 657 } 658 name = null; 659 file_root = null; 660 } 661 662 // Now if we can determine user home folder information, generate a 'special mapping' to it 663 String home_folder_str = System.getProperty("user.home"); 664 if(home_folder_str != null && home_folder_str.length() > 0) { 665 File home_folder = new File(home_folder_str); 666 String[] args = new String[1]; 667 args[0] = home_folder.getName(); 668 FileNode home_folder_node = new FileNode(home_folder, Dictionary.get("Tree.Home", args)); 669 workspace_root.insert(home_folder_node); 670 } 671 672 // If mirroring is enabled show the public and private caches. 673 if(Gatherer.config.get("workflow.mirror", false)) { 674 // Add Public workspace 675 FileNode public_root = new FileNode(new File(Utility.CACHE_DIR), Dictionary.get("Tree.Public")); 676 workspace_root.insert(public_root); 677 // Add Private workspace if a collection has been loaded. 678 if(ready()) { 679 FileNode private_root = new FileNode(new File(getCollectionCache()), Dictionary.get("Tree.Private")); 680 workspace_root.insert(private_root); 681 } 682 } 683 // Finally we retrieve and map any predefined special directories. 684 if(ready()) { 685 HashMap mappings = collection.getDirectoryMappings(); 686 for(Iterator names = mappings.keySet().iterator(); names.hasNext(); ) { 687 String name = (String) names.next(); 688 File file = (File) mappings.get(name); 689 FileNode special_root = new FileNode(file, name); 690 //workspace_root.insert(special_root); 691 SynchronizedTreeModelTools.insertNodeInto(workspace_model, workspace_root, special_root); 692 } 693 } 694 ///ystem.err.println("Returning for getWorkspace()"); 695 return workspace_model; 696 } 611 612 613 static public FileNode getGreenstoneCollectionsMapping() 614 { 615 FileNode greenstone_collections_node = new FileNode(Dictionary.get("Tree.World")); 616 greenstone_collections_node.unmap(); 617 return greenstone_collections_node; 618 } 619 620 621 static public FileNode[] getCollectionSpecificMappings() 622 { 623 if (!ready()) { 624 return null; 625 } 626 627 // Return any predefined special directories 628 HashMap mappings = collection.getDirectoryMappings(); 629 FileNode[] mapping_nodes = new FileNode[mappings.size()]; 630 Iterator mappings_iterator = mappings.keySet().iterator(); 631 for (int i = 0; mappings_iterator.hasNext(); i++) { 632 String mapping_name = (String) mappings_iterator.next(); 633 File mapping_file = (File) mappings.get(mapping_name); 634 mapping_nodes[i] = new FileNode(mapping_file, mapping_name); 635 } 636 637 return mapping_nodes; 638 } 639 640 697 641 /** This method when called, creates a new GShell in order to run the import.pl script. 698 642 * @see org.greenstone.gatherer.Configuration … … 855 799 // We're done. Let everyone know. 856 800 if(Gatherer.g_man != null) { 857 workspace_model = null;801 // workspace_model = null; 858 802 Gatherer.g_man.collectionChanged(ready()); 859 803 } … … 1097 1041 //} 1098 1042 // Signal collection changed. 1099 workspace_model = null;1043 // workspace_model = null; 1100 1044 Gatherer.g_man.collectionChanged(ready()); 1101 1045 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE); … … 1109 1053 * @return A <i>boolean</i> which is <i>true</i> to indicate a collection has been loaded and thus the collection is ready for editing, <i>false</i> otherwise. 1110 1054 */ 1111 public synchronized boolean ready() {1055 static public synchronized boolean ready() { 1112 1056 if(collection != null) { 1113 1057 return true; … … 1142 1086 /** Refresh the Greenstone Collections special mapping in the workspace tree to account for collections being added/removed 1143 1087 */ 1144 public void refreshGreenstoneCollections() { 1145 FileNode root = (FileNode) workspace_model.getRoot(); 1088 public void refreshGreenstoneCollections() 1089 { 1090 Gatherer.g_man.collection_pane.refreshWorkspaceTree(WorkspaceTree.COLLECTION_CHANGED); 1091 1092 /* FileNode root = (FileNode) workspace_model.getRoot(); 1146 1093 FileNode greenstone_collections_node = null; 1147 1094 int root_child_count = root.getChildCount(); … … 1161 1108 greenstone_collections_path = null; 1162 1109 greenstone_collections_node = null; 1163 } 1164 } 1165 1166 /** Called to refresh the models upon which the trees are based. 1167 * @see org.greenstone.gatherer.collection.Collection 1168 */ 1169 public void refreshTrees() { 1170 } 1110 } */ 1111 } 1112 1171 1113 /** This method associates the collection build monitor with the build monitor created in CreatePane. 1172 1114 * @param monitor A <strong>GShellProgressMonitor</strong> which we will use as the build monitor. … … 1197 1139 file = collection.removeDirectoryMapping(target.toString()); 1198 1140 // Update tree. 1199 FileSystemModel model = (FileSystemModel) Gatherer.g_man.collection_pane.getWorkspaceTree().getModel(); 1200 SynchronizedTreeModelTools.removeNodeFromParent(model, target); 1141 Gatherer.g_man.collection_pane.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED); 1201 1142 } 1202 1143 return file; -
trunk/gli/src/org/greenstone/gatherer/collection/Job.java
r5785 r5847 68 68 private GURL url = null; 69 69 70 private TreeModel model;70 // private TreeModel model; 71 71 72 72 private int depth; … … 91 91 /** 92 92 */ 93 public Job( TreeModel model,boolean clobber, boolean debug, boolean no_parents, boolean other_hosts, boolean page_requisites, boolean quiet, URL initial, int depth, String destination, String proxy_pass, String proxy_user, WGet mummy, boolean simple) {94 this.model = model;93 public Job(/* TreeModel model, */ boolean clobber, boolean debug, boolean no_parents, boolean other_hosts, boolean page_requisites, boolean quiet, URL initial, int depth, String destination, String proxy_pass, String proxy_user, WGet mummy, boolean simple) { 94 // this.model = model; 95 95 96 96 this.debug = debug;
Note:
See TracChangeset
for help on using the changeset viewer.