| E4 Injection - intercept perspective change [message #1705293] |
Thu, 13 August 2015 10:29  |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03634 seconds