Author: yradtsevich
Date: 2010-10-13 14:53:41 -0400 (Wed, 13 Oct 2010)
New Revision: 25810
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/VpeDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
Log:
https://jira.jboss.org/browse/JBIDE-7258 :
DnD in VPE does not work with rich:calendar
- code refactoring
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-10-13
17:15:54 UTC (rev 25809)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/dnd/VpeDnD.java 2010-10-13
18:53:41 UTC (rev 25810)
@@ -549,32 +549,27 @@
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out.print(" dragNode: " + element.getNodeName() + "(" +
element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
- canDrag = canInnerDrag(element);
- if (canDrag) {
- Node sourceNode = getSourceNode(element);
- if (sourceNode == null) {
- canDrag = false;
- }
+ Node sourceNode = getSourceNode(element);
+ if (sourceNode != null && canInnerDrag(sourceNode)) {
+ canDrag = true;
}
}
+
if (VpeDebug.PRINT_VISUAL_INNER_DRAGDROP_EVENT) {
System.out.println(" canDrag: " + canDrag); //$NON-NLS-1$
}
return canDrag;
}
- private boolean canInnerDrag(nsIDOMElement visualDragElement) {
+ private boolean canInnerDrag(Node node) {
VpeNodeMapping domMapping = vpeController.getDomMapping()
- .getNodeMapping(visualDragElement);
+ .getNodeMapping(node);
if (domMapping instanceof VpeElementMapping) {
VpeElementMapping elementMapping = (VpeElementMapping) domMapping;
if (elementMapping.getSourceNode() instanceof Element) {
return elementMapping.getTemplate().canInnerDrag(
vpeController.getPageContext(),
- (Element) elementMapping.getSourceNode(),
- vpeController.getXulRunnerEditor().getDOMDocument(),
- visualDragElement, elementMapping.getData());
+ (Element) elementMapping.getSourceNode());
}
}
return false;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2010-10-13
17:15:54 UTC (rev 25809)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2010-10-13
18:53:41 UTC (rev 25810)
@@ -25,7 +25,7 @@
protected VpeDomMapping domMapping;
private INodeAdapter sorceAdapter;
- private List sourceNodes = new ArrayList();
+ private List<Node> sourceNodes = new ArrayList();
public VpeDomBuilder(VpeDomMapping domMapping, INodeAdapter sorceAdapter) {
this.domMapping = domMapping;
@@ -66,7 +66,7 @@
return sorceAdapter;
}
- public List getSourceNodes() {
+ public List<Node> getSourceNodes() {
return sourceNodes;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2010-10-13
17:15:54 UTC (rev 25809)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2010-10-13
18:53:41 UTC (rev 25810)
@@ -10,32 +10,25 @@
******************************************************************************/
package org.jboss.tools.vpe.editor;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.selection.SelectionHelper;
-import org.jboss.tools.jst.jsp.util.NodesManagingUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
@@ -45,9 +38,7 @@
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VpeNodesManagingUtil;
-import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMNodeList;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -76,104 +67,6 @@
this.pageContext = pageContext;
}
- public void addNode(nsIDOMNode visualNode) {
- nsIDOMNode visualContainer = visualNode.getParentNode();
- Node sourceContainer = domMapping.getSourceNode(visualContainer);
-
- if (sourceContainer != null
- && (sourceContainer.getNodeType() == Node.ELEMENT_NODE || sourceContainer
- .getNodeType() == Node.DOCUMENT_NODE)) {
- nsIDOMNode visualNextNode = visualNode.getNextSibling();
- Node sourceNextNode = domMapping.getSourceNode(visualNextNode);
- addNode(visualNode, sourceNextNode, sourceContainer);
- }
- }
-
- public void removeNode(nsIDOMNode visualNode) {
- Node sourceNode = domMapping.getSourceNode(visualNode);
- if (sourceNode != null) {
- Node sourceContainer = sourceNode.getParentNode();
- if (sourceContainer != null) {
- sourceContainer.removeChild(sourceNode);
- getSourceNodes().remove(sourceNode);
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode)
- .removeAdapter(getSorceAdapter());
- }
- domMapping.remove(sourceNode);
- }
- } else {
- sourceNode = domMapping.getNearSourceNode(visualNode);
- if (sourceNode != null) {
- if (sourceNode.getNodeType() == Node.COMMENT_NODE) {
- sourceNode.setNodeValue(""); //$NON-NLS-1$
- }
- }
- }
- }
-
- public void setText(nsIDOMNode visualText) {
- Node sourceText = domMapping.getSourceNode(visualText);
- if (sourceText != null) {
- sourceText.setNodeValue(TextUtil.sourceText(visualText
- .getNodeValue()));
- } else {
- nsIDOMNode visualParent = visualText.getParentNode();
- if (visualParent != null) {
- Node sourceParent = domMapping.getNearSourceNode(visualText);
- if (sourceParent != null) {
- if (sourceParent.getNodeType() == Node.ELEMENT_NODE) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceParent);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
- template.setSourceAttributeValue(pageContext,
- (Element) sourceParent, elementMapping
- .getData());
- }
- } else if (sourceParent.getNodeType() == Node.COMMENT_NODE) {
- setComment(sourceParent, visualParent);
- // VpeElementMapping elementMapping =
- // (VpeElementMapping)domMapping.getNodeMapping(sourceParent);
- // if (elementMapping != null) {
- // VpeTemplate template = elementMapping.getTemplate();
- // template.setSourceCommentValue(pageContext,
- // (Comment)sourceParent, elementMapping.getData());
- // }
- }
- }
- }
- }
- }
-
- public void setSelectedRange(Node sourceNode, int start, int length) {
- // glory
- structuredTextViewer.setSelectedRange(start, length);
- structuredTextViewer.revealRange(start, length);
- // ISelection selection = new StructuredSelection(sourceNode);
- // SelectionChangedEvent event = new SelectionChangedEvent(outline,
- // selection);
- // selectionManager.selectionChanged(event);
- // selectionManager.setSelection(new TextSelection(start, length));
- }
-
- public void setSelectChanged(Node sourceNode) {
- // structuredTextViewer.setSelectedRange(start, length);
- // structuredTextViewer.revealRange(start, length);
-
- // glory
- // ISelection selection = new StructuredSelection(sourceNode);
- // SelectionChangedEvent event = new SelectionChangedEvent(outline,
- // selection);
- // selectionManager.selectionChanged(event);
- if (sourceNode instanceof IDOMNode) {
- IDOMNode n = (IDOMNode) sourceNode;
- int start = n.getStartOffset();
- int length = n.getLength();
- selectionManager.setSelection(new TextSelection(start, length));
- }
- }
-
void setSelectionAtDocumentEnd() {
if (sourceDocument == null)
return;
@@ -228,54 +121,6 @@
return (t == null) ? 0 : t.getCaretOffset();
}
- private void addNode(nsIDOMNode visualNewNode, Node sourceNextNode,
- Node sourceContainer) {
- Node sourceNewNode = createNode(visualNewNode);
- if (sourceNewNode != null) {
- if (sourceNextNode == null) {
- sourceContainer.appendChild(sourceNewNode);
- } else {
- sourceContainer.insertBefore(sourceNewNode, sourceNextNode);
- }
- }
- }
-
- private Node createNode(nsIDOMNode visualNewNode) {
- if (sourceDocument != null) {
- switch (visualNewNode.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element sourceNewElement = sourceDocument
- .createElement(visualNewNode.getNodeName());
- Set ifDependencySet = new HashSet();
- // VpeVisualDomBuilder visualBuildet =
- pageContext.getVisualBuilder();
- VpeTemplate template = getTemplateManager().getTemplate(
- pageContext, sourceNewElement, ifDependencySet);
- registerNodes(new VpeElementMapping(sourceNewElement,
- (nsIDOMElement) visualNewNode, null, template,
- ifDependencySet, null));
- addChildren(visualNewNode, sourceNewElement);
- return sourceNewElement;
- case Node.TEXT_NODE:
- Node sourceTextNode = sourceDocument
- .createTextNode(visualNewNode.getNodeValue());
- registerNodes(new VpeNodeMapping(sourceTextNode, visualNewNode));
- return sourceTextNode;
- }
- }
- return null;
- }
-
- private void addChildren(nsIDOMNode visualContainer, Element sourceContainer) {
- nsIDOMNodeList visualNodes = visualContainer.getChildNodes();
- long len = visualNodes.getLength();
-
- for (long i = 0; i < len; i++) {
- nsIDOMNode visualNode = visualNodes.item(i);
- addNode(visualNode, null, sourceContainer);
- }
- }
-
/**
*
*This method calls when openOn event occures in visual part of VPE
@@ -455,16 +300,6 @@
return sourceEditor.getTextViewer().getSelectedRange();
}
- public void setComment(Node sourceComment, nsIDOMNode visualElement) {
- nsIDOMNodeList visualNodes = visualElement.getChildNodes();
- long len = visualNodes.getLength();
-
- if (len > 0) {
- nsIDOMNode visualText = visualNodes.item(0);
- sourceComment.setNodeValue(visualText.getNodeValue());
- }
- }
-
public StructuredTextViewer getStructuredTextViewer() {
return structuredTextViewer;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2010-10-13
17:15:54 UTC (rev 25809)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2010-10-13
18:53:41 UTC (rev 25810)
@@ -145,13 +145,11 @@
public void refreshBundleValues() {
if (getVisualBuilder() == null) return;
- List nodes = getVisualBuilder().getSourceNodes();
+ List<Node> nodes = getVisualBuilder().getSourceNodes();
//Iterator iterator = bundleDependencySet.iterator();
- Iterator iterator = nodes.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object instanceof Element) {
- Element sourceElement = (Element) object;
+ for (Node node : nodes) {
+ if (node instanceof Element) {
+ Element sourceElement = (Element) node;
visualBuilder.refreshBundleValues(sourceElement);
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2010-10-13
17:15:54 UTC (rev 25809)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2010-10-13
18:53:41 UTC (rev 25810)
@@ -912,18 +912,12 @@
* Checks a capability of drag of visual element.
*
* @param sourceElement The current element of the source tree.
- * @param visualDocument The document of the visual tree.
- * @param data The arbitrary data, built by a method <code>create</code>
* @param pageContext Contains the information on edited page.
- * @param visualElement The current element of the visual tree.
*
* @return <code>true</code> The element can be dragged
*/
- public boolean canInnerDrag(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualElement, Object data) {
+ public boolean canInnerDrag(VpePageContext pageContext, Element sourceElement) {
if (getDragger() != null) {
-
return getDragger().isDragEnabled();
} else {
return true;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2010-10-13
17:15:54 UTC (rev 25809)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2010-10-13
18:53:41 UTC (rev 25810)
@@ -220,16 +220,10 @@
* Contains the information on edited page.
* @param sourceElement
* The current element of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param visualElement
- * The current element of the visual tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
+ *
* @return <code>true</code> The element can be dragged
*/
- boolean canInnerDrag(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMElement visualElement, Object data);
+ boolean canInnerDrag(VpePageContext pageContext, Element sourceElement);
/**
* Checks a capability to drop an element in the container