Jump to: navigation, search

Difference between revisions of "Eclipse4/RCP/Event Model"

< Eclipse4‎ | RCP
m
m
Line 1: Line 1:
 
{{caution|This page is a stub|This page is incomplete.  Please feel free to append questions to the end.}}
 
{{caution|This page is a stub|This page is incomplete.  Please feel free to append questions to the end.}}
  
E4AP uses a pub/sub approach to events.  The material on [http://wiki.eclipse.org/E4/Event_Processing | Event Processing in E4] should be integrated here.
+
E4AP uses a pub/sub approach to events.  The material on [[E4/Event_Processing | Event Processing in E4]] should be integrated here.
  
 
Topics:
 
Topics:

Revision as of 09:21, 26 April 2011

Stop.png
This page is a stub
This page is incomplete. Please feel free to append questions to the end.


E4AP uses a pub/sub approach to events. The material on Event Processing in E4 should be integrated here.

Topics:

 * UIEvents, the @UIEventTopic annotation
 * IEventBroker

FIXME: Pulled the following from the e4 image viewer demo, but it uses an OSGi EventAdmin directly rather than IEventBroker.

Notification of an Event

Can we use @UIEventTopic(UIEvents.buildTopic(UIEvents.UIElement.TOPIC, UIEvents.UIElement.WIDGET)) ??

@Inject @Optional
public void setInput(@UIEventTopic(Part.EVENT_NAME) PojoObject input) {
	...
}

Posting an Event

public class Part {
	final static public String EVENT_NAME = "org/eclipse/e4/demo/app/value"; 
 
	@Inject
	private EventAdmin eventAdmin;
 
	@PostConstruct
	void init() {
		...
		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
			public void selectionChanged(SelectionChangedEvent event) {
				Object selected = ((StructuredSelection) event.getSelection()).getFirstElement();
				if (eventAdmin != null)
					EventUtils.post(eventAdmin, EVENT_NAME, selected);
			}
		});
		....
	}