### Eclipse Workspace Patch 1.0 #P org.jboss.tools.vpe Index: src/org/jboss/tools/vpe/editor/VpeController.java =================================================================== --- src/org/jboss/tools/vpe/editor/VpeController.java (revision 18495) +++ src/org/jboss/tools/vpe/editor/VpeController.java (working copy) @@ -1111,13 +1111,13 @@ // selection will be set only if press left button if (mouseEvent.getButton() == LEFT_BUTTON) { - selectionManager.setSelection(mouseEvent); - //drag gesture isn't generated in XR 1.9 for Linux Platforms, so we start it's manually - //mareshkau - nsIDOMElement selectedElement = getXulRunnerEditor().getLastSelectedElement(); - if (VpeVisualDomBuilder.inDragArea(XulRunnerVpeUtils.getElementBounds(selectedElement), VisualDomUtil - .getMousePoint(mouseEvent))) { + if (visualBuilder.getDnd().getDraggablePattern() + .getDragIcon().getNode().equals(VisualDomUtil.getTargetNode(mouseEvent))) { + //drag gesture isn't generated in XR 1.9 for Linux Platforms, so we start it's manually +// nsIDOMElement selectedElement = getXulRunnerEditor().getLastSelectedElement(); dragGesture(mouseEvent); + } else { + selectionManager.setSelection(mouseEvent); } } } finally { @@ -1332,11 +1332,15 @@ public void dragGesture(nsIDOMEvent domEvent) { nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID); - boolean canDragFlag = canInnerDrag(mouseEvent); - // start drag sessionvpe-element - if (canDragFlag) { - - startDragSession(domEvent); + + if (visualBuilder.getDnd().getDraggablePattern() + .getDragIcon().getNode().equals(VisualDomUtil.getTargetNode(domEvent))) { + // TODO JBIDE-5042: move checking of inner drag possibility + // to the icon showing +// if (canInnerDrag(mouseEvent)) { + // start drag sessionvpe-element + startDragSession(domEvent); +// } } } @@ -2658,7 +2662,6 @@ * Start drag session */ public void startDragSession(nsIDOMEvent domEvent) { - visualBuilder.getDnd().startDragSession(domEvent); } Index: src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java =================================================================== --- src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java (revision 18495) +++ src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java (working copy) @@ -553,6 +553,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. * Index: src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java =================================================================== --- src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java (revision 18495) +++ src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java (working copy) @@ -178,7 +178,7 @@ xulRunnerEditor = visualEditor.getXulRunnerEditor(); // this.visualContentArea = visualEditor.getContentArea(); - this.dnd = new VpeDnD(); + this.dnd = new VpeDnD(visualEditor); this.pageContext = pageContext; // this.headNode = visualEditor.getHeadNode(); dropper = new VpeDnd(); @@ -1318,6 +1318,16 @@ int resizerConstrains = getResizerConstrains(visualElement); visualEditor.setSelectionRectangle(visualElement, resizerConstrains, scroll); + // TODO JBIDE-5042: check if the element is draggable + if (visualElement != null + && visualElement.getNodeType() == nsIDOMNode.ELEMENT_NODE + && visualEditor.getController().getVisualBuilder() + .canInnerDrag((nsIDOMElement) visualElement + .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))) { + getDnd().getDraggablePattern().showDragIcon(visualElement); + } else { + getDnd().getDraggablePattern().hideDragIcon(); + } } /** Index: src/org/jboss/tools/vpe/dnd/VpeDnD.java =================================================================== --- src/org/jboss/tools/vpe/dnd/VpeDnD.java (revision 18495) +++ src/org/jboss/tools/vpe/dnd/VpeDnD.java (working copy) @@ -15,13 +15,16 @@ import org.jboss.tools.vpe.editor.VpeVisualCaretInfo; import org.jboss.tools.vpe.editor.mozilla.EditorDomEventListener; import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo; +import org.jboss.tools.vpe.editor.mozilla.MozillaEditor; import org.jboss.tools.vpe.editor.selection.VpeSelectionController; import org.jboss.tools.vpe.xulrunner.XPCOM; import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor; import org.mozilla.interfaces.nsIComponentManager; +import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMEvent; import org.mozilla.interfaces.nsIDOMEventTarget; import org.mozilla.interfaces.nsIDOMMouseEvent; +import org.mozilla.interfaces.nsIDOMNSUIEvent; import org.mozilla.interfaces.nsIDOMNode; import org.mozilla.interfaces.nsIDragService; import org.mozilla.interfaces.nsISelectionController; @@ -42,6 +45,8 @@ * Default transfer data */ private static final String VPE_ELEMENT = ""; //$NON-NLS-1$ + + private DraggablePattern draggablePattern; /** * service manager */ @@ -59,22 +64,35 @@ /** + * @param domDocument + */ + public VpeDnD(MozillaEditor mozillaEditor) { + draggablePattern = new DraggablePattern(mozillaEditor); + } + + public DraggablePattern getDraggablePattern() { + return draggablePattern; + } + + /** * Starts drag session * @param dragetElement */ public void startDragSession(nsIDOMEvent domEvent) { + nsIDOMNSUIEvent uiEvent = (nsIDOMNSUIEvent) domEvent + .queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID); + draggablePattern.startSession(uiEvent.getPageX(), uiEvent.getPageY()); + nsISupportsArray transArray = (nsISupportsArray) getComponentManager() .createInstanceByContractID(XPCOM.NS_SUPPORTSARRAY_CONTRACTID, null, nsISupportsArray.NS_ISUPPORTSARRAY_IID); transArray.appendElement(createTransferable()); - getDragService().invokeDragSession((nsIDOMNode) domEvent.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID), transArray, null, + getDragService().invokeDragSession(draggablePattern.getNode(), transArray, null, nsIDragService.DRAGDROP_ACTION_MOVE | nsIDragService.DRAGDROP_ACTION_COPY | nsIDragService.DRAGDROP_ACTION_LINK); - domEvent.stopPropagation(); domEvent.preventDefault(); - } /** @@ -146,6 +164,10 @@ * @param event */ public void dragOver(nsIDOMEvent event, EditorDomEventListener editorDomEventListener) { + nsIDOMNSUIEvent uiEvent = (nsIDOMNSUIEvent) event + .queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID); + draggablePattern.move(uiEvent.getPageX(), uiEvent.getPageY()); + final nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID); final XulRunnerEditor editor = ((VpeController) editorDomEventListener).getXulRunnerEditor(); @@ -209,7 +231,7 @@ * @param editorDomEventListener */ public void dragDrop(nsIDOMEvent domEvent, EditorDomEventListener editorDomEventListener) { - + draggablePattern.closeSession(); if(editorDomEventListener!=null) { if(getDragService().getCurrentSession().getSourceDocument()==null) { Index: src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java =================================================================== --- src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java (revision 18495) +++ src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java (working copy) @@ -129,7 +129,8 @@ if(getEditorDomEventListener() != null) { final String eventType = domEvent.getType(); - if(MOUSEMOVEEVENTTYPE.equals(eventType)) { + System.out.println(eventType + System.currentTimeMillis()); + if(MOUSEMOVEEVENTTYPE.equals(eventType)) { nsIDOMMouseEvent mouseEvent; mouseEvent = (nsIDOMMouseEvent) domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID); getEditorDomEventListener().mouseMove(mouseEvent); @@ -156,6 +157,7 @@ //first param are null 0, because this not used in event handler getEditorDomEventListener().onShowContextMenu(0, domEvent, (nsIDOMNode) domEvent.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID)); } else if(DRAGGESTUREEVENT.equals(eventType)) { + // TODO JBIDE-5042: we do not need to handle DRAGGESTUREEVENT more if(getEditorDomEventListener()!=null) { getEditorDomEventListener().dragGesture(domEvent); } Index: src/org/jboss/tools/vpe/editor/util/HTML.java =================================================================== --- src/org/jboss/tools/vpe/editor/util/HTML.java (revision 18495) +++ src/org/jboss/tools/vpe/editor/util/HTML.java (working copy) @@ -145,6 +145,8 @@ 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$; } Index: src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java =================================================================== --- src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java (revision 18495) +++ src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java (working copy) @@ -1208,21 +1208,42 @@ setSelection(selection); } + VpeVisualInnerDragInfo createInnerDragInfo(nsIDOMNode node) { + VpeVisualInnerDragInfo info = null; + + int selectedNodeType = node.getNodeType(); + if (selectedNodeType == nsIDOMNode.ELEMENT_NODE) { + info = new VpeVisualInnerDragInfo( + (nsIDOMElement) node.queryInterface( + nsIDOMElement.NS_IDOMELEMENT_IID)); + } else if (selectedNodeType == nsIDOMNode.TEXT_NODE) { + info = new VpeVisualInnerDragInfo(node, 0, + node.getNodeValue().length()); + } + + return info; + } + VpeVisualInnerDragInfo getInnerDragInfo(nsIDOMMouseEvent event) { - VpeVisualInnerDragInfo info = null; - - nsISelection selection = visualSelectionController.getSelection(nsISelectionController.SELECTION_NORMAL); + nsISelection selection = visualSelectionController.getSelection( + nsISelectionController.SELECTION_NORMAL); nsIDOMNode focusNode = selection.getFocusNode(); nsIDOMNode anchorNode = selection.getAnchorNode(); + Point mousePoint = VisualDomUtil.getMousePoint(event); //when we select input this function return null //but we select elemnt - if(focusNode==null && anchorNode==null) { - - nsIDOMNode visualNode =(nsIDOMNode) event.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID); + if(focusNode == null && anchorNode == null) { + nsIDOMNode visualNode =(nsIDOMNode) event.getTarget() + .queryInterface(nsIDOMNode.NS_IDOMNODE_IID); //fix of JBIDE-1097 if(HTML.TAG_SPAN.equalsIgnoreCase(visualNode.getNodeName())) { - if(visualBuilder.getXulRunnerEditor().getLastSelectedElement()!=null&&!visualBuilder.getNodeBounds(visualBuilder.getXulRunnerEditor().getLastSelectedElement()).contains(VisualDomUtil.getMousePoint(event))){ + nsIDOMElement lastSelectedElement = visualBuilder + .getXulRunnerEditor().getLastSelectedElement(); + + if(lastSelectedElement != null + && !visualBuilder.getNodeBounds(lastSelectedElement) + .contains(mousePoint)){ return null; } } @@ -1230,7 +1251,7 @@ selection.removeAllRanges(); selection.collapse(visualNode.getParentNode(), offset); try { - selection.extend(visualNode.getParentNode(), offset + 1); + selection.extend(visualNode.getParentNode(), offset + 1); } catch(XPCOMException ex) { //just ignore exception // throws when we trying drag element which already resizing @@ -1245,29 +1266,30 @@ int offset = Math.min(focusOffset, anchorOffset); int length = Math.max(focusOffset, anchorOffset) - offset; - switch (focusNode.getNodeType()) { - case nsIDOMNode.ELEMENT_NODE: + int focusNodeType = focusNode.getNodeType(); + if (focusNodeType == nsIDOMNode.ELEMENT_NODE) { if (length == 1) { nsIDOMNodeList children = focusNode.getChildNodes(); - nsIDOMNode selectedNode = children.item(Math.min(focusOffset, anchorOffset)); - if (visualBuilder.getNodeBounds(selectedNode).contains(VisualDomUtil.getMousePoint(event))) { - switch(selectedNode.getNodeType()) { - case nsIDOMNode.ELEMENT_NODE: - info = new VpeVisualInnerDragInfo((nsIDOMElement)selectedNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)); - break; - case nsIDOMNode.TEXT_NODE: - info = new VpeVisualInnerDragInfo(selectedNode, 0, selectedNode.getNodeValue().length()); - break; + nsIDOMNode selectedNode = children.item(offset); + if (visualBuilder.getNodeBounds(selectedNode) + .contains(mousePoint)) { + int selectedNodeType = selectedNode.getNodeType(); + if (selectedNodeType == nsIDOMNode.ELEMENT_NODE) { + return new VpeVisualInnerDragInfo( + (nsIDOMElement) selectedNode.queryInterface( + nsIDOMElement.NS_IDOMELEMENT_IID)); + } else if (selectedNodeType == nsIDOMNode.TEXT_NODE) { + return new VpeVisualInnerDragInfo(selectedNode, 0, + selectedNode.getNodeValue().length()); } } } - break; - case nsIDOMNode.TEXT_NODE: - info = new VpeVisualInnerDragInfo(focusNode, offset, length); - break; + } else if (focusNodeType == nsIDOMNode.TEXT_NODE) { + return new VpeVisualInnerDragInfo(focusNode, offset, length); } } - return info; + + return null; } void setMouseUpSelection(nsIDOMMouseEvent mouseEvent) { Index: src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java =================================================================== --- src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java (revision 18495) +++ src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java (working copy) @@ -59,7 +59,6 @@ public class VpeFunctionSrc extends VpeFunction { static final String IMG_UNRESOLVED = "unresolved_image.gif"; //$NON-NLS-1$ - static final String IMG_PREFIX = "file:///"; //$NON-NLS-1$ private static final Pattern resourcePatternWithSinglCoat= Pattern.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*'(.*)'\\s*\\]\\s*\\}"); //$NON-NLS-1$ private static final Pattern resourcePatternWithDoableCoat= Pattern.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*\"(.*)\"\\s*\\]\\s*\\}"); //$NON-NLS-1$ @@ -175,11 +174,12 @@ } protected String getUnresolved() { - return IMG_PREFIX + getAbsoluteResourcePath(IMG_UNRESOLVED).replace('\\', '/'); + return VpeStyleUtil.getAbsoluteResourcePathUrl(IMG_UNRESOLVED); } protected String getPrefix() { - return IMG_PREFIX; + return VpeStyleUtil.FILE_PROTOCOL + VpeStyleUtil.SLASH + + VpeStyleUtil.SLASH + VpeStyleUtil.SLASH; } private String processValue(VpePageContext pageContext, Node sourceNode, @@ -288,18 +288,6 @@ resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue); return resolvedValue; } - - public static String getAbsoluteResourcePath(String resourcePathInPlugin) { - String pluginPath = VpePlugin.getPluginResourcePath(); - IPath pluginFile = new Path(pluginPath); - File file = pluginFile.append(resourcePathInPlugin).toFile(); - if (file.exists()) { - return file.getAbsolutePath(); - } else { - throw new RuntimeException("Can't get path for " //$NON-NLS-1$ - + resourcePathInPlugin); - } - } protected KbQuery createKbQuery(JspContentAssistProcessor processor, Node fNode, int offset, String attrName) { KbQuery kbQuery = new KbQuery(); Index: src/org/jboss/tools/vpe/dnd/DraggablePattern.java =================================================================== --- src/org/jboss/tools/vpe/dnd/DraggablePattern.java (revision 0) +++ src/org/jboss/tools/vpe/dnd/DraggablePattern.java (revision 0) @@ -0,0 +1,190 @@ +/******************************************************************************* + * 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 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 POSITION_POSTFIX = "px"; //$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, + toPxPosition(bounds.x), DEFAULT_PRIORITY); + dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_TOP, + toPxPosition(bounds.y - 20), DEFAULT_PRIORITY); + } + + private String toPxPosition(int position) { + return Integer.toString(position) + POSITION_POSTFIX; + } + + 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); + 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); + 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, + toPxPosition(offsetX + mouseX), IMPORTANT_PRIORITY); + nodeCopyStyle.setProperty(HTML.STYLE_PARAMETER_TOP, + toPxPosition(offsetY + mouseY), IMPORTANT_PRIORITY); + + DragIcon dragIcon = getDragIcon(); + dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_LEFT, + toPxPosition(offsetX + mouseX), DEFAULT_PRIORITY); + dragIcon.setStyleProperty(HTML.STYLE_PARAMETER_TOP, + toPxPosition(offsetY + mouseY - 20), DEFAULT_PRIORITY); + } + + public class DragIcon { + private final nsIDOMNode node; + private final nsIDOMCSSStyleDeclaration style; + + public DragIcon(nsIDOMNode node) { + this.node = node; + nsIDOMElementCSSInlineStyle inlineStyle = + (nsIDOMElementCSSInlineStyle) + node.queryInterface(nsIDOMElementCSSInlineStyle + .NS_IDOMELEMENTCSSINLINESTYLE_IID); + style = inlineStyle.getStyle(); + } + + public nsIDOMNode getNode() { + return node; + } + + public nsIDOMCSSStyleDeclaration getStyle() { + return style; + } + + public void setStyleProperty(String propertyName, String value, + String priority) { + style.setProperty(propertyName, value, priority); + } + } +}