Community
Participate
Working Groups
Created attachment 232836 [details] Exported plug-in that makes a contribution to the menu bar Hi, I've implemented a plug-in in Eclipse 3.7 which can dynamically populate the Eclipse menu bar. To achieve this I had to extend the AbstractContributionFactory, implemented its createContributionItems(...) method and register the factory to the IMenuService of the WorkbenchWindow. The code works fine in Eclipse 3.7, even in Eclipse 3.8. The only problem in Eclipse 4.2.2 is now that the AbstractContributionFactory#createContributionItems() method is never called. The javadoc says: "This method is not meant to be called by clients. It will be called by the menu service at the appropriate time." That doesn't seem to be true in Eclipse 4.3 (also tried with 4.2.2). I attached a simple project that contributes to the menu bar on startup. It works in Eclipse 3.7 or higher, but not 4.x.
Created attachment 232837 [details] Expected result from the attached plug-in project
Moving to Platform UI
The method should be called in Kepler (4.3). If you contribute to a menu, we got that working. Is it that you are contributing to the main menu bar? PW
(In reply to comment #3) > The method should be called in Kepler (4.3). If you contribute to a menu, > we got that working. Is it that you are contributing to the main menu bar? > > PW Yes, I'm contributing to the main menu bar (see Attachments).
I encountered another problem that is related to this one: Contributing to an editor context menu in Eclipse 4.x works in principle. But the invocation of the method org.eclipse.core.commands.AbstractHandler(Object) does not work properly for me: Eclipse 4.2.2: Method is called with an org.eclipse.e4.ui.workbench.modeling.ExpressionContext as parameter, instead of an org.eclipse.core.expressions.EvaluationContext (Eclipse 3.7). This has two downsides: 1) It adds a dependency to org.eclipse.e4... 2) It has discouraged access: Discouraged access: The type ExpressionContext is not accessible due to restriction on required library C:\Eclipse\Eclipse 4.2.2 SDK\plugins\org.eclipse.e4.ui.workbench_0.11.0.v20130125-100758.jar Eclipse 4.3: The method is not called at all. The ExpressionContext class does not exist (at least not in the same package). The effect is, that the editor contribution is always disabled for me. I managed to get it to work in Eclipse 4.2.2 by using the ExpressionContext, though.
Those are the implementation classes, you should use the interface to access it: org.eclipse.core.expressions.IEvaluationContext Which method call are you mentioning? org.eclipse.core.commands.AbstractHandler(Object) doesn't seem correct. PW
(In reply to comment #6) > Those are the implementation classes, you should use the interface to access > it: org.eclipse.core.expressions.IEvaluationContext >> Of course, thank you! > > Which method call are you mentioning? > org.eclipse.core.commands.AbstractHandler(Object) doesn't seem correct. > > PW Sorry, I was to hasty on this one! org.eclipse.core.commands.AbstractHandler.setEnabled(Object) is the correct method.
I ran into a similar problem which might be related: When contributing via ContributionFactory to a view that was not rendered before, the factory works as expected. But when contributing to an already visible view the contribution is not used. Even calling ((ViewPart) part).getViewSite().getActionBars().updateActionBars(); will not help. Might be related to the main toolbar/menu problem as these components are also already rendered when the factory comes into play.
Created attachment 240030 [details] Dynamic toolbar example Shows a new toolbar button in "Package Explorer": Example. When the button is clicked a dynamic contribution is added (see command handler). The new toolbar entry is not shown. After closing and re-opening the Package Explorer view the dynamic entry is visible.
ping. This is still an issue with Luna.
(In reply to Holger Schill from comment #10) > ping. This is still an issue with Luna. Nobody is looking at it at this moment. Patch would be appreciated - http://wiki.eclipse.org/Platform_UI/How_to_Contribute thanks in advance for your help, Daniel
This bug exists in Mars as well. It's not possible to register AbstractContributionFactory for status line toolbar. As I understand WorkbenchMenuService is responsible for factory registration. Its method addContributionFactory contains the code: MenuLocationURI location = new MenuLocationURI(factory.getLocation()); ....... if (inToolbar(location)) { if (MenuAdditionCacheEntry.isInWorkbenchTrim(location)) { // processTrimChildren(trimContributions, toolBarContributions, // configElement); } else { As you can see there is a special section which should handle the case of "toolbar:org.eclipse.ui.trim.status" URL (status line toolbar) but it does nothing: code is commented out. The same is in Luna.
This bug was mentioned in a comment in http://stackoverflow.com/questions/39225379/multiple-eclipse-instances-with-oomph as an example of Eclipse's decreasing quality / lack of reaction to bug reports. Just saying.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.