Changeset 5869


Ignore:
Timestamp:
2003-11-18T14:10:45+13:00 (20 years ago)
Author:
mdewsnip
Message:

More improvements to workspace tree refreshing... still not perfect though.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

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

    r5854 r5869  
    33import org.greenstone.gatherer.collection.CollectionManager;
    44import org.greenstone.gatherer.file.FileNode;
     5import org.greenstone.gatherer.gui.MirrorPane;
    56import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
    67
     
    1213    static private WorkspaceTreeModel workspace_tree_model = null;
    1314    static private FileNode greenstone_collections_mapping = null;
     15    static private FileNode public_web_cache_mapping = null;
     16    static private FileNode private_web_cache_mapping = null;
    1417    static private FileNode[] collection_specific_mappings = null;
    1518
     
    3740    workspace_tree_root.insert(FileSystem.getUserHomeMapping());
    3841
    39     // If mirroring is enabled show the public and private caches
    40 //      if (Gatherer.config.get("workflow.mirror", false)) {
    41 //          // Add Public workspace
    42 //          FileNode public_root = new FileNode(new File(Utility.CACHE_DIR), Dictionary.get("Tree.Public"));
    43 //          workspace_root.insert(public_root);
    44 //          // Add Private workspace if a collection has been loaded.
    45 //          if(ready()) {
    46 //          FileNode private_root = new FileNode(new File(getCollectionCache()), Dictionary.get("Tree.Private"));
    47 //          workspace_root.insert(private_root);
    48 //          }
    49 //      }
     42    // Add public and private web caches if applicable
     43    loadWebCacheMappings();
    5044
    5145    // Add any collection specific mappings
     46    loadCollectionSpecificMappings();
     47
     48    return workspace_tree_model;
     49    }
     50
     51
     52    static private void loadWebCacheMappings()
     53    {
     54    // If mirroring is enabled show the public and private caches
     55    public_web_cache_mapping = MirrorPane.getPublicWebCacheMapping();
     56    if (public_web_cache_mapping != null) {
     57        workspace_tree_root.insert(public_web_cache_mapping);
     58    }
     59    private_web_cache_mapping = MirrorPane.getPrivateWebCacheMapping();
     60    if (private_web_cache_mapping != null) {
     61        workspace_tree_root.insert(private_web_cache_mapping);
     62    }
     63    }
     64
     65
     66    static private void loadCollectionSpecificMappings()
     67    {
     68    // Add the current collection specific mappings
    5269    collection_specific_mappings = CollectionManager.getCollectionSpecificMappings();
    5370    if (collection_specific_mappings != null) {
     
    5875        }
    5976    }
    60 
    61     return workspace_tree_model;
    6277    }
    6378
    6479
     80    // !! NEEDS WORK !!
    6581    static public void refreshGreenstoneCollectionsMapping()
    6682    {
     83    ((FileSystemModel) workspace_tree_model).refresh(
    6784    greenstone_collections_mapping.unmap();
    6885    greenstone_collections_mapping.map();
     
    7087
    7188
     89    // !! NEEDS WORK !!
     90    static public void refreshWebCacheMappings()
     91    {
     92    if (public_web_cache_mapping != null) {
     93        SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
     94                                public_web_cache_mapping);
     95    }
     96    if (private_web_cache_mapping != null) {
     97        SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
     98                                private_web_cache_mapping);
     99    }
     100
     101    loadWebCacheMappings();
     102    }
     103
     104
     105    // !! NEEDS WORK !!
    72106    static public void refreshCollectionSpecificMappings()
    73107    {
     
    80114    }
    81115
    82     // Add the current collection specific mappings
    83     collection_specific_mappings = CollectionManager.getCollectionSpecificMappings();
    84     if (collection_specific_mappings != null) {
    85         for (int i = 0; i < collection_specific_mappings.length; i++) {
    86         SynchronizedTreeModelTools.insertNodeInto(workspace_tree_model,
    87                               workspace_tree_root,
    88                               collection_specific_mappings[i]);
    89         }
    90     }
     116    loadCollectionSpecificMappings();
    91117    }
    92118}
  • trunk/gli/src/org/greenstone/gatherer/gui/MirrorPane.java

    r5847 r5869  
    3939import java.awt.*;
    4040import java.awt.event.*;
     41import java.io.File;
    4142import java.net.*;
    4243import javax.swing.*;
     
    4748import org.greenstone.gatherer.Gatherer;
    4849import org.greenstone.gatherer.WGet;
     50import org.greenstone.gatherer.file.FileNode;
    4951import org.greenstone.gatherer.util.Utility;
    5052
     
    193195    }
    194196
     197
     198    static public FileNode getPublicWebCacheMapping()
     199    {
     200    if (Gatherer.config.get("workflow.mirror", false)) {
     201        return new FileNode(new File(Utility.CACHE_DIR), Dictionary.get("Tree.Public"));
     202    }
     203
     204    return null;
     205    }
     206
     207
     208    static public FileNode getPrivateWebCacheMapping()
     209    {
     210    if (Gatherer.config.get("workflow.mirror", false) && Gatherer.c_man.ready()) {
     211        return new FileNode(new File(Gatherer.c_man.getCollectionCache()), Dictionary.get("Tree.Private"));
     212    }
     213
     214    return null;
     215    }
     216
     217
    195218    private class DownloadButtonListener
    196219    implements ActionListener {
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/WorkspaceTree.java

    r5854 r5869  
    5555    if (refresh_reason == WorkspaceTree.MAPPED_DIRECTORIES_CHANGED) {
    5656        System.err.println("Reason: mapped directories changed.");
     57        WorkspaceTreeModel.refreshWebCacheMappings();
    5758        WorkspaceTreeModel.refreshCollectionSpecificMappings();
     59        updateUI();
    5860    }
    5961    }
Note: See TracChangeset for help on using the changeset viewer.