0

Ok, so I have successfully added the combo control to the main toolbar of my eclipse RCP application using the following extension within one of my application's plugins.

<extension
 point="org.eclipse.ui.menus">
<menuContribution
    allPopups="false"
    locationURI="toolbar:org.eclipse.ui.main.toolbar">
 <toolbar
       id="com.company.module.toolbar"
       label="Sample">
    <control
          class="com.company.module.ui.ComboToolbarContribution"
          id="zoomControl">
    </control>
</toolbar>

I have defined

public class ComboToolbarContribution extends
WorkbenchWindowControlContribution

and the above class returns a combo control that is pre-populated with values 100%, 200%, 300%, 400%

This toolbar is enabled for certain types of editors in my application using the visibleWhen clause on the toolbar extension.

Each editor in the application can support a different zoom level, so the content of the combo needs to be updated everytime an editor is activated to reflect the zoom level currently supported by it.

How do I update this combocontrol to reflect the value of the editor that is currently in focus or activated? Is there any hook available to do so?

greg-449
  • 109,219
  • 232
  • 102
  • 145

2 Answers2

0

Use IPartListener to listen for changes to the active part.

IWokbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

IPartService partService = window.getPartService();

partService.addPartListener(listener);
greg-449
  • 109,219
  • 232
  • 102
  • 145
0

You can use IPartListener#partActivated(IWorkbenchPart part) . See help here Also check this

Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
  • Thanks for your reply Greg and Chandra. I was looking more at how to access the combo control added to the toolbar under the main toolbar.I would need to use that mechanism whenever the event of an editor activation happens. Do you have any idea on how to go about it? – user1411252 Jun 25 '14 at 19:54