@Override public void mouseReleased(MouseEvent evt) { if (evt.getClickCount() % 2 != 0 && !GUIUtilities.isMiddleButton(evt.getModifiers())) return; int row = parentDirectories.locationToIndex(evt.getPoint()); if (row != -1) { Object obj = parentDirectories.getModel().getElementAt(row); if (obj instanceof VFSFile) { VFSFile dirEntry = (VFSFile) obj; if (!GUIUtilities.isPopupTrigger(evt)) { browser.setDirectory(dirEntry.getPath()); if (browser.getMode() == VFSBrowser.BROWSER) focusOnFileView(); } } } }
// {{{ showFilePopup() method private void showFilePopup(VFSFile[] files, Component comp, Point point) { popup = new BrowserCommandsMenu(browser, files); // for the parent directory right-click; on the click we select // the clicked item, but when the popup goes away we select the // currently showing directory. popup.addPopupMenuListener( new PopupMenuListener() { public void popupMenuCanceled(PopupMenuEvent e) {} public void popupMenuWillBecomeVisible(PopupMenuEvent e) {} public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // we use SwingUtilities.invokeLater() // so that the action is executed before // the popup is hidden. EventQueue.invokeLater( new Runnable() { public void run() { int index = parentDirectories.getModel().getSize() - 1; parentDirectories.setSelectedIndex(index); } }); } }); GUIUtilities.showPopupMenu(popup, comp, point.x, point.y); } // }}}
// {{{ mousePressed() method @Override public void mousePressed(MouseEvent evt) { Point p = evt.getPoint(); if (evt.getSource() != table) { p.x -= table.getX(); p.y -= table.getY(); } int row = table.rowAtPoint(p); int column = table.columnAtPoint(p); if (column == 0 && row != -1) { VFSDirectoryEntryTableModel.Entry entry = (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0); if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) { table.toggleExpanded(row); return; } } if (GUIUtilities.isMiddleButton(evt.getModifiers())) { if (row == -1) /* nothing */ ; else if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row); else table.getSelectionModel().setSelectionInterval(row, row); } else if (GUIUtilities.isPopupTrigger(evt)) { if (popup != null && popup.isVisible()) { popup.setVisible(false); popup = null; return; } if (row == -1) showFilePopup(null, table, evt.getPoint()); else { if (!table.getSelectionModel().isSelectedIndex(row)) table.getSelectionModel().setSelectionInterval(row, row); showFilePopup(getSelectedFiles(), table, evt.getPoint()); } } } // }}}
@Override public void mousePressed(MouseEvent evt) { int row = parentDirectories.locationToIndex(evt.getPoint()); if (row != -1) { Object obj = parentDirectories.getModel().getElementAt(row); if (obj instanceof VFSFile) { VFSFile dirEntry = (VFSFile) obj; if (GUIUtilities.isPopupTrigger(evt)) { if (popup != null && popup.isVisible()) { popup.setVisible(false); popup = null; } else { parentDirectories.setSelectedIndex(row); showFilePopup(new VFSFile[] {dirEntry}, parentDirectories, evt.getPoint()); } } } } }
// {{{ mouseClicked() method @Override public void mouseClicked(MouseEvent evt) { Point p = evt.getPoint(); int row = table.rowAtPoint(p); int column = table.columnAtPoint(p); if (row == -1) return; if (column == 0) { VFSDirectoryEntryTableModel.Entry entry = (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0); if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) { return; } } if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && evt.getClickCount() % 2 == 0) { browser.filesActivated( evt.isShiftDown() ? VFSBrowser.M_OPEN_NEW_VIEW : VFSBrowser.M_OPEN, true); } else if (GUIUtilities.isMiddleButton(evt.getModifiers())) { if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row); else table.getSelectionModel().setSelectionInterval(row, row); browser.filesActivated( evt.isShiftDown() ? VFSBrowser.M_OPEN_NEW_VIEW : VFSBrowser.M_OPEN, true); } } // }}}
// {{{ mouseReleased() method @Override public void mouseReleased(MouseEvent evt) { if (!GUIUtilities.isPopupTrigger(evt) && table.getSelectedRow() != -1) { browser.filesSelected(); } } // }}}