示例#1
0
 /**
  * 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
 }
示例#2
0
 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();
   }
 }