Author: dsakovich
Date: 2008-02-15 05:30:55 -0500 (Fri, 15 Feb 2008)
New Revision: 6328
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1460
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2008-02-15
10:09:18 UTC (rev 6327)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2008-02-15
10:30:55 UTC (rev 6328)
@@ -14,11 +14,11 @@
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.RichFacesTemplatesActivator;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -30,7 +30,7 @@
*
*/
public class RichFacesRecursiveTreeNodesAdaptorTemplate extends
- VpeAbstractTemplate {
+ RichFacesTreeNodeTemplate {
private static final String TREE_NAME = "tree";
@@ -48,29 +48,37 @@
public static final String ID_ATTR_NAME = "ID";
+ public static final String NODES_NAME = "nodes";
+
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "treeNodesAdaptor");
- nsIDOMElement visualElement = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR_NAME);
- if (isHasParentAdapter(sourceNode)) {
- visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- "dr-tree-h-ic-div");
- if (getShowLinesAttr(sourceNode)
- && (isAdapterBetweenNodes(sourceNode) ||
isHasNextParentAdaptorElement(sourceNode))) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_DIV_LINE;
- visualElement.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
- "background-image: url(file://" + path + "); "
- + ADAPTER_LINES_STYLE);
+ if (isEmptyNode(sourceNode)) {
+ return super.create(pageContext, sourceNode, visualDocument);
+ } else {
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
+ "treeNodesAdaptor");
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR_NAME);
+ if (isHasParentAdapter(sourceNode)) {
+ visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ "dr-tree-h-ic-div");
+ if (getShowLinesAttr(sourceNode)
+ && (isAdapterBetweenNodes(sourceNode) ||
isHasNextParentAdaptorElement(sourceNode))) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_DIV_LINE;
+ visualElement.setAttribute(
+ HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + path + "); "
+ + ADAPTER_LINES_STYLE);
+ }
}
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
+ visualElement);
+ return vpeCreationData;
}
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- return vpeCreationData;
}
/**
@@ -243,4 +251,29 @@
return false;
}
+ /**
+ *
+ * @param sourceElement
+ * @return
+ */
+ private boolean isEmptyNode(Node sourceNode) {
+
+ NodeList childs = sourceNode.getChildNodes();
+ for (int i = 0; i < childs.getLength(); i++) {
+ Node el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public void setPseudoContent(VpePageContext pageContext,
+ Node sourceContainer, nsIDOMNode visualContainer,
+ nsIDOMDocument visualDocument) {
+ // Empty
+ }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2008-02-15
10:09:18 UTC (rev 6327)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2008-02-15
10:30:55 UTC (rev 6328)
@@ -23,6 +23,7 @@
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.interfaces.nsIDOMText;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -216,11 +217,8 @@
Node sourceNode, VpeCreationData vpeCreationData) {
// creates icon node
String backgroundLinePath = null;
- if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
- System.out.println("call createBasicTree");
- }
+
boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
-
nsIDOMElement iconNode = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TD);
// creates icon with status of node(collapsed or not) node
@@ -331,15 +329,29 @@
.createElement(HtmlComponentUtil.HTML_TAG_TD);
addBasicNodeTitleAttributes(nodeTitle);
// Create mapping to Encode body
- VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+ String treeRecursiveNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ if (sourceNode.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ Element sourceElement = (Element) sourceNode;
+ String nodes = sourceElement
+ .getAttribute(RichFacesRecursiveTreeNodesAdaptorTemplate.NODES_NAME);
+ nsIDOMElement span = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_SPAN);
+ nsIDOMText text = visualDocument
+ .createTextNode((nodes == null) ? "" : nodes);
+ span.appendChild(text);
+ nodeTitle.appendChild(span);
+ } else {
+ VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
- // Create mapping to Encode body
- List<Node> children = ComponentUtil.getChildren((Element) sourceNode,
- false);
- for (Node child : children) {
- tdInfo.addSourceChild(child);
+ // Create mapping to Encode body
+ List<Node> children = ComponentUtil.getChildren(
+ (Element) sourceNode, false);
+ for (Node child : children) {
+ tdInfo.addSourceChild(child);
+ }
+ vpeCreationData.addChildrenInfo(tdInfo);
}
- vpeCreationData.addChildrenInfo(tdInfo);
treeRow.appendChild(nodeTitle);
}