Changeset 7484


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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r7482 r7484  
    138138    Gatherer.config.addDirectoryMapping(name, file);
    139139    // Now update the tree
    140     Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED);
     140    Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.FOLDER_SHORTCUTS_CHANGED);
    141141    }
    142142    /** This method calls the builcol.pl scripts via a GShell so as to not lock up the processor.
     
    411411        collection.cdm = new CollectionDesignManager(new File(getCollectionConfig()));
    412412
    413         // Now that we have a CDM, update several settings, such as if we created this collection by basing it on another, set it as public automatically
     413        // Now that we have a CDM, update several settings, such as if we created this collection by basing it on another, set it as public automatically
    414414        if(base_collection_directory != null) {
    415415            // Update the creator and maintainer
     
    472472        Gatherer.printStackTrace(error);
    473473    }
    474     // Done.
    475     if(Gatherer.g_man != null) {
    476         // workspace_model = null;
    477         // set the view to Gather pane
     474
     475    // Done, so refresh interface
     476    if (Gatherer.g_man != null) {
     477        // Return to some initial pane (Gather)
    478478        Gatherer.g_man.returnToInitialPane();
     479
     480        // Refresh the workspace tree to allow for the new collection
     481        Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED);
     482
    479483        Gatherer.g_man.collectionChanged(ready());
    480484    }
     
    719723
    720724
    721     static public FileNode[] getCollectionSpecificMappings()
     725    static public FileNode[] getFolderShortcuts()
    722726    {
    723727    // Return any predefined special directories
     
    11981202    File file = Gatherer.config.removeDirectoryMapping(target.toString());
    11991203    // Update tree.
    1200     Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED);
     1204    Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.FOLDER_SHORTCUTS_CHANGED);
    12011205    return file;
    12021206    }
  • trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java

    r7482 r7484  
    4949import org.greenstone.gatherer.gui.ModalDialog;
    5050import org.greenstone.gatherer.gui.SimpleMenuBar;
    51 import org.greenstone.gatherer.gui.tree.DragTree;
     51import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    5252import org.greenstone.gatherer.util.ArrayTools;
    5353import org.greenstone.gatherer.util.GSDLSiteConfig;
     
    327327
    328328        // Refresh the collections shown in the workspace tree
    329         Gatherer.g_man.refreshWorkspaceTree(DragTree.LIBRARY_CONTENTS_CHANGED);
     329        Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED);
    330330
    331331        resultPrompt(true);
  • 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}
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r7482 r7484  
    681681    // If the rawname was mirror then rebuild workspace tree to remove caches.
    682682    if (rawname.equals("Mirror")) {
    683         gather_pane.refreshWorkspaceTree(WorkspaceTree.MAPPED_DIRECTORIES_CHANGED);
     683        // gather_pane.refreshWorkspaceTree(WorkspaceTree.FOLDER_SHORTCUTS_CHANGED);
    684684    }
    685685    }
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r7482 r7484  
    246246    collection_tree_sync.add(collection_tree);
    247247
    248     refreshWorkspaceTree(DragTree.LOADED_COLLECTION_CHANGED);
     248    // Refresh the collection tree (the workspace tree stays the same)
    249249    refreshCollectionTree(DragTree.LOADED_COLLECTION_CHANGED);
    250250
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r6249 r7484  
    5858    static private final int AUTOSCROLL_MARGIN = 12;
    5959
    60     static public int LIBRARY_CONTENTS_CHANGED    = 0;
     60    static public int TREE_DISPLAY_CHANGED        = 0;
    6161    static public int LOADED_COLLECTION_CHANGED   = 1;
    6262    static public int COLLECTION_CONTENTS_CHANGED = 2;
    63     static public int TREE_DISPLAY_CHANGED        = 3;
    6463
    6564
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/WorkspaceTree.java

    r7482 r7484  
    66import org.greenstone.gatherer.Gatherer;
    77import org.greenstone.gatherer.file.FileNode;
    8 import org.greenstone.gatherer.file.FileSystemModel;
    98import org.greenstone.gatherer.file.WorkspaceTreeModel;
    109import org.greenstone.gatherer.util.Utility;
     
    1413    extends DragTree {
    1514
    16     static public int MAPPED_DIRECTORIES_CHANGED = 11;
     15    static public int LIBRARY_CONTENTS_CHANGED = 10;
     16    static public int FOLDER_SHORTCUTS_CHANGED = 11;
    1717
    1818
     
    2727    Gatherer.println("WorkspaceTree::refresh()... ");
    2828
    29     // The collections in the library have changed - refresh the collect directory
    30     if (refresh_reason == DragTree.LIBRARY_CONTENTS_CHANGED) {
    31         Gatherer.println("...Reason: library contents changed.");
    32         String collect_directory_str = Gatherer.config.gsdl_path + Utility.COL_DIR;
    33         refreshEveryNodeShowingFolder(collect_directory_str);
    34         WorkspaceTreeModel.refreshGreenstoneCollectionsMapping();
    35     }
     29    // The method for displaying the tree has changed - redraw the tree
     30    if (refresh_reason == DragTree.TREE_DISPLAY_CHANGED) {
     31        Gatherer.println("...Reason: tree display changed.");
     32        updateUI();
     33    }
    3634
    37     // A collection has been opened/closed - reload the whole shebang
     35    // The loaded collection has changed - currently do nothing
    3836    if (refresh_reason == DragTree.LOADED_COLLECTION_CHANGED) {
    3937        Gatherer.println("...Reason: loaded collection changed.");
    40         setModel(WorkspaceTreeModel.getWorkspaceTreeModel());
    4138    }
    4239
     
    4845    }
    4946
    50     // The method for displaying the tree has changed - redraw the tree
    51     if (refresh_reason == DragTree.TREE_DISPLAY_CHANGED) {
    52         Gatherer.println("...Reason: tree display changed.");
    53         updateUI();
    54     }
     47    // The collections in the library have changed - refresh the collect directory
     48    if (refresh_reason == WorkspaceTree.LIBRARY_CONTENTS_CHANGED) {
     49        Gatherer.println("...Reason: library contents changed.");
     50        String collect_directory_str = Gatherer.config.gsdl_path + Utility.COL_DIR;
     51        refreshEveryNodeShowingFolder(collect_directory_str);
     52        WorkspaceTreeModel.refreshGreenstoneCollectionsMapping();
     53    }
    5554
    56     // The collection specific mapped directories have changed - refresh only them
    57     if (refresh_reason == WorkspaceTree.MAPPED_DIRECTORIES_CHANGED) {
    58         Gatherer.println("...Reason: mapped directories changed.");
    59         WorkspaceTreeModel.refreshWebCacheMappings();
    60         WorkspaceTreeModel.refreshCollectionSpecificMappings();
    61         updateUI();
     55    // The folder shortcuts have changed - refresh only them
     56    if (refresh_reason == WorkspaceTree.FOLDER_SHORTCUTS_CHANGED) {
     57        Gatherer.println("...Reason: folder shortcuts changed.");
     58        WorkspaceTreeModel.refreshFolderShortcuts();
    6259    }
    6360    }
     
    8784        if (tree_node_path_str.equals(folder_path_str)) {
    8885        System.err.println("Must refresh node " + tree_node_path_str + "!");
    89         ((FileSystemModel) getModel()).refresh(expanded_tree_path);
     86        ((WorkspaceTreeModel) getModel()).refresh(expanded_tree_path);
    9087        }
    9188    }
Note: See TracChangeset for help on using the changeset viewer.