Author: yradtsevich
Date: 2010-03-19 12:14:36 -0400 (Fri, 19 Mar 2010)
New Revision: 20936
Added:
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/DropSpot.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java
trunk/vpe/plugins/org.jboss.tools.vpe/ve/dragIcon.gif
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5042
Enhance DnD support in VPE
- Created classes: DraggablePattern and DropableArea.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java 2010-03-19
16:00:30 UTC (rev 20935)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DndUtil.java 2010-03-19
16:14:36 UTC (rev 20936)
@@ -14,15 +14,19 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Stack;
+import java.util.Map.Entry;
import org.eclipse.swt.events.TypedEvent;
import org.jboss.tools.common.model.ui.editors.dnd.context.DropContext;
import org.jboss.tools.common.model.ui.editors.dnd.context.IDNDTextEditor;
import org.jboss.tools.vpe.editor.VpeController;
-import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
+import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.xulrunner.XPCOM;
import org.mozilla.interfaces.nsIComponentManager;
-import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNSDocument;
import org.mozilla.interfaces.nsIDragService;
import org.mozilla.interfaces.nsIDragSession;
import org.mozilla.interfaces.nsIServiceManager;
@@ -209,4 +213,51 @@
return dataLen;
}
}
+
+
+ public static void setTemporaryDndElement(nsIDOMElement element,
+ boolean temporary) {
+ if (temporary) {
+ element.setAttribute("vpeTemporaryDndElement",
+ Boolean.TRUE.toString());
+ } else {
+ element.removeAttribute("vpeTemporaryDndElement");
+ }
+ }
+
+ public static boolean isTemporaryDndElement(nsIDOMElement element) {
+ String attribute = element.getAttribute("vpeTemporaryDndElement");
+ if (Boolean.TRUE.toString().equals(attribute)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static nsIDOMElement getElementFromPoint(nsIDOMNSDocument document,
+ int x, int y) {
+ nsIDOMElement element = document.elementFromPoint(x, y);
+
+ Stack<nsIDOMElement> hiddenElements = new Stack<nsIDOMElement>();
+ Stack<String> hiddenElementsStyles = new Stack<String>();
+ while (element != null && isTemporaryDndElement(element)) {
+ hiddenElements.push(element);
+ hiddenElementsStyles.push(element.getAttribute(HTML.ATTR_STYLE));
+
+ element.setAttribute(HTML.ATTR_STYLE, "display:none !important;");
+ element = document.elementFromPoint(x, y);
+ }
+
+ while (!hiddenElements.empty()) {
+ nsIDOMElement element2 = hiddenElements.pop();
+ String style = hiddenElementsStyles.pop();
+ if (style == null) {
+ element2.removeAttribute(HTML.ATTR_STYLE);
+ } else {
+ element2.setAttribute(HTML.ATTR_STYLE, style);
+ }
+ }
+
+ return element;
+ }
}
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DraggablePattern.java 2010-03-19
16:14:36 UTC (rev 20936)
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.swt.graphics.Rectangle;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
+import org.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
+import org.mozilla.interfaces.nsIDOMCSSStyleDeclaration;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMElementCSSInlineStyle;
+import org.mozilla.interfaces.nsIDOMNode;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class DraggablePattern {
+ private static final String DRAGGING_OPACITY = "0.5"; //$NON-NLS-1$
+ private static final String DRAG_ICON_ID = "dragIcon"; //$NON-NLS-1$
+ private static final String DRAG_ICON_FILE = "dragIcon.gif"; //$NON-NLS-1$
+ private static final String DEFAULT_DISPLAY = ""; //$NON-NLS-1$
+ private static final String NONE_DISPLAY = "none"; //$NON-NLS-1$
+ private static final String ABSOLUTE_POSITION = "absolute"; //$NON-NLS-1$
+ private static final String IMPORTANT_PRIORITY = "important"; //$NON-NLS-1$
+ private static final String DEFAULT_PRIORITY = ""; //$NON-NLS-1$
+ private static final String DRAG_ICON_STYLE
+ = "display:none; position: absolute; cursor: move"; //$NON-NLS-1$
+
+ private int offsetX;
+ private int offsetY;
+ private boolean sessionStarted;
+ private nsIDOMNode nodeCopy;
+ private nsIDOMNode node;
+ private nsIDOMCSSStyleDeclaration nodeCopyStyle;
+ private final MozillaEditor mozillaEditor;
+
+ public DraggablePattern(MozillaEditor mozillaEditor) {
+ sessionStarted = false;
+ this.mozillaEditor = mozillaEditor;
+ }
+
+ public void showDragIcon(nsIDOMNode node) {
+ this.node = node;
+ Rectangle bounds = XulRunnerVpeUtils.getElementBounds(node);
+ DragIcon dragIcon = getDragIcon();
+ dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_DISPLAY,
+ DEFAULT_DISPLAY, DEFAULT_PRIORITY);
+ dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_LEFT,
+ VpeStyleUtil.toPxPosition(bounds.x), DEFAULT_PRIORITY);
+ dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_TOP,
+ VpeStyleUtil.toPxPosition(bounds.y - 20), DEFAULT_PRIORITY);
+ }
+
+ public void hideDragIcon() {
+ this.node = null;
+ DragIcon dragIcon = getDragIcon();
+ dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_DISPLAY,
+ NONE_DISPLAY, DEFAULT_PRIORITY);
+ }
+
+ public DragIcon getDragIcon() {
+ nsIDOMElement dragIconElement = mozillaEditor.getDomDocument()
+ .getElementById(DRAG_ICON_ID);
+ if (dragIconElement == null) {
+ dragIconElement = mozillaEditor.getDomDocument()
+ .createElement(HTML.TAG_IMG);
+ DndUtil.setTemporaryDndElement(dragIconElement, true);
+ mozillaEditor.getDomDocument().getElementsByTagName(HTML.TAG_BODY)
+ .item(0).appendChild(dragIconElement);
+ dragIconElement.setAttribute(HTML.ATTR_ID, DRAG_ICON_ID);
+ dragIconElement.setAttribute(HTML.ATTR_SRC,
+ VpeStyleUtil.getAbsoluteResourcePathUrl(DRAG_ICON_FILE));
+ dragIconElement.setAttribute(HTML.ATTR_STYLE, DRAG_ICON_STYLE);
+ }
+ return new DragIcon(dragIconElement);
+ }
+
+ public nsIDOMNode getNode() {
+ return node;
+ }
+
+ public void startSession(int mouseStartX, int mouseStartY) {
+ if (sessionStarted) {
+ new IllegalStateException(
+ "Session is already started."); //$NON-NLS-1$
+ }
+ if (node == null) {
+ new IllegalStateException(
+ "No node to drag."); //$NON-NLS-1$
+ }
+
+ Rectangle nodeBounds = XulRunnerVpeUtils.getElementBounds(node);
+ offsetX = nodeBounds.x - mouseStartX;
+ offsetY = nodeBounds.y - mouseStartY;
+
+ nodeCopy = node.cloneNode(true);
+ if (nodeCopy.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ nsIDOMElement elementCopy = (nsIDOMElement) nodeCopy.queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+ DndUtil.setTemporaryDndElement(elementCopy, true);
+ }
+ nodeCopyStyle = ((nsIDOMElementCSSInlineStyle)
+ nodeCopy.queryInterface(
+ nsIDOMElementCSSInlineStyle
+ .NS_IDOMELEMENTCSSINLINESTYLE_IID)).getStyle();
+
+ nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_POSITION,
+ ABSOLUTE_POSITION, IMPORTANT_PRIORITY);
+ nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_OPACITY,
+ DRAGGING_OPACITY, IMPORTANT_PRIORITY);
+ setVisible(false);
+ node.getParentNode().appendChild(nodeCopy);
+ move(mouseStartX, mouseStartY);
+ setVisible(true);
+ sessionStarted = true;
+ }
+
+ public void closeSession() {
+ if (!sessionStarted) {
+ new IllegalStateException(
+ "Session is already closed."); //$NON-NLS-1$
+ }
+
+ nsIDOMNode parent = nodeCopy.getParentNode();
+ if (parent != null) {
+ parent.removeChild(nodeCopy);
+ }
+
+ hideDragIcon();
+ nodeCopy = null;
+ nodeCopyStyle = null;
+ sessionStarted = false;
+ }
+
+ public void setVisible(boolean visible) {
+ nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_DISPLAY,
+ visible ? DEFAULT_DISPLAY : NONE_DISPLAY, IMPORTANT_PRIORITY);
+ DragIcon dragIcon = getDragIcon();
+ dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_DISPLAY,
+ visible ? DEFAULT_DISPLAY : NONE_DISPLAY, DEFAULT_PRIORITY);
+ }
+
+ public void move(int mouseX, int mouseY) {
+ nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_LEFT,
+ VpeStyleUtil.toPxPosition(offsetX + mouseX),
+ IMPORTANT_PRIORITY);
+ nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_TOP,
+ VpeStyleUtil.toPxPosition(offsetY + mouseY),
+ IMPORTANT_PRIORITY);
+
+ DragIcon dragIcon = getDragIcon();
+ dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_LEFT,
+ VpeStyleUtil.toPxPosition(offsetX + mouseX),
+ DEFAULT_PRIORITY);
+ dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_TOP,
+ VpeStyleUtil.toPxPosition(offsetY + mouseY - 20),
+ DEFAULT_PRIORITY);
+ }
+
+ public class DragIcon {
+ private final nsIDOMElement element;
+ private final nsIDOMCSSStyleDeclaration style;
+
+ public DragIcon(nsIDOMElement element) {
+ this.element = element;
+ style = VpeStyleUtil.getStyle(element);
+ }
+
+ public nsIDOMElement getElement() {
+ return element;
+ }
+
+ public nsIDOMCSSStyleDeclaration getStyle() {
+ return style;
+ }
+
+ public void setStyleProperty(String propertyName, String value,
+ String priority) {
+ style.setProperty(propertyName, value, priority);
+ }
+ }
+}
Added: 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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropSpot.java 2010-03-19
16:14:36 UTC (rev 20936)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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
+}
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/DropableArea.java 2010-03-19
16:14:36 UTC (rev 20936)
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.EnumSet;
+
+import org.eclipse.swt.graphics.Rectangle;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
+import org.jboss.tools.vpe.xulrunner.editor.XulRunnerVpeUtils;
+import org.mozilla.interfaces.nsIDOMCSSStyleDeclaration;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public class DropableArea {
+ private boolean visible;
+ private EnumSet<DropSpot> dropSpots;
+ 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;
+
+ /**
+ *
+ * @param document cannot be null
+ */
+ public DropableArea(nsIDOMDocument document) {
+ this.document = document;
+ }
+
+ /**
+ * @param node cannot be null
+ */
+ public void setNode(nsIDOMNode node) {
+ this.node = node;
+ }
+
+ /**
+ * @param dropSpots cannot be null
+ */
+ public void setDropSpots(EnumSet<DropSpot> dropSpots) {
+ this.dropSpots = dropSpots;
+ }
+
+ public void setVisible(boolean visible) {
+ this.visible = visible;
+ }
+
+ public void setHighlightedSpot(int mouseX, int mouseY) {
+ this.hightlightedSpot = getHighlightedSpot(mouseX, mouseY);
+ }
+
+ public DropSpot getHighlightedSpot(int mouseX, int mouseY) {
+ if (node == null) {
+ return null;
+ }
+
+ Rectangle bounds = XulRunnerVpeUtils.getElementBounds(node);
+ if (dropSpots.contains(DropSpot.BEFORE)
+ && bounds.x <= mouseX
+ && mouseX < bounds.x + bounds.width / 5) {
+ return DropSpot.BEFORE;
+ } else if (dropSpots.contains(DropSpot.AFTER)
+ && bounds.x + bounds.width * 4 / 5 <= mouseX
+ && mouseX < bounds.x + bounds.width) {
+ return DropSpot.AFTER;
+ } else if (dropSpots.contains(DropSpot.BEGIN)
+ && bounds.y <= mouseY
+ && mouseY < bounds.y + bounds.height / 5) {
+ return DropSpot.BEGIN;
+ } else if (dropSpots.contains(DropSpot.END)
+ && bounds.y + bounds.height * 4 / 5 <= mouseY
+ && mouseY < bounds.y + bounds.height) {
+ return DropSpot.END;
+ } else {
+ return null;
+ }
+ }
+
+ public void redraw() {
+ if (!visible || node == null) {
+ if (domArea != null) {
+ domArea.getParentNode().removeChild(domArea);
+ domArea = null;
+ }
+ return;
+ }
+
+ Rectangle bounds = XulRunnerVpeUtils.getElementBounds(node);
+
+ nsIDOMElement oldDomArea = domArea;
+ domArea = createRect(bounds, AREA_COLOR);
+ nsIDOMElement contentArea
+ = document.getElementById(MozillaEditor.CONTENT_AREA_ID);
+ contentArea.appendChild(domArea);
+
+ nsIDOMCSSStyleDeclaration style;
+ nsIDOMElement line;
+
+ if (dropSpots.contains(DropSpot.BEFORE)) {
+ line = createVerticalLine(bounds.height, getColor(DropSpot.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));
+ 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)) {
+ line = createHorizontalLine(bounds.width - 4,
+ getColor(DropSpot.BEGIN));
+ style = VpeStyleUtil.getStyle(line);
+ style.setProperty(HTML.STYLE_PARAMETER_LEFT,
+ VpeStyleUtil.toPxPosition(2), HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_TOP,
+ VpeStyleUtil.toPxPosition(1), HTML.STYLE_PRIORITY_DEFAULT);
+ domArea.appendChild(line);
+ }
+
+ if (dropSpots.contains(DropSpot.END)) {
+ line = createHorizontalLine(bounds.width - 4,
+ getColor(DropSpot.END));
+ style = VpeStyleUtil.getStyle(line);
+ style.setProperty(HTML.STYLE_PARAMETER_LEFT,
+ VpeStyleUtil.toPxPosition(2), HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_BOTTOM,
+ VpeStyleUtil.toPxPosition(1), HTML.STYLE_PRIORITY_DEFAULT);
+ domArea.appendChild(line);
+ }
+
+ if (oldDomArea != null) {
+ contentArea.removeChild(oldDomArea);
+ }
+ }
+
+ private String getColor(DropSpot dropSpot) {
+ if (dropSpot == hightlightedSpot) {
+ return "red";
+ } else {
+ return "black";
+ }
+ }
+
+ private nsIDOMElement createRect(Rectangle coords, String color) {
+ nsIDOMElement rect = createElement(HTML.TAG_DIV);
+
+ nsIDOMCSSStyleDeclaration style = VpeStyleUtil.getStyle(rect);
+ style.setProperty(HTML.STYLE_PARAMETER_POSITION,
+ HTML.STYLE_VALUE_ABSOLUTE,
+ HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_LEFT,
+ VpeStyleUtil.toPxPosition(coords.x),
+ HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_TOP,
+ VpeStyleUtil.toPxPosition(coords.y),
+ HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_HEIGHT,
+ VpeStyleUtil.toPxPosition(coords.height),
+ HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_WIDTH,
+ VpeStyleUtil.toPxPosition(coords.width),
+ HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_BACKGROUND_COLOR,
+ color,
+ HTML.STYLE_PRIORITY_DEFAULT);
+
+ return rect;
+ }
+
+ private void drawRect(nsIDOMElement container,
+ Rectangle coords, String color) {
+ container.appendChild(createRect(coords, color));
+ }
+
+ private nsIDOMElement createHorizontalLine(int width, String color) {
+ nsIDOMElement line = createElement(HTML.TAG_DIV);
+ nsIDOMCSSStyleDeclaration style = VpeStyleUtil.getStyle(line);
+ style.setProperty(HTML.STYLE_PARAMETER_POSITION,
+ HTML.STYLE_VALUE_ABSOLUTE, HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_WIDTH,
+ VpeStyleUtil.toPxPosition(width), HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_HEIGHT,
+ VpeStyleUtil.toPxPosition(6), HTML.STYLE_PRIORITY_DEFAULT);
+ for (int i = 0; i < 2; i++) {
+ drawRect(line, new Rectangle(i, i, 1, 6 - 2 * i), color);
+ }
+ drawRect(line, new Rectangle(2, 2, width - 2 * 2, 2), color);
+ for (int i = 0; i < 2; i++) {
+ drawRect(line, new Rectangle(width - 1 - i, i, 1, 6 - 2 * i),
+ color);
+ }
+
+ return line;
+ }
+
+ private nsIDOMElement createVerticalLine(int height, String color) {
+ nsIDOMElement line = createElement(HTML.TAG_DIV);
+ nsIDOMCSSStyleDeclaration style = VpeStyleUtil.getStyle(line);
+ style.setProperty(HTML.STYLE_PARAMETER_POSITION,
+ HTML.STYLE_VALUE_ABSOLUTE, HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_WIDTH,
+ VpeStyleUtil.toPxPosition(6), HTML.STYLE_PRIORITY_DEFAULT);
+ style.setProperty(HTML.STYLE_PARAMETER_HEIGHT,
+ VpeStyleUtil.toPxPosition(height), HTML.STYLE_PRIORITY_DEFAULT);
+ for (int i = 0; i < 2; i++) {
+ drawRect(line, new Rectangle(i, i, 6 - 2 * i, 1), color);
+ }
+ drawRect(line, new Rectangle(2, 2, 2, height - 2 * 2), color);
+ for (int i = 0; i < 2; i++) {
+ drawRect(line, new Rectangle(i, height - 1 - i, 6 - 2 * i, 1),
+ color);
+ }
+
+ return line;
+ }
+
+ private nsIDOMElement createElement(String tagName) {
+ nsIDOMElement element = document.createElement(tagName);
+ DndUtil.setTemporaryDndElement(element, true);
+ return element;
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2010-03-19
16:00:30 UTC (rev 20935)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2010-03-19
16:14:36 UTC (rev 20936)
@@ -141,9 +141,12 @@
public static final String STYLE_VALUE_NONE = "none"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_WIDTH = "width"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_TOP = "top"; //$NON-NLS-1$
+ public static final String STYLE_PARAMETER_BOTTOM = "bottom"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_LEFT = "left"; //$NON-NLS-1$
+ public static final String STYLE_PARAMETER_RIGHT = "right"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_HEIGHT = "height"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_BACKGROUND_IMAGE =
"background-image"; //$NON-NLS-1$
+ public static final String STYLE_PARAMETER_BACKGROUND_COLOR =
"background-color"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_BORDER_WIDTH = "border-width";
//$NON-NLS-1$
public static final String STYLE_PARAMETER_BORDER_STYLE = "border-style";
//$NON-NLS-1$
public static final String STYLE_PARAMETER_MAX_HEIGHT = "max-height";
//$NON-NLS-1$
@@ -151,6 +154,12 @@
public static final String STYLE_PARAMETER_CLEAR = "clear"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_OVERFLOW = "overflow";
//$NON-NLS-1$
public static final String STYLE_PARAMETER_TABLE_LAYOUT = "table-layout";
//$NON-NLS-1$
+ public static final String STYLE_PARAMETER_OPACITY = "opacity"; //$NON-NLS-1$
public static final String STYLE_VALUE_FIXED = "fixed"; //$NON-NLS-1$
public static final String STYLE_VALUE_MIDDLE = "middle"; //$NON-NLS-1$
+ public static final String STYLE_PARAMETER_POSITION = "position";
//$NON-NLS-1$;
+ public static final String STYLE_VALUE_ABSOLUTE = "absolute"; //$NON-NLS-1$;
+
+ public static final String STYLE_PRIORITY_DEFAULT = ""; //$NON-NLS-1$;
+ public static final String STYLE_PRIORITY_IMPORTANT = "important";
//$NON-NLS-1$;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2010-03-19
16:00:30 UTC (rev 20935)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2010-03-19
16:14:36 UTC (rev 20936)
@@ -27,6 +27,7 @@
import org.eclipse.ui.editors.text.ILocationProvider;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.ui.views.navigator.NDeleteAction;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.jst.web.project.WebProject;
@@ -34,8 +35,12 @@
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.mozilla.interfaces.nsIDOMCSSStyleDeclaration;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMElementCSSInlineStyle;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.interfaces.nsIDebug;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -69,7 +74,20 @@
public static String FILE_PROTOCOL = "file:"; //$NON-NLS-1$
public static String HTTP_PROTOCOL = "http:"; //$NON-NLS-1$
public static String SLASH = "/"; //$NON-NLS-1$
-
+
+ /**
+ * Returns CSS style declaration corresponding to the given {@code element}.
+ */
+ public static nsIDOMCSSStyleDeclaration getStyle(nsIDOMElement element) {
+ nsIDOMElementCSSInlineStyle inlineStyle =
+ (nsIDOMElementCSSInlineStyle)
+ element.queryInterface(nsIDOMElementCSSInlineStyle
+ .NS_IDOMELEMENTCSSINLINESTYLE_IID);
+ return inlineStyle.getStyle();
+ }
+
+
+
// sets parameter position in attribute style to absolute value
public static void setAbsolute(Element sourceElement) {
String style = sourceElement.getAttribute(ATTRIBUTE_STYLE);
@@ -553,6 +571,12 @@
return finalStr;
}
+ public static String getAbsoluteResourcePathUrl(String resourcePathInPlugin) {
+ return FILE_PROTOCOL + SLASH + SLASH + SLASH
+ + getAbsoluteResourcePath(resourcePathInPlugin)
+ .replace('\\', '/');
+ }
+
/**
* Adds the full path to image "src" attribute.
*
@@ -782,6 +806,14 @@
return size;
}
+ /**
+ * Converts the argument to the form {@code "Xpx"},
+ * where {@code X=position}.
+ */
+ public static String toPxPosition(int position) {
+ return Integer.toString(position) + PX_STRING;
+ }
+
public static String processUrl(String url, IFile file) {
String resolvedValue = url
Added: trunk/vpe/plugins/org.jboss.tools.vpe/ve/dragIcon.gif
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe/ve/dragIcon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream