@Override public void keyPressed(KeyEvent evt) { switch (evt.getKeyCode()) { case KeyEvent.VK_SPACE: goToSelectedNode(M_OPEN); // f**k me dead EventQueue.invokeLater( new Runnable() { @Override public void run() { resultTree.requestFocus(); } }); evt.consume(); break; case KeyEvent.VK_ENTER: goToSelectedNode(M_OPEN); evt.consume(); break; case KeyEvent.VK_DELETE: removeSelectedNode(); evt.consume(); break; default: break; } }
// {{{ BrowserView constructor BrowserView(final VFSBrowser browser) { this.browser = browser; tmpExpanded = new HashSet<String>(); DockableWindowManager dwm = jEdit.getActiveView().getDockableWindowManager(); KeyListener keyListener = dwm.closeListener(VFSBrowser.NAME); parentDirectories = new ParentDirectoryList(); parentDirectories.addKeyListener(keyListener); parentDirectories.setName("parent"); parentDirectories.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); parentDirectories.setCellRenderer(new ParentDirectoryRenderer()); parentDirectories.setVisibleRowCount(5); parentDirectories.addMouseListener(new ParentMouseHandler()); final JScrollPane parentScroller = new JScrollPane(parentDirectories); parentScroller.setMinimumSize(new Dimension(0, 0)); table = new VFSDirectoryEntryTable(this); table.addMouseListener(new TableMouseHandler()); table.addKeyListener(new TableKeyListener()); table.setName("file"); JScrollPane tableScroller = new JScrollPane(table); tableScroller.setMinimumSize(new Dimension(0, 0)); tableScroller.getViewport().setBackground(table.getBackground()); tableScroller.getViewport().addMouseListener(new TableMouseHandler()); splitPane = new JSplitPane( browser.isHorizontalLayout() ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT, parentScroller, tableScroller); splitPane.setOneTouchExpandable(true); EventQueue.invokeLater( new Runnable() { public void run() { String prop = browser.isHorizontalLayout() ? "vfs.browser.horizontalSplitter" : "vfs.browser.splitter"; int loc = jEdit.getIntegerProperty(prop, -1); if (loc == -1) loc = parentScroller.getPreferredSize().height; splitPane.setDividerLocation(loc); parentDirectories.ensureIndexIsVisible(parentDirectories.getModel().getSize()); } }); if (browser.isMultipleSelectionEnabled()) table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); else table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setLayout(new BorderLayout()); add(BorderLayout.CENTER, splitPane); propertiesChanged(); } // }}}
/** * @param searchNode the result node * @param selectNode the node that must be selected, or null * @since jEdit 4.3pre12 */ public void searchDone( final DefaultMutableTreeNode searchNode, final DefaultMutableTreeNode selectNode) { stop.setEnabled(false); final int nodeCount = searchNode.getChildCount(); if (nodeCount < 1) { searchFailed(); return; } caption.setText( jEdit.getProperty("hypersearch-results.done", new String[] {trimSearchString()})); EventQueue.invokeLater( new Runnable() { @Override public void run() { if (!multiStatus) { for (int i = 0; i < resultTreeRoot.getChildCount(); i++) { resultTreeRoot.remove(0); } } resultTreeRoot.add(searchNode); resultTreeModel.reload(resultTreeRoot); for (int i = 0; i < nodeCount; i++) { TreePath lastNode = new TreePath(((DefaultMutableTreeNode) searchNode.getChildAt(i)).getPath()); resultTree.expandPath(lastNode); } TreePath treePath; if (selectNode == null) { treePath = new TreePath(new Object[] {resultTreeRoot, searchNode}); } else { treePath = new TreePath(selectNode.getPath()); } resultTree.setSelectionPath(treePath); resultTree.scrollPathToVisible(treePath); } }); } // }}}
// {{{ InstallPanel constructor InstallPanel(PluginManager window, boolean updates) { super(new BorderLayout(12, 12)); this.window = window; this.updates = updates; setBorder(new EmptyBorder(12, 12, 12, 12)); final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setResizeWeight(0.75); /* Setup the table */ table = new JTable(pluginModel = new PluginTableModel()); table.setShowGrid(false); table.setIntercellSpacing(new Dimension(0, 0)); table.setRowHeight(table.getRowHeight() + 2); table.setPreferredScrollableViewportSize(new Dimension(500, 200)); table.setDefaultRenderer( Object.class, new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class))); table.addFocusListener(new TableFocusHandler()); InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED); ActionMap tableActionMap = table.getActionMap(); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward"); tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack"); tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin"); tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN)); tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager"); tableActionMap.put( "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER)); TableColumn col1 = table.getColumnModel().getColumn(0); TableColumn col2 = table.getColumnModel().getColumn(1); TableColumn col3 = table.getColumnModel().getColumn(2); TableColumn col4 = table.getColumnModel().getColumn(3); TableColumn col5 = table.getColumnModel().getColumn(4); col1.setPreferredWidth(30); col1.setMinWidth(30); col1.setMaxWidth(30); col1.setResizable(false); col2.setPreferredWidth(180); col3.setPreferredWidth(130); col4.setPreferredWidth(70); col5.setPreferredWidth(70); JTableHeader header = table.getTableHeader(); header.setReorderingAllowed(false); header.addMouseListener(new HeaderMouseHandler()); header.setDefaultRenderer( new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer())); scrollpane = new JScrollPane(table); scrollpane.getViewport().setBackground(table.getBackground()); split.setTopComponent(scrollpane); /* Create description */ JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox()); infoPane.setPreferredSize(new Dimension(500, 100)); split.setBottomComponent(infoPane); EventQueue.invokeLater( new Runnable() { @Override public void run() { split.setDividerLocation(0.75); } }); final JTextField searchField = new JTextField(); searchField.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { table.dispatchEvent(e); table.requestFocus(); } } }); searchField .getDocument() .addDocumentListener( new DocumentListener() { void update() { pluginModel.setFilterString(searchField.getText()); } @Override public void changedUpdate(DocumentEvent e) { update(); } @Override public void insertUpdate(DocumentEvent e) { update(); } @Override public void removeUpdate(DocumentEvent e) { update(); } }); table.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int i = table.getSelectedRow(), n = table.getModel().getRowCount(); if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1) || e.getKeyCode() == KeyEvent.VK_UP && i == 0) { searchField.requestFocus(); searchField.selectAll(); } } }); Box filterBox = Box.createHorizontalBox(); filterBox.add(new JLabel("Filter : ")); filterBox.add(searchField); add(BorderLayout.NORTH, filterBox); add(BorderLayout.CENTER, split); /* Create buttons */ Box buttons = new Box(BoxLayout.X_AXIS); buttons.add(new InstallButton()); buttons.add(Box.createHorizontalStrut(12)); buttons.add(new SelectallButton()); buttons.add(chooseButton = new ChoosePluginSet()); buttons.add(new ClearPluginSet()); buttons.add(Box.createGlue()); buttons.add(new SizeLabel()); add(BorderLayout.SOUTH, buttons); String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, ""); if (!path.isEmpty()) { loadPluginSet(path); } } // }}}