Пример #1
0
 public Event createEvent(Widget w) {
   Event e = new Event();
   e.widget = w;
   e.display = display;
   e.time = (int) System.currentTimeMillis();
   return e;
 }
        public void mouseDown(MouseEvent e) {
          Event event = new Event();
          event.display = e.display;
          event.x = e.x;
          event.y = e.y;
          event.widget = content;
          event.time = e.time;

          SelectionEvent selection = new SelectionEvent(event);
          selectionListener.widgetSelected(selection);
        }
Пример #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
 public Event createMouseEvent(
     Display display, Widget widget, int x, int y, int button, int stateMask, int count) {
   Event event = new Event();
   event.time = (int) System.currentTimeMillis();
   event.widget = widget;
   event.display = display;
   event.x = x;
   event.y = y;
   event.button = button;
   event.stateMask = stateMask;
   event.count = count;
   return event;
 }
  private static void click(final MenuItem menuItem) {
    final Event event = new Event();
    event.time = (int) System.currentTimeMillis();
    event.widget = menuItem;
    event.display = menuItem.getDisplay();
    event.type = SWT.Selection;

    UIThreadRunnable.asyncExec(
        menuItem.getDisplay(),
        new VoidResult() {
          public void run() {
            menuItem.notifyListeners(SWT.Selection, event);
          }
        });
  }
Пример #6
0
  // 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);
  }
 @Override
 public void handleTreeCollapse(TreeEvent event) {
   super.handleTreeCollapse(event);
   for (SynchronizedTreeViewer viewer : synchronizedViewers) {
     TreeItem otherItem = getMatchingItem(event.item.getData(), viewer);
     if (otherItem != null) {
       if (otherItem.getExpanded()) {
         Event rawEvent = new Event();
         rawEvent.doit = true;
         rawEvent.widget = viewer.getTree();
         rawEvent.display = event.display;
         TreeEvent otherEvent = new TreeEvent(rawEvent);
         otherEvent.item = otherItem;
         viewer.internalHandleTreeCollapse(otherEvent);
         viewer.setExpanded(otherItem, false);
       }
       viewer.getTree().redraw();
     }
   }
 }