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/collection
Files:
2 added
4 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    /**
Note: See TracChangeset for help on using the changeset viewer.