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

Added "open file in external program" option to the right-click menu for files, and tidied up further the right click menu for both panes.

File:
1 edited

Legend:

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

    r7493 r7499  
    491491    }
    492492
     493
    493494    public void refreshCollectionTree(int refresh_reason) {
    494495    collection_tree.refresh(null);
     
    524525    /** When a user right-clicks within the workspace and collection trees they are presented with a small popup menu of context based options. This class provides such functionality.
    525526     */
    526     private class GPopupMenu
     527    private class RightClickMenu
    527528    extends JPopupMenu
    528529    implements ActionListener {
     
    532533    /** The tree nodes selected when the right click action occurred. */
    533534    private TreePath[] selection_paths = null;
    534     /** The file record over which the right click action occurred, if any. */
     535    /** The file record over which the right click action occurred. */
    535536    private FileNode node = null;
    536537
     
    542543    private JMenuItem metaaudit = null;
    543544    private JMenuItem new_folder = null;
    544 
    545 
    546     public GPopupMenu(DragTree tree, MouseEvent event)
     545    private JMenuItem open_externally = null;
     546
     547
     548    private RightClickMenu(DragTree tree, MouseEvent event)
    547549    {
    548550        super();
     
    599601        node = (FileNode) path.getLastPathComponent();
    600602
    601         // There are currently no options for plain files
     603        // ---- Options for file nodes ----
    602604        if (node.isLeaf()) {
     605        // Open the file in an external program
     606        open_externally = new JMenuItem(Dictionary.get("Menu.Open_Externally"), KeyEvent.VK_O);
     607        open_externally.addActionListener(this);
     608        add(open_externally);
     609
    603610        return;
    604611        }
     
    649656
    650657
    651     /** Called whenever one of the menu items is actioned apon, this method then causes the appropriate effect. */
     658    /** Called whenever one of the menu items is clicked, this method then causes the appropriate effect. */
    652659    public void actionPerformed(ActionEvent event)
    653660    {
     
    695702        Gatherer.f_man.newFolder(tree, node);
    696703        }
     704
     705        // Open in external program
     706        else if (source == open_externally) {
     707        Gatherer.self.spawnApplication(node.getFile());
     708        }
    697709    }
    698710    }
     
    899911    /** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to open a pop-up menu if we detect a right mouse click over one of our registered components, and start an external application if someone double clicks on a certain file record. */
    900912    public void mouseClicked(MouseEvent event) {
    901         if(SwingUtilities.isRightMouseButton(event)) {
    902         new GPopupMenu((DragTree)event.getSource(), event);
     913        if (SwingUtilities.isRightMouseButton(event)) {
     914        new RightClickMenu((DragTree) event.getSource(), event);
    903915        }
    904916    }
Note: See TracChangeset for help on using the changeset viewer.