|
Re: Riena 5.0.0: No More Handles [message #1269955 is a reply to message #1269885] |
Wed, 12 March 2014 10:53 |
Eclipse User |
|
|
|
Hi Frank,
Are you using Riena on Eclipse 3.x or 4.x (have a look at the version of "org.eclipse.rcp" in your target platform)?
The view parts are handled differently in both Eclipse streams. Riena is relying on RCP for their management (we only hold view id's).
We also noticed that the view parts are accumulating, and implemented a configuration for Riena, which limits the number of open views. However this feature is not contained in the Riena 5.0.0.0 since we implemented it after the release. Do you need a Riena 6 milestone before the Release in June?
|
|
|
|
Re: Riena 5.0.0: No More Handles [message #1270802 is a reply to message #1270062] |
Thu, 13 March 2014 14:13 |
Eclipse User |
|
|
|
Hi Frank,
I looked at Riena for Eclipse 4.x and there's still a problem with the view cleanup, so it is not working. I created Bug 430168 for that and we will address it in the near future.
Until the bug is fixed, you can try to work around it:
When a view has to be shown, Riena looks for it in the E4 application model. If the view is not found there, Riena looks up the contribution from the extension registry (plugin.xml) and instantiates the view part. This happens in:
org.eclipse.riena.e4.launcher.part.RienaPartHelper.createPart(ISubModuleNode)
To "clean up" views manually, you can try these steps:
(1) remove the MPart instance from the E4 application model like in org.eclipse.riena.e4.launcher.part.RienaPartHelper.unregisterPart(MPart)
(2) remove the mapping from the ISubModuleNode to the partId by calling subModuleNode.removeContext(RienaPartHelper.KEY_E4_PART_ID)
The next time Riena looks up this view, it should go through the process described above as if this view has never been open. Be very careful with shared views, they're also registered in the ViewInstanceProvider!
For this to work, the RCP view contributions should be in the plugin.xml (the good old Eclipse 3.x way), not in the E4 e4xmi file. In any case, the RienaPartHelper is your friend (bundle org.eclipse.riena.e4.launcher).
I hope this helps!
Cheers,
Jordan
|
|
|
|
Re: Riena 5.0.0: No More Handles [message #1271181 is a reply to message #1271079] |
Fri, 14 March 2014 12:50 |
Frank Herberts Messages: 5 Registered: March 2013 |
Junior Member |
|
|
I tried this:
SubModuleNodeListener:
public void afterDeactivated() {
// eclipseContext is retrieved in Activator
// -> eclipseContext = EclipseContextFactory.getServiceContext(bundleContext);
ContextHelper helper = ContextInjectionFactory.make(ContextHelper.class,
eclipseContext);
helper.disposeView(getNavigationNode());
}
and
public class ContextHelper {
@Inject
public static IEclipseContext context;
@Inject
private static EPartService partService;
public void disposeView(ISubModuleNode node) {
MPart part = findPart(node);
if(part != null) {
part.setWidget(null);
part.getParent().getChildren().remove(part);
node.removeContext("E4PartId");
}
}
private MPart findPart(final ISubModuleNode node) {
final String KEY_E4_PART_ID = "E4PartId"; //$NON-NLS-1$
final String partId = (String) node.getContext(KEY_E4_PART_ID);
if (null == partId) {
return null;
}
return partService.findPart(partId);
}
}
But I get an exception that EPartService is not contained in the IEclipseContext at that time ("that time" being the afterDeactivated() callback of a SubModuleNodeListener). An neither is EModelService (which is used in RienaPartHelper).
So I guess I did something wrong when creating my ContextHelper class.
14.03.2014 13:55:16,426 ERROR PmzRunnableProgress:159 - Callback fehlgeschlagen!:
org.eclipse.e4.core.di.InjectionException: Unable to process "ContextHelper.partService": no actual value was found for the argument "EPartService".
at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:412)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:403)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:108)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at pmz.ui.controller.PmzSubModuleController.afterDeactivated(PmzSubModuleController.java:175)
Kind regards,
Frank
[Updated on: Fri, 14 March 2014 12:56] Report message to a moderator
|
|
|
Re: Riena 5.0.0: No More Handles [message #1272297 is a reply to message #1271181] |
Mon, 17 March 2014 15:19 |
Eclipse User |
|
|
|
Try to find the MPart as in RienaPartHelper
@Inject
private EModelService modelService;
private MPart findPart(final ISubModuleNode node) {
final String partId = (String) node.getContext(KEY_E4_PART_ID);
if (null == partId) {
return null;
}
final List<MPart> parts = modelService.findElements(context.get(MApplication.class), partId, MPart.class, null, EModelService.IN_ANY_PERSPECTIVE);
return parts.get(0);
}
The reason that you don't get the EPartService injected is that the E4 contexts are organized in a tree structure. The default injector look up strategy traverses from your eclipseContext to the tree root until it finds an appropriate instance to inject (in this case the EPartService). If the EPartService is available in another "branch" in the context tree, it won't be found.
Our way to look up the "right" context is this method, found in bundle org.eclipse.riena.ui.swt.e4, class WorkbenchFacadeImpl:
private IEclipseContext getWorkbenchContext() {
final org.eclipse.e4.ui.internal.workbench.Activator plugin = org.eclipse.e4.ui.internal.workbench.Activator.getDefault();
if (plugin == null) {
return null;
}
final IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(plugin.getContext());
return serviceContext.getActiveLeaf();
}
I can't guarantee that this is the absolute correct way, but it works for us
|
|
|
Powered by
FUDForum. Page generated in 0.04404 seconds