aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2014-03-24 17:13:24 (EDT)
committerEric Moffatt2014-03-25 13:35:58 (EDT)
commit931f731ad02d4dbd13d39f288043001d04801459 (patch)
tree5536a25ad1d17f463c99bc4a31d3e4d82ff41a50
parentfa1174d74aa1db35406d62fdaee91d56c329da44 (diff)
downloadeclipse.platform.ui-931f731ad02d4dbd13d39f288043001d04801459.zip
eclipse.platform.ui-931f731ad02d4dbd13d39f288043001d04801459.tar.gz
eclipse.platform.ui-931f731ad02d4dbd13d39f288043001d04801459.tar.bz2
Bug 430662 - Editor area splits when dragging an editor without Ctrl keyrefs/changes/99/23699/5
pressed Don't split the editor area when dragging within the editor area and the Ctrl key is not pressed. Don't split the editor area when dragging into the editor area from outside and the Ctrl key is pressed. Show outer rectangle as an indication that the part will be inserted into an existing editor area stack. Change-Id: I3df178aa8ff56c47ee71bbd0489cd4be05deaa04 Signed-off-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/SplitDropAgent.java65
1 files changed, 41 insertions, 24 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/SplitDropAgent.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/SplitDropAgent.java
index 7f7d086..824f7d4 100644
--- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/SplitDropAgent.java
+++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/SplitDropAgent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 IBM Corporation and others.
+ * Copyright (c) 2010, 2014 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Sergey Prigogin (Google) - bug 430662
******************************************************************************/
package org.eclipse.e4.ui.workbench.addons.dndaddon;
@@ -156,7 +157,7 @@ public class SplitDropAgent extends DropAgent {
}
getDockLocation(info);
- showFeedback(curDockLocation);
+ showFeedback(dragElement, curDockLocation);
}
/*
@@ -202,7 +203,7 @@ public class SplitDropAgent extends DropAgent {
int dockLocation = getDockLocation(info);
if (feedback != null) {
- feedback.setFeedback(getEnclosed(), getModified());
+ feedback.setFeedback(getEnclosed(dragElement), getModified());
}
if (dockLocation == curDockLocation && wasOnEdge == onEdge)
@@ -214,7 +215,7 @@ public class SplitDropAgent extends DropAgent {
curDockLocation = dockLocation;
if (curDockLocation != NOWHERE) {
- showFeedback(curDockLocation);
+ showFeedback(dragElement, curDockLocation);
dndManager.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
} else {
unDock(dragElement);
@@ -232,30 +233,44 @@ public class SplitDropAgent extends DropAgent {
* @return Whether this is a 'modified' drop.
*/
private boolean getModified() {
- if (!onEdge)
- return false;
return dndManager.isModified;
}
/**
+ * @param dragElement
+ * the element being dragged
* @return Whether the feedback should show an outer 'enclosing' rectangle or two separate
* rectangles.
*/
- private boolean getEnclosed() {
- if (onEdge) {
- if (outerRelTo instanceof MPerspectiveStack)
- return !getModified();
- return getModified(); // 'Inner' drop
- }
+ private boolean getEnclosed(MUIElement dragElement) {
+ return !willCreateNewStack(dragElement);
+ }
- return true;
+ /**
+ * @param dragElement
+ * the element being dragged
+ * @return Whether a new stack will be created on drop.
+ */
+ private boolean willCreateNewStack(MUIElement dragElement) {
+ if (outerRelTo instanceof MPerspectiveStack) {
+ // Dropping outside of the shared area always creates a new stack.
+ return true;
+ }
+ if (crossSharedAreaBoundary(dragElement, dropStack)) {
+ // Dragging into the shared area from outside. Without the Ctrl key creating a new
+ // stack, with the Ctrl key dropping into the existing shared area stack.
+ return !getModified();
+ }
+ // Dragging within the shared area. Without the Ctrl key dropping into the existing shared
+ // area stack, otherwise creating a new stack.
+ return getModified();
}
/**
- * @param curDockLocation2
- * @return
+ * @param dragElement
+ * @param location
*/
- private void showFeedback(int location) {
+ private void showFeedback(MUIElement dragElement, int location) {
if (location == NOWHERE)
return;
@@ -290,7 +305,7 @@ public class SplitDropAgent extends DropAgent {
clearFeedback();
feedback = new SplitFeedbackOverlay(dropCTF.getShell(), feedbackBounds, side, pct,
- getEnclosed(), getModified());
+ getEnclosed(dragElement), getModified());
feedback.setVisible(true);
}
@@ -336,6 +351,10 @@ public class SplitDropAgent extends DropAgent {
return dy < dyr ? EModelService.ABOVE : EModelService.BELOW;
}
+ /**
+ * @param dragElement
+ * the element being dragged
+ */
protected void unDock(MUIElement dragElement) {
dndManager.clearOverlay();
clearFeedback();
@@ -348,11 +367,7 @@ public class SplitDropAgent extends DropAgent {
MPartSashContainerElement relTo = dropStack;
MPartStack toInsert;
- if (crossSharedAreaBoundary(dragElement, dropStack)) {
- if (!dndManager.isModified) {
- relTo = (MPartSashContainerElement) outerRelTo;
- }
- } else if (getModified()) {
+ if (willCreateNewStack(dragElement)) {
relTo = (MPartSashContainerElement) outerRelTo;
}
@@ -381,8 +396,10 @@ public class SplitDropAgent extends DropAgent {
/**
* @param dragElement
- * @param dropStack2
- * @return
+ * the element being dragged
+ * @param dropStack
+ * the stack occupying the drop location
+ * @return Whether dragged into the shared area from outside
*/
private boolean crossSharedAreaBoundary(MUIElement dragElement, MPartStack dropStack) {
EModelService ms = dndManager.getModelService();