Author: mareshkau
Date: 2007-08-27 12:29:18 -0400 (Mon, 27 Aug 2007)
New Revision: 3362
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-743
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2007-08-27
15:43:48 UTC (rev 3361)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2007-08-27
16:29:18 UTC (rev 3362)
@@ -12,8 +12,12 @@
package org.jboss.tools.vpe.dnd;
import org.eclipse.swt.graphics.Rectangle;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.mozilla.EditorDomEventListener;
+import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
import org.mozilla.interfaces.nsIComponentManager;
import org.mozilla.interfaces.nsIDOMEvent;
+import org.mozilla.interfaces.nsIDOMMouseEvent;
import org.mozilla.interfaces.nsIDOMNSHTMLElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDragService;
@@ -150,5 +154,29 @@
}
return dragService;
}
+ /**
+ * Calls when drag over event ocure
+ * @param event
+ */
+ public void dragOver(nsIDOMEvent event, EditorDomEventListener editorDomEventListener)
{
+ boolean canDrop = false;
+
+ nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent)
event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+ //in this condition early was check for xulelement
+ if (editorDomEventListener != null) {
+ if
(getDragService().getCurrentSession().isDataFlavorSupported(VpeController.MODEL_FLAVOR))
{
+ MozillaDropInfo info = editorDomEventListener.canExternalDrop(mouseEvent,
VpeController.MODEL_FLAVOR, "");
+ if (info != null) {
+ canDrop = info.canDrop();
+ }
+ }
+ }
+ //sets possability to drop current element here
+ System.out.println("["+canDrop+"]");
+ getDragService().getCurrentSession().setCanDrop(canDrop);
+ mouseEvent.preventDefault();
+ mouseEvent.stopPropagation();
+
+ }
}
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-08-27
15:43:48 UTC (rev 3361)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-08-27
16:29:18 UTC (rev 3362)
@@ -1803,41 +1803,30 @@
}
public void dragOver(nsIDOMEvent event) {
- nsIDragSession dragSession = xulRunnerEditor.getCurrentDragSession();
-// int num =
- dragSession.getNumDropItems();
- boolean isFlavor = dragSession.isDataFlavorSupported(ModelTransfer.MODEL);
+// nsIDragSession dragSession = xulRunnerEditor.getCurrentDragSession();
+//
+// boolean isFlavor = dragSession.isDataFlavorSupported(ModelTransfer.MODEL);
- if (VpeDebug.printVisualDragDropEvent) {
- System.out.println("<<< outerDragOver isFlavor: " + isFlavor);
//$NON-NLS-1$
- }
-
- nsITransferable transferable = xulRunnerEditor.createTransferable();
-
- transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kURLDataMime);
- transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kFileMime);
- transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kURLMime);
-
- dragSession.getData(transferable, 0);
-
- nsISupportsArray array = transferable.flavorsTransferableCanImport();
-// int count =
- array.count();
-
- nsISupportsArray array2 = transferable.flavorsTransferableCanExport();
-// int count2 =
- array2.count();
-
-
- String[] flavors = new String[] {null};
- nsISupports[] data = new nsISupports[] {null};
- long[] length = new long[] {0};
- transferable.getAnyTransferData(flavors, data, length);
-// num =
- dragSession.getNumDropItems();
-
- dragSession.setCanDrop(true);
- event.preventDefault();
+// if (VpeDebug.printVisualDragDropEvent) {
+// System.out.println("<<< outerDragOver isFlavor: " + isFlavor);
//$NON-NLS-1$
+// }
+ visualBuilder.getDnd().dragOver(event, this);
+// nsITransferable transferable = xulRunnerEditor.createTransferable();
+//
+// transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kURLDataMime);
+// transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kFileMime);
+// transferable.addDataFlavor(XulRunnerEditor.TRANS_FLAVOR_kURLMime);
+//
+// dragSession.getData(transferable, 0);
+//
+// String[] flavors = new String[] {null};
+// nsISupports[] data = new nsISupports[] {null};
+// long[] length = new long[] {0};
+// transferable.getAnyTransferData(flavors, data, length);
+//
+//
+// dragSession.setCanDrop(true);
+// event.preventDefault();
}
public void _dragOver(nsIDOMEvent event) {
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-27
15:43:48 UTC (rev 3361)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaDomEventListener.java 2007-08-27
16:29:18 UTC (rev 3362)
@@ -263,25 +263,27 @@
* @see
org.mozilla.interfaces.nsIClipboardDragDropHooks#allowDrop(org.mozilla.interfaces.nsIDOMEvent,
org.mozilla.interfaces.nsIDragSession)
*/
// checks is drop allowed
+ @Deprecated
+ // functionality was moved to VpeDnD.dragOver
public boolean allowDrop(nsIDOMEvent event, nsIDragSession dragSession) {
boolean canDrop = false;
- nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent)
event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
-
- if (editorDomEventListener != null && !isXulElement(mouseEvent)) {
- if (dragSession.isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
- MozillaDropInfo info = editorDomEventListener.canExternalDrop(mouseEvent,
VpeController.MODEL_FLAVOR, "");
- if (info != null && info.canDrop()) {
- // TODO Sergey Vasilyev figures out with this drop
- String nodeName = info.getCaretParent().getNodeName();
- if ("input".equalsIgnoreCase(nodeName)) {
- canDrop = true;
- }
- }
- }
- }
- mouseEvent.preventDefault();
- mouseEvent.stopPropagation();
-
+// nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent)
event.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
+//
+// if (editorDomEventListener != null && !isXulElement(mouseEvent)) {
+// if (dragSession.isDataFlavorSupported(VpeController.MODEL_FLAVOR)) {
+// MozillaDropInfo info = editorDomEventListener.canExternalDrop(mouseEvent,
VpeController.MODEL_FLAVOR, "");
+// if (info != null && info.canDrop()) {
+// // TODO Sergey Vasilyev figures out with this drop
+// String nodeName = info.getCaretParent().getNodeName();
+// if ("input".equalsIgnoreCase(nodeName)) {
+// canDrop = true;
+// }
+// }
+// }
+// }
+// mouseEvent.preventDefault();
+// mouseEvent.stopPropagation();
+//
return canDrop;
}
@@ -366,18 +368,19 @@
getEditorDomEventListener().onShowContextMenu(0, domEvent, (nsIDOMNode)
domEvent.getTarget().queryInterface(nsIDOMNode.NS_IDOMNODE_IID));
} else if(DRAGGESTUREEVENT.equals(domEvent.getType())) {
//here was moved functionality from can drag function
- System.out.print(DRAGGESTUREEVENT);
+// System.out.print(DRAGGESTUREEVENT);
nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent)
domEvent.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
if (editorDomEventListener != null && !isXulElement(mouseEvent)) {
boolean canDragFlag = editorDomEventListener.canInnerDrag(mouseEvent);
//TODO Max Areshkau think about using can -or not can drag if we can drag we should
//start drag session
- editorDomEventListener.startDragSession(domEvent);
+ getEditorDomEventListener().startDragSession(domEvent);
System.out.println("Can drag"+canDragFlag);
}
//TODO Max Areshkau Drag gesture event
} else if(DRAGDROPEVENT.equals(domEvent.getType())) {
+
System.out.println(DRAGDROPEVENT);
//TODO Max Areshkau drag drop gesture event
} else if(DRAGENTEREVENT.equals(domEvent.getType())) {
@@ -387,6 +390,8 @@
System.out.println(DRAGEXITEVENT);
//TODO Max Areshkau drag enter event
} else if(DRAGOVEREVENT.equals(domEvent.getType())) {
+
+ getEditorDomEventListener().dragOver(domEvent);
System.out.println(DRAGOVEREVENT);
//TODO Max Areshkau drag over event
}
Modified:
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-08-27
15:43:48 UTC (rev 3361)
+++
branches/jbosstools_xulrunner/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2007-08-27
16:29:18 UTC (rev 3362)
@@ -25,6 +25,7 @@
import org.jboss.tools.vpe.editor.VpeSourceInnerDropInfo;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.selection.VpeSourceSelection;
+import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
import org.jboss.tools.vpe.editor.template.resize.VpeResizer;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -48,7 +49,7 @@
private VpeResizer resizer;
// TODO Max Areshkau add DnD support
-// private VpeDnd dragger;
+ private VpeDnd dragger;
private TextFormatingData textFormatingData;
private VpePseudoContentCreator pseudoContentCreator;
@@ -211,10 +212,10 @@
private void initDndHandler(Element templateSection) {
// TODO Max Areshkau add DnD support
-// if (dragger == null) {
-// dragger = new VpeDnd();
-// dragger.setDndData(templateSection);
-// }
+ if (getDragger() == null) {
+ setDragger(new VpeDnd());
+ getDragger().setDndData(templateSection);
+ }
}
private void initTextFormatingHandler(Element templateSection) {
@@ -663,11 +664,12 @@
*/
public boolean canInnerDrag(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement visualElement, Object data) {
// TODO Max Areshkau add DnD support
-// if (dragger != null) {
-// return dragger.isDragEnabled();
-// } else {
+ if (getDragger() != null) {
+
+ return getDragger().isDragEnabled();
+ } else {
return true;
-// }
+ }
}
/**
@@ -679,11 +681,11 @@
*/
public boolean canInnerDrop(VpePageContext pageContext, Node container, Node
sourceDragNode) {
// TODO Max Areshkau add DnD support
-// if (dragger != null) {
-// return dragger.isDropEnabled(pageContext, container, sourceDragNode);
-// } else {
+ if (dragger != null) {
+ return dragger.isDropEnabled(pageContext, container, sourceDragNode);
+ } else {
return false;
-// }
+ }
}
/**
@@ -920,4 +922,19 @@
public boolean isHaveVisualPreview() {
return haveVisualPreview;
}
+
+ /**
+ * @return the dragger
+ */
+ public VpeDnd getDragger() {
+
+ return dragger;
+ }
+
+ /**
+ * @param dragger the dragger to set
+ */
+ public void setDragger(VpeDnd dragger) {
+ this.dragger = dragger;
+ }
}