Changeset 8783
- Timestamp:
- 2004-12-13T12:01:25+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 4 added
- 1 deleted
- 22 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 /** -
trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r8599 r8783 41 41 import org.greenstone.gatherer.Dictionary; 42 42 import org.greenstone.gatherer.Gatherer; 43 import org.greenstone.gatherer.collection.CollectionTreeNode; 43 44 import org.greenstone.gatherer.gui.LongProgressBar; 44 45 import org.greenstone.gatherer.gui.NewFolderPrompt; … … 124 125 } 125 126 126 public void newFolder(DragTree tree, FileNode parent_node) {127 public void newFolder(DragTree tree, CollectionTreeNode parent_node) { 127 128 // Ask the user for the directories name. 128 129 NewFolderPrompt new_folder_prompt = new NewFolderPrompt(parent_node); … … 143 144 144 145 // Update the parent node to show the new folder 145 parent_node.unmap(); 146 parent_node.map(); 146 parent_node.refresh(); 147 147 148 148 // Refresh workspace tree (collection tree is done automatically) -
trunk/gli/src/org/greenstone/gatherer/file/FileNode.java
r8243 r8783 7 7 import javax.swing.filechooser.*; 8 8 import javax.swing.tree.*; 9 import org.greenstone.gatherer.Configuration;10 9 import org.greenstone.gatherer.DebugStream; 11 import org.greenstone.gatherer.Dictionary;12 import org.greenstone.gatherer.Gatherer;13 import org.greenstone.gatherer.collection.BasicCollectionConfiguration;14 import org.greenstone.gatherer.collection.Collection;15 10 import org.greenstone.gatherer.util.ArrayTools; 16 import org.greenstone.gatherer.util.StaticStrings; 17 import org.greenstone.gatherer.util.Utility; 18 19 public class FileNode 20 implements MutableTreeNode { 21 22 static final private int FALSE = 0; 23 static final private int TRUE = 1; 24 static final private int UNKNOWN = 2; 25 26 private ArrayList children; 27 private ArrayList raw_children; 28 private boolean children_readonly = true; 29 private boolean current_collection = false; 30 private boolean readonly = true; 31 private File file; 32 private FileSystemModel model; 33 private int allows_children = UNKNOWN; 34 private MutableTreeNode parent; 35 private String title; 36 private boolean gs3_site = false; 37 38 public FileNode(File file) { 39 // System.err.println("New FileNode(" + file.getAbsolutePath() + ")"); 11 12 13 public abstract class FileNode 14 implements MutableTreeNode 15 { 16 protected boolean allows_children = true; 17 protected ArrayList child_nodes = null; 18 protected ArrayList child_nodes_unfiltered = null; 19 protected File file = null; 20 protected FileSystemModel model = null; 21 protected MutableTreeNode parent = null; 22 23 protected boolean current_collection = false; 24 25 26 public FileNode(File file) 27 { 40 28 this.file = file; 41 } 42 43 public FileNode(File file, boolean readonly) { 44 this(file); 45 this.children_readonly = readonly; 46 this.readonly = readonly; 47 } 48 49 public FileNode(File file, FileSystemModel model) { 50 this(file); 51 this.model = model; 52 } 53 54 public FileNode(File file, FileSystemModel model, boolean readonly) { 55 this(file, readonly); 56 this.model = model; 57 } 58 59 public FileNode(File file, FileSystemModel model, String title) { 60 this(file, model); 61 this.title = title; 62 } 63 64 public FileNode(File file, String title) { 65 this(file); 66 this.title = title; 67 } 68 69 public FileNode(File file, String title, boolean readonly) { 70 this(file, readonly); 71 this.title = title; 72 } 73 74 public FileNode(File file, FileSystemModel model, String title, boolean readonly) { 75 this(file, model, readonly); 76 this.title = title; 77 } 78 79 /** The special 'dummy' root node, that is not based on a particular file, but instead holds several special directory mappings. */ 80 public FileNode(String title) { 81 this.children = new ArrayList(); 82 this.title = title; 83 } 84 85 /** Returns the children of the receiver as an Enumeration. */ 86 public Enumeration children() { 29 30 // Files cannot have children 31 if (file != null && file.isFile()) { 32 // Cache this result to prevent unceasing missing disk messages being thrown if the 33 // removable media was, um, removed after directory mapped 34 this.allows_children = false; 35 } 36 } 37 38 39 /** Returns the children of the node as an Enumeration. */ 40 public Enumeration children() 41 { 87 42 return new FileEnumeration(); 88 43 } 89 44 90 /** Compare two filenodes for equality. */ 91 public boolean equals(FileNode node) { 92 boolean result = false; 93 if(node != null) { 94 if(file != null) { 95 result = (file.equals(node.getFile())); 96 } 97 else { 98 result = toString().equals(node.toString()); 99 } 100 } 101 return result; 102 } 103 104 /** Retrieve the filenode at the given index, regardless of filters set. 105 * @param index int 106 */ 107 public FileNode get(int index) { 108 if(0 <= index && index < size() && file != null) { 109 return (FileNode) raw_children.get(index); 110 } 111 return null; 112 } 113 114 /** Returns true if the receiver allows children. We have to cache the result of this call to prevent unceasing missing disk messages being thrown if the removable media was, um, removed after directory mapped. */ 115 public boolean getAllowsChildren() { 116 if(readonly) { 117 if(allows_children == UNKNOWN) { 118 // If the file is non-null but doesn't exist (as is the case for removable media), return true anyway. 119 if(file != null) { 120 if(isFileSystemRoot()) { 121 allows_children = TRUE; 122 } 123 else if(file.exists() && file.isDirectory()) { 124 allows_children = TRUE; 125 } 126 // Any mapped directories always allow children. 127 else if(getParent() != null && getParent().getParent() == null) { 128 allows_children = TRUE; 129 } 130 else { 131 allows_children = FALSE; 132 } 133 } 134 // Allows children is always true for dummy nodes. 135 else { 136 allows_children = TRUE; 137 } 138 } 139 return (allows_children == TRUE); 140 } 141 else { 142 return (file == null || file.isDirectory()); 143 } 144 } 145 45 46 /** Returns true if the receiver allows children. */ 47 public boolean getAllowsChildren() 48 { 49 return allows_children; 50 } 51 52 146 53 /** Returns the child TreeNode at index childIndex. */ 147 public TreeNode getChildAt(int index) { 148 TreeNode result = null; 149 map(); 150 if(0 <= index && index < children.size()) { 151 result = (TreeNode) children.get(index); 152 } 153 else { 154 result = new DefaultMutableTreeNode("Error"); 155 } 156 ///ystem.err.println(this + ".getChildAt(" + index + ") = " + result); 157 return result; 158 } 54 public TreeNode getChildAt(int index) 55 { 56 return (TreeNode) child_nodes.get(index); 57 } 58 159 59 160 60 /** Returns the number of children TreeNodes the receiver contains. */ 161 public int getChildCount() { 61 public int getChildCount() 62 { 162 63 int size = 0; 163 // We don't automatically map if this is a system root, or we risk the 50,000 Disk not found error messages of death. 164 if(isFileSystemRoot()) { 165 size = 1; // Size is always non-zero for a system root 64 65 // We don't map if this is a system root, or we risk the 50,000 Disk not found error messages of death 66 if (isFileSystemRoot()) { 67 size = 1; // Size is always non-zero for a system root 166 68 } 167 69 else { 168 70 map(); 169 71 } 170 if(children != null) { 171 size = children.size(); 172 } 173 ///ystem.err.println(this + ".getChildCount() = " + size); 72 73 // Use the number of (filtered) child nodes 74 if (child_nodes != null) { 75 size = child_nodes.size(); 76 } 77 174 78 return size; 175 79 } 80 81 82 /** Returns the index of node in the receivers children. */ 83 public int getIndex(TreeNode node) 84 { 85 return child_nodes.indexOf(node); 86 } 87 88 89 /** Returns the parent TreeNode of the receiver. */ 90 public TreeNode getParent() 91 { 92 return parent; 93 } 94 95 96 /** Adds child to the receiver at index. */ 97 public void insert(MutableTreeNode child, int index) 98 { 99 DebugStream.println("Insert " + child + " in " + this + " at index " + index + " [Model: " + model + "]"); 100 if (child == null) { 101 return; 102 } 103 104 try { 105 FileNode child_node = (FileNode) child; 106 child_nodes.add(index, child_node); 107 child_node.model = model; 108 child_node.parent = this; 109 } 110 catch (Exception exception) { 111 DebugStream.printStackTrace(exception); 112 } 113 } 114 115 116 /** Returns true if the receiver is a leaf. */ 117 public boolean isLeaf() 118 { 119 return (allows_children == false); 120 } 121 122 123 /** Removes the child at index from the receiver. */ 124 public void remove(int index) 125 { 126 if (index >= 0 && index < child_nodes.size()) { 127 child_nodes.remove(index); 128 } 129 } 130 131 132 /** Removes node from the receiver. */ 133 public void remove(MutableTreeNode node) 134 { 135 remove(getIndex(node)); 136 } 137 138 139 /** Removes the receiver from its parent. */ 140 public void removeFromParent() 141 { 142 parent.remove(this); 143 parent = null; 144 } 145 146 147 /** Resets the user object of the receiver to object. */ 148 public void setUserObject(Object object) { 149 try { 150 file = (File) object; 151 } 152 catch (Exception exception) { 153 DebugStream.printStackTrace(exception); 154 } 155 } 156 157 158 // ------------------------------------------------------------------------------- 159 160 161 protected abstract FileNode addChildNode(File file); 162 163 164 /** Compare two FileNodes for equality. */ 165 public boolean equals(FileNode node) 166 { 167 if (node == null) { 168 // Definitely not a match 169 return false; 170 } 171 172 if (file != null) { 173 return file.equals(node.getFile()); 174 } 175 else { 176 return toString().equals(node.toString()); 177 } 178 } 179 180 181 /** Retrieve the file node at the given index, regardless of filters set. */ 182 public FileNode getChildAtUnfiltered(int index) 183 { 184 if (index >= 0 && index < size()) { 185 return (FileNode) child_nodes_unfiltered.get(index); 186 } 187 return null; 188 } 189 176 190 177 191 public File getFile() { … … 179 193 } 180 194 181 /** Returns the index of node in the receivers children. */182 public int getIndex(TreeNode node) {183 map();184 return children.indexOf(node);185 }186 187 /** Returns the parent TreeNode of the receiver. */188 public TreeNode getParent() {189 return parent;190 }191 195 192 196 /** Retrieves the tree path from the root node to this node. */ … … 208 212 } 209 213 214 210 215 public void insert(MutableTreeNode child) { 211 insert(child, children.size()); 212 } 213 214 /** Adds child to the receiver at index. */ 215 public void insert(MutableTreeNode child, int index) { 216 DebugStream.println("Insert " + child + " in " + this + " at index " + index + " [Model: " + model + "]"); 217 if (child == null) { 218 return; 219 } 220 try { 221 children.add(index, child); 222 // Set parent and model. 223 FileNode new_child = (FileNode) child; 224 new_child.setModel(model); 225 new_child.setParent(this); 226 new_child.setReadOnly(readonly); 227 } 228 catch(Exception error) { 229 error.printStackTrace(); 230 } 231 } 216 insert(child, child_nodes.size()); 217 } 218 219 220 public boolean isFileSystemRoot() { 221 if (file != null) { 222 return FileSystemView.getFileSystemView().isFileSystemRoot(file); 223 } 224 else { 225 return false; 226 } 227 } 228 232 229 233 230 /** Is this file node within the currently open collection? */ 234 231 public boolean isInCurrentCollection() { 235 if (current_collection) {232 if (current_collection) { 236 233 return true; 237 234 } 238 235 else { 239 236 FileNode parent = (FileNode) getParent(); 240 if (parent != null) {237 if (parent != null) { 241 238 return parent.isInCurrentCollection(); 242 239 } … … 245 242 } 246 243 247 /** Returns true if the receiver is a leaf. */ 248 public boolean isLeaf() { 249 return !getAllowsChildren(); 250 } 251 252 public boolean isReadOnly() { 253 return readonly; 254 } 255 256 public boolean isFileSystemRoot() { 257 boolean result = false; 258 if(file != null) { 259 result = FileSystemView.getFileSystemView().isFileSystemRoot(file); 260 } 261 return result; 262 } 263 264 public void map() { 265 if(children != null) { 244 245 /** Overridden if necessary by subclasses. */ 246 public boolean isReadOnly() 247 { 248 return false; 249 } 250 251 252 public void map() 253 { 254 // If this node has already been mapped, don't bother doing it again 255 if (child_nodes != null) { 266 256 return; 267 257 } 268 children = new ArrayList(); 269 // 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. 270 if(file == null) { // a special mapping folder 271 if (title.equals(Dictionary.get("Tree.World")) && Gatherer.GS3) { 272 // the Greenstone collections folder for GS3 - this contains a 273 // folder for each site 274 File start = new File(Utility.getSitesDir(Configuration.gsdl3_path)); 275 File sites[] = start.listFiles(); 276 ArrayTools.sort(sites); 277 for (int i=0; sites != null && i < sites.length; i++) { 278 //File site = sites[i]; 279 File collect_dir = new File(sites[i], Utility.COL_DIR); 280 if(!collect_dir.exists()) { 281 continue; 258 child_nodes = new ArrayList(); 259 260 // General case, only map if children are allowed 261 if (file != null && getAllowsChildren()) { 262 File[] files = file.listFiles(); 263 if (files != null && files.length > 0) { 264 // Sort the child files 265 ArrayTools.sort(files); 266 267 // Now add them to child_nodes_unfiltered 268 child_nodes_unfiltered = new ArrayList(); 269 for (int i = 0; i < files.length; i++) { 270 child_nodes_unfiltered.add(this.addChildNode(files[i])); 271 } 272 273 // Apply the filters set in the model 274 FileFilter[] filters = model.getFilters(); 275 for (int i = 0; filters != null && i < filters.length; i++) { 276 files = ArrayTools.filter(files, filters[i].filter, filters[i].exclude); 277 } 278 279 // Add the files left after filtering to child_nodes 280 for (int i = 0; i < files.length; i++) { 281 FileNode child_node = this.addChildNode(files[i]); 282 int index = -1; 283 if ((index = child_nodes_unfiltered.indexOf(child_node)) != -1) { 284 child_nodes.add(child_nodes_unfiltered.get(index)); 282 285 } 283 284 FileNode child = new FileNode(sites[i].getName()); 285 child.setGS3Site(true); 286 child.unmap(); 287 child.setParent(this); 288 child.setModel(model); 289 child.map(); 290 children.add(child); 291 } 292 293 } else if (title.equals(Dictionary.get("Tree.World")) || gs3_site) { 294 // the collect dir for gs2 or a site dir for gs3 295 ///atherer.println("Map the 'Greenstone Collections' node."); 296 // For each of the children directories, which are collections... 297 File start; 298 if (gs3_site) { 299 start = new File(Utility.getCollectDir(Configuration.gsdl3_path, title)); 300 } else { 301 start = new File(Utility.getCollectDir(Configuration.gsdl_path)); 302 } 303 File cols[] = start.listFiles(); 304 ArrayTools.sort(cols); 305 // We add their import directories, except for the model collection 306 for(int i = 0; cols != null && i < cols.length; i++) { 307 if (!cols[i].getName().equals(StaticStrings.MODEL_COLLECTION_NAME)) { 308 //File dirs[] = cols[i].listFiles(); 309 //ArrayTools.sort(dirs); 310 File import_dir = new File(cols[i], StaticStrings.IMPORT_FOLDER); 311 if(!import_dir.exists()) { 312 continue; 313 } 314 // we don't care if there is no config file 315 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(cols[i], Utility.CONFIG_FILE)); 316 FileNode collection_root = new FileNode(import_dir, collect_cfg.toString(), true); 317 collection_root.setParent(this); 318 collection_root.setModel(model); 319 // One last piece of magic so we can determine the current collection 320 Collection collection = Gatherer.c_man.getCollection(); 321 if(collection != null) { 322 collection_root.setCurrentCollection(cols[i].getName().equals(collection.getName())); 323 } 324 children.add(collection_root); 325 collection_root = null; 326 import_dir = null; 327 //dirs = null; 328 } 329 } // for each coll 330 cols = null; 331 model.nodeStructureChanged(this); 332 } 333 } // if file == null 334 // General case: Only map if there are no children. 335 else { // file !=null 336 if(getAllowsChildren()) { 337 File[] files = file.listFiles(); 338 if(files != null && files.length > 0) { 339 // Sort the remaining files. 340 DebugStream.println("Number of files to sort: " + files.length); 341 ArrayTools.sort(files); 342 DebugStream.println("Files sorted."); 343 // Now add them to children. 344 raw_children = new ArrayList(); 345 for(int i = 0; i < files.length; i++) { 346 FileNode child = new FileNode(files[i], model, children_readonly); 347 child.setParent(this); 348 raw_children.add(child); 349 } 350 351 // Apply the filters set in the model. 352 //if(model != null) { 353 FileFilter[] filters = model.getFilters(); 354 for(int i = 0; filters != null && i < filters.length; i++) { 355 files = ArrayTools.filter(files, filters[i].filter, filters[i].exclude); 356 } 357 //} 358 359 // Now add them to children. 360 for(int i = 0; i < files.length; i++) { 361 FileNode child = new FileNode(files[i], model, children_readonly); 362 int index = -1; 363 if((index = raw_children.indexOf(child)) != -1) { 364 children.add(raw_children.get(index)); 365 } 366 else { 367 child.setParent(this); 368 children.add(child); 369 } 286 else { 287 child_nodes.add(child_node); 370 288 } 371 289 } 372 model.nodeStructureChanged(this);373 290 } 374 } 375 376 } 377 378 /** Removes the child at index from the receiver. */ 379 public void remove(int index) { 380 if(0 <= index && index < children.size()) { 381 children.remove(index); 382 } 383 } 384 385 /** Removes node from the receiver. */ 386 public void remove(MutableTreeNode node){ 387 int index = getIndex(node); 388 if(index != -1) { 389 children.remove(index); 390 } 391 } 392 393 /** Removes the receiver from its parent. */ 394 public void removeFromParent() { 395 parent.remove(this); 396 parent = null; 397 } 291 292 model.nodeStructureChanged(this); 293 } 294 } 295 296 297 public void refresh() 298 { 299 unmap(); 300 map(); 301 } 302 398 303 399 304 public void setCurrentCollection(boolean current_collection) { … … 401 306 } 402 307 403 public void setFile(File file) {404 this.file = file;405 }406 407 public void setGS3Site(boolean is_site) {408 this.gs3_site = is_site;409 }410 411 308 public void setModel(FileSystemModel model) { 412 309 this.model = model; … … 417 314 } 418 315 419 public void setReadOnly(boolean readonly) { 420 this.readonly = readonly; 421 } 422 423 /** Resets the user object of the receiver to object. */ 424 public void setUserObject(Object object) { 425 try { 426 file = (File) object; 427 title = null; 428 } 429 catch(Exception error) { 430 error.printStackTrace(); 431 } 432 } 433 434 /** Retrieve the total number of child files for the file this node represents, irrespective of filters set 435 * @return int 436 */ 316 317 /** Return the total number of child files for the file this node represents, irrespective of filters set. */ 437 318 public int size() { 438 if (raw_children!= null) {439 return raw_children.size();319 if (child_nodes_unfiltered != null) { 320 return child_nodes_unfiltered.size(); 440 321 } 441 322 return 0; 442 323 } 443 324 444 public String toString() { 445 if(title == null) { 446 if(isFileSystemRoot()) { 447 title = file.getAbsolutePath(); 448 } 449 else { 450 title = file.getName(); 451 } 452 } 453 return title; 454 } 455 456 /** Unmap this nodes children. */ 457 public void unmap() { 458 // You cannot unmap nodes that have no file basis. 459 if(file != null || title.equals(Dictionary.get("Tree.World")) || gs3_site) { 460 ///atherer.println("Unmap: " + this); 461 children = null; 462 raw_children = null; 463 } 464 else { 465 ///ystem.err.println("No file for " + this + " - can't unmap."); 466 } 467 } 468 469 470 public void refresh() 471 { 472 unmap(); 473 map(); 325 326 public String toString() 327 { 328 if (isFileSystemRoot()) { 329 return file.getAbsolutePath(); 330 } 331 else { 332 return file.getName(); 333 } 334 } 335 336 337 /** Unmap this node's children. */ 338 public void unmap() 339 { 340 System.err.println("Unmapping " + this + "..."); 341 child_nodes_unfiltered = null; 342 child_nodes = null; 474 343 } 475 344 476 345 477 346 private class FileEnumeration 478 implements Enumeration { 347 implements Enumeration 348 { 479 349 private int index = 0; 350 480 351 /** Tests if this enumeration contains more elements. */ 481 352 public boolean hasMoreElements() { 482 return (index < children.size()); 483 } 353 return (index < child_nodes.size()); 354 } 355 484 356 /** Returns the next element of this enumeration if this enumeration object has at least one more element to provide. */ 485 357 public Object nextElement() { 486 358 Object result = null; 487 if (index < children.size()) {488 result = child ren.get(index);359 if (index < child_nodes.size()) { 360 result = child_nodes.get(index); 489 361 index++; 490 362 } -
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r8652 r8783 36 36 import org.greenstone.gatherer.Dictionary; 37 37 import org.greenstone.gatherer.Gatherer; 38 import org.greenstone.gatherer.collection.CollectionTreeNode; 38 39 import org.greenstone.gatherer.gui.LongProgressBar; 39 40 import org.greenstone.gatherer.gui.tree.DragTree; … … 257 258 if(destination_node != null) { 258 259 TreePath destination_path = new TreePath(destination_node.getPath()); 259 FileNode temp_target_node = new FileNode(target_file, target_model, true);260 CollectionTreeNode temp_target_node = new CollectionTreeNode(target_file); // !!! , target_model, true); 260 261 TreePath target_path = destination_path.pathByAddingChild(temp_target_node); 261 262 SynchronizedTreeModelTools.removeNodeFromParent(target_model, target_model.getNode(target_path)); … … 353 354 if (!cancel_action) { 354 355 // Create a dummy FileNode with the correct structure (so getPath works) 355 new_node = new FileNode(target_file);356 new_node = new CollectionTreeNode(target_file); 356 357 SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, new_node); 357 358 } … … 360 361 else if(source_file.isDirectory()) { 361 362 // create new record 362 FileNode directory_record = new FileNode(target_file);363 CollectionTreeNode directory_record = new CollectionTreeNode(target_file); 363 364 SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, directory_record); 364 365 // Why is this not happening eh? … … 408 409 for (int i = 0; i < assigned_metadata.size(); i++) { 409 410 MetadataValue metadata_value = (MetadataValue) assigned_metadata.get(i); 410 MetadataXMLFileManager.removeMetadata( origin_node, metadata_value);411 MetadataXMLFileManager.addMetadata( new_node, metadata_value);411 MetadataXMLFileManager.removeMetadata((CollectionTreeNode) origin_node, metadata_value); 412 MetadataXMLFileManager.addMetadata((CollectionTreeNode) new_node, metadata_value); 412 413 } 413 414 } … … 417 418 for (int i = 0; i < assigned_metadata.size(); i++) { 418 419 MetadataValue metadata_value = (MetadataValue) assigned_metadata.get(i); 419 MetadataXMLFileManager.addMetadata( new_node, metadata_value);420 MetadataXMLFileManager.addMetadata((CollectionTreeNode) new_node, metadata_value); 420 421 } 421 422 } … … 453 454 for (int i = 0; i < assigned_metadata.size(); i++) { 454 455 MetadataValue metadata_value = (MetadataValue) assigned_metadata.get(i); 455 MetadataXMLFileManager.removeMetadata( origin_node, metadata_value);456 MetadataXMLFileManager.removeMetadata((CollectionTreeNode) origin_node, metadata_value); 456 457 } 457 458 … … 472 473 origin_node.refresh(); 473 474 for(int i = 0; i < origin_node.size(); i++) { 474 FileNode child_record = (FileNode) origin_node.get (i);475 FileNode child_record = (FileNode) origin_node.getChildAtUnfiltered(i); 475 476 ///atherer.println("Queuing: " + child_record); 476 477 addJob(job.ID(), job.source, child_record, job.target, destination_node, FileJob.DELETE, false, position); -
trunk/gli/src/org/greenstone/gatherer/file/FileSystem.java
r8243 r8783 11 11 public class FileSystem 12 12 { 13 static public FileNode getLocalFilespaceNode(FileSystemModel model)13 static public WorkspaceTreeNode getLocalFilespaceNode(FileSystemModel model) 14 14 { 15 FileNode file_system_root = null;15 WorkspaceTreeNode file_system_root = null; 16 16 17 17 // Get all the available roots mounted on the filesystem … … 23 23 // If there is just one root use it as the tree root (Linux) 24 24 if (roots.length == 1) { 25 file_system_root = new FileNode(roots[0], Dictionary.get("Tree.Root"));25 file_system_root = new WorkspaceTreeNode(roots[0], Dictionary.get("Tree.Root")); 26 26 } 27 27 28 28 // Otherwise build a dummy node which has the roots as children 29 29 else { 30 file_system_root = new FileNode(Dictionary.get("Tree.Root"));30 file_system_root = new WorkspaceTreeNode(null, Dictionary.get("Tree.Root")); 31 31 file_system_root.setModel(model); 32 32 … … 36 36 // Only add root if it isn't a floppy drive 37 37 if (!FileSystemView.getFileSystemView().isFloppyDrive(roots[i])) { 38 file_system_root.insert(new FileNode(roots[i]));38 file_system_root.insert(new WorkspaceTreeNode(roots[i])); 39 39 } 40 40 } … … 45 45 46 46 47 static public FileNode getHomeFolderNode()47 static public WorkspaceTreeNode getHomeFolderNode() 48 48 { 49 49 // Get the name of the OS we're running on … … 68 68 // Generate a special mapping to the user home folder 69 69 File home_folder = new File(home_folder_str); 70 return new FileNode(home_folder, Dictionary.get("Tree.Home", home_folder.getName()));70 return new WorkspaceTreeNode(home_folder, Dictionary.get("Tree.Home", home_folder.getName())); 71 71 } 72 72 73 73 74 static public FileNode getDownloadedFilesNode()74 static public WorkspaceTreeNode getDownloadedFilesNode() 75 75 { 76 return new FileNode(Utility.getCacheDir(), "Downloaded Files");76 return new WorkspaceTreeNode(Utility.getCacheDir(), "Downloaded Files"); 77 77 } 78 78 } -
trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java
r8243 r8783 7 7 import javax.swing.tree.*; 8 8 import org.greenstone.gatherer.DebugStream; 9 import org.greenstone.gatherer.Dictionary;10 9 import org.greenstone.gatherer.Gatherer; 11 10 import org.greenstone.gatherer.gui.tree.DragTree; … … 14 13 public class FileSystemModel 15 14 extends DefaultTreeModel 16 implements TreeExpansionListener, TreeWillExpandListener { 17 18 private int counter = 0; 19 private DragTree tree; 20 private FileFilter current_filter; 21 private FileFilter[] filters; 15 implements TreeExpansionListener, TreeWillExpandListener 16 { 17 private DragTree tree = null; 18 private FileFilter current_filter = null; 19 private FileFilter[] filters = null; 22 20 /** The filters in place for any file system model. */ 23 21 private FileFilter[] default_filters = { new FileFilter("\\..*", true), new FileFilter("metadata\\.xml", true) }; … … 25 23 public FileSystemModel(FileNode root) { 26 24 super(root); 27 current_filter = null;28 filters = null;29 tree = null;30 25 root.setModel(this); 31 26 root.map(); … … 68 63 DebugStream.print("Searching for '" + stale_object + "': "); 69 64 // Locate the fresh node by searching current's children. Remember to ensure that current is mapped. 70 //current.unmap();71 65 boolean found = false; 72 66 … … 84 78 // Failing that we search through all the children, including filtered files 85 79 for(int j = 0; !found && j < current.size(); j++) { 86 FileNode child_node = (FileNode) current.get (j);80 FileNode child_node = (FileNode) current.getChildAtUnfiltered(j); 87 81 DebugStream.print(child_node + " "); 88 82 if((stale_node != null && stale_node.equals(child_node)) || stale_object.toString().equals(child_node.toString())) { … … 110 104 ///ystem.err.println("insertNodeInto(" + newChild + ", " + parent + ", " + index + ")"); 111 105 super.insertNodeInto(newChild, parent, index); 112 }113 114 public void mapDirectory(File directory, String title) {115 FileNode node = new FileNode(directory, this, title, true);116 SynchronizedTreeModelTools.insertNodeInto(this, (FileNode)root, node);117 106 } 118 107 … … 236 225 TreePath path = event.getPath(); 237 226 FileNode node = (FileNode) path.getLastPathComponent(); 238 ///ystem.err.println("Unmap: " + node);239 227 node.unmap(); 240 228 // Fire the appropriate event. … … 255 243 } 256 244 } 257 245 258 246 /** Invoked whenever a node in the tree is about to be expanded. */ 259 247 public void treeWillExpand(TreeExpansionEvent event) -
trunk/gli/src/org/greenstone/gatherer/file/RecycleBin.java
r8670 r8783 80 80 setOpaque(true); 81 81 82 this.model = new FileSystemModel(new FileNode(new File(Utility.getGLIUserFolder(), "recycle"), "Undo"));82 this.model = new FileSystemModel(new RecycleBinNode(new File(Utility.getGLIUserFolder(), "recycle"))); 83 83 } 84 84 … … 174 174 this.group = group; 175 175 } 176 177 178 public class RecycleBinNode 179 extends FileNode 180 { 181 public RecycleBinNode(File file) 182 { 183 super(file); 184 } 185 186 public FileNode addChildNode(File file) { return null; } 187 188 public void map() { } 189 } 176 190 } -
trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeModel.java
r8243 r8783 1 /** 2 *############################################################################ 3 * A component of the Greenstone Librarian Interface, part of the Greenstone 4 * digital library suite from the New Zealand Digital Library Project at the 5 * University of Waikato, New Zealand. 6 * 7 * Author: Michael Dewsnip, NZDL Project, University of Waikato, NZ 8 * 9 * Copyright (C) 2004 New Zealand Digital Library Project 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 *############################################################################ 25 */ 26 1 27 package org.greenstone.gatherer.file; 2 28 29 import java.io.*; 30 import java.util.*; 3 31 import javax.swing.tree.TreePath; 32 import org.greenstone.gatherer.Configuration; 4 33 import org.greenstone.gatherer.DebugStream; 34 import org.greenstone.gatherer.Dictionary; 5 35 import org.greenstone.gatherer.Gatherer; 6 import org.greenstone.gatherer.collection.CollectionManager;7 import org.greenstone.gatherer.gui.MirrorPane;8 36 import org.greenstone.gatherer.util.SynchronizedTreeModelTools; 9 37 10 38 11 39 public class WorkspaceTreeModel 12 extends FileSystemModel { 40 extends FileSystemModel 41 { 42 static private WorkspaceTreeModel workspace_tree_model = null; 43 static private WorkspaceTreeNode workspace_tree_root = null; 13 44 14 static private FileNode workspace_tree_root = null; 15 static private WorkspaceTreeModel workspace_tree_model = null; 16 17 static private FileNode greenstone_collections_node = null; 18 static private FileNode local_filespace_node = null; 19 static private FileNode downloaded_files_node = null; 20 static private FileNode[] folder_shortcuts = null; 45 static private WorkspaceTreeNode greenstone_collections_node = null; 46 static private WorkspaceTreeNode local_filespace_node = null; 47 static private WorkspaceTreeNode downloaded_files_node = null; 48 static private WorkspaceTreeNode[] folder_shortcuts = null; 21 49 22 50 23 public WorkspaceTreeModel( FileNode root)51 public WorkspaceTreeModel(WorkspaceTreeNode root_node) 24 52 { 25 super(root); 53 super(root_node); 54 } 55 56 57 static public WorkspaceTreeNode[] getFolderShortcuts() 58 { 59 // Return any predefined special directories 60 HashMap mappings = Configuration.getDirectoryMappings(); 61 WorkspaceTreeNode[] mapping_nodes = new WorkspaceTreeNode[mappings.size()]; 62 Iterator mappings_iterator = mappings.keySet().iterator(); 63 for (int i = 0; mappings_iterator.hasNext(); i++) { 64 String mapping_name = (String) mappings_iterator.next(); 65 File mapping_file = (File) mappings.get(mapping_name); 66 mapping_nodes[i] = new WorkspaceTreeNode(mapping_file, mapping_name); 67 } 68 return mapping_nodes; 26 69 } 27 70 … … 30 73 { 31 74 // Create a root node to contain the various nodes in the workspace tree 32 workspace_tree_root = new FileNode("ABS_ROOT");75 workspace_tree_root = new WorkspaceTreeNode(null, "ABS_ROOT"); 33 76 workspace_tree_model = new WorkspaceTreeModel(workspace_tree_root); 34 77 35 78 // Add the "Documents in Greenstone Collections" node 36 greenstone_collections_node = CollectionManager.getGreenstoneCollectionsMapping();79 greenstone_collections_node = new WorkspaceTreeNode(null, Dictionary.get("Tree.World")); 37 80 workspace_tree_root.insert(greenstone_collections_node); 38 81 … … 72 115 { 73 116 // Check for new/deleted folder shortcuts 74 FileNode[] old_folder_shortcuts = folder_shortcuts;75 folder_shortcuts = CollectionManager.getFolderShortcuts();117 WorkspaceTreeNode[] old_folder_shortcuts = folder_shortcuts; 118 folder_shortcuts = getFolderShortcuts(); 76 119 77 120 // Remove any deleted shortcuts from the tree … … 80 123 if (!doesArrayContain(folder_shortcuts, old_folder_shortcuts[i])) { 81 124 DebugStream.println("Deleted shortcut: " + old_folder_shortcuts[i]); 82 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model, 83 old_folder_shortcuts[i]); 125 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model, old_folder_shortcuts[i]); 84 126 } 85 127 } … … 109 151 // Refresh each of the nodes in the workspace tree 110 152 for (int i = 0; i < workspace_tree_root.getChildCount(); i++) { 111 FileNode child_node = (FileNode) workspace_tree_root.getChildAt(i);153 WorkspaceTreeNode child_node = (WorkspaceTreeNode) workspace_tree_root.getChildAt(i); 112 154 super.refresh(new TreePath(child_node.getPath())); 113 155 } … … 115 157 // Refresh the local filespace tree specially (it is not unmapped so not refreshed) 116 158 for (int i = 0; i < local_filespace_node.getChildCount(); i++) { 117 FileNode child_node = (FileNode) local_filespace_node.getChildAt(i);159 WorkspaceTreeNode child_node = (WorkspaceTreeNode) local_filespace_node.getChildAt(i); 118 160 super.refresh(new TreePath(child_node.getPath())); 119 161 } -
trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java
r8695 r8783 51 51 import org.greenstone.gatherer.Gatherer; 52 52 import org.greenstone.gatherer.collection.CollectionManager; 53 import org.greenstone.gatherer. file.FileNode;53 import org.greenstone.gatherer.collection.CollectionTreeNode; 54 54 import org.greenstone.gatherer.gui.tree.DragTree; 55 55 import org.greenstone.gatherer.metadata.MetadataElement; … … 103 103 private Filter filter = null; 104 104 /** The currently reported selection. */ 105 private FileNode[] file_nodes = null;105 private CollectionTreeNode[] file_nodes = null; 106 106 /** The button, which when clicked, adds metadata to the selected records. */ 107 107 private JButton add; … … 493 493 else { 494 494 TreePath paths[] = collection_tree.getSelectionPaths(); 495 file_nodes = new FileNode[paths.length];495 file_nodes = new CollectionTreeNode[paths.length]; 496 496 for (int i = 0; i < paths.length; i++) { 497 file_nodes[i] = ( FileNode) paths[i].getLastPathComponent();497 file_nodes[i] = (CollectionTreeNode) paths[i].getLastPathComponent(); 498 498 } 499 499 … … 1369 1369 TreePath path = tree.getLeadSelectionPath(); 1370 1370 if(path != null) { 1371 File file = (( FileNode)path.getLastPathComponent()).getFile();1371 File file = ((CollectionTreeNode) path.getLastPathComponent()).getFile(); 1372 1372 if(file != null) { 1373 1373 if (file.isFile() || vk_left_pressed) { … … 1394 1394 TreePath path = tree.getLeadSelectionPath(); 1395 1395 if(path == null) return; 1396 File file = (( FileNode)path.getLastPathComponent()).getFile();1396 File file = ((CollectionTreeNode) path.getLastPathComponent()).getFile(); 1397 1397 if(file == null) return; 1398 1398 … … 1431 1431 private TreePath[] selection_paths = null; 1432 1432 /** The file record over which the right click action occurred. */ 1433 private FileNode node = null;1433 private CollectionTreeNode node = null; 1434 1434 1435 1435 private JMenuItem collapse_folder = null; … … 1475 1475 1476 1476 TreePath path = selection_paths[0]; 1477 node = ( FileNode) path.getLastPathComponent();1477 node = (CollectionTreeNode) path.getLastPathComponent(); 1478 1478 1479 1479 // ---- Options for file nodes ---- -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r8634 r8783 56 56 import org.greenstone.gatherer.collection.DeleteCollectionPrompt; 57 57 import org.greenstone.gatherer.collection.ExportCollectionPrompt; 58 import org.greenstone.gatherer.file.FileNode;59 58 import org.greenstone.gatherer.file.FileOpenActionListener; 60 59 import org.greenstone.gatherer.gui.metaaudit.MetaAuditFrame; 61 60 import org.greenstone.gatherer.gui.tree.DragTree; 62 import org.greenstone.gatherer.gui.tree.WorkspaceTree;63 61 import org.greenstone.gatherer.util.StaticStrings; 64 62 import org.greenstone.gatherer.util.TreeSynchronizer; -
trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java
r8600 r8783 48 48 import org.greenstone.gatherer.Dictionary; 49 49 import org.greenstone.gatherer.Gatherer; 50 import org.greenstone.gatherer.collection.CollectionTreeNode; 50 51 import org.greenstone.gatherer.collection.CollectionManager; 51 52 import org.greenstone.gatherer.file.FileNode; … … 54 55 import org.greenstone.gatherer.file.FileSystemModel; 55 56 import org.greenstone.gatherer.file.RecycleBin; 57 import org.greenstone.gatherer.file.WorkspaceTree; 58 import org.greenstone.gatherer.file.WorkspaceTreeNode; 56 59 import org.greenstone.gatherer.gui.tree.DragTree; 57 import org.greenstone.gatherer.gui.tree.WorkspaceTree;58 60 import org.greenstone.gatherer.util.DragComponent; 59 61 import org.greenstone.gatherer.util.DragGroup; … … 178 180 if(count == 1) { 179 181 TreePath path = collection_tree.getSelectionPath(); 180 FileNode node = (FileNode) path.getLastPathComponent();181 if (node.getAllowsChildren()) {182 CollectionTreeNode node = (CollectionTreeNode) path.getLastPathComponent(); 183 if (node.getAllowsChildren()) { 182 184 Gatherer.f_man.newFolder(collection_tree, node); 183 185 } 184 186 else { 185 187 // try the parent 186 FileNode parent = (FileNode)node.getParent();188 CollectionTreeNode parent = (CollectionTreeNode) node.getParent(); 187 189 if (parent!=null && parent.getAllowsChildren()) { 188 190 Gatherer.f_man.newFolder(collection_tree, parent); … … 197 199 if(error) { 198 200 // instead of an error, we now create a new folder at the root 199 FileNode node = (FileNode) collection_tree.getModel().getRoot();201 CollectionTreeNode node = (CollectionTreeNode) collection_tree.getModel().getRoot(); 200 202 Gatherer.f_man.newFolder(collection_tree, node); 201 203 } … … 390 392 public void gainFocus() { 391 393 // Update the meta-audit view to show the current selection, if any. 392 Gatherer.g_man.meta_audit.setRecords(getSelected()); 393 } 394 395 /** Retrieve a list of the currently selected file records in the active tree. */ 396 public FileNode[] getSelected() { 394 Gatherer.g_man.meta_audit.setRecords(getCollectionTreeSelection()); 395 } 396 397 /** Retrieve a list of the currently selected file records in the collection tree. */ 398 private CollectionTreeNode[] getCollectionTreeSelection() 399 { 397 400 TreePath paths[] = collection_tree.getSelectionPaths(); 398 FileNode records[] = null;399 if (paths != null) {400 records = new FileNode[paths.length];401 for (int i = 0; i < records.length; i++) {402 records[i] = ( FileNode) paths[i].getLastPathComponent();401 CollectionTreeNode records[] = null; 402 if (paths != null) { 403 records = new CollectionTreeNode[paths.length]; 404 for (int i = 0; i < records.length; i++) { 405 records[i] = (CollectionTreeNode) paths[i].getLastPathComponent(); 403 406 } 404 407 } 405 408 return records; 406 409 } 407 408 public String getSelectionDetails() { 409 return collection_tree.getSelectionDetails(); 410 } 410 411 411 412 412 /** Called whenever the detail mode changes to ensure the filters are at an appropriate level (ie only editable by those that understand regular expression matching) … … 555 555 add(new_folder); 556 556 557 node = ( FileNode) tree.getModel().getRoot();557 node = (CollectionTreeNode) tree.getModel().getRoot(); 558 558 } 559 559 … … 623 623 624 624 // You can unmap 1st level nodes 625 FileNode root = (FileNode) tree.getModel().getRoot();625 WorkspaceTreeNode root = (WorkspaceTreeNode) tree.getModel().getRoot(); 626 626 if (root.getIndex(node) != -1) { 627 627 delete_shortcut = new JMenuItem(Dictionary.get("MappingPrompt.Unmap"), KeyEvent.VK_R); … … 652 652 // Delete shortcut 653 653 else if (source == delete_shortcut) { 654 Gatherer.c_man.removeDirectoryMapping(node);654 workspace_tree.removeDirectoryMapping((WorkspaceTreeNode) node); 655 655 } 656 656 … … 683 683 // New folder 684 684 else if (source == new_folder) { 685 Gatherer.f_man.newFolder(tree, node);685 Gatherer.f_man.newFolder(tree, (CollectionTreeNode) node); 686 686 } 687 687 … … 864 864 setVisible(true); 865 865 // If not cancelled create mapping. 866 if (!cancelled) {867 Gatherer.c_man.addDirectoryMapping(name_field.getText(), file);866 if (!cancelled) { 867 workspace_tree.addDirectoryMapping(name_field.getText(), file); 868 868 } 869 869 } -
trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java
r8353 r8783 50 50 import org.greenstone.gatherer.Gatherer; 51 51 import org.greenstone.gatherer.WGet; 52 import org.greenstone.gatherer.file.FileNode; 53 import org.greenstone.gatherer.gui.tree.WorkspaceTree; 52 import org.greenstone.gatherer.file.WorkspaceTree; 54 53 import org.greenstone.gatherer.util.StaticStrings; 55 54 import org.greenstone.gatherer.util.Utility; -
trunk/gli/src/org/greenstone/gatherer/gui/NewFolderPrompt.java
r8474 r8783 44 44 import org.greenstone.gatherer.Dictionary; 45 45 import org.greenstone.gatherer.Gatherer; 46 import org.greenstone.gatherer. file.FileNode;46 import org.greenstone.gatherer.collection.CollectionTreeNode; 47 47 48 48 public class NewFolderPrompt 49 49 extends JDialog 50 50 implements ActionListener { 51 private FileNode node;51 private CollectionTreeNode node; 52 52 private JButton cancel_button; 53 53 private JButton ok_button; … … 56 56 static final private Dimension SIZE = new Dimension(350,115); 57 57 58 public NewFolderPrompt( FileNode node) {58 public NewFolderPrompt(CollectionTreeNode node) { 59 59 super(Gatherer.g_man, Dictionary.get("NewFolderPrompt.Title"), true); 60 60 this.node = node; -
trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/MetaAuditFrame.java
r8231 r8783 45 45 import org.greenstone.gatherer.Dictionary; 46 46 import org.greenstone.gatherer.Gatherer; 47 import org.greenstone.gatherer.file.FileNode; 48 import org.greenstone.gatherer.util.TreeSynchronizer; 47 import org.greenstone.gatherer.collection.CollectionTreeNode; 49 48 import org.greenstone.gatherer.gui.GLIButton; 50 49 import org.greenstone.gatherer.gui.SimpleMenuBar; 51 50 import org.greenstone.gatherer.gui.ModalDialog; 52 53 /** The MetaAuditFrame provides a table view of all of the metadata assigned to a selection of FileNodes. All values for a certain file and a certain metadata element appear in the same cell. This table can be sorted by any column, and also has a MS Excel-like AutoFilter allowing you to restrict the rows visible to only those that match a certain set of criteria (applied to each column, and then 'ANDED', or cojoined, to determine the filter). Finally this dialog does not block the Gatherer tool, so the file selection can be changed and the dialog will just generate a new table dynamically.<BR> 51 import org.greenstone.gatherer.util.TreeSynchronizer; 52 53 /** The MetaAuditFrame provides a table view of all of the metadata assigned to a selection of CollectionTreeNodes. All values for a certain file and a certain metadata element appear in the same cell. This table can be sorted by any column, and also has a MS Excel-like AutoFilter allowing you to restrict the rows visible to only those that match a certain set of criteria (applied to each column, and then 'ANDED', or cojoined, to determine the filter). Finally this dialog does not block the Gatherer tool, so the file selection can be changed and the dialog will just generate a new table dynamically.<BR> 54 54 * Much effort has gone into optimizing this table, as it quickly becomes slow and unresponsive to build/filter/sort when the number of records selected is high. However its performance is still nowhere as good as the Excel spreadsheet, and selections of 1000+ records can cause some serious waiting problems. Performance progression, shown in terms of time taken to perform action, are shown below. Note that building includes both the creation of the data model, and/or the time taken to lay out row and column sizes (due to this using multiple entry cells). Also all tables, by default, must be sorted by one column, which is initially the first column in ascending order:<BR><BR> 55 55 * <TABLE border=1 cellspacing=0 cellpadding=5> … … 90 90 private boolean invalid = true; 91 91 /** An array holding the most recent list of paths selected (plus some nulls for those paths removed). */ 92 private FileNode records[];92 private CollectionTreeNode records[]; 93 93 /** A reference to ourselves so that inner classes can interact with us. */ 94 94 private MetaAuditFrame self; … … 99 99 100 100 /** Constructor.*/ 101 public MetaAuditFrame(TreeSynchronizer tree_sync, FileNode records[]) {101 public MetaAuditFrame(TreeSynchronizer tree_sync, CollectionTreeNode records[]) { 102 102 super(Gatherer.g_man); 103 103 … … 157 157 } 158 158 159 public void setRecords( FileNode[] records) {159 public void setRecords(CollectionTreeNode[] records) { 160 160 this.records = records; 161 161 if(isVisible()) { … … 175 175 TreePath paths[] = ((JTree)source).getSelectionPaths(); 176 176 if(paths != null) { 177 records = new FileNode[paths.length];177 records = new CollectionTreeNode[paths.length]; 178 178 for(int i = 0; i < paths.length; i++) { 179 records[i] = ( FileNode) paths[i].getLastPathComponent();179 records[i] = (CollectionTreeNode) paths[i].getLastPathComponent(); 180 180 } 181 181 if(isVisible()) { -
trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/MetaAuditTable.java
r8432 r8783 43 43 import javax.swing.event.TableModelEvent; 44 44 import javax.swing.table.*; 45 import org.greenstone.gatherer. file.FileNode;45 import org.greenstone.gatherer.collection.CollectionTreeNode; 46 46 import org.greenstone.gatherer.metadata.MetadataAuditTableModel; 47 47 … … 102 102 } 103 103 104 public void newModel( FileNode records[]) {104 public void newModel(CollectionTreeNode records[]) { 105 105 if(records == null || records.length == 0) { 106 106 setModel(new DefaultTableModel()); -
trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java
r8588 r8783 454 454 } 455 455 456 public void mapDirectory(File file, String title) {457 try {458 ((FileSystemModel)treeModel).mapDirectory(file, title);459 }460 catch (Exception error) {461 error.printStackTrace();462 }463 }464 456 465 457 public void paint(Graphics g) { -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataAuditTableModel.java
r8554 r8783 35 35 import org.greenstone.gatherer.Configuration; 36 36 import org.greenstone.gatherer.Dictionary; 37 import org.greenstone.gatherer. file.FileNode;37 import org.greenstone.gatherer.collection.CollectionTreeNode; 38 38 39 39 … … 41 41 extends AbstractTableModel 42 42 { 43 /** The FileNodes this model is built for */44 private FileNode[] file_nodes = null;43 /** The CollectionTreeNodes this model is built for */ 44 private CollectionTreeNode[] file_nodes = null; 45 45 /** The list of MetadataElements in the table (columns) */ 46 46 private ArrayList metadata_elements = new ArrayList(); … … 145 145 146 146 147 public void rebuild( FileNode[] file_nodes)147 public void rebuild(CollectionTreeNode[] file_nodes) 148 148 { 149 149 metadata_elements = MetadataSetManager.getEveryMetadataSetElement(); -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTableModel.java
r8606 r8783 36 36 import org.greenstone.gatherer.Dictionary; 37 37 import org.greenstone.gatherer.Gatherer; 38 import org.greenstone.gatherer. file.FileNode;38 import org.greenstone.gatherer.collection.CollectionTreeNode; 39 39 import org.greenstone.gatherer.gui.WarningDialog; 40 40 … … 43 43 extends AbstractTableModel 44 44 { 45 /** The FileNodes this model is built for */46 private FileNode[] file_nodes = null;45 /** The CollectionTreeNodes this model is built for */ 46 private CollectionTreeNode[] file_nodes = null; 47 47 /** The list of MetadataValueTableEntries in the table */ 48 48 private ArrayList metadata_value_table_entries = new ArrayList(); … … 126 126 127 127 128 public void rebuild( FileNode[] file_nodes)128 public void rebuild(CollectionTreeNode[] file_nodes) 129 129 { 130 130 this.file_nodes = file_nodes; -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java
r8240 r8783 31 31 import java.util.*; 32 32 import org.greenstone.gatherer.DebugStream; 33 import org.greenstone.gatherer. file.FileNode;33 import org.greenstone.gatherer.collection.CollectionTreeNode; 34 34 import org.greenstone.gatherer.util.Utility; 35 35 import org.greenstone.gatherer.util.XMLTools; … … 42 42 43 43 44 static public void addMetadata( FileNode file_node, MetadataValue metadata_value)45 { 46 FileNode[] file_nodes = new FileNode[1];44 static public void addMetadata(CollectionTreeNode file_node, MetadataValue metadata_value) 45 { 46 CollectionTreeNode[] file_nodes = new CollectionTreeNode[1]; 47 47 file_nodes[0] = file_node; 48 48 addMetadata(file_nodes, metadata_value); … … 50 50 51 51 52 static public void addMetadata( FileNode[] file_nodes, MetadataValue metadata_value)52 static public void addMetadata(CollectionTreeNode[] file_nodes, MetadataValue metadata_value) 53 53 { 54 54 // Add the metadata to each file node in turn … … 228 228 229 229 230 static public void removeMetadata( FileNode file_node, MetadataValue metadata_value)231 { 232 FileNode[] file_nodes = new FileNode[1];230 static public void removeMetadata(CollectionTreeNode file_node, MetadataValue metadata_value) 231 { 232 CollectionTreeNode[] file_nodes = new CollectionTreeNode[1]; 233 233 file_nodes[0] = file_node; 234 234 removeMetadata(file_nodes, metadata_value); … … 236 236 237 237 238 static public void removeMetadata( FileNode[] file_nodes, MetadataValue metadata_value)238 static public void removeMetadata(CollectionTreeNode[] file_nodes, MetadataValue metadata_value) 239 239 { 240 240 // Remove the metadata from each file node in turn
Note:
See TracChangeset
for help on using the changeset viewer.