Author: yradtsevich
Date: 2010-03-25 05:56:39 -0400 (Thu, 25 Mar 2010)
New Revision: 21015
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
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/VpeVisualDomBuilder.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5042
Enhance DnD support in VPE
- A little refactoring of VpeDnD and VpeController has been made
- Selection notification from VpeVisualDomBuilder to VpeDnD has been added
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-03-25
09:00:24 UTC (rev 21014)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-03-25
09:56:39 UTC (rev 21015)
@@ -40,6 +40,7 @@
import org.jboss.tools.vpe.editor.VpeVisualInnerDragInfo;
import org.jboss.tools.vpe.editor.VpeVisualInnerDropInfo;
import org.jboss.tools.vpe.editor.mozilla.MozillaDropInfo;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaDndListener;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.editor.template.VpePseudoContentCreator;
@@ -100,15 +101,19 @@
private VpeController vpeController;
private VpeVisualInnerDragInfo innerDragInfo = null;
+ private DraggablePattern draggablePattern;
- public VpeDnD(VpeController vpeController) {
+ public VpeDnD(VpeController vpeController, MozillaEditor mozillaEditor) {
this.vpeController = vpeController;
+ this.draggablePattern = new DraggablePattern(mozillaEditor);
}
public void dragGesture(nsIDOMEvent domEvent) {
nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) domEvent
.queryInterface(nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID);
- boolean canDragFlag = canInnerDrag(mouseEvent);
+ nsIDOMElement selectedElement = vpeController.getXulRunnerEditor()
+ .getLastSelectedElement();
+ boolean canDragFlag = isDraggable(selectedElement);
// start drag sessionvpe-element
if (canDragFlag) {
startDragSession(domEvent);
@@ -143,6 +148,10 @@
}
vpeController.onRefresh();
}
+
+ public void selectionChanged() {
+
+ }
/**
* Starts drag session
@@ -266,7 +275,7 @@
dropCommand.execute(dropData);
}
- private boolean canInnerDrag(nsIDOMMouseEvent event) {
+ private boolean isDraggable(nsIDOMElement element) {
vpeController.onHideTooltip();
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
@@ -277,7 +286,7 @@
innerDragInfo = null;
}
boolean canDrag = false;
- VpeVisualInnerDragInfo dragInfo = getInnerDragInfo(event);
+ VpeVisualInnerDragInfo dragInfo = getInnerDragInfo(element);
if (dragInfo != null) {
nsIDOMNode dragNode = dragInfo.getNode();
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
@@ -609,8 +618,13 @@
}
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
- System.out
- .println(" canDrop: " + canDrop + (canDrop ? " container: " +
caretParent.getNodeName() + " offset: " + caretOffset : ""));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ System.out.println(" canDrop: " + canDrop //$NON-NLS-1$
+ + (canDrop ?
+ " container: " //$NON-NLS-1$
+ + caretParent.getNodeName()
+ + " offset: " //$NON-NLS-1$
+ + caretOffset
+ : "")); //$NON-NLS-1$
}
return new MozillaDropInfo(canDrop, caretParent, caretOffset);
@@ -654,12 +668,11 @@
return dragService;
}
- private VpeVisualInnerDragInfo getInnerDragInfo(nsIDOMMouseEvent event) {
- nsIDOMElement selectedElement =
vpeController.getVisualBuilder().getXulRunnerEditor().getLastSelectedElement();
- if (selectedElement == null) {
+ private VpeVisualInnerDragInfo getInnerDragInfo(nsIDOMElement element) {
+ if (element == null) {
return null;
} else {
- return new VpeVisualInnerDragInfo(selectedElement);
+ return new VpeVisualInnerDragInfo(element);
}
// fix of JBIDE-4998
@@ -725,19 +738,23 @@
}
private VpeVisualInnerDropInfo getInnerDropInfo(nsIDOMEvent event) {
- nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
event.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
+ nsIDOMNSUIEvent nsuiEvent = (nsIDOMNSUIEvent)
+ event.queryInterface(nsIDOMNSUIEvent.NS_IDOMNSUIEVENT_IID);
nsIDOMNode dropContainer = null;
int dropOffset = 0;
int mouseX = nsuiEvent.getPageX();
int mouseY = nsuiEvent.getPageY();
- nsIDOMNode originalNode =
vpeController.getVisualBuilder().getOriginalTargetNode(event);
+ System.out.println(String.format("x = %s; y = %s", mouseX, mouseY));
+ nsIDOMNode originalNode = vpeController.getVisualBuilder()
+ .getOriginalTargetNode(event);
if (originalNode == null || originalNode.getParentNode() == null ||
originalNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
return new VpeVisualInnerDropInfo(null, 0, mouseX, mouseY);
}
if (originalNode.getNodeType() == Node.TEXT_NODE) {
dropContainer = nsuiEvent.getRangeParent();
- nsIDOMNode containerForPseudoContent =
VpePseudoContentCreator.getContainerForPseudoContent(dropContainer);
+ nsIDOMNode containerForPseudoContent = VpePseudoContentCreator
+ .getContainerForPseudoContent(dropContainer);
if (containerForPseudoContent != null) {
dropContainer = containerForPseudoContent;
dropOffset = 0;
@@ -754,7 +771,8 @@
long count = childen.getLength();
for (long i = 0; i < count; i++) {
nsIDOMNode child = childen.item(i);
- if (VpeVisualDomBuilder.isPseudoElement(child) ||
VpeVisualDomBuilder.isAnonElement(child)) {
+ if (VpeVisualDomBuilder.isPseudoElement(child)
+ || VpeVisualDomBuilder.isAnonElement(child)) {
continue;
}
Rectangle rect = vpeController.getVisualBuilder().getNodeBounds(child);
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 2010-03-25
09:00:24 UTC (rev 21014)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-03-25
09:56:39 UTC (rev 21015)
@@ -162,7 +162,7 @@
VpeDomMapping domMapping;
private VpeSourceDomBuilder sourceBuilder;
private VpeVisualDomBuilder visualBuilder;
- private MozillaDndListener dndListener;
+ private VpeDnD vpeDnD;
/** @deprecated */
private VpeSelectionBuilder selectionBuilder;
// private VpeVisualKeyHandler visualKeyHandler;
@@ -242,7 +242,7 @@
VpeTemplateManager.getInstance(), sourceEditor, pageContext);
visualBuilder = new VpeVisualDomBuilder(domMapping, this, visualEditor,
pageContext);
- dndListener = new VpeDnD(this);
+ vpeDnD = new VpeDnD(this, visualEditor);
pageContext.setSourceDomBuilder(sourceBuilder);
pageContext.setVisualDomBuilder(visualBuilder);
IDOMModel sourceModel = (IDOMModel) getModel();
@@ -455,7 +455,7 @@
= visualEditor.getMozillaEventAdapter();
if (mozillaEventAdapter != null) {
mozillaEventAdapter.addContextMenuListener(this);
- mozillaEventAdapter.addDndListener(dndListener);
+ mozillaEventAdapter.addDndListener(vpeDnD);
mozillaEventAdapter.addKeyListener(this);
mozillaEventAdapter.addMouseListener(this);
mozillaEventAdapter.addSelectionListener(this);
@@ -472,7 +472,7 @@
= visualEditor.getMozillaEventAdapter();
if (mozillaEventAdapter != null) {
mozillaEventAdapter.removeContextMenuListener(this);
- mozillaEventAdapter.removeDndListener(dndListener);
+ mozillaEventAdapter.removeDndListener(vpeDnD);
mozillaEventAdapter.removeKeyListener(this);
mozillaEventAdapter.removeMouseListener(this);
mozillaEventAdapter.removeSelectionListener(this);
@@ -1202,7 +1202,7 @@
XulRunnerVpeUtils.getElementBounds(
selectedElement),
VisualDomUtil.getMousePoint(mouseEvent))) {
- dndListener.dragGesture(mouseEvent);
+ vpeDnD.dragGesture(mouseEvent);
} else {
selectionManager.setSelection(mouseEvent);
}
@@ -2227,6 +2227,10 @@
return includeList;
}
+ public VpeDnD getVpeDnD() {
+ return vpeDnD;
+ }
+
/**
* Processed selection events from source editor, if reason of selection is
* visial editor, selection will be stopped processing by this condition
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 2010-03-25
09:00:24 UTC (rev 21014)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2010-03-25
09:56:39 UTC (rev 21015)
@@ -44,7 +44,6 @@
import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.vpe.VpeDebug;
import org.jboss.tools.vpe.VpePlugin;
-import org.jboss.tools.vpe.dnd.VpeDnD;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
@@ -1323,6 +1322,7 @@
int resizerConstrains = getResizerConstrains(visualElement);
visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
scroll);
+ this.visualEditor.getController().getVpeDnD().selectionChanged();
}
/**