Пример #1
0
  /**
   * Handle an event. This can either be ignored or contribute to the recording. For a given event,
   * if no current semantic recorder is active, select one based on the event's component. If the
   * semantic recorder accepts the event, then it is used to consume each subsequent event, until
   * its recordEvent method returns true, indicating that the semantic event has completed.
   */
  protected void recordEvent(java.awt.AWTEvent event) throws RecordingFailedException {

    // Discard any key/button release events at the start of the recording.
    if (steps.size() == 0 && event.getID() == KeyEvent.KEY_RELEASED) {
      Log.log("Ignoring initial release event");
      return;
    }

    SemanticRecorder newRecorder = null;

    // Process extraneous key modifiers used to simulate mouse buttons
    // Only check events while we have no semantic recorder, though,
    // because we wish to ignore everything between the modifiers
    if (Platform.isMacintosh() && semanticRecorder == null) {
      if (pruneClickModifiers(event)) return;
    }

    if (semanticRecorder == null) {
      SemanticRecorder sr =
          (event.getSource() instanceof Component)
              ? getSemanticRecorder((Component) event.getSource())
              // Use ComponentRecorder for MenuComponents
              : getSemanticRecorder(Component.class);
      if (sr.accept(event)) {
        semanticRecorder = newRecorder = sr;
        setStatus("Recording semantic event with " + sr);
        if (event.getSource() instanceof JInternalFrame) {
          // Ideally, adding an extra listener would be done by the
          // JInternalFrameRecorder, but the object needs more state
          // than is available to the recorder (notably to be able
          // to send events to the primary recorder).  If something
          // else turns up similar to this, then the EventRecorder
          // should be made available to the semantic recorders.
          //
          // Must add a listener, since COMPONENT_HIDDEN is not sent
          // on JInternalFrame close (1.4.1).
          JInternalFrame f = (JInternalFrame) event.getSource();
          new InternalFrameWatcher(f);
        }
      }
    }

    // If we're currently recording a semantic event, continue to do so
    if (semanticRecorder != null) {
      boolean consumed = semanticRecorder.record(event);
      boolean finished = semanticRecorder.isFinished();
      if (finished) {
        Log.debug("Semantic recorder is finished");
        saveSemanticEvent();
      }
      // If not consumed, need to check for semantic recorder (again)
      // (but avoid recursing indefinitely)
      if (!consumed && newRecorder == null) {
        Log.debug("Event was not consumed, parse it again");
        recordEvent(event);
      }
    } else {
      captureRawEvent(event);
    }
  }
 public void eventDispatched(AWTEvent event) {
   if (event.getID() == WindowEvent.WINDOW_OPENED) {
     handleWindowOpened(event);
   } else if (event.getID() == WindowEvent.WINDOW_CLOSED) {
     handleWindowClosed(event);
   }
 }
Пример #3
0
 /** see: http://www.javakey.net/4-java-gui/686df4a3d194cade.htm */
 private synchronized void startModal() {
   if (this.isVisible() && !this.isShowing()) {
     Container parent = this.getParent();
     while (parent != null) {
       if (parent.isVisible() == false) {
         parent.setVisible(true);
       }
       parent = parent.getParent();
     }
   }
   try {
     if (SwingUtilities.isEventDispatchThread()) {
       EventQueue theQueue = getToolkit().getSystemEventQueue();
       while (this.isVisible()) {
         AWTEvent event = theQueue.getNextEvent();
         Object source = event.getSource();
         if (event instanceof ActiveEvent) {
           ((ActiveEvent) event).dispatch();
         } else if (source instanceof Component) {
           ((Component) source).dispatchEvent(event);
         } else if (source instanceof MenuComponent) {
           ((MenuComponent) source).dispatchEvent(event);
         } else {
           System.err.println("Unable to dispatch: " + event);
         }
       }
     } else {
       while (this.isVisible()) {
         wait();
       }
     }
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
Пример #4
0
 /**
  * Used only on Mac OS, to remove key modifiers that are used to simulate mouse buttons 2 and 3.
  * Returns whether the event should be ignored.
  */
 private boolean pruneClickModifiers(AWTEvent event) {
   lastButton = 0;
   boolean ignoreEvent = false;
   if (event.getID() == MouseEvent.MOUSE_PRESSED) {
     MouseEvent me = (MouseEvent) event;
     int buttons = me.getModifiers() & (MouseEvent.BUTTON2_MASK | MouseEvent.BUTTON3_MASK);
     pruneButtonModifier = buttons != 0;
     lastButton = buttons;
   } else if (event.getID() == KeyEvent.KEY_RELEASED && pruneButtonModifier) {
     pruneButtonModifier = false;
     KeyEvent ke = (KeyEvent) event;
     int code = ke.getKeyCode();
     if ((code == KeyEvent.VK_CONTROL
             || code == KeyEvent.VK_ALT && (lastButton & MouseEvent.BUTTON2_MASK) != 0)
         || (code == KeyEvent.VK_META && (lastButton & MouseEvent.BUTTON3_MASK) != 0)) {
       if (steps.size() > 1) {
         Step step = (Step) steps.get(steps.size() - 2);
         if ((code == KeyEvent.VK_CONTROL && isKey(step, "VK_CONTROL", PRESS)
                 || (code == KeyEvent.VK_ALT && isKey(step, "VK_ALT", PRESS)))
             || (code == KeyEvent.VK_META && isKey(step, "VK_META", PRESS))) {
           // might be another one
           steps.remove(steps.size() - 2);
           pruneButtonModifier = true;
           ignoreEvent = true;
         }
       }
     }
   }
   return ignoreEvent;
 }
 public final void processEvent(AWTEvent evt) {
   if (evt.getID() == WindowEvent.WINDOW_CLOSING) {
     extension.closeConsole();
     return;
   }
   if (evt.getID() == WindowEvent.WINDOW_OPENED) {}
   super.processEvent(evt);
 }
Пример #6
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;
  }
Пример #7
0
  public void processEvent(AWTEvent arg0) {

    if ((Component) arg0.getSource() instanceof javax.swing.JInternalFrame
        && !this.lastWidgetClicked.equals("")) {

      if (arg0.getID() == 1400)
        this.hierarchy.processWidget((Component) arg0.getSource(), this.lastWidgetClicked + "/0");
    }

    if (arg0.getID() == WindowEvent.WINDOW_ACTIVATED /*&& !this.lastWidgetClicked.equals("")*/) {
      System.err.println("[GUIMIN][Replayer] WINDOW ACTIVATED: " + this.lastWidgetClicked);

      if (this.hierarchy.findWidgetId((Component) arg0.getSource()) == null
          && this.hierarchy.findWidget(this.lastWidgetClicked + "/0") == null) {

        this.hierarchy.processWidget((Component) arg0.getSource(), this.lastWidgetClicked + "/0");

        /*				try {
        	Thread.sleep(3000);
        } catch (InterruptedException e1) {
        	// TODO Auto-generated catch block
        	e1.printStackTrace();
        }*/

      } else if (this.hierarchy.findWidgetId((Component) arg0.getSource()) == null
          && this.hierarchy.findWidget(this.lastWidgetClicked + "/0") != null) {

        this.hierarchy.updateWidget((Component) arg0.getSource(), this.lastWidgetClicked + "/0");
      }
    }
  }
Пример #8
0
 /**
  * Distributes an event based on its eventid. Calls all lambda expressions with matching id and
  * auto-obtained subid.
  *
  * @param e
  */
 public final void fireEvent(AWTEvent e) {
   Pair<Integer, Integer> id = null;
   if (e instanceof MouseEvent) {
     id = new Pair<>(e.getID(), ((MouseEvent) e).getButton());
   } else if (e instanceof KeyEvent) {
     id = new Pair<>(e.getID(), ((KeyEvent) e).getKeyCode());
   }
   if (id != null && this.bindings.containsKey(id)) {
     bindings.get(id).stream().forEach((c) -> c.accept(e));
   }
   id = new Pair<>(e.getID(), 0);
   if (this.bindings.containsKey(id)) {
     bindings.get(id).stream().forEach((c) -> c.accept(e));
   }
 }
Пример #9
0
 public void eventDispatched(AWTEvent event) {
   if (isDirectedScanning) {
     MouseEvent me = (MouseEvent) event;
     if (me.getButton() == MouseEvent.BUTTON1) {
       // 96
       // if (HiHaFiambreig) PararTimerFiambreig();
       if (me.getID() == MouseEvent.MOUSE_RELEASED) {
         if (withSwaying) {
           stopSwayingTimer();
         }
         actPanel.clickLeftButton();
         if (withSwaying) {
           startDirectedScanSwayingTimer();
         }
       }
     } else if (me.getButton() == MouseEvent.BUTTON3) {
       if (event.getID() == MouseEvent.MOUSE_RELEASED) {
         if (withSwaying) {
           stopSwayingTimer();
         }
         actPanel.nextScanPosition();
         if (withSwaying) {
           startSwayingTimer();
         }
       }
     }
   }
 }
  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;
      }
    }
  }
Пример #11
0
 public void userInserted(AWTEvent e) {
   User u = (User) e.getSource();
   pUser.add(0, u);
   ((UserBrowserModel) table.getModel()).fireTableDataChanged();
   table.updateUI();
   if (table.getRowCount() > 0) table.setRowSelectionInterval(0, 0);
 }
  @Override
  public void eventDispatched(AWTEvent event) {
    assert event instanceof KeyEvent
        : "Shall only listen to KeyEvents, so no other events shall come here";
    assert assertEDT(); // REMEMBER THAT THIS IS SINGLE THREADED, so no need for synch.

    // ?: Is this one of our synthetic RELEASED events?
    if (event instanceof Reposted) {
      // -> Yes, so we shalln't process it again.
      return;
    }

    // ?: KEY_TYPED event? (We're only interested in KEY_PRESSED and KEY_RELEASED).
    if (event.getID() == KeyEvent.KEY_TYPED) {
      // -> Yes, TYPED, don't process.
      return;
    }

    final KeyEvent keyEvent = (KeyEvent) event;

    // ?: Is this already consumed?
    // (Note how events are passed on to all AWTEventListeners even though a previous one consumed
    // it)
    if (keyEvent.isConsumed()) {
      return;
    }

    // ?: Is this RELEASED? (the problem we're trying to fix!)
    if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
      // -> Yes, so stick in wait
      /**
       * Really just wait until "immediately", as the point is that the subsequent PRESSED shall
       * already have been posted on the event queue, and shall thus be the direct next event no
       * matter which events are posted afterwards. The code with the ReleasedAction handles if the
       * Timer thread actually fires the action due to lags, by cancelling the action itself upon
       * the PRESSED.
       */
      final Timer timer = new Timer(2, null);
      ReleasedAction action = new ReleasedAction(keyEvent, timer);
      timer.addActionListener(action);
      timer.start();

      _map.put(Integer.valueOf(keyEvent.getKeyCode()), action);

      // Consume the original
      keyEvent.consume();
    } else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
      // Remember that this is single threaded (EDT), so we can't have races.
      ReleasedAction action = _map.remove(Integer.valueOf(keyEvent.getKeyCode()));
      // ?: Do we have a corresponding RELEASED waiting?
      if (action != null) {
        // -> Yes, so dump it
        action.cancel();
      }
      // System.out.println("PRESSED: [" + keyEvent + "]");
    } else {
      throw new AssertionError("All IDs should be covered.");
    }
  }
Пример #13
0
 /**
  * Fetches and possibly removes the next event from the internal queues. This method returns
  * immediately. When all queues are empty, this returns <code>null</code>:
  *
  * @param remove <true> when the event should be removed from the queue, <code>false</code>
  *     otherwise
  * @return the next event or <code>null</code> when all internal queues are empty
  */
 private AWTEvent getNextEventImpl(boolean remove) {
   AWTEvent next = null;
   for (int i = 0; i < queues.length && next == null; i++) {
     Queue q = queues[i];
     if (q.queueHead != null) {
       // Got an event, remove it.
       next = q.queueHead;
       if (remove) {
         // Unlink event from the queue.
         q.queueHead = next.queueNext;
         if (q.queueHead == null) q.queueTail = null;
         next.queueNext = null;
       }
     }
   }
   return next;
 }
Пример #14
0
 protected void dispatchEvent(AWTEvent event) {
   waitTimer.startTimer(event.getSource());
   try {
     super.dispatchEvent(event);
   } finally {
     waitTimer.stopTimer();
   }
 }
Пример #15
0
 @Override
 public Component findComponentAt(int x, int y) {
   final Component c = super.findComponentAt(x, y);
   if (c == null) {
     return null;
   }
   final AWTEvent currentEvent = EventQueue.getCurrentEvent();
   if (controller != Controller.getCurrentController()
       && currentEvent instanceof MouseEvent
       && currentEvent.getID() == MouseEvent.MOUSE_MOVED) {
     if (appletLock.tryLock()) {
       Controller.setCurrentController(controller);
       appletLock.unlock();
     }
   }
   return c;
 }
Пример #16
0
 /** Return the JComboBox for the given event, or null if none. */
 private JComboBox getComboBox(AWTEvent event) {
   Component comp = (Component) event.getSource();
   // Depends somewhat on LAF; sometimes the combo box is itself the
   // button, sometimes a panel containing the button.
   if (comp instanceof javax.swing.JButton) comp = comp.getParent();
   if (comp instanceof JComboBox) return (JComboBox) comp;
   return null;
 }
Пример #17
0
  /** "Return" invokes smart scroll, which closes up current section, and opens next. */
  public boolean eventAfter(AWTEvent e, Point scrn, Node obsn) {
    int eid = e.getID();
    // System.out.println("Outliner eventBefore "+eid+", outActive_="+outActive_);
    if (outActive_ != null
        && outActive_.isSet()
        && outActive_.isOpen() /*always true?*/ /* && outSects_.indexOf(outActive_)==-1*/
        && /*active_ &&*/ eid == KeyEvent.KEY_PRESSED
        && ((KeyEvent) e).getKeyChar() == ' ' // ).getKeyCode()==KeyEvent.VK_ENTER
    ) {
      Browser br = getBrowser();

      // find next
      OutlineSpan next = nextSection(outActive_.getStart().leaf);
      Node outn = outActive_.getStart().leaf;
      IScrollPane isp = outn.getIScrollPane();
      VScrollbar vsb = isp.getVsb();
      int y = vsb.getValue(), h = isp.bbox.height;

      if (next != null) {
        Leaf l = (Leaf) next.getStart().leaf;
        Point rel = l.getRelLocation(isp);

        // if next on screen open next, closing up previous of <= level
        // System.out.println(y+" .. "+l.getNextLeaf()+"/"+rel.y+" .. "+(y+h));
        if (y < rel.y && rel.y < y + h) {
          // close up current and previous while <= level

          int level = Integers.parseInt(next.getAttr(OutlineSpan.ATTR_LEVEL), 1);

          for (OutlineSpan prev = outActive_;
              prev != null;
              prev = prevSection(prev.getStart().leaf)) {
            br.eventq(OutlineSpan.MSG_CLOSE, prev);
            if (Integers.parseInt(prev.getAttr(OutlineSpan.ATTR_LEVEL), Integer.MIN_VALUE) <= level)
              break; // stop after first at same level as next/new current
          }

          outActive_ = next;
          br.eventq(OutlineSpan.MSG_OPEN, outActive_); // includes l.scrollTo(0,0, true);
          // System.out.println("open "+outActive_);
        } // else fall through to scroll
        return true;

      } else if (y + h >= vsb.getMax()) { // at end, just close up
        // System.out.println("couldn't find next OutlineSpan"); -- at end
        br.eventq(OutlineSpan.MSG_CLOSE, outActive_);
        outActive_ = null;
      }

      // close current and open next
      // br.setGrab(this);	// get key release
      // return true;
    }

    return false;
  }
Пример #18
0
 /** Override the default window parsing to consume everything between dialog open and close. */
 protected boolean parseWindowEvent(AWTEvent event) {
   boolean consumed = true;
   if (event.getSource() instanceof FileDialog) {
     if (isOpen(event)) {
       dialog = (FileDialog) event.getSource();
       originalFile = dialog.getFile();
       originalDir = dialog.getDirectory();
     }
     // The FileDialog robot uses some event listener hacks to set the
     // correct state on dialog close; make sure we record after that
     // listener is finished.
     if (event instanceof FileDialogTerminator) setFinished(true);
     else if (event.getSource() == dialog && isClose(event)) {
       AWTEvent terminator = new FileDialogTerminator(dialog, event.getID());
       dialog.getToolkit().getSystemEventQueue().postEvent(terminator);
     }
   }
   return consumed;
 }
Пример #19
0
 /**
  * Tries to find the owning window for the AWT-event's source.
  *
  * @param aEvent the AWT event to find the owning window for, may be <code>null</code>.
  * @return the owning window, or <code>null</code> if no such window could be found, or a <code>
  *     null</code> event was given.
  */
 public static final Window getOwningWindow(final AWTEvent aEvent) {
   Window owner = null;
   if (aEvent != null) {
     final Object source = aEvent.getSource();
     if (source instanceof Component) {
       owner = getOwningWindow((Component) source);
     }
   }
   return owner;
 }
Пример #20
0
  public void setActivo(boolean val) {
    glass.setVisible(val);
    setVisible(val);
    JLayeredPane.getLayeredPaneAbove(glass).moveToFront(glass);

    if (val) {
      synchronized (syncMonitor) {
        try {
          if (SwingUtilities.isEventDispatchThread()) {
            EventQueue theQueue = getToolkit().getSystemEventQueue();
            while (isVisible()) {
              AWTEvent event = theQueue.getNextEvent();
              Object source = event.getSource();

              if (event instanceof ActiveEvent) {
                ((ActiveEvent) event).dispatch();
              } else if (source instanceof Component) {
                ((Component) source).dispatchEvent(event);
              } else if (source instanceof MenuComponent) {
                ((MenuComponent) source).dispatchEvent(event);
              } else {
                System.out.println("No se puede despachar: " + event);
              }
            }
          } else {
            while (isVisible()) {
              syncMonitor.wait();
            }
          }
        } catch (InterruptedException ignored) {
          System.out.println("Excepción de interrupción: " + ignored.getMessage());
        }
      }
    } else {
      synchronized (syncMonitor) {
        setVisible(false);
        glass.setVisible(false);
        syncMonitor.notifyAll();

        eliminarDelContenedor();
      }
    }
  }
 void dispatchEventImpl(AWTEvent e) {
   if (newEventsOnly
       || (parent != null
           && parent instanceof MenuComponent
           && ((MenuComponent) parent).newEventsOnly)) {
     if (eventEnabled(e)) {
       processEvent(e);
     } else if (e instanceof ActionEvent && parent != null) {
       ((MenuComponent) parent)
           .dispatchEvent(
               new ActionEvent(parent, e.getID(), ((ActionEvent) e).getActionCommand()));
     }
   } else { // backward compatibility
     Event olde = e.convertToOld();
     if (olde != null) {
       postEvent(olde);
     }
   }
 }
 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();
       }
     }
   }
 }
 public void itemListenerAction(IItemType itemType, AWTEvent event) {
   if (event.getID() == FocusEvent.FOCUS_LOST) {
     if (itemType == validFrom) {
       checkValidFrom();
     }
     if (itemType == validUntil) {
       checkValidUntil();
     }
   }
 }
Пример #24
0
    @Override
    public boolean consumeEvent(AWTEvent evt, boolean isOutsideEvent) {
      if (!isOutsideEvent && evt.getID() == MouseEvent.MOUSE_DRAGGED) {
        MouseEvent me = (MouseEvent) evt;

        // calculate area to repaint
        Rectangle bBox = m_scaled.getScreenBBox();
        m_scaled.scale(calculateScaleX(me.getX()), calculateScaleY(me.getY()), m_scalePtIdx);
        bBox.add(m_scaled.getScreenBBox());

        m_factory
            .getSceneManager()
            .getScreenManager()
            .repaint(bBox, SVGObjectOutline.SELECTOR_OVERLAP);
      } else if (evt.getID() == MouseEvent.MOUSE_RELEASED) {
        actionCompleted();
        m_scaled.commitChanges();
      }
      return false;
    }
Пример #25
0
 @Override
 public synchronized ComposerAction startAction(AWTEvent e, boolean isOutsideEvent) {
   if (!isOutsideEvent && !m_sceneMgr.isReadOnly() && e.getID() == MouseEvent.MOUSE_PRESSED) {
     MouseEvent me = (MouseEvent) e;
     SVGObject selObj = getObjectToScaleAt(me);
     if (selObj != null) {
       return new ScaleAction(this, selObj, me);
     }
   }
   return null;
 }
  private boolean isMatchFilter(AWTEvent event) {
    if (event instanceof MouseEvent) {
      MouseEvent mouseEvent = (MouseEvent) event;
      return filter.mouseClicked && MouseEvent.MOUSE_CLICKED == mouseEvent.getID()
          || filter.mouseDragged && MouseEvent.MOUSE_DRAGGED == mouseEvent.getID()
          || filter.mouseEntered && MouseEvent.MOUSE_ENTERED == mouseEvent.getID()
          || filter.mouseExited && MouseEvent.MOUSE_EXITED == mouseEvent.getID()
          || filter.mouseMoved && MouseEvent.MOUSE_MOVED == mouseEvent.getID()
          || filter.mousePressed && MouseEvent.MOUSE_PRESSED == mouseEvent.getID()
          || filter.mouseReleased && MouseEvent.MOUSE_RELEASED == mouseEvent.getID()
          || filter.mouseWeel && MouseEvent.MOUSE_WHEEL == mouseEvent.getID();
    }
    if (event instanceof KeyEvent) {
      return filter.keyPressed && KeyEvent.KEY_PRESSED == event.getID()
          || filter.keyReleased && KeyEvent.KEY_RELEASED == event.getID()
          || filter.keyTyped && KeyEvent.KEY_TYPED == event.getID();
    }

    return false;
  }
Пример #27
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);
       }
     }
   }
 }
    /**
     * AWT event listener. Used to reset the mouse cursor when divider was changed and mouse exited
     * event had not occurred normally.
     *
     * @param event
     */
    public void eventDispatched(AWTEvent event) {
      if (event.getID() == MouseEvent.MOUSE_MOVED || event.getID() == MouseEvent.MOUSE_RELEASED) {
        MouseEvent mev = (MouseEvent) event;
        if (mev.getSource() != Handler.this.container && withinBounds) {
          if (mev.getSource() instanceof GlassedPane.GlassPane) {
            // on glass pane -> check with traditional method

            // Question by Beni: does this ever happen?
            checkMousePositionAsync();
          } else {
            // mouse is over another component which is not the registered container and the mouse
            // cursor had not been reseted yet -> reset mouse cursor
            Point p = SwingUtilities.convertPoint(mev.getComponent(), mev.getPoint(), station);
            if (station.getBounds().contains(p)) {
              // only if mouse is within our station
              setCursor(null);
              withinBounds = false;
            }
          }
        }
      }
    }
    public void eventDispatched(AWTEvent event) {
      if (!isMatchFilter(event)) {
        return;
      }
      // ignore events of Swing explorer
      if (SwingUtilities.isDescendingFrom((Component) event.getSource(), rootContainer)) {
        return;
      }

      for (AWTEventListener l : listeners) {
        l.eventDispatched(event);
      }
    }
Пример #30
0
 // WARNING: it's called on the Toolkit thread!
 void preprocessPostEvent(AWTEvent event) {
   if (event instanceof WindowEvent) {
     WindowListener listener = windowListener;
     if (listener != null) {
       switch (event.getID()) {
         case WindowEvent.WINDOW_CLOSING:
           listener.windowClosing((WindowEvent) event);
           break;
         case WindowEvent.WINDOW_ICONIFIED:
           listener.windowIconified((WindowEvent) event);
           break;
       }
     }
   }
 }