reusable collapse all action? [message #505334] |
Tue, 29 December 2009 11:33  |
Eclipse User |
|
|
|
Hi,
I have a view with a treeviewer, and I am wondering if there is a simple way to reuse a collapse all action, in such a way that I could perhaps declare it in the plugin.xml and it would show up in the view toolbar, re-using icon and or handlers. Is this possible? I suppose it might not be since the handler would need access to the view's treeviewer. I looked at the org.eclipse.ui.CollapseAllHandler but I am not sure how to create an action in the view that links to the handler.
One problem I am trying to avoid is creating and identical copy of icons that are already in use elsewhere in the workbench, e.g. the collapse all icon. Is there a way to reuse an icon from another plugin's image registry? Something similar is done for fonts and colors in the JFaceResources, but I looked at its image registry but was unsuccessful.
Any help is appreciated,
Thanks.
|
|
|
|
|
Re: reusable collapse all action? [message #506064 is a reply to message #506031] |
Tue, 05 January 2010 18:31   |
Eclipse User |
|
|
|
Actually, I think there is a regression in 3.6, as this does not work. When I register the handler, my view's toolbar loses 3 or so of its actions, they aren't visible until I resize the view, and a text label appears for the collapse all action.
I have tested with the Sample view, and I still get the same problem.
Create a plugin using the Sample view template, and select a Tree viewer when prompted. Modify the view's get part control to add this at the end of the method, and you will see that several of the actions are missing.
IWorkbenchPartSite site = getSite();
if (site != null) {
IHandlerService handlerService = (IHandlerService) site.getService(
IHandlerService.class);
if (handlerService != null) {
fCollapseHandler = new CollapseAllHandler(viewer);
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, fCollapseHandler, null);
}
}
EDIT:
Here is a screenshot. The picture on the left shows the collapse all action when the handler is not activated, and the middle and right pictures show what the view looks like afterwards.
http://img10.imageshack.us/img10/8449/screenshotqb.png
[Updated on: Tue, 05 January 2010 18:45] by Moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04858 seconds