@Override public void actionPerformed(ActionEvent e) { // On first escape press, if the param choices window is visible, // just remove it, but keep ability to tab through params. If // param choices window isn't visible, or second escape press, // exit tabbing through params entirely. if (paramChoicesWindow!=null && paramChoicesWindow.isVisible()) { paramChoicesWindow.setVisible(false); paramChoicesWindow = null; } else { deactivate(); } }
/** * Hides any popup windows and terminates parameterized completion * assistance. * * @see #activate() */ public void deactivate() { if (!active) { return; } active = false; listener.uninstall(); if (tip!=null) { tip.setVisible(false); } if (paramChoicesWindow!=null) { paramChoicesWindow.setVisible(false); } }
setVisible(false); list.ensureIndexIsVisible(0); if (!isVisible()) { setVisible(true); setVisible(false);
/** * Updates the optional window listing likely completion choices. */ private void prepareParamChoicesWindow() { // If this window was set to null, the user pressed Escape to hide it if (paramChoicesWindow!=null) { int offs = getCurrentParameterStartOffset(); if (offs==-1) { paramChoicesWindow.setVisible(false); return; } JTextComponent tc = ac.getTextComponent(); try { Rectangle r = tc.modelToView(offs); Point p = new Point(r.x, r.y); SwingUtilities.convertPointToScreen(p, tc); r.x = p.x; r.y = p.y; paramChoicesWindow.setLocationRelativeTo(r); } catch (BadLocationException ble) { // Should never happen UIManager.getLookAndFeel().provideErrorFeedback(tc); ble.printStackTrace(); } // Toggles visibility, if necessary. paramChoicesWindow.setParameter(lastSelectedParam, paramPrefix); } }
paramChoicesWindow.setVisible(true);