Java Code Examples for org.eclipse.swt.widgets.Widget#addListener()

The following examples show how to use org.eclipse.swt.widgets.Widget#addListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractExampleTab.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void updateListeners() {
	for (int eventId : eventIds) {
		boolean selected = selectedEvents.contains(new Integer(eventId));

		controlExample.removeListener(eventId, listenerThatPrints);
		if (selected && listen.getSelection()) {
			controlExample.addListener(eventId, listenerThatPrints);
		}

		for (Iterator iterator = additionalEventParticipants.iterator(); iterator.hasNext();) {
			Widget participant = (Widget) iterator.next();

			participant.removeListener(eventId, listenerThatPrints);
			if (selected && listen.getSelection()) {
				participant.addListener(eventId, listenerThatPrints);
			}
		}
	}
}
 
Example 2
Source File: Popup2.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public Popup2(final IPopupProvider provider, final Widget... controls) {
	super(WorkbenchHelper.getShell(), PopupDialog.HOVER_SHELLSTYLE, false, false, false, false, false, null, null);
	this.provider = provider;
	final Shell parent = provider.getControllingShell();
	parent.addListener(SWT.Move, hide);
	parent.addListener(SWT.Resize, hide);
	parent.addListener(SWT.Close, hide);
	parent.addListener(SWT.Deactivate, hide);
	parent.addListener(SWT.Hide, hide);
	parent.addListener(SWT.Dispose, event -> close());
	for (final Widget c : controls) {
		if (c == null) {
			continue;
		}
		final TypedListener typedListener = new TypedListener(mtl);
		c.addListener(SWT.MouseEnter, typedListener);
		c.addListener(SWT.MouseExit, typedListener);
		c.addListener(SWT.MouseHover, typedListener);
	}
}
 
Example 3
Source File: EventVsFrp.java    From gradle-and-eclipse-rcp with Apache License 2.0 6 votes vote down vote up
@Test(expected = ClassCastException.class)
public void eventBased() {
	Widget widget = (Widget) new Object();
	widget.addListener(SWT.KeyDown, e -> {
		// this is our chance to react
		System.out.println("keyCode=" + e.keyCode);
		// this is how we do filtering
		if (e.keyCode == 'q') {
			System.out.println("user wants to leave talk");
		}
		// this is how we do mapping
		int accel = e.keyCode | e.stateMask;
		String keyPress = Actions.getAcceleratorString(accel);
		System.out.println(keyPress);
	});
}
 
Example 4
Source File: XkcdColors.java    From gradle-and-eclipse-rcp with Apache License 2.0 4 votes vote down vote up
public Lookup(Widget lifecycle) {
	this.executor = Executors.newSingleThreadExecutor();
	lifecycle.addListener(SWT.Dispose, e -> {
		executor.shutdown();
	});
}
 
Example 5
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the listener for pastable widget.
 *
 * @param w the w
 */
// **************************************************
protected void addListenerForPastableWidget(Widget w) {
  w.addListener(SWT.KeyUp, this);
  w.addListener(SWT.MouseUp, this); // for paste operation
}