This is part of the Eclipse 3.1 migration series that I have put up on my blog. The previous blog post on 3.1 migrations can be found at
Hope you have found those information useful.
In Eclipse 3.1, the WorkbenchAdvisor has been refactored to move out window-level responsibilities to a new window advisor - WorkbenchWindowAdvisor, and further division is the new ActionBarAdvisor to handle actionbar related functionalities. These changes lead to a cleaner and easier implementation.
WorkbenchWindowAdvisor
Under your existing WorkbenchAdvisor, commonly used functions like initialize, preStartup, postStartup, openWindows, preShutdown, postShutdown, getInitialWindowPerspectiveId, getMainPreferencePageId, getWorkbenchConfigurer and state related functions are remained unchanged in WorkbenchAdvisor.
If you make use of functions like preWindowOpen, postWindowRestore, postWindowCreate, openIntro, postWindowOpen and preWindowShellClose, just create a new class to extend the WorkbenchWindowAdvisor (e.g. MyWindowAdvisor). Move all these functions to the new MyWindowAdvisor class. In your existing WorkbenchAdvisor, create a new function:
public WorkbenchWindowAdvisor
createWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer configurer)
{
return new MyWindowAdvisor(configurer);
}
To get the IWorkbenchWindowConfigurer,
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
ActionBarAdvisor
Similarly, if fillActionBars is used, create a new MyActionBarAdvisor that extends ActionBarAdvisor. If you have coding coventions used in RCP Browser example, migrating to the ActionBarAdvisor is a breeze as the new ActionBarAdvisor provides new functions such as fillCoolBar, fillMenuBar, fillStatusLine and makeActions.
I find that fillActionBars implementation in the previous WorkbenchAdvisor is no longer needed in my case as the new functions have covered that, it depends on your need, you may still require the fillActionBars.
Put your codes into the relevant functions like coolbar related into fillCoolBar, creating actions into makeActions, and so on.
In any point you need to access WorkbenchWindow, example is creating IContributionItems using ContributionItemFactory, issue a call to
IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer() .getWindow();
Once you have done that, it is time to call the newly created MyActionBarAdvisor. The code to add is in your WorkbenchWindowAdvisor implementation:
public ActionBarAdvisor
createActionBarAdvisor(IActionBarConfigurer configurer) {
return new MyActionBarAdvisor(configurer);
}
With that, migration to new WorkbenchAdvisor API is complete. I am not aware of other changes other than the above. Please let me know if I miss out something. =)
Recent comments
31 weeks 6 days ago
44 weeks 3 days ago
49 weeks 6 days ago
1 year 36 weeks ago
1 year 45 weeks ago
4 years 34 weeks ago
4 years 47 weeks ago
6 years 36 weeks ago
6 years 36 weeks ago
6 years 41 weeks ago