| Summary: | [PresentationAPI] (regression) Implementors of StackPresentation now must implement save/restore state methods | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Matthew Hatem <Matthew_Hatem> | ||||||
| Component: | UI | Assignee: | Paul Webster <pwebster> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | major | ||||||||
| Priority: | P2 | CC: | michaelvanmeekeren, Mike_Wilson, n.a.edgar, shaun, sxenos | ||||||
| Version: | 3.2 | ||||||||
| Target Milestone: | 3.2 RC1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Stefan, do you know whether this was an intentional change? I'm not sure if this problem was introduced in recent builds or if it's been there since the beginning of 3.2. We've just recently moved to 3.2 and more recently began running tests without cleaning the runtime workspace. Looks like an unintentional regression to me. So this means that existing presentation implementations out there coded against 3.0 or 3.1 will fail against 3.2 unless this is addressed. Matt, do you still have an error log around that you could attach to the bug? Was it NPEs in PresentablePart? Thanx in advance, PW Created attachment 39175 [details]
Changes to PresentablePartFolder#insert(IPresentablePart, int)
Normally if a part already exists in the folder, insert is short circuited with a call to return. This change will add a check to see if the part should be moved before returning.
There were no runtime errors to log. The problem is that perspectives are restored but no views are added. Created attachment 39262 [details]
partstack patch + example patch
The PartStack should always add parts to the presentation so that they can be restored by the presentation serializer.
PW
The PartStack was getting the parts, but not adding them to the presentation. In the case where the presentation implemented restoreState(*), the presentation was adding the parts to itself. Any presentation that didn't implement restoreState(*) got the default one that did nothing (so now parts got added to the presentation). Now the part stack adds the parts to the presentation, and restoreState(*) re-orders them based on it's algorithm. Fixed in HEAD >20060424 PW bookkeeping |
In previous releases it was okay not to implement the save/restore state methods for subclasses of StackPresentation. In recent builds, unexpected errors occur when restoring a perpsective from a previous run. Without code that looks like the following, no views are ever added to the StackPresentation on a restore event. public void restoreState(IPresentationSerializer serializer, IMemento savedState) { IMemento[] parts = savedState.getChildren(IWorkbenchConstants.TAG_PART); for (int idx = 0; idx < parts.length; idx++) { String id = parts[idx].getString(IWorkbenchConstants.TAG_ID); if (id != null) { IPresentablePart part = serializer.getPart(id); if (part != null) { addPart(part, null); } } } } public void saveState(IPresentationSerializer context, IMemento { TabItem[] items = tabFolder.getItems(); ArrayList parts = new ArrayList(3); for (int i=0; i<items.length; i++) { parts.add(getPartForTab(items[i])); } Iterator iter = parts.iterator(); while (iter.hasNext()) { IPresentablePart next = (IPresentablePart) iter.next(); IMemento childMem = memento .createChild(IWorkbenchConstants.TAG_PART); childMem.putString(IWorkbenchConstants.TAG_ID, context.getId(next)); } } We are fine with this change in behavior, we will update our presentation, however we should probably update the Javadoc.