Author: yradtsevich
Date: 2009-11-20 05:02:52 -0500 (Fri, 20 Nov 2009)
New Revision: 18757
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4998
Now Drag&Drop works for selected components.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-11-20
10:00:39 UTC (rev 18756)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-11-20
10:02:52 UTC (rev 18757)
@@ -1149,16 +1149,19 @@
// 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 (selectedElement != null
+ && VpeVisualDomBuilder.inDragArea(
+ XulRunnerVpeUtils.getElementBounds(
+ selectedElement),
+ VisualDomUtil.getMousePoint(mouseEvent))) {
dragGesture(mouseEvent);
+ } else {
+ selectionManager.setSelection(mouseEvent);
}
}
} finally {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2009-11-20
10:00:39 UTC (rev 18756)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2009-11-20
10:02:52 UTC (rev 18757)
@@ -1209,65 +1209,74 @@
}
VpeVisualInnerDragInfo getInnerDragInfo(nsIDOMMouseEvent event) {
- nsISelection selection = visualSelectionController.getSelection(
- nsISelectionController.SELECTION_NORMAL);
- nsIDOMNode focusNode = selection.getFocusNode();
- nsIDOMNode anchorNode = selection.getAnchorNode();
- //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);
- //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))) {
- return null;
- }
- }
- int offset = (int) VisualDomUtil.getOffset(visualNode);
- selection.removeAllRanges();
- selection.collapse(visualNode.getParentNode(), offset);
- try {
- selection.extend(visualNode.getParentNode(), offset + 1);
- } catch(XPCOMException ex) {
- //just ignore exception
- // throws when we trying drag element which already resizing
- return null;
- }
- focusNode = selection.getFocusNode();
- anchorNode = selection.getAnchorNode();
+ nsIDOMElement selectedElement
+ = visualBuilder.getXulRunnerEditor().getLastSelectedElement();
+ if (selectedElement == null) {
+ return null;
+ } else {
+ return new VpeVisualInnerDragInfo(selectedElement);
}
- if (focusNode != null && focusNode.equals(anchorNode)) {
- int focusOffset = selection.getFocusOffset();
- int anchorOffset = selection.getAnchorOffset();
- int offset = Math.min(focusOffset, anchorOffset);
- int length = Math.max(focusOffset, anchorOffset) - offset;
- 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)))
{
- 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());
- }
- }
- }
- } else if (focusNodeType == nsIDOMNode.TEXT_NODE) {
- return new VpeVisualInnerDragInfo(focusNode, offset, length);
- }
- }
-
- return null;
+ // fix of JBIDE-4998
+// nsISelection selection = visualSelectionController.getSelection(
+// nsISelectionController.SELECTION_NORMAL);
+// nsIDOMNode focusNode = selection.getFocusNode();
+// nsIDOMNode anchorNode = selection.getAnchorNode();
+// //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);
+// //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))) {
+// return null;
+// }
+// }
+// int offset = (int) VisualDomUtil.getOffset(visualNode);
+// selection.removeAllRanges();
+// selection.collapse(visualNode.getParentNode(), offset);
+// try {
+// selection.extend(visualNode.getParentNode(), offset + 1);
+// } catch(XPCOMException ex) {
+// //just ignore exception
+// // throws when we trying drag element which already resizing
+// return null;
+// }
+// focusNode = selection.getFocusNode();
+// anchorNode = selection.getAnchorNode();
+// }
+// if (focusNode != null && focusNode.equals(anchorNode)) {
+// int focusOffset = selection.getFocusOffset();
+// int anchorOffset = selection.getAnchorOffset();
+// int offset = Math.min(focusOffset, anchorOffset);
+// int length = Math.max(focusOffset, anchorOffset) - offset;
+//
+// 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)))
{
+// 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());
+// }
+// }
+// }
+// } else if (focusNodeType == nsIDOMNode.TEXT_NODE) {
+// return new VpeVisualInnerDragInfo(focusNode, offset, length);
+// }
+// }
+//
+// return null;
}
void setMouseUpSelection(nsIDOMMouseEvent mouseEvent) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2009-11-20
10:00:39 UTC (rev 18756)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2009-11-20
10:02:52 UTC (rev 18757)
@@ -156,9 +156,11 @@
//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)) {
- if(getEditorDomEventListener()!=null) {
- getEditorDomEventListener().dragGesture(domEvent);
- }
+ // fix of JBIDE-4998: since drag events now are implemented by
+ // handling CLICKEVENTTYPE, there is no need to handle them here
+ // if(getEditorDomEventListener()!=null) {
+ // getEditorDomEventListener().dragGesture(domEvent);
+ // }
} else if(DRAGDROPEVENT.equals(eventType)) {
// calls when drop event occure
getEditorDomEventListener().dragDrop(domEvent);