Author: sdzmitrovich
Date: 2008-04-07 04:21:36 -0400 (Mon, 07 Apr 2008)
New Revision: 7372
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2005
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-04-07
08:18:53 UTC (rev 7371)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfVerbatim.java 2008-04-07
08:21:36 UTC (rev 7372)
@@ -10,9 +10,13 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.template;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.EditableTemplateAdapter;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
@@ -39,24 +43,53 @@
Element element = (Element) sourceNode;
+ // create span
nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
+ // get children
NodeList list = element.getChildNodes();
- if (list.getLength() != 0) {
- Node firstNode = list.item(0);
- Node lastNode = list.item(list.getLength() - 1);
+ // creation data
+ VpeCreationData creationData = new VpeCreationData(span);
- String text = TemplateManagingUtil.getSourceText(pageContext,
- ((IDOMNode) firstNode).getStartOffset(),
- ((IDOMNode) lastNode).getEndOffset() - 1);
+ // for each child
+ for (int i = 0; i < list.getLength(); i++) {
- span.appendChild(visualDocument.createTextNode(text));
+ Node child = list.item(i);
+ // create span for child
+ nsIDOMElement childSpan = visualDocument
+ .createElement(HTML.TAG_SPAN);
+ span.appendChild(childSpan);
+
+ // if child is text or not html tag
+ if ((child.getNodeType() == Node.ELEMENT_NODE && child.getPrefix() != null)
+ || (child.getNodeType() == Node.TEXT_NODE)) {
+
+ // create children info and add to creationData
+ VpeChildrenInfo childSpanInfo = new VpeChildrenInfo(childSpan);
+ childSpanInfo.addSourceChild(child);
+ creationData.addChildrenInfo(childSpanInfo);
+
+ } else {
+ // get text by positions and add to span
+ String text = TemplateManagingUtil.getSourceText(pageContext,
+ ((IDOMNode) child).getStartOffset(), ((IDOMNode) child)
+ .getEndOffset() - 1);
+ span.appendChild(visualDocument.createTextNode(text));
+ }
+
}
- VpeCreationData creationData = new VpeCreationData(span);
+ // for case when all children are html tags
+ if ((list.getLength() != 0)
+ && (creationData.getChildrenInfoList() == null)) {
+ // set empty children info list to visualDomBuilder doesn't
+ // search children himself
+ creationData.setChildrenInfoList(new ArrayList<VpeChildrenInfo>());
+ }
+
return creationData;
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-04-07
08:18:53 UTC (rev 7371)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-04-07
08:21:36 UTC (rev 7372)
@@ -12,7 +12,7 @@
<vpe:tag name="f:verbatim" case-sensitive="yes">
<vpe:if test="(@escape='true')">
- <vpe:template children="no" modify="yes"
+ <vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.jsf.template.JsfVerbatim">
<vpe:dnd>
<vpe:drag start-enable="yes" />
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2008-04-07
08:18:53 UTC (rev 7371)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2008-04-07
08:21:36 UTC (rev 7372)
@@ -7,13 +7,12 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.ArrayList;
import java.util.List;
-import org.jboss.tools.common.model.util.XMLUtil;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
@@ -24,7 +23,7 @@
private nsIDOMNode node;
private List<VpeChildrenInfo> childrenInfoList;
private List<Node> illegalChildren;
-
+
/**
* @deprecated - You must use elementData. If VpeElementData has not
* necessary functionality you must extend its
@@ -39,29 +38,33 @@
public nsIDOMNode getNode() {
return node;
}
-
- public void addChildrenInfo(VpeChildrenInfo info) {
+
+ public void addChildrenInfo(VpeChildrenInfo info) {
if (childrenInfoList == null) {
childrenInfoList = new ArrayList<VpeChildrenInfo>();
}
childrenInfoList.add(info);
}
-
+
+ public void setChildrenInfoList(List<VpeChildrenInfo> childrenInfoList) {
+ this.childrenInfoList = childrenInfoList;
+ }
+
public List<VpeChildrenInfo> getChildrenInfoList() {
return childrenInfoList;
}
-
+
public void addIllegalChild(Node child) {
if (illegalChildren == null) {
illegalChildren = new ArrayList<Node>();
}
illegalChildren.add(child);
}
-
+
public List<Node> getIllegalChildren() {
return illegalChildren;
}
-
+
/**
* @deprecated - You must use elementData. If VpeElementData has not
* necessary functionality you must extend its
@@ -73,15 +76,16 @@
/**
* @deprecated - You must use elementData. If VpeElementData has not
- * necessary functionality you must extend its
+ * necessary functionality you must extend its
* @return
*/
public Object getData() {
return data;
}
-
+
/**
* get element data
+ *
* @return
*/
public VpeElementData getElementData() {
@@ -90,38 +94,39 @@
/**
* set element data
+ *
* @param elementData
*/
public void setElementData(VpeElementData elementData) {
this.elementData = elementData;
}
-
+
/**
- * Added method for creation copy which will
- * placed in cash to improve perfomance of VPE
- * Added by Max Areshkau JBIDE-675.
- * Here copyed only nsI****
+ * Added method for creation copy which will placed in cash to improve
+ * perfomance of VPE Added by Max Areshkau JBIDE-675. Here copyed only
+ * nsI****
+ *
* @return
*/
public VpeCreationData createHashCopy() {
- nsIDOMNode node=null;
- if(this.node!=null) {
- node = XmlUtil.createClone(this.node);
- } else {
- VpeDebugUtil.debugInfo("Node is Null");
- }
- if(node.getNodeType()!=nsIDOMNode.ELEMENT_NODE) {
+ nsIDOMNode node = null;
+ if (this.node != null) {
+ node = XmlUtil.createClone(this.node);
+ } else {
+ VpeDebugUtil.debugInfo("Node is Null");
+ }
+ if (node.getNodeType() != nsIDOMNode.ELEMENT_NODE) {
VpeDebugUtil.debugInfo("It's Not Element");
}
-
+
VpeCreationData data = new VpeCreationData(node);
- if(this.childrenInfoList!=null) {
- data.childrenInfoList= new ArrayList<VpeChildrenInfo>();
- for (VpeChildrenInfo childrenInfo : this.childrenInfoList) {
- data.childrenInfoList.add(childrenInfo.createCashCopy());
+ if (this.childrenInfoList != null) {
+ data.childrenInfoList = new ArrayList<VpeChildrenInfo>();
+ for (VpeChildrenInfo childrenInfo : this.childrenInfoList) {
+ data.childrenInfoList.add(childrenInfo.createCashCopy());
+ }
}
- }
- data.illegalChildren =this.illegalChildren;
+ data.illegalChildren = this.illegalChildren;
data.data = this.data;
data.elementData = this.elementData;
return data;