Author: dsakovich
Date: 2007-10-12 07:34:45 -0400 (Fri, 12 Oct 2007)
New Revision: 4147
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
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
Log:
Fix RichFaces treeNodesAdaptor and recursiveTreeNodesAdaptor templates
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 2007-10-12
10:30:23 UTC (rev 4146)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-10-12
11:34:45 UTC (rev 4147)
@@ -49,14 +49,17 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
Document visualDocument) {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
"recursiveTreeNodesAdaptor");
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
+ "recursiveTreeNodesAdaptor");
Element visualElement = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME, RECURSIVE_TREE_NODES_ADAPTOR_NAME);
+ visualElement.setAttribute(ID_ATTR_NAME,
+ RECURSIVE_TREE_NODES_ADAPTOR_NAME);
if (isHasParentAdapter(sourceNode)) {
visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
"dr-tree-h-ic-div");
- if (getShowLinesAttr(sourceNode)) {
+ if (getShowLinesAttr(sourceNode)
+ && isHasNextParentAdaptorElement(sourceNode)) {
String path = RichFacesTemplatesActivator
.getPluginResourcePath()
+ ICON_DIV_LINE;
@@ -153,4 +156,46 @@
}
return showLinesValue;
}
+
+ /**
+ * Has Next element
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isHasNextParentAdaptorElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ String treeNodeName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODE_NAME;
+ String treeNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ Node lastElement = null;
+ Node el = null;
+
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+
+ if (lastElement != null) {
+ break;
+ }
+ if (el.equals(sourceNode)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
}
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 2007-10-12
10:30:23 UTC (rev 4146)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-10-12
11:34:45 UTC (rev 4147)
@@ -255,7 +255,7 @@
"background-image: url(file://" + path + "); "
+ NODE_LINES_STYLE);
}
- } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
(isAdaptorInTree(sourceNode) == isLastElementAfterAdaptor(sourceNode)))
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
(isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)) /*&&
(isAdaptorInTree(sourceNode) == isLastElementAfterAdaptor(sourceNode))*/)
|| (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))) {
backgroundLinePath = RichFacesTemplatesActivator
.getPluginResourcePath()
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-10-12
10:30:23 UTC (rev 4146)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-10-12
11:34:45 UTC (rev 4147)
@@ -55,7 +55,8 @@
if (isHasParentAdapter(sourceNode)) {
visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
"dr-tree-h-ic-div");
- if (getShowLinesAttr(sourceNode)) {
+ if (getShowLinesAttr(sourceNode)
+ && isHasNextParentAdaptorElement(sourceNode)) {
String path = RichFacesTemplatesActivator
.getPluginResourcePath()
+ ICON_DIV_LINE;
@@ -152,4 +153,46 @@
}
return showLinesValue;
}
+
+ /**
+ * Has Next element
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isHasNextParentAdaptorElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ String treeNodeName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODE_NAME;
+ String treeNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ Node lastElement = null;
+ Node el = null;
+
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+
+ if (lastElement != null) {
+ break;
+ }
+ if (el.equals(sourceNode)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
}
Show replies by date