Community
Participate
Working Groups
Build ID: I20070621-1340 The getWorkbenchWindow method in WorkbenchWindowControlContribution returns null for control contributions to the global toolbar. Steps To Reproduce: 1. Create a control contribution that extends from WorkbenchWindowControlContribution. 2. In the createControl method call getWorkbenchWindow. This will be null at runtime. 3. Add the control contribution to a toolbar via the org.eclipse.ui.menus ext point. 4. Run the application and the call to getWorkbenchWindow will be null. More information: I put a break point in InternalControlContribution.setWorkbenchWindow(IWorkbenchWindow) and debugged, but never saw it get called. I noticed TrimContributionManager calls this setWorkbenchWindow method, but that is used for Trim contributions, whereas I'm doing a toolbar contribution.
Hm, that's a public method exposed by an internal class. Is it supposed to be used by adopters? The javadoc is kind of lacking so I guess the specifications haven't really been fleshed out. For all we know it could be spec'ed to allow for null returns.
(In reply to comment #1) > Hm, that's a public method exposed by an internal class. Is it supposed to be > used by adopters? The javadoc is kind of lacking so I guess the specifications > haven't really been fleshed out. For all we know it could be spec'ed to allow > for null returns. > Remy, I'm not sure what you mean - WorkbenchWindowControlContribution [1] is not an internal class. Per the javadoc, any control contributed via the org.eclipse.ui.menus ext point must extend this class. I debugged the internal class, InternalControlContribution, looking for clues as to what the problem could be, but the API for getWorkbenchWindow is on WorkbenchWindowControlContribution. [1] http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/menus/WorkbenchWindowControlContribution.html
(In reply to comment #2) > I'm not sure what you mean - WorkbenchWindowControlContribution [1] is not an > internal class. Per the javadoc, any control contributed via the > org.eclipse.ui.menus ext point must extend this class. I meant that InternalControlContribution is an internal class. But I see that WWCC is exposing it again as a public method. I must've gotten it confused with another class or something. Sorry about the confusion.
Kris, could you attach a zip file of a simple project that shows this problem?
Created attachment 81783 [details] Simple RCP app demonstrating the issue The attached RCP app has a control contribution added to both the main toolbar, and also to the trim status area. Clicking the button in the contribution will display the result of "getWorkbenchWindow()". The main toolbar one will return null, and the trim contribution will return the correct value.
Created attachment 82023 [details] Patch to set the contribution's IWorkbenchWindow when it is being constructed. Thanks for the test case, Kris, I have reproduced the error locally.
Released to HEAD >20080408 PW
In I20080429-0100
This seems to be a problem again, but with the DynamicToolBarContributionItem class that was recently added.
Please open a new bug, as this is marked fixed in 3.4 PW
.
(In reply to comment #9) > This seems to be a problem again, but with the DynamicToolBarContributionItem > class that was recently added. See bug 294118.