コード例 #1
0
ファイル: BasicText.java プロジェクト: hangum/dslforge
 public void notifyListeners(String eventName, JsonObject properties) {
   JsonValue value = properties.get("value");
   Event event = new Event();
   event.type = stringToTypeEvent(eventName);
   event.text = (value != null && value.isString() ? value.asString() : "");
   event.data = properties;
   listener.handleEvent(event);
 }
コード例 #2
0
 private void fireItemSelectionChanged(int button) {
   Event event = new Event();
   event.button = button;
   event.x = 0;
   event.y = 0;
   event.width = -1;
   event.height = -1;
   event.item = selectedAnnotation;
   event.data = (selectedAnnotation != null) ? selectedAnnotation.getData() : null;
   notifyListeners(SWT.Selection, event);
 }
コード例 #3
0
  @Test
  public void testUntypedEventConstructor() {
    Event event = new Event();
    event.display = display;
    event.widget = mock(Widget.class);
    event.time = 9;
    event.data = new Object();

    TestTypedEvent typedEvent = new TestTypedEvent(event);

    assertSame(event.widget, typedEvent.getSource());
    EventTestHelper.assertFieldsEqual(typedEvent, event);
  }
コード例 #4
0
ファイル: RibbonShell.java プロジェクト: Raccoonwao/ribbonide
  // internal callback for when the big button is clicked
  void bigButtonClicked(MouseEvent me) {
    Event e = new Event();
    e.button = me.button;
    e.data = this;
    e.display = me.display;
    e.stateMask = me.stateMask;
    e.widget = me.widget;
    e.x = me.x;
    e.y = me.y;
    SelectionEvent se = new SelectionEvent(e);

    for (int i = 0; i < mBigButtonListeners.size(); i++) {
      mBigButtonListeners.get(i).widgetSelected(se);
    }
  }
  @Test
  public void testUntypedEventConstructor() {
    Event event = new Event();
    event.display = display;
    event.widget = mock(Widget.class);
    event.item = mock(Item.class);
    event.x = 1;
    event.y = 2;
    event.width = 3;
    event.height = 4;
    event.doit = true;
    event.data = new Object();

    CTabFolderEvent selectionEvent = new CTabFolderEvent(event);

    EventTestHelper.assertFieldsEqual(selectionEvent, event);
  }
コード例 #6
0
ファイル: PopupMenu.java プロジェクト: daicaheb/nutch-bbcore
  public void open() {
    if (screenPos == null) screenPos = Display.getDefault().getCursorLocation();
    leftScreenPos = screenPos;
    popupRight = true;
    if (control == null || control.isDisposed()) return;
    control.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(DisposeEvent e) {
            dispose();
          }
        });
    final ShellListener shellListener =
        new ShellAdapter() {

          public void shellClosed(ShellEvent e) {
            hideMenu();
          }

          public void shellDeactivated(ShellEvent e) {
            hideMenu();
          }

          public void shellIconified(ShellEvent e) {
            hideMenu();
          }
        };
    control.getShell().addShellListener(shellListener);
    ignoreTaskbar = true;

    Event event = new Event();
    event.data = this;
    event.type = SWT.OPEN;
    menu.fireMenuEvent(event);

    createAndShowWindow();
    installMouseHook();
    shell.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(DisposeEvent e) {
            if (!control.isDisposed()) control.getShell().removeShellListener(shellListener);
          }
        });

    final Listener mouseDownListener =
        new Listener() {

          public void handleEvent(Event e) {
            if (shell == null || shell.isDisposed()) {
              Display.getDefault().removeFilter(SWT.MouseDown, this);
              return;
            }
            if (e.widget == null
                || e.widget.isDisposed()
                || checkMouseDownEvent(((Control) e.widget).toDisplay(e.x, e.y))) {
              hideMenu();
            }
          }
        };

    Display.getDefault().addFilter(SWT.MouseDown, mouseDownListener);

    final Listener keyDownListener =
        new Listener() {

          public void handleEvent(Event e) {
            if (shell == null || shell.isDisposed()) {
              Display.getDefault().removeFilter(SWT.KeyDown, this);
              e.doit = false;
              return;
            }
            KeyEvent ke = new KeyEvent(e);
            if ((ke.keyCode == SWT.ALT) || ke.keyCode == SWT.F10) {
              hideMenu();
              return;
            }
            getCurrentMenu().dealAltKeyEvent(ke);

            if (ke.keyCode == KEY_RIGHT && trackItemIndex > -1) {
              getCurrentMenu().subMenuSelected();
            }
            if (ke.keyCode == KEY_LEFT && trackItemIndex > -1) {
              getCurrentMenu().parentMenuSelected();
            }
            if (ke.keyCode == KEY_DOWN || ke.keyCode == KEY_UP) {
              if (ke.keyCode == KEY_DOWN) getCurrentMenu().downSelected();
              else getCurrentMenu().upSelected();
            }
            if (ke.keyCode == SWT.ESC) {
              if (getCurrentMenu().parentMenu == null) getCurrentMenu().hideMenu();
              else getCurrentMenu().parentMenuSelected();
            }
            if (ke.keyCode == SWT.CR) {
              getCurrentMenu().handleSelectedEvent();
            }
          }
        };
    Display.getDefault().addFilter(SWT.KeyDown, keyDownListener);

    shell.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(DisposeEvent e) {
            Display.getDefault().removeFilter(SWT.MouseDown, mouseDownListener);
            Display.getDefault().removeFilter(SWT.KeyDown, keyDownListener);
            getShell().removeShellListener(shellListener);
          }
        });
  }