Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 461180 - Views open in a wrong window after dragging editor between windows
Summary: Views open in a wrong window after dragging editor between windows
Status: CLOSED DUPLICATE of bug 445305
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P2 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 346009
Blocks:
  Show dependency tree
 
Reported: 2015-03-02 05:58 EST by Alexander Zakusylo CLA
Modified: 2015-05-12 07:44 EDT (History)
7 users (show)

See Also:


Attachments
Reproduction (3.05 MB, application/x-shockwave-flash)
2015-03-03 17:40 EST, Chauncey Xu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Zakusylo CLA 2015-03-02 05:58:47 EST
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).
Comment 1 Yurii Polek CLA 2015-03-03 11:50:57 EST
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?
Comment 2 darrel karisch CLA 2015-03-03 14:32:45 EST
@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.
Comment 3 Brian de Alwis CLA 2015-03-03 15:49:05 EST
Could you try the latest 4.4 SR2 as I can't reproduce in my 4.4 or 4.5 workspaces on OSX.
Comment 4 Chauncey Xu CLA 2015-03-03 17:40:45 EST
Created attachment 251266 [details]
Reproduction

Attached video for reproduction in 4.4 SR2 in Windows 7.
Comment 5 Chauncey Xu CLA 2015-03-03 17:48:34 EST
Same behavior observed in 4.5 M5.
Comment 6 Alexander Zakusylo CLA 2015-03-04 04:23:55 EST
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)
Comment 7 Alexander Zakusylo CLA 2015-03-04 07:49:43 EST
More investigation:

- PartSite.workbenchWindow in not updated, still pointing to window A
- for window A IEclipseContext.getActiveLeaf() still returns that editor context
Comment 8 darrel karisch CLA 2015-03-10 09:47:21 EDT
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
Comment 9 Brian de Alwis CLA 2015-03-20 14:54:11 EDT
One solution might be to change IServiceLocator.getService() to return a proxy wrapper that updates its values via a RAT.
Comment 10 Brian de Alwis CLA 2015-03-20 14:58:54 EDT
Might explain some of the issues described in bug 384308 comment 19.
Comment 11 Dani Megert CLA 2015-05-12 07:44:06 EDT

*** This bug has been marked as a duplicate of bug 445305 ***