Customizing the workbench window toolbar

To demonstrate how the HostAccessActionBarAdvisor class can be extended, the following steps show how to add a toolbar item to the main coolbar area of the workbench window. When clicked, a new instance of a specified ZIETrans rich client application opens.
  1. Update the HostAccessWorkbenchWindowAdvisor.preOpen() method to show the workbench window's coolbar area. This method has already been implemented, so you only need to add the call to the setShowCoolBar(boolean) method:
        public void preWindowOpen() {
            ...
            configurer.setShowCoolBar(true);
            ...
        }
  2. Add a new private member to the HostAccessActionBarAdvisor:
    private LaunchApplicationAction launchAppAction;
  3. Add code to the HostAccessActionBarAdvisor.makeActions() method to create a new instance of the LaunchApplicationAction class. The constructor for this class takes two arguments:
    1. The ID of the ZIETrans rich client application
    2. The IWorkbenchWindow object, which is passed into the makeActions() method):
          protected void makeActions(final IWorkbenchWindow window) {
              ...
              launchAppAction = new LaunchApplicationAction("myPlugin", window);
          }
  4. Add or update the ApplicationActionBarAdvsior.fillCoolBar() method to create a toolbar, add the new launcher action to the toolbar, and then add the toolbar to the coolbar:
    protected void fillCoolBar(ICoolBarManager coolBar) {
        // Create toolbar manager
        IToolBarManager mainToolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
        // Add the launch action to the toolbar manager
        mainToolbar.add(launchAppAction);
                
        // Add the main toolbar to the window coolbar
        coolBar.add(new ToolBarContributionItem(mainToolbar, "main"));   
    
    }
  5. Launch a new Eclipse workbench. You should have a new toolbar item that, when clicked, will open a new instance of the transformation view associated with this plug-in.
Figure 1. Launching a new workbench
Launching a new workbench
Note: You can change both the default image and text displayed for the launch action by calling the setText() and setImageDescriptor() methods on the launchAppAction object. See the Eclipse API for the org.eclipse.jface.action.Action class for more information.