/** * Notify any DialogListeners of changes having occurred If a listener returns false, do not call * further listeners and disable the OK button and preview Checkbox (if it exists). For * PlugInFilters, this ensures that the PlugInFilterRunner, which listens as the last one, is not * called if the PlugInFilter has detected invalid parameters. Thus, unnecessary calling the * run(ip) method of the PlugInFilter for preview is avoided in that case. */ private void notifyListeners(AWTEvent e) { if (dialogListeners == null) return; boolean everythingOk = true; for (int i = 0; everythingOk && i < dialogListeners.size(); i++) try { resetCounters(); if (!((DialogListener) dialogListeners.elementAt(i)).dialogItemChanged(this, e)) everythingOk = false; } // disable further listeners if false (invalid parameters) returned catch (Exception err) { // for exceptions, don't cover the input by a window but IJ.beep(); // show them at in the "Log" IJ.log( "ERROR: " + err + "\nin DialogListener of " + dialogListeners.elementAt(i) + "\nat " + (err.getStackTrace()[0]) + "\nfrom " + (err.getStackTrace()[1])); // requires Java 1.4 } boolean workaroundOSXbug = IJ.isMacOSX() && okay != null && !okay.isEnabled() && everythingOk; if (previewCheckbox != null) previewCheckbox.setEnabled(everythingOk); if (okay != null) okay.setEnabled(everythingOk); if (workaroundOSXbug) repaint(); // OSX 10.4 bug delays update of enabled until the next input }
/** Method to set default values of abstract dialog */ public void setDefaultQueryDialogOptions() { // To prevent selecting current view as it is the default value if (!currentViewButton.isEnabled()) { currentViewButton.setSelection(false); newViewButton.setSelection(true); } else { currentViewButton.setSelection(true); newViewButton.setSelection(false); } lengthLimit.setText(String.valueOf(DEFAULT_LENGTH_LIMIT)); if (bothButton != null) { bothButton.setSelection(true); downstreamButton.setSelection(false); upstreamButton.setSelection(false); } else if (downstreamButton != null) { downstreamButton.setSelection(true); upstreamButton.setSelection(false); } if (shortestPlusK != null) { shortestPlusK.setText(String.valueOf(DEFAULT_SHORTEST_PLUS_K)); shortestPlusKButton.setSelection(false); strictButton.setSelection(false); } }
public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); IJ.setKeyDown(keyCode); if (keyCode == KeyEvent.VK_ENTER && textArea1 == null && okay != null && okay.isEnabled()) { wasOKed = true; if (IJ.isMacOSX()) accessTextFields(); dispose(); } else if (keyCode == KeyEvent.VK_ESCAPE) { wasCanceled = true; dispose(); IJ.resetEscape(); } else if (keyCode == KeyEvent.VK_W && (e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) { wasCanceled = true; dispose(); } }