Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » E4 Injection - intercept perspective change(How to react to the change of the active perspective using the E4 Dependency injection mechanism?)
E4 Injection - intercept perspective change [message #1705293] Thu, 13 August 2015 10:29 Go to next message
Eclipse UserFriend
Hallo,

In my eclipse E4 application I react to perspective change in the Application Lifecycle class, using a quite complex code:

	@ProcessAdditions
	void processAdditions(MApplication app){
		MTrimmedWindow window = (MTrimmedWindow) application.getChildren().get(0);
		Object perspectiveStack = findStack(window);
		((Notifier) perspectiveStack).eAdapters().add(new AdapterImpl() {
			@Override
			public void notifyChanged(Notification msg) {
				if (msg.getEventType() == Notification.SET
						&& msg.getFeatureID(Integer.class) == AdvancedPackageImpl.PERSPECTIVE_STACK__SELECTED_ELEMENT) {
					// this is the action executed
					System.out.println("Perspective Changed !!");
				}
			}
		});
	}


This works, but the code it is not good, because AdvancedPackageImpl access is discouraged.

Quote:
I remember it is possible to react to the change of the active perspective using the E4 Dependency injection mechanism.


Can anyone suggest me how to do this according E4 DI best practices ?

Kind Regards.
Re: E4 Injection - intercept perspective change [message #1705296 is a reply to message #1705293] Thu, 13 August 2015 10:52 Go to previous message
Eclipse UserFriend
Listen to the according UIEvent as explained here http://www.vogella.com/tutorials/Eclipse4ModelEvents/article.html#d166142e480
Previous Topic:Part not displayed on exported product
Next Topic:Eclipse Mars is a instance of Eclipse 4 or Eclipse 3.x RCP
Goto Forum:
  


Current Time: Thu Nov 06 04:40:57 EST 2025

Powered by FUDForum. Page generated in 0.05650 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top