Ignore:
Timestamp:
2003-11-16T17:50:12+13:00 (21 years ago)
Author:
mdewsnip
Message:

More improvements to smart workspace tree refreshing. Library contents changes (eg. deleting collections) now refreshes the collect directory nicely.

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

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/CollectionPane.java

    r5847 r5854  
    244244    collection_tree_sync.add(collection_tree);
    245245
    246     refreshWorkspaceTree(DragTree.COLLECTION_CHANGED);
    247     refreshCollectionTree(DragTree.COLLECTION_CHANGED);
     246    refreshWorkspaceTree(DragTree.LOADED_COLLECTION_CHANGED);
     247    refreshCollectionTree(DragTree.LOADED_COLLECTION_CHANGED);
    248248
    249249    // Enable or disable the control buttons
     
    504504    workspace_tree.refresh(refresh_reason);
    505505    }
    506 
    507 
    508     /* public void refreshWorkspace() {
    509     System.err.println("CollectionPane::refreshWorkspace()... (ignored)");
    510     // workspace = Gatherer.c_man.getWorkspace();
    511     // workspace_tree.setModel(workspace);
    512     // workspace_tree_sync.add(workspace_tree);
    513     } */
    514506
    515507
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r5847 r5854  
    5454    static private final int AUTOSCROLL_MARGIN = 12;
    5555
    56     static public int COLLECTION_CHANGED          = 1;
     56    static public int LIBRARY_CONTENTS_CHANGED    = 0;
     57    static public int LOADED_COLLECTION_CHANGED   = 1;
    5758    static public int COLLECTION_CONTENTS_CHANGED = 2;
    5859    static public int TREE_DISPLAY_CHANGED        = 3;
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/WorkspaceTree.java

    r5847 r5854  
    2525    System.err.print("WorkspaceTree::refresh()... ");
    2626
    27     // A collection has been opened/closed - reload the workspace tree model
    28     if (refresh_reason == DragTree.COLLECTION_CHANGED) {
    29         System.err.println("Reason: collection changed.");
     27    // The collections in the library have changed - refresh the collect directory
     28    if (refresh_reason == DragTree.LIBRARY_CONTENTS_CHANGED) {
     29        System.err.println("Reason: library contents changed.");
     30        String collect_directory_str = Gatherer.config.gsdl_path + Utility.COL_DIR;
     31        refreshEveryNodeShowingFolder(collect_directory_str);
     32        WorkspaceTreeModel.refreshGreenstoneCollectionsMapping();
     33    }
     34
     35    // A collection has been opened/closed - reload the whole shebang
     36    if (refresh_reason == DragTree.LOADED_COLLECTION_CHANGED) {
     37        System.err.println("Reason: loaded collection changed.");
    3038        setModel(WorkspaceTreeModel.getWorkspaceTreeModel());
    3139    }
    3240
    33     // The collection's contents have changed - refresh expanded parts of the collection
     41    // The collection's contents have changed - refresh collection's import folder
    3442    if (refresh_reason == DragTree.COLLECTION_CONTENTS_CHANGED) {
    3543        System.err.println("Reason: collection contents changed.");
    36 
    3744        String import_directory_str = Gatherer.c_man.getCollectionImport();
    38 
    39         TreePath tree_root_path = new TreePath(getModel().getRoot());
    40         Enumeration expanded_tree_paths = getExpandedDescendants(tree_root_path);
    41         while (expanded_tree_paths.hasMoreElements()) {
    42         TreePath expanded_tree_path = (TreePath) expanded_tree_paths.nextElement();
    43         FileNode tree_node = (FileNode) expanded_tree_path.getLastPathComponent();
    44 
    45         File tree_node_file = tree_node.getFile();
    46         if (tree_node_file == null) {
    47             continue;
    48         }
    49 
    50         // Get the path of the open tree node
    51         String tree_node_path_str = tree_node_file.toString();
    52         if (!tree_node_path_str.endsWith(File.separator)) {
    53             tree_node_path_str = tree_node_path_str + File.separator;
    54         }
    55 
    56         // If the collection import directory is open, it must be refreshed
    57         if (tree_node_path_str.equals(import_directory_str)) {
    58             System.err.println("Must refresh collection import directory!");
    59             ((FileSystemModel) getModel()).refresh(expanded_tree_path);
    60         }
    61         }
     45        refreshEveryNodeShowingFolder(import_directory_str);
    6246    }
    6347
     
    7458    }
    7559    }
     60
     61
     62    private void refreshEveryNodeShowingFolder(String folder_path_str)
     63    {
     64    // Search through the expanded tree paths, checking if any show the given folder
     65    TreePath tree_root_path = new TreePath(getModel().getRoot());
     66    Enumeration expanded_tree_paths = getExpandedDescendants(tree_root_path);
     67    while (expanded_tree_paths.hasMoreElements()) {
     68        TreePath expanded_tree_path = (TreePath) expanded_tree_paths.nextElement();
     69        FileNode tree_node = (FileNode) expanded_tree_path.getLastPathComponent();
     70
     71        File tree_node_file = tree_node.getFile();
     72        if (tree_node_file == null) {
     73        continue;
     74        }
     75
     76        // Get the path of the open tree node
     77        String tree_node_path_str = tree_node_file.toString();
     78        if (!tree_node_path_str.endsWith(File.separator)) {
     79        tree_node_path_str = tree_node_path_str + File.separator;
     80        }
     81
     82        // If the collection import directory is open, it must be refreshed
     83        if (tree_node_path_str.equals(folder_path_str)) {
     84        System.err.println("Must refresh node " + tree_node_path_str + "!");
     85        ((FileSystemModel) getModel()).refresh(expanded_tree_path);
     86        }
     87    }
     88    }
    7689}
Note: See TracChangeset for help on using the changeset viewer.