Bug 62038 - [Workbench] Move editor management decisions into the presentation API
Summary: [Workbench] Move editor management decisions into the presentation API
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Michael Van Meekeren CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-12 19:32 EDT by Stefan Xenos CLA
Modified: 2004-05-17 16:19 EDT (History)
6 users (show)

See Also:


Attachments
This patch contains the API changes for this enhancement (12.74 KB, patch)
2004-05-12 19:46 EDT, Stefan Xenos CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2004-05-12 19:32:54 EDT
There are currently a number of bugs that require decisions about editor
arrangement to be made by the presentation. The current API does not allow this
since presentations do not carry any persistent state.

This enhancement requests that the following enhancements be added to the
presentation API.

1. Presentation objects may carry persistent information, and can save and
restore that information in the workbench.
2. The protocol for adding new parts to a presentation should allow the
presentation to make decisions about the location of the new part, while still
allowing it to determine which dragover affordance was being displayed when a
part was dropped.
Comment 1 Stefan Xenos CLA 2004-05-12 19:46:33 EDT
Created attachment 10577 [details]
This patch contains the API changes for this enhancement

This does not update the existing presentation code or workbench code to
support the new API. If this is approved, I will make the remaining changes to
hook this API up to the workbench.


One suggestion:

This is the new API that was discussed in the meeting on the 12th, and it will
solve the problem quite well.

However, my preference would be to split up IPresentationSerializer into
IPresentationSaveContext and IPresentationLoadContext, and provide the IMemento
through a new method on these objects. This would provide a convenient place to
provide information that is only meaningful at initialization-time without
making breaking changes to AbstractPresentationFactory in the future. 

(Lesser benefits would be that there would be fewer arguments to the factory
methods and the interfaces seen by clients at any given time would be simpler).
Comment 2 Stefan Xenos CLA 2004-05-12 19:48:05 EDT
Adding Andrew, since the R21 presentation will be affected.
Comment 3 Kim Horne CLA 2004-05-13 07:48:26 EDT
I agree with Stefan... two interfaces would be preferable as it'd be clearer
what the implementor would be expected to do with them in the context of the
operation they are implementing.
Comment 4 Nick Edgar CLA 2004-05-13 11:22:37 EDT
If we can reuse existing persistance APIs rather than defining new ones, that
would be best.  See IPersistableElement and IElementFactory.
Comment 5 Stefan Xenos CLA 2004-05-14 01:27:55 EDT
Okay... the patch has been committed, with 1 change. Rather than passing
additional arguments to the factory methods, I have added a restoreState method
to StackPresentation. This avoids breaking changes to existing presentation
factories.

I did not add the changes that were suggested by myself, Kim, and Nick since I
wanted to stay as close as possible to the API that has already been reviewed
and approved.

I've updated the default presentation, R21 presentation, and Native presentation
to conform to the new API, and I've updated the default presentation to persist
the tab order.

This has caused some minor regressions:
- Serialization currently only works for views. Although the API is in place, I
haven't had a chance to hook it up to editors yet, so editor order will be lost
between workbench sessions (I know... it would be better if the opposite were
true <g> -- I'll try to fix this tomorrow).
- I haven't written any serialization code for the R21 presentation, so it will
forget its tab order between sessions. (Note: The Native presentation doesn't
need any serialization code, since it doesn't support dragging).
- LWP will get compile errors in their addPart method, but it can be fixed
trivially by changing the type of the second argument to Object and downcasting
to IPresentablePart. I believe their presentation doesn't support dragging, so
they shouldn't need to use the persistence API.

Hanna, this should open things up enough for you to fix the editor management
bugs you were working on. The presentation now has full control over tab order.

Nick, I fixed the bug in NativeStackPresentation that was causing blank editors
and views to appear when you switch tabs. It is now somewhat useable.

Comment 6 Stefan Xenos CLA 2004-05-14 01:32:50 EDT
I've filed bug 62217 for the editor serialization issue and bug 62218 for the
R21 presentation issue.

The enhancement requested by this bug is fixed.
Comment 7 Nick Edgar CLA 2004-05-14 11:23:46 EDT
If presentations don't implement restoreState, what order will the parts be in?
That is, does the workbench itself maintain any order for the calls to addPart?
Comment 8 Stefan Xenos CLA 2004-05-14 16:29:28 EDT
The first time a perspective is opened, the workbench will add the parts in the
same order as the parts were added in the perspective extension (that is: it
will insert the tabs in the correct order the first time).

Once drag/drop operations start happening or the user opens new editors/views,
the order is undefined (note: the order will be consistent between sessions, but
it will have not particular relation to what the user sees on their screen).
Comment 9 Nick Edgar CLA 2004-05-17 14:22:20 EDT
Yes, I more interested in the default order preserved between sessions.
Also, what is the order of events between addPart and restoreState?
On restore, is addPart called for all the parts, and then restoreState to
restore their order?
Comment 10 Stefan Xenos CLA 2004-05-17 16:19:08 EDT
No. Event ordering is like this:

1. Presentaiton constructed (no parts in the presentation)
2. If a saved state exists, restoreState is called. The presentation can choose
to add any parts it previously knew about (and it can use
IPresentationSerializer to access those parts).
3. addPart is called for all parts (including any parts the presentation may
have added in step 2). addPart is now documented to ignore the call if an
identical part already exists.

This ordering means that the presentation can completely restore its state in
the restoreState call.