Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Eclipse4/RCP/Event Model

< Eclipse4‎ | RCP
Revision as of 10:36, 12 April 2011 by Briandealwis.gmail.com (Talk | contribs) (New page: E4AP uses a pub/sub approach to events. FIXME: Pulled the following from the e4 image viewer demo, but it uses an OSGi EventAdmin directly rather than IEventBroker. = Notification of an ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

E4AP uses a pub/sub approach to events.

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

Notification of an Event

	@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);
			}
		});
		....
	}

Back to the top