Author: yradtsevich
Date: 2010-03-19 12:26:24 -0400 (Fri, 19 Mar 2010)
New Revision: 20938
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropTarget.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropSpot.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5042
Enhance DnD support in VPE
- Some comments have added.
- DropSpot has been renamed to DropTarget.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java 2010-03-19
16:14:58 UTC (rev 20937)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java 2010-03-19
16:26:24 UTC (rev 20938)
@@ -21,6 +21,8 @@
import org.mozilla.interfaces.nsIDOMNode;
/**
+ * Class responsible for showing the drag icon and the node being dragged.
+ *
* @author Yahor Radtsevich (yradtsevich)
*/
public class DraggablePattern {
Deleted: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropSpot.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropSpot.java 2010-03-19
16:14:58 UTC (rev 20937)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropSpot.java 2010-03-19
16:26:24 UTC (rev 20938)
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.vpe.dnd;
-
-/**
- * @author Yahor Radtsevich (yradtsevich)
- *
- */
-public enum DropSpot {
- BEFORE,
- AFTER,
- BEGIN,
- END
-}
Copied: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropTarget.java
(from rev 20936,
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropSpot.java)
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropTarget.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropTarget.java 2010-03-19
16:26:24 UTC (rev 20938)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.dnd;
+
+/**
+ * Target of a Drag&Drop action.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public enum DropTarget {
+ BEFORE,
+ AFTER,
+ BEGIN,
+ END
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java 2010-03-19
16:14:58 UTC (rev 20937)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java 2010-03-19
16:26:24 UTC (rev 20938)
@@ -23,17 +23,19 @@
import org.mozilla.interfaces.nsIDOMNode;
/**
+ * Class responsible for showing the place where the node being dragged
+ * could be dropped.
+ *
* @author Yahor Radtsevich (yradtsevich)
- *
*/
public class DropableArea {
private boolean visible;
- private EnumSet<DropSpot> dropSpots;
+ private EnumSet<DropTarget> dropTargets;
private final nsIDOMDocument document;
private nsIDOMNode node;
private nsIDOMElement domArea;
private static final String AREA_COLOR = "rgba(166, 202, 240, 0.5)";
//$NON-NLS-1$
- private DropSpot hightlightedSpot;
+ private DropTarget hightlightedDropTarget;
/**
*
@@ -51,10 +53,10 @@
}
/**
- * @param dropSpots cannot be null
+ * @param dropTargets cannot be null
*/
- public void setDropSpots(EnumSet<DropSpot> dropSpots) {
- this.dropSpots = dropSpots;
+ public void setDropTargets(EnumSet<DropTarget> dropTargets) {
+ this.dropTargets = dropTargets;
}
public void setVisible(boolean visible) {
@@ -62,31 +64,31 @@
}
public void setHighlightedSpot(int mouseX, int mouseY) {
- this.hightlightedSpot = getHighlightedSpot(mouseX, mouseY);
+ this.hightlightedDropTarget = getHighlightedDropTarget(mouseX, mouseY);
}
- public DropSpot getHighlightedSpot(int mouseX, int mouseY) {
+ public DropTarget getHighlightedDropTarget(int mouseX, int mouseY) {
if (node == null) {
return null;
}
Rectangle bounds = XulRunnerVpeUtils.getElementBounds(node);
- if (dropSpots.contains(DropSpot.BEFORE)
+ if (dropTargets.contains(DropTarget.BEFORE)
&& bounds.x <= mouseX
&& mouseX < bounds.x + bounds.width / 5) {
- return DropSpot.BEFORE;
- } else if (dropSpots.contains(DropSpot.AFTER)
+ return DropTarget.BEFORE;
+ } else if (dropTargets.contains(DropTarget.AFTER)
&& bounds.x + bounds.width * 4 / 5 <= mouseX
&& mouseX < bounds.x + bounds.width) {
- return DropSpot.AFTER;
- } else if (dropSpots.contains(DropSpot.BEGIN)
+ return DropTarget.AFTER;
+ } else if (dropTargets.contains(DropTarget.BEGIN)
&& bounds.y <= mouseY
&& mouseY < bounds.y + bounds.height / 5) {
- return DropSpot.BEGIN;
- } else if (dropSpots.contains(DropSpot.END)
+ return DropTarget.BEGIN;
+ } else if (dropTargets.contains(DropTarget.END)
&& bounds.y + bounds.height * 4 / 5 <= mouseY
&& mouseY < bounds.y + bounds.height) {
- return DropSpot.END;
+ return DropTarget.END;
} else {
return null;
}
@@ -112,25 +114,25 @@
nsIDOMCSSStyleDeclaration style;
nsIDOMElement line;
- if (dropSpots.contains(DropSpot.BEFORE)) {
- line = createVerticalLine(bounds.height, getColor(DropSpot.BEFORE));
+ if (dropTargets.contains(DropTarget.BEFORE)) {
+ line = createVerticalLine(bounds.height, getColor(DropTarget.BEFORE));
style = VpeStyleUtil.getStyle(line);
style.setProperty(HTML.STYLE_PARAMETER_LEFT,
VpeStyleUtil.toPxPosition(-6), HTML.STYLE_PRIORITY_DEFAULT);
domArea.appendChild(line);
}
- if (dropSpots.contains(DropSpot.AFTER)) {
- line = createVerticalLine(bounds.height, getColor(DropSpot.AFTER));
+ if (dropTargets.contains(DropTarget.AFTER)) {
+ line = createVerticalLine(bounds.height, getColor(DropTarget.AFTER));
style = VpeStyleUtil.getStyle(line);
style.setProperty(HTML.STYLE_PARAMETER_RIGHT,
VpeStyleUtil.toPxPosition(-6), HTML.STYLE_PRIORITY_DEFAULT);
domArea.appendChild(line);
}
- if (dropSpots.contains(DropSpot.BEGIN)) {
+ if (dropTargets.contains(DropTarget.BEGIN)) {
line = createHorizontalLine(bounds.width - 4,
- getColor(DropSpot.BEGIN));
+ getColor(DropTarget.BEGIN));
style = VpeStyleUtil.getStyle(line);
style.setProperty(HTML.STYLE_PARAMETER_LEFT,
VpeStyleUtil.toPxPosition(2), HTML.STYLE_PRIORITY_DEFAULT);
@@ -139,9 +141,9 @@
domArea.appendChild(line);
}
- if (dropSpots.contains(DropSpot.END)) {
+ if (dropTargets.contains(DropTarget.END)) {
line = createHorizontalLine(bounds.width - 4,
- getColor(DropSpot.END));
+ getColor(DropTarget.END));
style = VpeStyleUtil.getStyle(line);
style.setProperty(HTML.STYLE_PARAMETER_LEFT,
VpeStyleUtil.toPxPosition(2), HTML.STYLE_PRIORITY_DEFAULT);
@@ -155,8 +157,8 @@
}
}
- private String getColor(DropSpot dropSpot) {
- if (dropSpot == hightlightedSpot) {
+ private String getColor(DropTarget dropTarget) {
+ if (dropTarget == hightlightedDropTarget) {
return "red";
} else {
return "black";