Community
Participate
Working Groups
Reproducible in Eclipse IDE: - Open a second window (menu Window->New Window) - Open any editor in the 2nd window and drag it to the 1st window - Try to open any view in 2nd window (Window->Show View...) Views open in the 1st window. They are expected to open in the 2nd one. (Note that Quick access opens views in correct window).
Observation which may be related to this bug: editor.getSite().getWorkbenchWindow() for editor dragged to 2nd window returns object of 1st workbench window. Is it correct behavior or bug?
@Inject protected Adapter _adapter; @Inject @Optional public void partActivated(@UIEventTopic(UIEvents.UILifeCycle.ACTIVATE) Event event) { Object x = event.getProperty(UIEvents.EventTags.ELEMENT); IEditorPart editor = _adapter.adapt(x, IEditorPart.class); MPart mpart = _adapter.adapt(x, MPart.class); IWorkbenchWindow mpartContextWindow = mpart.getContext().get(IWorkbenchWindow.class); IWorkbenchWindow editorSiteWindow = editor.getSite().getWorkbenchWindow(); IWorkbenchWindow editorSiteServiceWindow = (IWorkbenchWindow) editor.getSite().getService(IWorkbenchWindow.class); } Among these IWorkbenchWindow values only editorSiteWindow retains the original window value. The others adapt to the move. Seems more like a bug rather than a feature.
Could you try the latest 4.4 SR2 as I can't reproduce in my 4.4 or 4.5 workspaces on OSX.
Created attachment 251266 [details] Reproduction Attached video for reproduction in 4.4 SR2 in Windows 7.
Same behavior observed in 4.5 M5.
If you drag an editor from window A to B, then execute a command in A: In command handler: HandlerUtil.getActiveWorkbenchWindow returns B (wrong) PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns A (correct)
More investigation: - PartSite.workbenchWindow in not updated, still pointing to window A - for window A IEclipseContext.getActiveLeaf() still returns that editor context
as Alex noted... The perspective of the prior host window retains the editor context as its active child. perspectiveContext.getActiveChild().getParent() != perspectiveContext also... The EPartService of the former window host retains the moved editor as its activePart. priorMWindow.getContext().get(EPartService.class).getActivePart() == movedEditorMPart
One solution might be to change IServiceLocator.getService() to return a proxy wrapper that updates its values via a RAT.
Might explain some of the issues described in bug 384308 comment 19.
*** This bug has been marked as a duplicate of bug 445305 ***