Community
Participate
Working Groups
Created attachment 271781 [details] View with toolbar normal and broken; Preference spy window with and without toolbar. Views defined by an E4 part descriptor loose their toolbar when the application is not closed nominally with an automatic workbench state save present. E4 spies shows that the toolbar is gone entirely. Restarting the application won't bring the toolbar back. Only clearing the persisted state or deleting the faulty view from the model will restore the toolbar when the view is created anew. Views using the compatibility layer are unaffected by this. Steps to reproduce: - Install E4 spies - Open the preference spy. Toolbar should be visible - Wait for the workbench state to be saved automatically (<workspace path>\.metadata\.plugins\org.eclipse.e4.workbench\workbench.xmi). Delay can be lowered in the settings - Terminate eclipse with task manager (or something similar) - When restarting eclipse, the toolbar will be gone. Eclipse version is Oxygen.1a.
Hi Chrsitian, i'm facing the same problem with my new e4 plugins. Did you find a workaround ? thanks, thomas
I did find a workaround. For our application it comes down to two cases: Normal part and shared part. For a normal part the following code should bring the toolbar back MPart part = partService.findPart(PART_ID); if (part != null) { List<MToolBarElement> toolbarItems = part.getToolbar().getChildren(); if (toolbarItems.isEmpty()) { partService.hidePart(part, true); } } part = partService.showPart(PART_ID, PartState.ACTIVATE); For shared parts, that are made visible by a placeholder, things become slightly more complicated. hidePart, by design, only removes the placeholder. Deleting the broken view from the model has to be done manually by deleting it from the list of shared parts. Then the shared view and the placeholder have to be recreated // Recreate view if toolbar is broken MPart part = partService.findPart(PART_ID); if (part != null) { List<MToolBarElement> toolbarItems = part.getToolbar().getChildren(); if (toolbarItems.isEmpty()) { // The actual view is stored as a shared element and can only be deleted manually List<MUIElement> elements = modelService.getTopLevelWindowFor(part).getSharedElements(); ListIterator<MUIElement> iterator = elements.listIterator(); while (iterator.hasNext()) { MUIElement muiElement = iterator.next(); if (PART_ID.equals(muiElement.getElementId())) { iterator.remove(); // view found, remove it. } } partService.hidePart(part, true); // this removes the placeholder MPlaceholder sharedPart2 = partService.createSharedPart(PART_ID); // Create a new shared part. The returned placeholder only serves as a temporary handle to get the // shared view MUIElement partPartNew = sharedPart2.getRef(); // Find the bottom part stack where the view is located by default MPartStack partStack = (MPartStack) modelService.find(BOTTOM_FOLDER_ID, application); // Create a new placeholder for the view in the bottom part stack MPlaceholder placeholder = modelService.createModelElement(MPlaceholder.class); placeholder.setElementId(PART_ID); placeholder.setRef(partPartNew); partStack.getChildren().add(placeholder); } } partService.showPart(PART_ID, PartState.ACTIVATE); These solutions were found with E4 spies and some trial and error. So far we haven't experienced any issues with the workarounds. There isn't much documentation on this part of E4 so I don't know how it is meant to be done. I can only go by what works for me. Good luck.
Hi Christian, thanks for this, It helped me to understand the mechanisms behind. By chance, i found another workaround :-) The problem does not occur if using ToolbarContributions instead of a Toolbar in a PartDescriptor (empty toolbar + contribution). This also resolves the problem of updated PartDescriptors (addititional menu+toolbar elements) that get not snyced with the part. thanks, thomas
New Gerrit change created: https://git.eclipse.org/r/147397
(In reply to Thomas Haber from comment #3) > This also resolves the problem of updated PartDescriptors (addititional > menu+toolbar elements) that get not snyced with the part. Can you open another bug for this issue?
Please add the bug in which you marked the menu and toolbars as not to be persist as dependent bug of this one.
Gerrit change https://git.eclipse.org/r/147397 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=588a46b994bbc204f9e721a15b83df72c6479162