コード例 #1
0
  /** Parse clicks to cancel the recording if we get a click that's not in the JList (or ESC). */
  protected boolean parseClick(AWTEvent event) {

    if (isFinished()) {
      return false;
    }

    // FIXME add key-based activation/termination?
    boolean consumed = true;
    if (combo == null) {
      combo = getComboBox(event);
      listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
              index = combo.getSelectedIndex();
              if (!combo.isPopupVisible()) {
                combo.removeActionListener(listener);
                setFinished(true);
              }
            }
          };
      combo.addActionListener(listener);
      setStatus("Waiting for selection");
    } else if (event.getID() == KeyEvent.KEY_RELEASED
        && (((KeyEvent) event).getKeyCode() == KeyEvent.VK_SPACE
            || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) {
      index = combo.getSelectedIndex();
      setFinished(true);
    }
    // Cancel via click somewhere else
    else if (event.getID() == MouseEvent.MOUSE_PRESSED
        && !AWT.isOnPopup((Component) event.getSource())
        && combo != getComboBox(event)) {
      setFinished(true);
      consumed = false;
    }
    // Cancel via ESC key
    else if (event.getID() == KeyEvent.KEY_RELEASED
        && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ESCAPE) {
      setStatus("Selection canceled");
      setFinished(true);
    } else {
      Log.debug("Event ignored");
    }
    if (list == null && combo.isPopupVisible()) list = tester.findComboList(combo);

    if (isFinished()) {
      combo.removeActionListener(listener);
      listener = null;
    }

    return consumed;
  }
コード例 #2
0
  private boolean dispatchMouseEvent(AWTEvent event) {
    if (event.getID() != MouseEvent.MOUSE_PRESSED) {
      return false;
    }

    if (ourShowingStep == null) {
      return false;
    }

    WizardPopup eachParent = ourShowingStep;
    final MouseEvent mouseEvent = ((MouseEvent) event);

    Point point = (Point) mouseEvent.getPoint().clone();
    SwingUtilities.convertPointToScreen(point, mouseEvent.getComponent());

    while (true) {
      JComponent content = eachParent.getContent();
      if (content == null || !content.isShowing()) {
        getActiveRoot().cancel();
        return false;
      }

      if (eachParent.getBounds().contains(point) || !eachParent.canClose()) {
        return false;
      }

      eachParent = eachParent.getParent();
      if (eachParent == null) {
        getActiveRoot().cancel();
        return false;
      }
    }
  }
コード例 #3
0
 public void eventDispatched(final AWTEvent event) {
   if (event.getID() == WindowEvent.WINDOW_ACTIVATED) {
     if (myCancelOnWindow
         && myPopup != null
         && !myPopup.isPopupWindow(((WindowEvent) event).getWindow())) {
       cancel();
     }
   } else if (event.getID() == MouseEvent.MOUSE_ENTERED) {
     if (withinPopup(event)) {
       myEverEntered = true;
     }
   } else if (event.getID() == MouseEvent.MOUSE_MOVED) {
     if (myCancelOnMouseOutCallback != null && myEverEntered && !withinPopup(event)) {
       if (myCancelOnMouseOutCallback.check((MouseEvent) event)) {
         cancel();
       }
     }
   }
 }
コード例 #4
0
 public void itemListenerAction(IItemType itemType, AWTEvent event) {
   if (event.getID() == FocusEvent.FOCUS_LOST) {
     if (itemType == validFrom) {
       checkValidFrom();
     }
     if (itemType == validUntil) {
       checkValidUntil();
     }
   }
 }
コード例 #5
0
 @Override
 public void eventDispatched(AWTEvent event) {
   if (event.getID() == WindowEvent.WINDOW_OPENED) {
     final WindowEvent we = (WindowEvent) event;
     for (JBPopup each : JBPopupFactory.getInstance().getChildPopups(this)) {
       if (each.getContent() != null
           && SwingUtilities.isDescendingFrom(each.getContent(), we.getWindow())) {
         super.setPopupVisible(false);
       }
     }
   }
 }
コード例 #6
0
    @Override
    protected void focusedComponentChanged(final Component component, final AWTEvent cause) {
      EditorWindow newWindow = null;

      if (component != null) {
        newWindow = findWindowWith(component);
      } else if (cause instanceof ContainerEvent
          && cause.getID() == ContainerEvent.COMPONENT_REMOVED) {
        // do not change current window in case of child removal as in JTable.removeEditor
        // otherwise Escape in a toolwindow will not focus editor with JTable content
        return;
      }

      setCurrentWindow(newWindow);
      setCurrentWindow(newWindow, false);
    }