Author: mareshkau
Date: 2007-10-17 14:49:14 -0400 (Wed, 17 Oct 2007)
New Revision: 4304
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/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1097
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 2007-10-17
17:54:58 UTC (rev 4303)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-10-17
18:49:14 UTC (rev 4304)
@@ -887,6 +887,16 @@
sourceSelectionChanged();
}
+ 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);
+ }
+ }
+
private void createMenuForNode(Node node, MenuManager manager) {
createMenuForNode(node, manager, false);
}
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 2007-10-17
17:54:58 UTC (rev 4303)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSelectionBuilder.java 2007-10-17
18:49:14 UTC (rev 4304)
@@ -38,6 +38,7 @@
import org.mozilla.interfaces.nsISelection;
import org.mozilla.interfaces.nsISelectionController;
import org.mozilla.interfaces.nsISelectionDisplay;
+import org.mozilla.xpcom.XPCOMException;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -1193,12 +1194,25 @@
//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();
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-10-17
17:54:58 UTC (rev 4303)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-10-17
18:49:14 UTC (rev 4304)
@@ -2012,4 +2012,18 @@
return visualNewTextNode;
}
+
+ /**
+ * @return the xulRunnerEditor
+ */
+ public XulRunnerEditor getXulRunnerEditor() {
+ return xulRunnerEditor;
+ }
+
+ /**
+ * @param xulRunnerEditor the xulRunnerEditor to set
+ */
+ public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
+ this.xulRunnerEditor = xulRunnerEditor;
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java 2007-10-17
17:54:58 UTC (rev 4303)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/EditorDomEventListener.java 2007-10-17
18:49:14 UTC (rev 4304)
@@ -48,6 +48,11 @@
void dragExit(nsIDOMEvent event);
void dragOver(nsIDOMEvent event);
void drop(nsIDOMEvent event);
+ /**
+ * Drag gesture event handler
+ * @param event xulrunner drag event
+ */
+ void dragGesture(nsIDOMEvent event);
boolean canInnerDrag(nsIDOMMouseEvent mouseEvent);
MozillaDropInfo canInnerDrop(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 2007-10-17
17:54:58 UTC (rev 4303)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-10-17
18:49:14 UTC (rev 4304)
@@ -124,9 +124,8 @@
* @see
org.mozilla.interfaces.nsIDOMEventListener#handleEvent(org.mozilla.interfaces.nsIDOMEvent)
*/
public void handleEvent(nsIDOMEvent domEvent) {
- //TODO To many information in LOG
- //VpePlugin.getDefault().logInfo("VPE was handled+EventType
is["+domEvent.getType()+"]");
try{
+
if(getEditorDomEventListener()==null){
return;
@@ -136,46 +135,43 @@
mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
getEditorDomEventListener().mouseMove(mouseEvent);
} else if(MOUSEDOWNEVENTTYPE.equals(domEvent.getType())) {
-
+
nsIDOMMouseEvent mouseEvent;
mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
getEditorDomEventListener().mouseDown(mouseEvent);
} else if(MOUSEUPEVENTTYPE.equals(domEvent.getType())) {
-
+
nsIDOMMouseEvent mouseEvent;
mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
getEditorDomEventListener().mouseUp(mouseEvent);
} else if(CLICKEVENTTYPE.equals(domEvent.getType())) {
-
+
nsIDOMMouseEvent mouseEvent;
mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
getEditorDomEventListener().mouseClick(mouseEvent);
} else if(DBLCLICK.equals(domEvent.getType())) {
-
+
nsIDOMMouseEvent mouseEvent;
mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
getEditorDomEventListener().mouseDblClick(mouseEvent);
} else if(KEYPRESS.equals(domEvent.getType())) {
-
+
nsIDOMKeyEvent keyEvent = (nsIDOMKeyEvent)
domEvent.queryInterface(nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID);
getEditorDomEventListener().keyPress(keyEvent);
} else if(CONTEXTMENUEVENTTYPE.equals(domEvent.getType())) {
+
//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(domEvent.getType())) {
- nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+
+ if(getEditorDomEventListener()!=null) {
- if (editorDomEventListener != null && !isXulElement(mouseEvent)) {
- boolean canDragFlag = editorDomEventListener.canInnerDrag(mouseEvent);
- //start drag sessionvpe-element
- if(canDragFlag) {
-
- getEditorDomEventListener().startDragSession(domEvent);
- }
+ getEditorDomEventListener().dragGesture(domEvent);
}
} else if(DRAGDROPEVENT.equals(domEvent.getType())) {
// calls when drop event occure
+
getEditorDomEventListener().dragDrop(domEvent);
domEvent.stopPropagation();
domEvent.preventDefault();
@@ -184,6 +180,7 @@
} else if(DRAGEXITEVENT.equals(domEvent.getType())) {
//just ignore this event
} else if(DRAGOVEREVENT.equals(domEvent.getType())) {
+
getEditorDomEventListener().dragOver(domEvent);
}