| Summary: | [PresentationAPI] [RCP] [EditorMgmt] Workbench sometimes restores multiple empty editor folders | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Boris Bokowski <bokowski> | ||||||||
| Component: | UI | Assignee: | Paul Webster <pwebster> | ||||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | balouin.c, daniel.stein, daniel_megert, ECOMAR, emoffatt, jean-michel_lemieux, jflicke, mole.moore, rafi.dar, remy.suen | ||||||||
| Version: | 3.2 | Keywords: | helpwanted | ||||||||
| Target Milestone: | 3.7 M4 | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Windows XP | ||||||||||
| Whiteboard: | |||||||||||
| Bug Depends on: | |||||||||||
| Bug Blocks: | 372273 | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Boris Bokowski
Created attachment 27530 [details]
screenshot
I found this in my log, I think it is related and happens when you open an editor after you restart the application and start to drag it around. !ENTRY org.eclipse.ui 4 0 2005-09-26 14:30:06.593 !MESSAGE -1 !STACK 0 java.lang.ArrayIndexOutOfBoundsException: -1 at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.getItem(AbstractTabFolder.java:151) at org.eclipse.ui.internal.presentations.util.ReplaceDragHandler.dragOver(ReplaceDragHandler.java:59) at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.dragOver(TabbedStackPresentation.java:398) at org.eclipse.ui.internal.PartStack.getDropTarget(PartStack.java:551) at org.eclipse.ui.internal.PartSashContainer.drag(PartSashContainer.java:986) at org.eclipse.ui.internal.dnd.DragUtil.getDropTarget(DragUtil.java:337) at org.eclipse.ui.internal.dnd.DragUtil.getDropTarget(DragUtil.java:360) at org.eclipse.ui.internal.dnd.DragUtil$2.run(DragUtil.java:216) at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:152) at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:28) at org.eclipse.swt.widgets.Display.syncExec(Display.java:3413) at org.eclipse.ui.internal.dnd.DragUtil$1.handleEvent(DragUtil.java:210) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852) at org.eclipse.swt.widgets.Tracker.wmMouse(Tracker.java:1030) at org.eclipse.swt.widgets.Tracker.open(Tracker.java:509) at org.eclipse.ui.internal.dnd.DragUtil.dragToTarget(DragUtil.java:291) at org.eclipse.ui.internal.dnd.DragUtil.performDrag(DragUtil.java:123) at org.eclipse.ui.internal.PartStack.dragStart(PartStack.java:1368) at org.eclipse.ui.internal.PartStack$1.dragStart(PartStack.java:107) at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:111) at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:267) at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:280) at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.handleDragStarted(AbstractTabFolder.java:364) at org.eclipse.ui.internal.presentations.util.AbstractTabFolder$2.handleEvent(AbstractTabFolder.java:68) at org.eclipse.ui.presentations.PresentationUtil.handleMouseMove(PresentationUtil.java:96) at org.eclipse.ui.presentations.PresentationUtil.access$4(PresentationUtil.java:89) at org.eclipse.ui.presentations.PresentationUtil$2.handleEvent(PresentationUtil.java:61) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3080) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2713) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.examples.rcp.adventurebuilder.GoWild.run(GoWild.java:34) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948) *** Bug 74899 has been marked as a duplicate of this bug. *** I suspect that this happens because we save the EditorStacks and save the editors ... on restore we restore the editor stacks but if the editor wasn't persistable they're not restored. I'm not sure what's valid ... right now, we restore what was there. The DND could be modified to accept the first editor in an empty editor area, but that might not be consistent with current DND (where dragging out the last editor closes the editor stack, right). Another option would be have post-restore code that closes all editor stacks until there's only one empty one left or all stacks left have editors open in them. Another option would be to try not to save editor stacks unless we can find at least one matching "part" that is also saved. That being said, this is not on the plan for 3.4 PW A workaround is on startup to look for empty editor workbooks and remove them from the editor area.
this appears to work on 3.4.2:
WorkbenchPage activePage = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
EditorAreaHelper editorAreaHelper = activePage.getEditorPresentation();
EditorSashContainer editorSashContainer = (EditorSashContainer) editorAreaHelper.getLayoutPart();
ArrayList workbooks = editorAreaHelper.getWorkbooks();
for (int i = 0; i < workbooks.size(); i++) {
EditorStack editorStack = (EditorStack) workbooks.get(i);
if(editorStack.getChildren().length==0) {
editorSashContainer.remove(editorStack);
}
}
Edoardo, would you be able to contribute this as a patch (against the current 3.7 development stream)? See http://wiki.eclipse.org/Platform_UI/How_to_Contribute (In reply to comment #6) > Edoardo, would you be able to contribute this as a patch (against the current > 3.7 development stream)? See Boris, yes I think so, but ... patch to what ? I added that code to my RCP's WorkbenchWindowAdvisor.postWindowOpen() would you want it added to the Eclipse SDK IDE's WorkbenchWindowAdvisor ? It should probably be in org.eclipse.ui.workbench, close to the place that calls postWindowOpen. (In reply to comment #8) > It should probably be in org.eclipse.ui.workbench, close to the place that > calls postWindowOpen. Ok, will do a patch - cheers Created attachment 180115 [details]
patch for IDEWorkbenchWindowAdvisor
I have attached a patch that I manually tested against one of the latest nightly 3.7 builds, following the approach of the duplicate bug: Just opened two text editors off a CVS repository and dragged them side by side, and restarted the SDK. Without the patch you get two 'ghost' panes, with the patch all is good. The code is maybe too defensive with redundant NPE checks, but hey that won't hurt performance as this method is invoked once per workbench window being opened. Edoardo Sorry, I'll get this in M4 PW Created attachment 182769 [details]
patch for too many editor areas v02
Make the behaviour a protected method in WorkbenchWindowAdvisor, and call it from IDEWorkbenchWindowAdvisor's postWindowRestore() method.
Edoardo, thanx for the patch. Could you take a look at my revised patch and see that it still addresses your usecase? Just a note, this will be an opt-in scenario, as a regular RCP app won't get this for free. PW (In reply to comment #14) > Edoardo, thanx for the patch. Could you take a look at my revised patch and > see that it still addresses your usecase? > > Just a note, this will be an opt-in scenario, as a regular RCP app won't get > this for free. > > PW looks ok to me. I see the need for the explicit call. Released for M4 PW In I20101206-1800 PW *** Bug 339032 has been marked as a duplicate of this bug. *** *** Bug 362037 has been marked as a duplicate of this bug. *** *** Bug 365382 has been marked as a duplicate of this bug. *** *** Bug 369900 has been marked as a duplicate of this bug. *** |