Project: Eclipse_Platform_UI
Bug 214680 [Trim] TrimContributionManager won't accept IToolBarContributionItem
Reported: 2008-01-08 17:05:22 | Status: verified fixed

Build ID: M20071023-1652 Steps To Reproduce: We are building a new presentation for Eclipse 3.3 and have implemented a custom IToolBarManager. We would like to be able to use the org.eclipse.ui.menus extension point to allow adding custom controls to the status bar. Unfortunately, TrimContributionManager checks for the ToolBarContributionItem class instead of the IToolBarContributionItem interface, so our contributions are ignored. It's not possible for our presentation implementation to use ToolBarContributionItem directly since it has an assertion/cast in its constructor from IToolBarManager to ToolBarManager. Our custom tool bar manager extends ContributionManager and implements IToolBarManager so we get an assertion failure here. More information: Here is the assertion failure stack I get when attempting to use ToolbarContributionItem: !ENTRY org.eclipse.ui.workbench 4 2 2008-01-08 14:26:00.842 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench". !STACK 0 org.eclipse.core.runtime.AssertionFailedException: assertion failed: at org.eclipse.core.runtime.Assert.isTrue(Assert.java:109) at org.eclipse.core.runtime.Assert.isTrue(Assert.java:95) at org.eclipse.jface.action.ToolBarContributionItem.<init>(ToolBarContributionItem.java:126) at org.eclipse.jface.internal.provisional.action.ToolBarContributionItem2.<init>(ToolBarContributionItem2.java:51) at myplugin.MyPresentationFactory.createToolBarContributionItem(MyPresentationFactory.java:74) at org.eclipse.ui.internal.menus.MenuAdditionCacheEntry.createToolBarAdditionContribution(MenuAdditionCacheEntry.java:206) at org.eclipse.ui.internal.menus.MenuAdditionCacheEntry.createContributionItems(MenuAdditionCacheEntry.java:181) at org.eclipse.ui.internal.menus.TrimContributionManager.update(TrimContributionManager.java:224) at org.eclipse.ui.internal.WorkbenchWindow.updateLayoutDataForContents(WorkbenchWindow.java:3582) at org.eclipse.ui.internal.WorkbenchWindow.setLayoutDataForContents(WorkbenchWindow.java:3593) at org.eclipse.ui.internal.WorkbenchWindow.createDefaultContents(WorkbenchWindow.java:1090) at org.eclipse.ui.internal.WorkbenchWindowConfigurer.createDefaultContents(WorkbenchWindowConfigurer.java:624) at org.eclipse.ui.application.WorkbenchWindowAdvisor.createWindowContents(WorkbenchWindowAdvisor.java:268) at myplugin.ApplicationWorkbenchWindowAdvisor.createWindowContents(ApplicationWorkbenchWindowAdvisor.java:141) ...

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/TrimContributionManager.java