Author: mareshkau
Date: 2008-07-31 10:42:16 -0400 (Thu, 31 Jul 2008)
New Revision: 9453
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.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/template/SelectionManager.java
Log:
JBIDE-2584
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 2008-07-31
13:30:13 UTC (rev 9452)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-07-31
14:42:16 UTC (rev 9453)
@@ -422,7 +422,7 @@
// switch (sourceNode.getNodeType()) {
// case Node.ELEMENT_NODE:
- // Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
+// Map<?, ?> xmlnsMap = createXmlns((Element) sourceNode);
Set<Node> ifDependencySet = new HashSet<Node>();
pageContext.setCurrentVisualNode(visualOldContainer);
VpeTemplate template = templateManager.getTemplate(pageContext,
@@ -553,7 +553,7 @@
}
}
- protected nsIDOMElement createComment(Node sourceNode) {
+ private nsIDOMElement createComment(Node sourceNode) {
nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
div.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, COMMENT_STYLE);
String value = COMMENT_PREFIX + sourceNode.getNodeValue()
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-07-31
13:30:13 UTC (rev 9452)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-07-31
14:42:16 UTC (rev 9453)
@@ -325,21 +325,37 @@
nsIDOMNode visualNode = nodeData.getVisualNode();
- if(visualNode!=null&&visualNode.getNodeType()==nsIDOMNode.TEXT_NODE&&nodeData.getSourceNode()!=null)
{
- NodeImpl targetSourceNode = (NodeImpl)nodeData.getSourceNode();
- String sourceNodeValue = nodeData.getSourceNode().getNodeValue();
- ITextRegion valueRegion = targetSourceNode.getValueRegion();
- if(valueRegion==null) {
- return;
+ if(visualNode!=null
+ &&visualNode.getNodeType()==nsIDOMNode.TEXT_NODE
+ &&nodeData.getSourceNode()!=null){
+
+ if(nodeData.getSourceNode().getNodeType()==Node.ELEMENT_NODE) {
+ NodeImpl targetSourceNode = (NodeImpl)nodeData.getSourceNode();
+ String sourceNodeValue = nodeData.getSourceNode().getNodeValue();
+ ITextRegion valueRegion = targetSourceNode.getValueRegion();
+ if(valueRegion==null) {
+ return;
+ }
+ ITextRegion nameRegion = targetSourceNode.getNameRegion();
+ int offcetReferenceToSourceNode =
focusOffcetInSourceDocument-valueRegion.getStart()-targetSourceNode.getStartOffset()+nameRegion.getStart()-1;
+
+ if(offcetReferenceToSourceNode<visualNode.getNodeValue().length()){
+
+ selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).collapse(visualNode,
offcetReferenceToSourceNode);
+ }
+ }else if (nodeData.getSourceNode().getNodeType()==Node.TEXT_NODE){
+
+ IndexedRegion targetSourceNode = (IndexedRegion) nodeData.getSourceNode();
+
+ int offcetReferenceToSourceNode =
focusOffcetInSourceDocument-targetSourceNode.getStartOffset();
+
+ int visualNodeOffcet =
TextUtil.visualPosition(((Node)targetSourceNode).getNodeValue(),offcetReferenceToSourceNode);
+
+
selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).collapse(visualNode,
visualNodeOffcet);
+
+ }
}
- ITextRegion nameRegion = targetSourceNode.getNameRegion();
- int offcetReferenceToSourceNode =
focusOffcetInSourceDocument-valueRegion.getStart()-targetSourceNode.getStartOffset()+nameRegion.getStart()-1;
-
- if(offcetReferenceToSourceNode<visualNode.getNodeValue().length()){
- selectionController.getSelection(nsISelectionController.SELECTION_NORMAL).collapse(visualNode,
offcetReferenceToSourceNode);
- }
- }
}
/**
* Restore cursor position in visual document for by source position
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2008-07-31
13:30:13 UTC (rev 9452)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2008-07-31
14:42:16 UTC (rev 9453)
@@ -12,6 +12,10 @@
package org.jboss.tools.vpe.html.template;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.NodeData;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
+import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -48,4 +52,22 @@
return new VpeCreationData(element);
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getNodeData(org.mozilla.interfaces.nsIDOMNode,
org.jboss.tools.vpe.editor.mapping.VpeElementData,
org.jboss.tools.vpe.editor.mapping.VpeDomMapping)
+ */
+ @Override
+ public NodeData getNodeData(nsIDOMNode node, VpeElementData elementData,
+ VpeDomMapping domMapping) {
+
+ NodeData result;
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(node);
+ if(node.getNodeType()==nsIDOMNode.ELEMENT_NODE) {
+ result = new NodeData(nodeMapping.getSourceNode(),node.getFirstChild(),true);
+ } else {
+ result = new NodeData(nodeMapping.getSourceNode(),node,true);
+ }
+ return result;
+ }
+
+
}