Bug 83658 - [RCP] Split WorkbenchAdvisor into separate advisors for workbench, window, and action bars
Summary: [RCP] Split WorkbenchAdvisor into separate advisors for workbench, window, an...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2005-01-25 16:03 EST by Nick Edgar CLA
Modified: 2005-06-13 12:37 EDT (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2005-01-25 16:03:38 EST
3.1 M4

The WorkbenchAdvisor is currently overloaded with the responsibility to
configure the workbench, all workbench windows, and the windows' action bars.

This leads to either a large implementing advisor class, or to clients
delegating to other objects in an ad-hoc way (e.g. the IDE's
WorkbenchActionBuilder).

Implementors often get state management wrong, keeping window-level state as
fields on the (singleton) workbench advisor.

The window-level responsibilities in WorkbenchAdvisor should be split out into a
window-level advisor, WorkbenchWindowAdvisor.  Action bar configuration split
out as well into an ActionBarAdvisor.  This will lead to a 1:1 correspondence
between the advisors and the configurers.

In addition, this opens up the possibility of allowing different window
configurations within the same application (e.g. main window, help window,
update window).  Currently Help and Update have to resort to using a JFace
ApplicationWindow to avoid unwanted menu contributions.

These changes must not break any existing WorkbenchAdvisor implementations.
Backwards compatibility should be provided via a
CompatibilityWorkbenchWindowAdvisor, which will delegate to the old
WorkbenchAdvisor methods.
Comment 1 Nick Edgar CLA 2005-01-25 16:07:52 EST
ActionBarAdvisor should also provide a default implementaton of fillActionBars
that implements the best practices for handling the FILL_PROXY flags,
instantiating actions, and actually populating the action bars.
It may also provide conveniences for managing window-level actions.
Comment 2 Nick Edgar CLA 2005-01-25 17:53:11 EST
First cut released.  Readme example fixed up, working on Hyperbola and IDE.

Still need to figure out how to move getInitialPerspectiveId() and
getDefaultPageInput() over to WorkbenchWindowAdvisor -- the workbench assumes
these are global in some places.  Maybe getMainPreferencePageId() too.
Comment 3 Jean-Michel Lemieux CLA 2005-01-25 21:12:45 EST
Will also have to fix up the PDE RCP templates.
Comment 4 Nick Edgar CLA 2005-01-26 10:26:03 EST
CC'ing Wassim for the required template work.
I can provide a fixed up template for the default example.
Comment 5 Nick Edgar CLA 2005-02-11 00:12:04 EST
Refactored IDEWorkbenchAdvisor, adding IDEWorkbenchWindowAdvisor, and changing
WorkbenchActionBuilder to extend ActionBarAdvisor.
Comment 6 Nick Edgar CLA 2005-02-11 19:06:02 EST
The main changes have been released for M5.  Still want to look at possibility
of moving getDefaultPageInput() and getInitialPerspectiveId() to window advisor
for M6.

Filed bug 84971 for the PDE template work.
Comment 7 Nick Edgar CLA 2005-02-11 19:06:52 EST
And also the possibility of allowing different window advisors for different
windows.
Comment 8 Ed Burnette CLA 2005-02-15 10:43:45 EST
While you're at it can you fix it so the developer doesn't have to create a
perspective factory and default perspective unless they really need one? That
would simplify the minimal RCP app.
Comment 9 Ed Burnette CLA 2005-02-15 10:51:43 EST
I put a note about the changes here:
http://www.eclipsepowered.org/archives/2005/02/15/workbenchadvisor-refactored/ .
It pretty much repeats what was said here and asks for comments (to come back here).
Comment 10 Nick Edgar CLA 2005-02-15 11:53:18 EST
The perspective can be null, see bug 71150, however you usually should provide
one so I've left getInitialPerspectiveId() as abstract.
Comment 11 Ed Burnette CLA 2005-02-15 14:51:35 EST
That's not quite the same thing. I wasn't asking for "no perspective" (I'm not
sure what that would even mean, how can you open windows and have toolbar
actions?) I was asking for a default (stub, empty, do-nothing) perspective.

If it ever makes any sense to omit it then getInitialPerspectiveId() should not
be abstract. It's not a big deal but I would argue that the default
implementation should get the id of some kind of stub perspective. I was
thinking that simple RCP apps that don't need more than one perspective, maybe
most RCP apps, could just use the default one, and we could simplify the doc for
learning how to build RCP apps. I know, I know, it's not hard to make one but
it's one thing you could do to lower the bar for adoption.
Comment 12 Matthew Hatem CLA 2005-02-15 14:58:41 EST
Re Comment #11

> I would argue that the default implementation should get the id of some kind
of stub perspective.

Seems strange.  What purpose would this stub perspective serve?  An RCP
application needs to contribute at least one perspective to do anything useful,
no?  What views would be visible in this perspective by default?  Would the stub
perspective contain an editor area?
Comment 13 Nick Edgar CLA 2005-02-15 15:48:59 EST
We also wouldn't want the stub perspective showing up in the list of available
perspectives (assuming that's made visible by the app).

If getting off the ground is the main concern, the PDE templates provides a good
start.
Comment 14 Ed Burnette CLA 2005-02-15 17:47:06 EST
Views can be contributed to a perspective with the
org.eclipse.ui.perspectiveExtensions extension point.
Editor area defaults to on.
It's not a big deal, just struck me as odd when I was writing the tutorial.
Comment 15 Ed Burnette CLA 2005-03-08 17:25:46 EST
Didn't this (split api) get completed in 3.1M5a?
Comment 16 Nick Edgar CLA 2005-03-09 10:32:10 EST
I'm still pondering the points in comment #6, in addition to the idea of
allowing different types of window advisor in the same app.
Comment 17 Jean-Michel Lemieux CLA 2005-03-09 11:51:01 EST
An unfortunate side-effect of this split is that it is technically hard to have
more than one type of WorkbenchWindowAdvisor - but the APIs make this seem
possible. The WorkbenchAdvisor needs information about which type of
WindowAdvisor to create and currently it doesn't have access to either the page
input or perspective id when createWorkbenchWindowAdvisor() is called.
Comment 18 Nick Edgar CLA 2005-03-09 12:08:56 EST
> it doesn't have access to either the page input or perspective id when
createWorkbenchWindowAdvisor() is called

I'm aware of this limitation, and am planning on making this info available,
either to the create method directly, or via get methods on the
IWorkbenchWindowConfigurer.  Any preference?
Comment 19 Jean-Michel Lemieux CLA 2005-03-09 13:04:55 EST
Advantage of method parameters are that they are explicit but the advisor will
have to cache them if they are needed later. If they are available via the
configurer they are automatically cached. I don't have a strong preference.
Comment 20 Nick Edgar CLA 2005-03-22 17:03:02 EST
> it doesn't have access to either the page input or perspective id when
createWorkbenchWindowAdvisor() is called

It turns out this is harder to handle than I thought.  The page input and
perspective ID are available and can be passed when the window is first opened,
however when a window is restored from a previous session, this info is not
available before the window is created (and is no longer considered an argument
to the window creation).

I'm going to have to leave this for 3.2.  I've filed bug 88816 for this.

Closing this PR with M5 tag (no advisor changes were in M6).
Comment 21 Nick Edgar CLA 2005-06-13 12:37:58 EDT
Marking as verified.  You're soaking in it.