Bug 309447 Possibility to take out editor as standalone shell
diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DetachedDropAgent.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DetachedDropAgent.java
index cf70e2e..cad4e0d 100644
--- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DetachedDropAgent.java
+++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DetachedDropAgent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,8 +29,7 @@
@Override
public boolean canDrop(MUIElement dragElement, CursorInfo info) {
- if (dragElement instanceof MPart && info.curElement == null
- && !dragElement.getTags().contains("Editor")) //$NON-NLS-1$
+ if (dragElement instanceof MPart && info.curElement == null)
return true;
return false;
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
index 3276c95..466f48e 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
@@ -506,12 +506,24 @@
public void detach(MPartSashContainerElement element, int x, int y, int width, int height) {
// Determine the correct parent for the new window
MUIElement curParent = element.getParent();
- while (curParent != null && !(curParent instanceof MPerspective)
- && !(curParent instanceof MWindow))
- curParent = curParent.getParent();
+ MUIElement current = element;
+ MWindow window = getTopLevelWindowFor(element);
+ while (!(curParent instanceof MPerspective) && !(curParent instanceof MWindow)) {
+ if (curParent == null) {
+ // no parent, maybe we're being represented by a placeholder
+ current = findPlaceholderFor(window, current);
+ if (current == null) {
+ return; // log??
+ }
- if (curParent == null)
- return; // log??
+ curParent = current.getParent();
+ if (curParent == null) {
+ return; // log??
+ }
+ }
+ current = curParent;
+ curParent = current.getParent();
+ }
MTrimmedWindow newWindow = BasicFactoryImpl.INSTANCE.createTrimmedWindow();
@@ -529,7 +541,6 @@
MPerspective persp = (MPerspective) curParent;
persp.getWindows().add(newWindow);
- MWindow window = getTopLevelWindowFor(persp);
IPresentationEngine renderingEngine = persp.getContext().get(IPresentationEngine.class);
renderingEngine.createGui(newWindow, window.getWidget(), persp.getContext());
} else if (curParent instanceof MWindow) {
@@ -542,9 +553,6 @@
* @return
*/
private MWindowElement wrapElementForWindow(MPartSashContainerElement element) {
- if (element instanceof MWindowElement)
- return (MWindowElement) element;
-
if (element instanceof MPlaceholder) {
MUIElement ref = ((MPlaceholder) element).getRef();
if (ref instanceof MPart) {
@@ -552,6 +560,12 @@
newPS.getChildren().add((MPlaceholder) element);
return newPS;
}
+ } else if (element instanceof MPart) {
+ MPartStack newPS = MBasicFactory.INSTANCE.createPartStack();
+ newPS.getChildren().add((MPart) element);
+ return newPS;
+ } else if (element instanceof MWindowElement) {
+ return (MWindowElement) element;
}
return null;
}