Changeset 5847
- Timestamp:
- 2003-11-14T15:03:33+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/WGet.java
r5785 r5847 254 254 * @see org.greenstone.gatherer.util.GURL 255 255 */ 256 public void newJob( TreeModel model,boolean overwrite, boolean no_parents, boolean other_hosts, boolean page_requisites, URL url, int depth, String destination) {256 public void newJob(/* TreeModel model, */ boolean overwrite, boolean no_parents, boolean other_hosts, boolean page_requisites, URL url, int depth, String destination) { 257 257 // Create the job and fill in the details from gatherer.config. 258 258 Gatherer.println("About to create a new job"); … … 261 261 destination = destination + url.getHost(); 262 262 } 263 Job new_job = new Job( model,overwrite, Gatherer.config.get("mirroring.debug", false), no_parents, other_hosts, page_requisites, Gatherer.config.get("mirroring.quiet", false), url, depth, destination, Gatherer.config.proxy_pass, Gatherer.config.proxy_user, this, simple);263 Job new_job = new Job(/* model, */ overwrite, Gatherer.config.get("mirroring.debug", false), no_parents, other_hosts, page_requisites, Gatherer.config.get("mirroring.quiet", false), url, depth, destination, Gatherer.config.proxy_pass, Gatherer.config.proxy_user, this, simple); 264 264 // Add to job_queue job list. 265 265 job_queue.add(new_job); -
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; -
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r5833 r5847 596 596 // Force the trees to refresh (but only if there is something on screen!) 597 597 if(Gatherer.g_man != null) { 598 Gatherer.g_man.refreshTrees( );598 Gatherer.g_man.refreshTrees(DragTree.COLLECTION_CONTENTS_CHANGED); 599 599 } 600 600 // Reset status area -
trunk/gli/src/org/greenstone/gatherer/gui/CollectionPane.java
r5773 r5847 53 53 import org.greenstone.gatherer.gui.GComboBox; 54 54 import org.greenstone.gatherer.gui.tree.DragTree; 55 import org.greenstone.gatherer.gui.tree.WorkspaceTree; 55 56 import org.greenstone.gatherer.undo.UndoManager; 56 57 import org.greenstone.gatherer.util.DragComponent; … … 71 72 private DragTree collection_tree = null; 72 73 /** The tree showing the available source workspace. */ 73 private DragTree workspace_tree= null;74 private WorkspaceTree workspace_tree = null; 74 75 /** The threaded queue that handles the actually movement of files, so that the gui remains responsive. */ 75 76 private FileQueue file_queue = null; … … 243 244 collection_tree_sync.add(collection_tree); 244 245 245 refreshWorkspace(); 246 refreshWorkspaceTree(DragTree.COLLECTION_CHANGED); 247 refreshCollectionTree(DragTree.COLLECTION_CHANGED); 246 248 247 249 // Enable or disable the control buttons … … 250 252 new_folder.setEnabled(ready); 251 253 } 254 252 255 /** Generates the pane on controls used to 'collect' files into the collection. Resposible for creating, connecting and laying out these controls. */ 253 256 public void display() { … … 269 272 Dictionary.registerText(workspace_label, "Collection.Workspace"); 270 273 271 workspace = Gatherer.c_man.getWorkspace(); 272 workspace_tree = new DragTree(Utility.WORKSPACE_TREE, workspace, null, true); 274 workspace_tree = new WorkspaceTree(Utility.WORKSPACE_TREE); 273 275 group.add(workspace_tree); 274 276 workspace_tree.addFocusListener(this); … … 491 493 } 492 494 493 public DragTree getWorkspaceTree() { 494 return workspace_tree; 495 } 496 497 public void refreshTrees() { 495 496 public void refreshCollectionTree(int refresh_reason) 497 { 498 498 collection_tree.refresh(null); 499 workspace_tree.refresh(null); 500 } 501 502 public void refreshWorkspace() { 503 workspace = Gatherer.c_man.getWorkspace(); 504 workspace_tree.setModel(workspace); 505 workspace_tree_sync.add(workspace_tree); 506 } 499 } 500 501 502 public void refreshWorkspaceTree(int refresh_reason) 503 { 504 workspace_tree.refresh(refresh_reason); 505 } 506 507 508 /* public void refreshWorkspace() { 509 System.err.println("CollectionPane::refreshWorkspace()... (ignored)"); 510 // workspace = Gatherer.c_man.getWorkspace(); 511 // workspace_tree.setModel(workspace); 512 // workspace_tree_sync.add(workspace_tree); 513 } */ 507 514 508 515 -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r5842 r5847 72 72 import org.greenstone.gatherer.gui.metaaudit.MetaAuditFrame; 73 73 import org.greenstone.gatherer.gui.tree.DragTree; 74 import org.greenstone.gatherer.gui.tree.WorkspaceTree; 74 75 import org.greenstone.gatherer.help.HelpFrame; 75 76 import org.greenstone.gatherer.msm.ElementWrapper; … … 359 360 create_pane.collectionChanged(ready); // Used to indicate a new BuildOptions model should be loaded. 360 361 preview_pane.collectionChanged(ready); // preview should know when teh coll has changed so it can reload the home page 361 // Force tree model updates. 362 Gatherer.c_man.refreshTrees(); 362 363 363 if(!locked) { 364 364 // Now enable tabs as necessary. Do this on event queue to prevent crazy NPEs … … 533 533 } 534 534 535 public void refreshTrees() { 536 collection_pane.refreshTrees(); 537 //metaedit_pane.refreshTrees(); 535 public void refreshTrees(int refresh_reason) 536 { 537 collection_pane.refreshWorkspaceTree(refresh_reason); 538 collection_pane.refreshCollectionTree(refresh_reason); 539 metaedit_pane.refreshTrees(); 538 540 } 539 541 … … 580 582 // If the rawname was mirror then rebuild workspace tree to remove caches. 581 583 if(rawname.equals("Mirroring")) { 582 collection_pane.refreshWorkspace ();584 collection_pane.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED); 583 585 } 584 586 } -
trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java
r5593 r5847 208 208 if(url != null) { 209 209 // Otherwise construct a new download job 210 getter.newJob( Gatherer.c_man.getWorkspace(),overwrite_checkbox.isSelected(), !higher_checkbox.isSelected(), !same_host_checkbox.isSelected(), automatic_checkbox.isSelected(), url, ((Integer)depth_spinner.getValue()).intValue(), (public_radiobutton.isSelected() ? Utility.CACHE_DIR : Gatherer.c_man.getCollectionCache()));210 getter.newJob(/* Gatherer.c_man.getWorkspace(), */ overwrite_checkbox.isSelected(), !higher_checkbox.isSelected(), !same_host_checkbox.isSelected(), automatic_checkbox.isSelected(), url, ((Integer)depth_spinner.getValue()).intValue(), (public_radiobutton.isSelected() ? Utility.CACHE_DIR : Gatherer.c_man.getCollectionCache())); 211 211 } 212 212 } -
trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r5715 r5847 15 15 import org.greenstone.gatherer.gui.ModalDialog; 16 16 import org.greenstone.gatherer.gui.SimpleMenuBar; 17 import org.greenstone.gatherer.gui.tree.DragTree; 17 18 import org.greenstone.gatherer.util.StaticStrings; 18 19 import org.greenstone.gatherer.util.Utility; … … 428 429 // General preferences 429 430 Gatherer.config.set("general.show_file_size", Configuration.COLLECTION_SPECIFIC, show_file_size_checkbox.isSelected()); 430 Gatherer.g_man.collection_pane.refreshTrees(); 431 Gatherer.g_man.metaedit_pane.refreshTrees(); 431 Gatherer.g_man.refreshTrees(DragTree.TREE_DISPLAY_CHANGED); 432 432 433 433 Gatherer.config.set("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC, view_extracted_metadata_checkbox.isSelected()); -
trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java
r5593 r5847 54 54 static private final int AUTOSCROLL_MARGIN = 12; 55 55 56 static public int COLLECTION_CHANGED = 1; 57 static public int COLLECTION_CONTENTS_CHANGED = 2; 58 static public int TREE_DISPLAY_CHANGED = 3; 59 60 56 61 public DragTree(String name, String background_name, boolean mixed_selection) { 57 62 super(); … … 452 457 453 458 public void refresh(TreePath path) { 454 ((FileSystemModel)treeModel).refresh(path); 459 if (treeModel instanceof FileSystemModel) { 460 ((FileSystemModel)treeModel).refresh(path); 461 } 462 else { 463 // System.err.println("DragTree::refresh - Tree model is " + treeModel); 464 } 455 465 } 456 466
Note:
See TracChangeset
for help on using the changeset viewer.