@Override public void actionPerformed(ActionEvent e) { if (paramChoicesWindow!=null && paramChoicesWindow.isVisible()) { paramChoicesWindow.incSelection(amount); } else if (oldAction!=null) { oldAction.actionPerformed(e); } else { deactivate(); } }
@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(); } }
/** * Toggles the visibility of this popup window. * * @param visible Whether this window should be visible. */ @Override public void setVisible(boolean visible) { if (visible!=isVisible()) { // i.e. if no possibilities matched what's been typed if (visible && model.size()==0) {//list.getVisibleRowCount()==0) { return; } super.setVisible(visible); } }
@Override public void actionPerformed(ActionEvent e) { // If the param choices window is visible and something is chosen, // replace the parameter with it and move to the next one. if (paramChoicesWindow!=null && paramChoicesWindow.isVisible()) { if (insertSelectedChoice()) { return; } } // Otherwise, just move to the end. deactivate(); JTextComponent tc = ac.getTextComponent(); int dot = tc.getCaretPosition(); if (dot!=defaultEndOffs.getOffset()) { tc.setCaretPosition(defaultEndOffs.getOffset()); } else { // oldEnterAction isn't what we're looking for (wrong key) Action a = getDefaultEnterAction(tc); if (a!=null) { a.actionPerformed(e); } else { tc.replaceSelection("\n"); } } }
/** * Inserts the choice selected in the parameter choices window. * * @return Whether the choice was inserted. This will be <code>false</code> * if the window is not visible, or no choice is selected. */ boolean insertSelectedChoice() { if (paramChoicesWindow!=null && paramChoicesWindow.isVisible()) { String choice = paramChoicesWindow.getSelectedChoice(); if (choice!=null) { JTextComponent tc = ac.getTextComponent(); Highlight h = getCurrentParameterHighlight(); if (h!=null) { // "+1" is a workaround for Java Highlight issues. tc.setSelectionStart(h.getStartOffset()+1); tc.setSelectionEnd(h.getEndOffset()); tc.replaceSelection(choice); moveToNextParam(); } else { UIManager.getLookAndFeel().provideErrorFeedback(tc); } return true; } } return false; }