Changeset 9108


Ignore:
Timestamp:
2005-02-18T14:54:12+13:00 (19 years ago)
Author:
kjdon
Message:

fixed up the right click selection on the colleciton tree

File:
1 edited

Legend:

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

    r8853 r9108  
    5858import org.greenstone.gatherer.file.WorkspaceTreeNode;
    5959import org.greenstone.gatherer.gui.tree.DragTree;
     60import org.greenstone.gatherer.gui.ExplodeMetadataPrompt;
    6061import org.greenstone.gatherer.util.DragComponent;
    6162import org.greenstone.gatherer.util.DragGroup;
     
    488489        this.tree = tree;
    489490
    490         // Get the paths currently selected in the tree
    491         selection_paths = tree.getSelectionPaths();
    492 
     491        // Note we have to use setImmediate() with the set selction paths
     492        // otherwise the selection doesn't get updated until after the
     493        // popup comes up.
     494
     495        // the right click position
     496        TreePath right_click_path = tree.getPathForLocation(event.getX(), event.getY());
     497        if (right_click_path == null) {
     498        // user has clicked outside of the tree, clear the selection
     499        selection_paths = null;
     500        tree.setImmediate(true);
     501        tree.clearSelection();
     502        tree.setImmediate(false);
     503        } else {
     504        // Get the paths currently selected in the tree
     505        selection_paths = tree.getSelectionPaths();
     506        if (selection_paths == null) {
     507            // nothing currently selected - we shift the selection to
     508            // the node that was right clicked on
     509            selection_paths = new TreePath[1];
     510            selection_paths[0] = right_click_path;
     511            tree.setImmediate(true);
     512            tree.setSelectionPath(right_click_path);
     513            tree.setImmediate(false);
     514        } else if (selection_paths.length == 1 && ! selection_paths[0].equals( right_click_path)) {
     515            tree.setImmediate(true);
     516            tree.clearSelection();
     517            tree.setSelectionPath(right_click_path);
     518            tree.setImmediate(false);
     519            selection_paths[0] = right_click_path;
     520        } else {
     521            // we had multiply selected paths in the tree.
     522            // if we clicked on one of those paths, then use all the
     523            // current selection, otherwise clear the selection and
     524            // select the one we right clicked on
     525            boolean clicked_in_selection = false;
     526            for (int i=0; i<selection_paths.length; i++) {
     527            if (selection_paths[i].equals(right_click_path)) {
     528                clicked_in_selection = true;
     529                break;
     530            }
     531            }
     532            if (!clicked_in_selection) {
     533            // want the tree to update right away
     534            tree.setImmediate(true);
     535            tree.clearSelection();
     536            tree.setSelectionPath(right_click_path);
     537            tree.setImmediate(false);
     538            selection_paths = new TreePath[1];
     539            selection_paths[0] = right_click_path;
     540            }
     541        }
     542        }
     543        // finally we have the correct selection paths!!
     544       
    493545        // Create an appropriate context menu, based on what is selected
    494546        buildContextMenu(selection_paths);
     
    628680        // Explode metadata database
    629681        else if (source == explode_metadata_database) {
     682        ExplodeMetadataPrompt emp = new ExplodeMetadataPrompt(node.getFile());
     683        //emp.destroy();
    630684        // !! TO DO: Open dialog with options to explode_metadata_databases.pl, then run it
    631685        }
Note: See TracChangeset for help on using the changeset viewer.