- Timestamp:
- 2003-05-27T15:57:37+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileOpenActionListener.java
r4293 r4366 48 48 */ 49 49 public class FileOpenActionListener 50 51 52 53 54 55 56 57 50 extends MouseAdapter 51 implements TreeExpansionListener { 52 /** This flag gets toggled to <i>true</i> if the listener determines that the next mouse clicked event it will recieve is actually caused by the tree expanding or collapsing. */ 53 private boolean ignore = false; 54 /** The constructor. */ 55 public FileOpenActionListener() { 56 } 57 /** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to start an external application if someone double clicks on an appropriate file record. 58 58 * @param event A <strong>MouseEvent</strong> containing further information about the mouse click performed. 59 59 * @see org.greenstone.gatherer.Gatherer … … 61 61 * @see org.greenstone.gatherer.tree.GTree 62 62 */ 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 63 public void mouseClicked(MouseEvent event) { 64 ///ystem.err.println("Mouse clicked"); 65 if(!ignore) { 66 if(event.getClickCount() >= 2) { 67 // Find the file we're clicking on. 68 JTree tree = (JTree)event.getSource(); 69 TreePath path = tree.getClosestPathForLocation(event.getX(), event.getY()); 70 if(path != null) { 71 FileNode record = (FileNode)path.getLastPathComponent(); 72 ///ystem.err.println("Double clicked on " + record); 73 File file = record.getFile(); 74 if(file != null && file.isFile()) { 75 ///ystem.err.println("Running " + file); 76 Gatherer.self.spawnApplication(file); 77 } 78 } 79 } 80 } 81 else { 82 82 ///ystem.err.println("Caused by tree expansion / collapse. Ignoring."); 83 84 85 86 83 ignore = false; 84 } 85 } 86 /** Any implementation of TreeExpansionListener must include this method so that we can be informed when a tree node has been collapsed, thus indicating that any mouse click events about to be recieved are most likely related to this event. 87 87 * @param event A <strong>TreeExpansionEvent</strong> containing information about the node collapsed. 88 88 */ 89 90 91 92 93 89 public void treeCollapsed(TreeExpansionEvent event) { 90 ///ystem.err.println("Tree Collapsed"); 91 ignore = true; 92 } 93 /** Any implementation of TreeExpansionListener must include this method so that we can be informed when a tree node has been expanded, thus indicating that any mouse click events about to be recieved are most likely related to this event. 94 94 * @param event A <strong>TreeExpansionEvent</strong> containing information about the node expanded. 95 95 */ 96 97 98 99 96 public void treeExpanded(TreeExpansionEvent event) { 97 ///ystem.err.println("Tree Expanded"); 98 ignore = true; 99 } 100 100 }
Note:
See TracChangeset
for help on using the changeset viewer.