Tuesday, March 20, 2012

Adding 'Collapse All' button to a view

Start by adding extension point to plugin.xml of plugin where View lives:

 

    
       
    
 

Then add service code to the View's createPartControl method:

 
 IWorkbenchPartSite site = getSite();
        if (site != null) {
         IHandlerService handlerService = (IHandlerService) site.getService(
           IHandlerService.class);
         if (handlerService != null) {
          CollapseAllHandler fCollapseHandler = new CollapseAllHandler(viewer);
          handlerService.activateHandler(CollapseAllHandler.COMMAND_ID ,
            fCollapseHandler);
         }
        }

No comments:

Post a Comment

Blogger Syntax Highliter