| Summary: | Double items in contextual menu | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] Sirius | Reporter: | Julien Dupont <julien.dupont> | ||||
| Component: | Diagram | Assignee: | Maxime Porhel <maxime.porhel> | ||||
| Status: | CLOSED FIXED | QA Contact: | Pierre-Charles David <pierre-charles.david> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | maxime.porhel, pierre-charles.david | ||||
| Version: | 1.0.0M7 | Keywords: | triaged | ||||
| Target Milestone: | 1.0.0 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | 435949 | ||||||
| Bug Blocks: | |||||||
| Attachments: |
|
||||||
I confirm the bug using Eclipse SDK 4.4RC2 and a pre-rc2 Sirius 1.0.0 (1.0.0.201405261437). However I do not see the bug using Eclipse SDK 4.4M7 + Sirius M7, or with Eclipse SDK 4.4M7 + a pre-rc2 Sirius 1.0.0 (1.0.0.201405261437). Those items are provided by an extension to org.eclipse.ui.menus:
<extension
point="org.eclipse.ui.menus">
...
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=org.eclipse.sirius.diagram.ui.popup.otherActions">
<command
commandId="org.eclipse.sirius.diagram.ui.command.validateDiagram"
label="Validate diagram"
style="push">
<visibleWhen
...
</visibleWhen>
</menuContribution>
</extension>
This occurs for three menu contributions with command to org.eclipse.ui.menus.
Step to reproduce: . Install Sirius SDK in an Eclipse SDK Luna RC2 . Open the Modeling perspective . Create a Modeling Project . Create an EMF Project . Activate the Design Viewpoint . Open or create a diagram . Right clic the diagram Each of our three menu contribution with command is added twice, here is the stack: Thread [main] (Suspended (breakpoint at line 328 in ContributionManager)) DiagramEditorContextMenuProvider(ContributionManager).insert(int, IContributionItem) line: 328 MenuManagerRenderer.addToManager(MenuManager, MMenuElement, IContributionItem) line: 624 MenuManagerRenderer.processHandledItem(MenuManager, MHandledMenuItem) line: 820 MenuManagerRenderer.modelProcessSwitch(MenuManager, MMenuElement) line: 673 MenuManagerRenderer.processContents(MElementContainer<MUIElement>) line: 606 PopupMenuExtender.addMenuContributions(IMenuManager) line: 423 PopupMenuExtender.menuAboutToShow(IMenuManager) line: 393 DiagramEditorContextMenuProvider(MenuManager).fireAboutToShow(IMenuManager) line: 352 DiagramEditorContextMenuProvider(MenuManager).handleAboutToShow() line: 492 MenuManager.access$1(MenuManager) line: 487 MenuManager$2.menuShown(MenuEvent) line: 519 TypedListener.handleEvent(Event) line: 255 EventTable.sendEvent(Event) line: 84 Display.sendEvent(EventTable, Event) line: 4353 Each of the duplicated menus has two org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem. It looks like we have some duplicated org.eclipse.e4.ui.model.application.ui.menu.impl.HandledMenuItemImpl which cause the duplicated HandledContributionItem and resulting menus. As expected only one HandledMenuItemImpl is created for each contribution during startup: Thread [main] (Suspended (breakpoint at line 137 in HandledMenuItemImpl)) owns: RunnableLock (id=63) HandledMenuItemImpl.setCommand(MCommand) line: 137 MenuAdditionCacheEntry.createMenuCommandAddition(IConfigurationElement) line: 258 MenuAdditionCacheEntry.addMenuChildren(MElementContainer<MMenuElement>, IConfigurationElement, String) line: 212 MenuAdditionCacheEntry.mergeIntoModel(ArrayList<MMenuContribution>, ArrayList<MToolBarContribution>, ArrayList<MTrimContribution>) line: 167 MenuPersistence.readAdditions() line: 163 MenuPersistence.read() line: 111 WorkbenchMenuService.readRegistry() line: 573 Workbench$46.runWithException() line: 2386 Workbench$46(StartupThreading$StartupRunnable).run() line: 32 RunnableLock.run() line: 35 In MenuManagerRenderer.generateContributions(), curList contains each MMenuContribution twice. MenuManagerRenderer.generateContributions(MMenu, ArrayList<MMenuContribution>, boolean) line: 495 MenuManagerRenderer.processContributions(MMenu, String, boolean, boolean) line: 460 PopupMenuExtender.addMenuContributions(IMenuManager) line: 421 PopupMenuExtender.menuAboutToShow(IMenuManager) line: 393 It seems to comes from org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer.XXXgatherMenuContributions(MMenu, List<MMenuContribution>, String, ArrayList<MMenuContribution>, ExpressionContext, boolean) The issue comes from org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer.XXXgatherMenuContributions(MMenu, List<MMenuContribution>, String, ArrayList<MMenuContribution>, ExpressionContext, boolean) :
if (!filtered && menuContribution.isToBeRendered() && popupAny) {
// process POPUP_ANY first
toContribute.add(menuContribution);
} else if (filtered || (!popupTarget && !parentID.equals(id))
|| !menuContribution.isToBeRendered()) {
continue;
}
includedPopups.add(menuContribution);
}
toContribute.addAll(includedPopups);
The popupAny contributions (locationUri popup:org.eclipse.ui.popup.anybefore=additions for example) are added twice !
The if/else if block should be improved to avoid duplicated entries or a LinkedHAshSet should be used.
Bug 435949 has been created to track the issue in Platform UI. I have submitted a patch set to Gerrit. The sumbitted patch has been merged (see Bug 435949). It will be available in Luna RC3 (should be available in staging from next Monday). Submitted patch have merged in Bug 435949. Verified using Eclipse SDK 4.4RC3 (I20140528-2000) and a current Sirius build (between rc2 and rc3). Available in Sirius 1.0.0. |
Created attachment 243498 [details] Double Items in Contextual menu Items named "Refresh", "Validate Diagram" and "Unsynchronized" are duplicate in the contextual menu. See image attached.