Changeset 8783


Ignore:
Timestamp:
2004-12-13T12:01:25+13:00 (19 years ago)
Author:
mdewsnip
Message:

Big tidy up of the workspace and collection trees (Gather/Enrich panes). Still a few more changes and bug fixes to come.

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  
    4747import org.greenstone.gatherer.cdm.CollectionMeta;
    4848import org.greenstone.gatherer.cdm.CollectionMetaManager;
    49 import org.greenstone.gatherer.file.FileNode;
    5049import org.greenstone.gatherer.util.StaticStrings;
    5150import org.greenstone.gatherer.util.Utility;
     
    302301    private int getCount(TreeNode node, boolean count_folders, boolean count_files) {
    303302    int count = 0;
    304     File file = ((FileNode)node).getFile();
     303    File file = ((CollectionTreeNode)node).getFile();
    305304    if(file.isFile() && count_files) {
    306305        count++;
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r8652 r8783  
    3838
    3939import java.io.*;
    40 import java.lang.Class;
    4140import java.util.*;
    4241import javax.swing.*;
     
    5453import org.greenstone.gatherer.cdm.CollectionMetaManager;
    5554import 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;
     55import org.greenstone.gatherer.file.WorkspaceTree;  // !!! Don't like this here
    5956import org.greenstone.gatherer.gui.LockFileDialog;
    6057import org.greenstone.gatherer.gui.NewCollectionMetadataPrompt;
    6158import org.greenstone.gatherer.gui.ExternalCollectionPrompt;
    6259import org.greenstone.gatherer.gui.WarningDialog;
    63 import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    6460import org.greenstone.gatherer.metadata.DocXMLFileManager;
    6561import org.greenstone.gatherer.metadata.MetadataSet;
     
    9490    static private Collection collection = null;
    9591    /** The collection_model. */
    96     private FileSystemModel collection_model = null;
     92    private CollectionTreeModel collection_model = null;
    9793    /** An inner class listener responsible for noting tree changes and resetting saved when they occur. */
    9894    private FMTreeModelListener fm_tree_model_listener = null;
     
    126122    {
    127123    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 config
    138     Configuration.addDirectoryMapping(name, file);
    139     // Now update the tree
    140     Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.FOLDER_SHORTCUTS_CHANGED);
    141124    }
    142125
     
    291274    }
    292275    DebugStream.println("Copying images and macros dirs from the base collection");
    293     FileQueue fq = Gatherer.f_man.getQueue();
    294276    try {
    295277        // do the images dir
     
    301283       
    302284        // 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) {
    306289        DebugStream.println("Couldn't copy over the images dir from the base collection: "+e.toString());
    307290    }
     
    315298       
    316299        // 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);
    318301        }
    319     } catch (Exception e) {
     302    }
     303    catch (Exception e) {
    320304        DebugStream.println("Couldn't copy over the macros dir from the base collection: "+e.toString());
    321305    }
     
    529513
    530514
     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
    531535    public void fireFileAddedToCollection(File file)
    532536    {
     
    706710    /** Retrieve the record set (tree model) associated with the current collection. */
    707711    public TreeModel getRecordSet() {
    708     if(collection_model == null && collection != null) {
    709         // Use the import directory to generate a new FileSystemModel
    710         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())));
    711715        // 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) {
    713717        fm_tree_model_listener = new FMTreeModelListener();
    714718        }
     
    716720    }
    717721    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 directories
    732     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;
    741722    }
    742723
     
    12041185    public void registerImportMonitor(GShellProgressMonitor monitor) {
    12051186    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.FileNode
    1211      */
    1212     public File removeDirectoryMapping(FileNode target) {
    1213     // Remove from config, remembering file
    1214     File file = Configuration.removeDirectoryMapping(target.toString());
    1215     // Update tree.
    1216     Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.FOLDER_SHORTCUTS_CHANGED);
    1217     return file;
    12181187    }
    12191188
  • trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java

    r8620 r8783  
    5151import org.greenstone.gatherer.gui.ModalDialog;
    5252import org.greenstone.gatherer.gui.SimpleMenuBar;
    53 import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    5453import org.greenstone.gatherer.util.ArrayTools;
    5554import org.greenstone.gatherer.util.StaticStrings;
     
    351350        }
    352351
    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())) {
    360353        if (Gatherer.c_man.getCollection() != null && collection.getShortName().equals(Gatherer.c_man.getCollection().getName())) {
    361354            current_coll_deleted = true;
    362355        }
    363356        list_model.removeElement(collection);
    364 
    365         // Refresh the collections shown in the workspace tree
    366         Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED);
    367357
    368358        resultPrompt(true);
  • trunk/gli/src/org/greenstone/gatherer/collection/DownloadJob.java

    r8782 r8783  
    4747import org.greenstone.gatherer.Gatherer;
    4848import org.greenstone.gatherer.WGet;
     49import org.greenstone.gatherer.file.WorkspaceTree;
    4950import org.greenstone.gatherer.gui.DownloadProgressBar;
    50 import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    5151import org.greenstone.gatherer.util.AppendLineOnlyFileDocument;
    5252import org.greenstone.gatherer.util.GURL;
     
    486486    }
    487487
    488     public void downloadComplete(String current_file_downloading) {
     488
     489    public void downloadComplete(String current_file_downloading)
     490    {
    489491    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
    532495
    533496    /** Called by the WGet native code when the requested download returns
     
    535498     */
    536499    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
    539501    progress.downloadFailed();
     502    DebugStream.println("Download failed: " + current_url);
    540503    }
    541504     
     
    546509    }
    547510
    548     /**
    549      * @return A String representing the currently downloading url.
    550      */
    551     /* private String getCurrent() {
    552     return current_url;
    553     } */
    554511
    555512    /**
  • trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r8599 r8783  
    4141import org.greenstone.gatherer.Dictionary;
    4242import org.greenstone.gatherer.Gatherer;
     43import org.greenstone.gatherer.collection.CollectionTreeNode;
    4344import org.greenstone.gatherer.gui.LongProgressBar;
    4445import org.greenstone.gatherer.gui.NewFolderPrompt;
     
    124125    }
    125126
    126     public void newFolder(DragTree tree, FileNode parent_node) {
     127    public void newFolder(DragTree tree, CollectionTreeNode parent_node) {
    127128    // Ask the user for the directories name.
    128129    NewFolderPrompt new_folder_prompt = new NewFolderPrompt(parent_node);
     
    143144
    144145        // Update the parent node to show the new folder
    145         parent_node.unmap();
    146         parent_node.map();
     146        parent_node.refresh();
    147147
    148148        // Refresh workspace tree (collection tree is done automatically)
  • trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r8243 r8783  
    77import javax.swing.filechooser.*;
    88import javax.swing.tree.*;
    9 import org.greenstone.gatherer.Configuration;
    109import 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;
    1510import 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
     13public 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    {
    4028    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    {
    8742    return new FileEnumeration();
    8843    }
    8944
    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
    14653    /** 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
    15959
    16060    /** Returns the number of children TreeNodes the receiver contains. */
    161     public int getChildCount() {
     61    public int getChildCount()
     62    {
    16263    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
    16668    }
    16769    else {
    16870        map();
    16971    }
    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
    17478    return size;
    17579    }
     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
    176190
    177191    public File getFile() {
     
    179193    }
    180194
    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     }
    191195
    192196    /** Retrieves the tree path from the root node to this node. */
     
    208212    }
    209213
     214
    210215    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
    232229
    233230    /** Is this file node within the currently open collection? */
    234231    public boolean isInCurrentCollection() {
    235     if(current_collection) {
     232    if (current_collection) {
    236233        return true;
    237234    }
    238235    else {
    239236        FileNode parent = (FileNode) getParent();
    240         if(parent != null) {
     237        if (parent != null) {
    241238        return parent.isInCurrentCollection();
    242239        }
     
    245242    }
    246243
    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) {
    266256        return;
    267257    }
    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));
    282285            }
    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);
    370288            }
    371289        }
    372         model.nodeStructureChanged(this);
    373290        }
    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
    398303
    399304    public void setCurrentCollection(boolean current_collection) {
     
    401306    }
    402307
    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 
    411308    public void setModel(FileSystemModel model) {
    412309    this.model = model;
     
    417314    }
    418315
    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. */
    437318    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();
    440321    }
    441322    return 0;
    442323    }
    443324
    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;
    474343    }
    475344
    476345
    477346    private class FileEnumeration
    478     implements Enumeration {
     347    implements Enumeration
     348    {
    479349    private int index = 0;
     350
    480351    /** Tests if this enumeration contains more elements. */
    481352    public boolean hasMoreElements() {
    482         return (index < children.size());
    483     }
     353        return (index < child_nodes.size());
     354    }
     355
    484356    /** Returns the next element of this enumeration if this enumeration object has at least one more element to provide. */
    485357    public Object nextElement() {
    486358        Object result = null;
    487         if(index < children.size()) {
    488         result = children.get(index);
     359        if (index < child_nodes.size()) {
     360        result = child_nodes.get(index);
    489361        index++;
    490362        }
  • trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java

    r8652 r8783  
    3636import org.greenstone.gatherer.Dictionary;
    3737import org.greenstone.gatherer.Gatherer;
     38import org.greenstone.gatherer.collection.CollectionTreeNode;
    3839import org.greenstone.gatherer.gui.LongProgressBar;
    3940import org.greenstone.gatherer.gui.tree.DragTree;
     
    257258                    if(destination_node != null) {
    258259                        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);
    260261                        TreePath target_path = destination_path.pathByAddingChild(temp_target_node);
    261262                        SynchronizedTreeModelTools.removeNodeFromParent(target_model, target_model.getNode(target_path));
     
    353354                    if (!cancel_action) {
    354355                    // 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);
    356357                    SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, new_node);
    357358                    }
     
    360361                else if(source_file.isDirectory()) {
    361362                    // create new record
    362                     FileNode directory_record = new FileNode(target_file);
     363                    CollectionTreeNode directory_record = new CollectionTreeNode(target_file);
    363364                    SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, directory_record);
    364365                    // Why is this not happening eh?
     
    408409                    for (int i = 0; i < assigned_metadata.size(); i++) {
    409410                        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);
    412413                    }
    413414                    }
     
    417418                    for (int i = 0; i < assigned_metadata.size(); i++) {
    418419                        MetadataValue metadata_value = (MetadataValue) assigned_metadata.get(i);
    419                         MetadataXMLFileManager.addMetadata(new_node, metadata_value);
     420                        MetadataXMLFileManager.addMetadata((CollectionTreeNode) new_node, metadata_value);
    420421                    }
    421422                    }
     
    453454                for (int i = 0; i < assigned_metadata.size(); i++) {
    454455                MetadataValue metadata_value = (MetadataValue) assigned_metadata.get(i);
    455                 MetadataXMLFileManager.removeMetadata(origin_node, metadata_value);
     456                MetadataXMLFileManager.removeMetadata((CollectionTreeNode) origin_node, metadata_value);
    456457                }
    457458
     
    472473                origin_node.refresh();
    473474                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);
    475476                    ///atherer.println("Queuing: " + child_record);
    476477                    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  
    1111public class FileSystem
    1212{
    13     static public FileNode getLocalFilespaceNode(FileSystemModel model)
     13    static public WorkspaceTreeNode getLocalFilespaceNode(FileSystemModel model)
    1414    {
    15     FileNode file_system_root = null;
     15    WorkspaceTreeNode file_system_root = null;
    1616
    1717    // Get all the available roots mounted on the filesystem
     
    2323    // If there is just one root use it as the tree root (Linux)
    2424    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"));
    2626    }
    2727
    2828    // Otherwise build a dummy node which has the roots as children
    2929    else {
    30         file_system_root = new FileNode(Dictionary.get("Tree.Root"));
     30        file_system_root = new WorkspaceTreeNode(null, Dictionary.get("Tree.Root"));
    3131        file_system_root.setModel(model);
    3232
     
    3636        // Only add root if it isn't a floppy drive
    3737        if (!FileSystemView.getFileSystemView().isFloppyDrive(roots[i])) {
    38             file_system_root.insert(new FileNode(roots[i]));
     38            file_system_root.insert(new WorkspaceTreeNode(roots[i]));
    3939        }
    4040        }
     
    4545
    4646
    47     static public FileNode getHomeFolderNode()
     47    static public WorkspaceTreeNode getHomeFolderNode()
    4848    {
    4949    // Get the name of the OS we're running on
     
    6868    // Generate a special mapping to the user home folder
    6969    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()));
    7171    }
    7272
    7373
    74     static public FileNode getDownloadedFilesNode()
     74    static public WorkspaceTreeNode getDownloadedFilesNode()
    7575    {
    76     return new FileNode(Utility.getCacheDir(), "Downloaded Files");
     76    return new WorkspaceTreeNode(Utility.getCacheDir(), "Downloaded Files");
    7777    }
    7878}
  • trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java

    r8243 r8783  
    77import javax.swing.tree.*;
    88import org.greenstone.gatherer.DebugStream;
    9 import org.greenstone.gatherer.Dictionary;
    109import org.greenstone.gatherer.Gatherer;
    1110import org.greenstone.gatherer.gui.tree.DragTree;
     
    1413public class FileSystemModel
    1514    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;
    2220    /** The filters in place for any file system model. */
    2321    private FileFilter[] default_filters = { new FileFilter("\\..*", true), new FileFilter("metadata\\.xml", true) };
     
    2523    public FileSystemModel(FileNode root) {
    2624    super(root);
    27     current_filter = null;
    28     filters = null;
    29     tree = null;
    3025    root.setModel(this);
    3126    root.map();
     
    6863        DebugStream.print("Searching for '" + stale_object + "': ");
    6964        // Locate the fresh node by searching current's children. Remember to ensure that current is mapped.
    70         //current.unmap();
    7165        boolean found = false;
    7266
     
    8478        // Failing that we search through all the children, including filtered files
    8579        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);
    8781            DebugStream.print(child_node + " ");
    8882            if((stale_node != null && stale_node.equals(child_node)) || stale_object.toString().equals(child_node.toString())) {
     
    110104    ///ystem.err.println("insertNodeInto(" + newChild + ", " + parent + ", " + index + ")");
    111105    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);
    117106    }
    118107
     
    236225    TreePath path = event.getPath();
    237226    FileNode node = (FileNode) path.getLastPathComponent();
    238     ///ystem.err.println("Unmap: " + node);
    239227    node.unmap();
    240228    // Fire the appropriate event.
     
    255243    }
    256244    }
    257      
     245
    258246    /** Invoked whenever a node in the tree is about to be expanded. */
    259247    public void treeWillExpand(TreeExpansionEvent event)
  • trunk/gli/src/org/greenstone/gatherer/file/RecycleBin.java

    r8670 r8783  
    8080    setOpaque(true);
    8181
    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")));
    8383    }
    8484
     
    174174    this.group = group;
    175175    }
     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    }
    176190}
  • 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
    127package org.greenstone.gatherer.file;
    228
     29import java.io.*;
     30import java.util.*;
    331import javax.swing.tree.TreePath;
     32import org.greenstone.gatherer.Configuration;
    433import org.greenstone.gatherer.DebugStream;
     34import org.greenstone.gatherer.Dictionary;
    535import org.greenstone.gatherer.Gatherer;
    6 import org.greenstone.gatherer.collection.CollectionManager;
    7 import org.greenstone.gatherer.gui.MirrorPane;
    836import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
    937
    1038
    1139public 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;
    1344
    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;
    2149
    2250
    23     public WorkspaceTreeModel(FileNode root)
     51    public WorkspaceTreeModel(WorkspaceTreeNode root_node)
    2452    {
    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;
    2669    }
    2770
     
    3073    {
    3174    // 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");
    3376    workspace_tree_model = new WorkspaceTreeModel(workspace_tree_root);
    3477
    3578    // Add the "Documents in Greenstone Collections" node
    36     greenstone_collections_node = CollectionManager.getGreenstoneCollectionsMapping();
     79    greenstone_collections_node = new WorkspaceTreeNode(null, Dictionary.get("Tree.World"));
    3780    workspace_tree_root.insert(greenstone_collections_node);
    3881
     
    72115    {
    73116    // 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();
    76119
    77120    // Remove any deleted shortcuts from the tree
     
    80123        if (!doesArrayContain(folder_shortcuts, old_folder_shortcuts[i])) {
    81124            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]);
    84126        }
    85127        }
     
    109151    // Refresh each of the nodes in the workspace tree
    110152    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);
    112154        super.refresh(new TreePath(child_node.getPath()));
    113155    }
     
    115157    // Refresh the local filespace tree specially (it is not unmapped so not refreshed)
    116158    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);
    118160        super.refresh(new TreePath(child_node.getPath()));
    119161    }
  • trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java

    r8695 r8783  
    5151import org.greenstone.gatherer.Gatherer;
    5252import org.greenstone.gatherer.collection.CollectionManager;
    53 import org.greenstone.gatherer.file.FileNode;
     53import org.greenstone.gatherer.collection.CollectionTreeNode;
    5454import org.greenstone.gatherer.gui.tree.DragTree;
    5555import org.greenstone.gatherer.metadata.MetadataElement;
     
    103103    private Filter filter = null;
    104104    /** The currently reported selection. */
    105     private FileNode[] file_nodes = null;
     105    private CollectionTreeNode[] file_nodes = null;
    106106    /** The button, which when clicked, adds metadata to the selected records. */
    107107    private JButton add;
     
    493493    else {
    494494        TreePath paths[] = collection_tree.getSelectionPaths();
    495         file_nodes = new FileNode[paths.length];
     495        file_nodes = new CollectionTreeNode[paths.length];
    496496        for (int i = 0; i < paths.length; i++) {
    497         file_nodes[i] = (FileNode) paths[i].getLastPathComponent();
     497        file_nodes[i] = (CollectionTreeNode) paths[i].getLastPathComponent();
    498498        }
    499499
     
    13691369        TreePath path = tree.getLeadSelectionPath();
    13701370        if(path != null) {
    1371             File file = ((FileNode)path.getLastPathComponent()).getFile();
     1371            File file = ((CollectionTreeNode) path.getLastPathComponent()).getFile();
    13721372            if(file != null) {
    13731373            if (file.isFile() || vk_left_pressed) {
     
    13941394        TreePath path = tree.getLeadSelectionPath();
    13951395        if(path == null) return;
    1396         File file = ((FileNode)path.getLastPathComponent()).getFile();
     1396        File file = ((CollectionTreeNode) path.getLastPathComponent()).getFile();
    13971397        if(file == null) return;
    13981398       
     
    14311431    private TreePath[] selection_paths = null;
    14321432    /** The file record over which the right click action occurred. */
    1433     private FileNode node = null;
     1433    private CollectionTreeNode node = null;
    14341434
    14351435    private JMenuItem collapse_folder = null;
     
    14751475
    14761476        TreePath path = selection_paths[0];
    1477         node = (FileNode) path.getLastPathComponent();
     1477        node = (CollectionTreeNode) path.getLastPathComponent();
    14781478
    14791479        // ---- Options for file nodes ----
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r8634 r8783  
    5656import org.greenstone.gatherer.collection.DeleteCollectionPrompt;
    5757import org.greenstone.gatherer.collection.ExportCollectionPrompt;
    58 import org.greenstone.gatherer.file.FileNode;
    5958import org.greenstone.gatherer.file.FileOpenActionListener;
    6059import org.greenstone.gatherer.gui.metaaudit.MetaAuditFrame;
    6160import org.greenstone.gatherer.gui.tree.DragTree;
    62 import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    6361import org.greenstone.gatherer.util.StaticStrings;
    6462import org.greenstone.gatherer.util.TreeSynchronizer;
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r8600 r8783  
    4848import org.greenstone.gatherer.Dictionary;
    4949import org.greenstone.gatherer.Gatherer;
     50import org.greenstone.gatherer.collection.CollectionTreeNode;
    5051import org.greenstone.gatherer.collection.CollectionManager;
    5152import org.greenstone.gatherer.file.FileNode;
     
    5455import org.greenstone.gatherer.file.FileSystemModel;
    5556import org.greenstone.gatherer.file.RecycleBin;
     57import org.greenstone.gatherer.file.WorkspaceTree;
     58import org.greenstone.gatherer.file.WorkspaceTreeNode;
    5659import org.greenstone.gatherer.gui.tree.DragTree;
    57 import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    5860import org.greenstone.gatherer.util.DragComponent;
    5961import org.greenstone.gatherer.util.DragGroup;
     
    178180        if(count == 1) {
    179181        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()) {
    182184            Gatherer.f_man.newFolder(collection_tree, node);
    183185        }
    184186        else {
    185187            // try the parent
    186             FileNode parent = (FileNode)node.getParent();
     188            CollectionTreeNode parent = (CollectionTreeNode) node.getParent();
    187189            if (parent!=null && parent.getAllowsChildren()) {
    188190            Gatherer.f_man.newFolder(collection_tree, parent);
     
    197199        if(error) {
    198200        // 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();
    200202        Gatherer.f_man.newFolder(collection_tree, node);
    201203        }
     
    390392    public void gainFocus() {
    391393    // 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    {
    397400    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();
    403406        }
    404407    }
    405408    return records;
    406409    }
    407    
    408     public String getSelectionDetails() {
    409     return collection_tree.getSelectionDetails();
    410     }
     410
    411411   
    412412    /** 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)
     
    555555            add(new_folder);
    556556
    557             node = (FileNode) tree.getModel().getRoot();
     557            node = (CollectionTreeNode) tree.getModel().getRoot();
    558558        }
    559559
     
    623623
    624624        // You can unmap 1st level nodes
    625         FileNode root = (FileNode) tree.getModel().getRoot();
     625        WorkspaceTreeNode root = (WorkspaceTreeNode) tree.getModel().getRoot();
    626626        if (root.getIndex(node) != -1) {
    627627            delete_shortcut = new JMenuItem(Dictionary.get("MappingPrompt.Unmap"), KeyEvent.VK_R);
     
    652652        // Delete shortcut
    653653        else if (source == delete_shortcut) {
    654         Gatherer.c_man.removeDirectoryMapping(node);
     654        workspace_tree.removeDirectoryMapping((WorkspaceTreeNode) node);
    655655        }
    656656
     
    683683        // New folder
    684684        else if (source == new_folder) {
    685         Gatherer.f_man.newFolder(tree, node);
     685        Gatherer.f_man.newFolder(tree, (CollectionTreeNode) node);
    686686        }
    687687
     
    864864        setVisible(true);
    865865        // 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);
    868868        }
    869869    }
  • trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java

    r8353 r8783  
    5050import org.greenstone.gatherer.Gatherer;
    5151import org.greenstone.gatherer.WGet;
    52 import org.greenstone.gatherer.file.FileNode;
    53 import org.greenstone.gatherer.gui.tree.WorkspaceTree;
     52import org.greenstone.gatherer.file.WorkspaceTree;
    5453import org.greenstone.gatherer.util.StaticStrings;
    5554import org.greenstone.gatherer.util.Utility;
  • trunk/gli/src/org/greenstone/gatherer/gui/NewFolderPrompt.java

    r8474 r8783  
    4444import org.greenstone.gatherer.Dictionary;
    4545import org.greenstone.gatherer.Gatherer;
    46 import org.greenstone.gatherer.file.FileNode;
     46import org.greenstone.gatherer.collection.CollectionTreeNode;
    4747
    4848public class NewFolderPrompt
    4949    extends JDialog
    5050    implements ActionListener {
    51     private FileNode node;
     51    private CollectionTreeNode node;
    5252    private JButton cancel_button;
    5353    private JButton ok_button;
     
    5656    static final private Dimension SIZE = new Dimension(350,115);
    5757
    58     public NewFolderPrompt(FileNode node) {
     58    public NewFolderPrompt(CollectionTreeNode node) {
    5959    super(Gatherer.g_man, Dictionary.get("NewFolderPrompt.Title"), true);
    6060    this.node = node;
  • trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/MetaAuditFrame.java

    r8231 r8783  
    4545import org.greenstone.gatherer.Dictionary;
    4646import org.greenstone.gatherer.Gatherer;
    47 import org.greenstone.gatherer.file.FileNode;
    48 import org.greenstone.gatherer.util.TreeSynchronizer;
     47import org.greenstone.gatherer.collection.CollectionTreeNode;
    4948import org.greenstone.gatherer.gui.GLIButton;
    5049import org.greenstone.gatherer.gui.SimpleMenuBar;
    5150import 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>
     51import 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>
    5454 * 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>
    5555 * <TABLE border=1 cellspacing=0 cellpadding=5>
     
    9090    private boolean invalid = true;
    9191    /** 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[];
    9393    /** A reference to ourselves so that inner classes can interact with us. */
    9494    private MetaAuditFrame self;
     
    9999
    100100    /** Constructor.*/
    101     public MetaAuditFrame(TreeSynchronizer tree_sync, FileNode records[]) {
     101    public MetaAuditFrame(TreeSynchronizer tree_sync, CollectionTreeNode records[]) {
    102102    super(Gatherer.g_man);
    103103
     
    157157    }
    158158
    159     public void setRecords(FileNode[] records) {
     159    public void setRecords(CollectionTreeNode[] records) {
    160160    this.records = records;
    161161    if(isVisible()) {
     
    175175        TreePath paths[] = ((JTree)source).getSelectionPaths();
    176176        if(paths != null) {
    177         records = new FileNode[paths.length];
     177        records = new CollectionTreeNode[paths.length];
    178178        for(int i = 0; i < paths.length; i++) {
    179             records[i] = (FileNode) paths[i].getLastPathComponent();
     179            records[i] = (CollectionTreeNode) paths[i].getLastPathComponent();
    180180        }
    181181        if(isVisible()) {
  • trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/MetaAuditTable.java

    r8432 r8783  
    4343import javax.swing.event.TableModelEvent;
    4444import javax.swing.table.*;
    45 import org.greenstone.gatherer.file.FileNode;
     45import org.greenstone.gatherer.collection.CollectionTreeNode;
    4646import org.greenstone.gatherer.metadata.MetadataAuditTableModel;
    4747
     
    102102    }
    103103
    104     public void newModel(FileNode records[]) {
     104    public void newModel(CollectionTreeNode records[]) {
    105105    if(records == null || records.length == 0) {
    106106        setModel(new DefaultTableModel());
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r8588 r8783  
    454454    }
    455455
    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     }
    464456
    465457    public void paint(Graphics g) {
  • trunk/gli/src/org/greenstone/gatherer/metadata/MetadataAuditTableModel.java

    r8554 r8783  
    3535import org.greenstone.gatherer.Configuration;
    3636import org.greenstone.gatherer.Dictionary;
    37 import org.greenstone.gatherer.file.FileNode;
     37import org.greenstone.gatherer.collection.CollectionTreeNode;
    3838
    3939
     
    4141    extends AbstractTableModel
    4242{
    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;
    4545    /** The list of MetadataElements in the table (columns) */
    4646    private ArrayList metadata_elements = new ArrayList();
     
    145145
    146146
    147     public void rebuild(FileNode[] file_nodes)
     147    public void rebuild(CollectionTreeNode[] file_nodes)
    148148    {
    149149    metadata_elements = MetadataSetManager.getEveryMetadataSetElement();
  • trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTableModel.java

    r8606 r8783  
    3636import org.greenstone.gatherer.Dictionary;
    3737import org.greenstone.gatherer.Gatherer;
    38 import org.greenstone.gatherer.file.FileNode;
     38import org.greenstone.gatherer.collection.CollectionTreeNode;
    3939import org.greenstone.gatherer.gui.WarningDialog;
    4040
     
    4343    extends AbstractTableModel
    4444{
    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;
    4747    /** The list of MetadataValueTableEntries in the table */
    4848    private ArrayList metadata_value_table_entries = new ArrayList();
     
    126126
    127127
    128     public void rebuild(FileNode[] file_nodes)
     128    public void rebuild(CollectionTreeNode[] file_nodes)
    129129    {
    130130    this.file_nodes = file_nodes;
  • trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java

    r8240 r8783  
    3131import java.util.*;
    3232import org.greenstone.gatherer.DebugStream;
    33 import org.greenstone.gatherer.file.FileNode;
     33import org.greenstone.gatherer.collection.CollectionTreeNode;
    3434import org.greenstone.gatherer.util.Utility;
    3535import org.greenstone.gatherer.util.XMLTools;
     
    4242
    4343
    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];
    4747    file_nodes[0] = file_node;
    4848    addMetadata(file_nodes, metadata_value);
     
    5050
    5151
    52     static public void addMetadata(FileNode[] file_nodes, MetadataValue metadata_value)
     52    static public void addMetadata(CollectionTreeNode[] file_nodes, MetadataValue metadata_value)
    5353    {
    5454    // Add the metadata to each file node in turn
     
    228228
    229229
    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];
    233233    file_nodes[0] = file_node;
    234234    removeMetadata(file_nodes, metadata_value);
     
    236236
    237237
    238     static public void removeMetadata(FileNode[] file_nodes, MetadataValue metadata_value)
     238    static public void removeMetadata(CollectionTreeNode[] file_nodes, MetadataValue metadata_value)
    239239    {
    240240    // Remove the metadata from each file node in turn
Note: See TracChangeset for help on using the changeset viewer.