Project: Eclipse_Platform_UI
Bug 185386 [EditorMgmt] Uses the least recently used perspective when trying to close view that implements ISaveablePart2
Reported: 2007-05-03 12:23:18 | Status: verified fixed

Build ID: M20070212-1330 Steps To Reproduce: I run into an issue with Eclipse 3.2.2 view implementing ISaveablePart2 when there are multiple perspectives. Here's the case: 1 have a view which implements ISavablePart2, which means user will be prompted when the 'X' is clicked and my application has 2 perspectives (called p1 & p2). When the application starts up, it will be loaded into one of the perspective, for now, let say it's p1 and view is created as well. and it gets switched to p2. With p2 as the active perspective, the 'X' on the view is clicked. What happen at this point is a dialog comes up asking user whether to close the view and the perspective gets switched back to p1. After a little investigation i found the following code in EditorManager.saveAll(1147 to 1153): if (part instanceof IViewPart) { Perspective perspective = page .getFirstPerspectiveWithView((IViewPart) part); if (perspective != null) { page.setPerspective(perspective.getDesc()); } } so, according to the snippet above, before the confirmation dialog is pop, it will always switch back to the least recently used perspective. It uses the WorkbechPage.persList.usedList, and this list keeps tracks of recent used perspective, and the last one on the list is the the most recent one and the first one is the least recently used. This is an issue because if user cancels the confirmation, then the perspective remains. if user decides to go with it, it will switch back to p1. In general, user will be confused. More information:

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java