Ignore:
Timestamp:
2004-05-28T13:41:13+12:00 (20 years ago)
Author:
mdewsnip
Message:

Many more improvements to the workspace and collection trees and their refreshing.

Location:
trunk/gli/src/org/greenstone/gatherer/file
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r7361 r7484  
    131131        FileNode folder_node = new FileNode(folder_file);
    132132        SynchronizedTreeModelTools.insertNodeInto(model, parent_node, folder_node);
     133
     134        // Refresh workspace tree (collection tree is done automatically)
     135        Gatherer.g_man.refreshWorkspaceTree(DragTree.COLLECTION_CONTENTS_CHANGED);
     136
    133137        folder_node = null;
    134138        }
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeModel.java

    r7203 r7484  
    22
    33import javax.swing.tree.TreePath;
     4import org.greenstone.gatherer.Gatherer;
    45import org.greenstone.gatherer.collection.CollectionManager;
    56import org.greenstone.gatherer.file.FileNode;
     
    1314    static private FileNode workspace_tree_root = null;
    1415    static private WorkspaceTreeModel workspace_tree_model = null;
     16
    1517    static private FileNode greenstone_collections_mapping = null;
    1618    static private FileNode local_filespace_mapping = null;
    17     static private FileNode web_cache_mapping = null;
    18     static private FileNode[] collection_specific_mappings = null;
     19    // static private FileNode web_cache_mapping = null;
     20    static private FileNode[] folder_shortcuts = null;
    1921
    2022
     
    4345
    4446    // Add public and private web caches if applicable
    45     loadWebCacheMappings();
     47    // loadWebCacheMappings();
    4648
    47     // Add any collection specific mappings
    48     loadCollectionSpecificMappings();
     49    // Add any folder shortcuts the user has created
     50    refreshFolderShortcuts();
    4951
    5052    return workspace_tree_model;
     
    5254
    5355
    54     static private void loadWebCacheMappings()
    55     {
    56     // If mirroring is enabled show the public and private caches
    57     web_cache_mapping = MirrorPane.getWebCacheMapping();
    58     if (web_cache_mapping != null) {
    59         workspace_tree_root.insert(web_cache_mapping);
    60     }
    61     }
    62 
    63 
    64     static private void loadCollectionSpecificMappings()
    65     {
    66     ///ystem.err.print("Load Collection Specific Mappings... ");
    67     // Add the current collection specific mappings
    68     collection_specific_mappings = CollectionManager.getCollectionSpecificMappings();
    69     ///ystem.err.print("Retrieved Mappings... ");
    70     if (collection_specific_mappings != null) {
    71         for (int i = 0; i < collection_specific_mappings.length; i++) {
    72         ///ystem.err.print("Setting " + i + " Mapping... ");
    73         SynchronizedTreeModelTools.insertNodeInto(workspace_tree_model, workspace_tree_root, collection_specific_mappings[i], false);
    74         }
    75     }
    76     ///ystem.err.println("Done.");
    77     }
    78 
    79 
    80     // !! NEEDS WORK !!
    8156    static public void refreshGreenstoneCollectionsMapping()
    8257    {
     
    8661
    8762
    88     // !! NEEDS WORK !!
    89     static public void refreshWebCacheMappings()
     63    static public void refreshFolderShortcuts()
    9064    {
    91     if (web_cache_mapping != null) {
    92         SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model, web_cache_mapping);
    93     }
     65    // Check for new/deleted folder shortcuts
     66    FileNode[] old_folder_shortcuts = folder_shortcuts;
     67    folder_shortcuts = CollectionManager.getFolderShortcuts();
    9468
    95     loadWebCacheMappings();
    96        
    97     }
    98 
    99 
    100     // !! NEEDS WORK !!
    101     static public void refreshCollectionSpecificMappings()
    102     {
    103     // Remove all the old collection specific mappings
    104     if (collection_specific_mappings != null) {
    105         for (int i = 0; i < collection_specific_mappings.length; i++) {
    106         SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
    107                                 collection_specific_mappings[i]);
     69    // Remove any deleted shortcuts from the tree
     70    if (old_folder_shortcuts != null) {
     71        for (int i = 0; i < old_folder_shortcuts.length; i++) {
     72        if (!doesArrayContain(folder_shortcuts, old_folder_shortcuts[i])) {
     73            Gatherer.println("Deleted shortcut: " + old_folder_shortcuts[i]);
     74            SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
     75                                    old_folder_shortcuts[i]);
     76        }
    10877        }
    10978    }
    11079
    111     loadCollectionSpecificMappings();
     80    // Add any new shortcuts to the tree
     81    if (folder_shortcuts != null) {
     82        for (int i = 0; i < folder_shortcuts.length; i++) {
     83        if (!doesArrayContain(old_folder_shortcuts, folder_shortcuts[i])) {
     84            Gatherer.println("Added shortcut: " + folder_shortcuts[i]);
     85            SynchronizedTreeModelTools.insertNodeInto(workspace_tree_model, workspace_tree_root, folder_shortcuts[i], false);
     86        }
     87        }
     88    }
    11289    }
    11390
     
    132109    }
    133110    }
     111
     112
     113    static private boolean doesArrayContain(Object[] array, Object item)
     114    {
     115    if (array == null) {
     116        return false;
     117    }
     118
     119    for (int i = 0; i < array.length; i++) {
     120        if (item.toString().equals(array[i].toString())) {
     121        return true;
     122        }
     123    }
     124
     125    return false;
     126    }
    134127}
Note: See TracChangeset for help on using the changeset viewer.