@Override public void testAddClickListener() { final TableRidget ridget = getRidget(); ridget.updateFromModel(); final Table control = getWidget(); control.getColumn(0).setWidth(100); control.getColumn(1).setWidth(100); try { ridget.addClickListener(null); fail(); } catch (final RuntimeException npe) { ok(); } final FTClickListener listener1 = new FTClickListener(); ridget.addClickListener(listener1); final FTClickListener listener2 = new FTClickListener(); ridget.addClickListener(listener2); ridget.addClickListener(listener2); final Event mdEvent = new Event(); mdEvent.widget = control; mdEvent.type = SWT.MouseDown; mdEvent.button = 2; final TableItem row2 = control.getItem(2); mdEvent.item = row2; mdEvent.x = row2.getBounds().x + 1; mdEvent.y = row2.getBounds().y + 1; control.notifyListeners(SWT.MouseDown, mdEvent); assertEquals(0, listener1.getCount()); assertEquals(0, listener2.getCount()); mdEvent.type = SWT.MouseUp; control.notifyListeners(SWT.MouseUp, mdEvent); assertEquals(1, listener1.getCount()); assertEquals(1, listener2.getCount()); final ClickEvent event = listener2.getEvent(); assertEquals(ridget, event.getSource()); assertEquals(2, event.getButton()); assertEquals(0, event.getColumnIndex()); assertEquals(row2.getData(), event.getRow()); ridget.removeClickListener(listener1); mdEvent.type = SWT.MouseDown; control.notifyListeners(SWT.MouseDown, mdEvent); mdEvent.type = SWT.MouseUp; control.notifyListeners(SWT.MouseUp, mdEvent); assertEquals(1, listener1.getCount()); }
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); }
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); }
private void fireSelectionChanged() { Event event = new Event(); event.button = 1; Rectangle bounds = getCanvas().getBounds(); int visualLow = getVisualLow(); int visualHigh = getVisualHigh(); event.x = visualLow + bounds.x; event.y = bounds.y; event.width = visualHigh - visualLow; event.height = bounds.height; event.item = null; notifyListeners(SWT.Selection, event); }
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 void doEventBasedSelection(int item, int stateMask, int button) { Table t = table.getViewer().getTable(); t.setSelection(item); while (Display.getCurrent().readAndDispatch()) ; Rectangle bounds = t.getItem(item).getBounds(); Event event = new Event(); event.button = button; event.stateMask = stateMask; event.x = bounds.x + 1; event.y = bounds.y + 1; t.notifyListeners(SWT.MouseUp, event); while (Display.getCurrent().readAndDispatch()) ; }
// 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); } }
public Event sendEvent(final Widget w, final int event, int x, int y, int button) { try { Event e = createEvent(w); e.x = x; e.y = y; e.button = button; e.type = event; sendEventRaw(event, e); return e; } catch (SecurityException e) { TeslaCore.log(e); } catch (IllegalArgumentException e) { TeslaCore.log(e); } return null; }
public void selectionChanged(SelectionChangedEvent event) { GC gc = new GC(viewer.getTextWidget()); try { Event e = new Event(); e.gc = gc; e.widget = viewer.getTextWidget(); Rectangle bounds = viewer.getTextWidget().getBounds(); e.height = bounds.height; e.width = bounds.width; e.x = 0; e.y = 0; PaintEvent paintEvent = new PaintEvent(e); painter.paintControl(paintEvent); } finally { gc.dispose(); } }
@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); }
public Event sendEvent(final SWTUIElement w, final int event, int x, int y) { if (PlayerWrapUtils.unwrapWidget(w).isDisposed()) { return null; } try { Event e = createEvent(w); e.x = x; e.y = y; e.type = event; sendEventRaw(event, e); return e; } catch (SecurityException e) { TeslaCore.log(e); } catch (IllegalArgumentException e) { TeslaCore.log(e); } return null; }