Author: dsakovich
Date: 2007-10-10 11:02:43 -0400 (Wed, 10 Oct 2007)
New Revision: 4096
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/divLine.gif
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css
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
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
Log:
Fix RichFaces recursiveTreeNodeAdaptor and treeNodesAdaptor templates
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/divLine.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/divLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css 2007-10-10
14:09:31 UTC (rev 4095)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css 2007-10-10
15:02:43 UTC (rev 4096)
@@ -10,8 +10,8 @@
}
.dr-tree-h-ic-div {
- margin-left: 8px;
- padding-left: 14px;
+ margin-left: 10px;
+ padding-left: 12px;
}
.dr-tree-full-width {
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-10
14:09:31 UTC (rev 4095)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-10-10
15:02:43 UTC (rev 4096)
@@ -1,105 +1,156 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jsf.vpe.richfaces.template;
-
-import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
-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.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Create template for rich:recursiveTreeNodesAdaptor element
- *
- * @author dsakovich(a)exadel.com
- *
- */
-public class RichFacesRecursiveTreeNodesAdaptorTemplate extends
- VpeAbstractTemplate {
- private final static String TREE_NODE_NAME = "treeNode";
-
- private static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
-
- private static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
-
- private static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
-
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- Document visualDocument) {
- Element visualElement = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- addBasicTreeNodeAttributes(visualElement);
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- return vpeCreationData;
- }
-
- /**
- *
- * Function for parsing tree by tree nodes;
- *
- * @param pageContext
- * @param sourceNode
- * @param visualDocument
- * @return
- */
- public void parseTree(VpePageContext pageContext, Node sourceNode,
- Document visualDocument, VpeCreationData vpeCreationData,
- Element parentElement) {
- NodeList nodeList = sourceNode.getChildNodes();
- Element element = null;
- int lenght = nodeList.getLength();
- String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
- VpeChildrenInfo vpeChildrenInfo = null;
- for (int i = 0; i < lenght; i++) {
- if (!(nodeList.item(i) instanceof Element)) {
- continue;
- }
- element = (Element) nodeList.item(i);
- if (element.getNodeName().equals(treeNodeName)) {
- Element tr = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- Element td = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- tr.appendChild(td);
- vpeChildrenInfo = new VpeChildrenInfo(td);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- parentElement.appendChild(tr);
- }
- }
- }
-
- /**
- * Set attributes for treeNode
- *
- * @param table
- */
- private void addBasicTreeNodeAttributes(Element table) {
- if (table == null) {
- return;
- }
- table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
- TREE_TABLE_ATR_CELLPADDING_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
- TREE_TABLE_ATR_CELLSPACING_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
- TREE_TABLE_ATR_BORDER_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- "dr-tree-full-width");
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+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.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Create template for rich:recursiveTreeNodesAdaptor element
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesRecursiveTreeNodesAdaptorTemplate extends
+ VpeAbstractTemplate {
+
+ private static final String TREE_NAME = "tree";
+
+ private final static String TREE_NODE_NAME = "treeNode";
+
+ public final static String TREE_NODES_ADAPTOR_NAME = "treeNodesAdaptor";
+
+ public final static String RECURSIVE_TREE_NODES_ADAPTOR_NAME =
"recursiveTreeNodesAdaptor";
+
+ private static final String STYLE_PATH = "/tree/tree.css";
+
+ public static final String ICON_DIV_LINE = "/tree/divLine.gif";
+
+ private static final String ADAPTER_LINES_STYLE = "background-position: left
center; background-repeat: repeat-y;";
+
+ public static final String ID_ATTR_NAME = "ID";
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
"recursiveTreeNodesAdaptor");
+ Element visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ 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)) {
+ 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;
+ }
+
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ public void parseTree(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument, VpeCreationData vpeCreationData,
+ Element parentElement) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ int lenght = nodeList.getLength();
+ String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_NODES_ADAPTOR_NAME;
+ String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RECURSIVE_TREE_NODES_ADAPTOR_NAME;
+ VpeChildrenInfo vpeChildrenInfo = null;
+ for (int i = 0; i < lenght; i++) {
+ if (!(nodeList.item(i) instanceof Element)) {
+ continue;
+ }
+ element = (Element) nodeList.item(i);
+ if (element.getNodeName().equals(treeNodeName)
+ || element.getNodeName().equals(
+ recursiveTreeNodesAdaptorName)) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ } else if (element.getNodeName().equals(treeNodesAdaptorName)) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ public boolean isHasParentAdapter(Node sourceNode) {
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_NODES_ADAPTOR_NAME;
+ String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RECURSIVE_TREE_NODES_ADAPTOR_NAME;
+ Node node = sourceNode.getParentNode();
+ if (node.getNodeName().equals(treeNodesAdaptorName)
+ || node.getNodeName().equals(recursiveTreeNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Get showConnectingLines attribute
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean getShowLinesAttr(Node sourceNode) {
+ String treeName = sourceNode.getPrefix() + ":" + TREE_NAME;
+ do {
+ sourceNode = sourceNode.getParentNode();
+ if (!(sourceNode instanceof Element)) {
+ return true;
+ }
+ } while (!sourceNode.getNodeName().equals(treeName));
+
+ String showLinesParam = ((Element) sourceNode)
+ .getAttribute(RichFacesTreeTemplate.SHOW_LINES_ATTR_NAME);
+
+ boolean showLinesValue = true;
+ if (showLinesParam != null &&
showLinesParam.equalsIgnoreCase("false")) {
+ showLinesValue = false;
+ }
+ return showLinesValue;
+ }
+}
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-10
14:09:31 UTC (rev 4095)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-10-10
15:02:43 UTC (rev 4096)
@@ -220,9 +220,9 @@
// creates icon with status of node(collapsed or not) node
Element td1 = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TD);
-
// sets icon node
- if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)) {
+ if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
+ && !isHasNextAdaptorElement(sourceNode)) {
backgroundLinePath = RichFacesTemplatesActivator
.getPluginResourcePath()
+ ICON_LINE;
@@ -234,7 +234,28 @@
(Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
showLinesValue == true ? ICON_NODE_WITH_LINE
: ICON_NODE_WITHOUT_LINES);
- } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
isLastElementAfterAdaptor(sourceNode))
+ } else if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
+ && isHasNextAdaptorElement(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
+ : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ if (showLinesValue) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_LEFT_LINE;
+ iconNode.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + path + "); "
+ + NODE_LINES_STYLE);
+ }
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
(isAdaptorInTree(sourceNode) == isLastElementAfterAdaptor(sourceNode)))
|| (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))) {
backgroundLinePath = RichFacesTemplatesActivator
.getPluginResourcePath()
@@ -311,8 +332,8 @@
Document visualDocument, Node visualNode, Object data, String name,
String value) {
/*
- * processed only next attributes iconExpanded and icon, becouse tree
- * allways shows as expanded and information is it leaf or not contains
+ * processed only next attributes iconExpanded and icon, because tree
+ * always shows as expanded and information is it leaf or not contains
* in model
*/
if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
@@ -344,8 +365,8 @@
Element sourceElement, Document visualDocument, Node visualNode,
Object data, String name) {
/*
- * processed only next attributes iconExpanded and icon, becouse tree
- * allways shows as expanded and information is it leaf or not contains
+ * processed only next attributes iconExpanded and icon, because tree
+ * always shows as expanded and information is it leaf or not contains
* in model
*/
@@ -402,6 +423,7 @@
}
/**
+ * Node is Adaptor child
*
* @param sourceNode
* @return
@@ -425,6 +447,7 @@
}
/**
+ * Node is last element
*
* @param parentTree
* @param sourceNode
@@ -456,6 +479,45 @@
}
/**
+ * Next element is Adaptor
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isHasNextAdaptorElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ 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(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Adds basic attributes to tree
*
* @param img
@@ -511,6 +573,7 @@
}
/**
+ * Node has element after adaptor
*
* @param sourceNode
* @return
@@ -522,4 +585,30 @@
}
return isLastElement(nodeAdaptor);
}
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorInTree(Node sourceNode) {
+ Node adaptorNode = sourceNode.getParentNode();
+ if (!(adaptorNode instanceof Element)) {
+ return true;
+ }
+ String treeNodesAdaptorName = adaptorNode.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = adaptorNode.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ if (adaptorNode.getNodeName().equals(treeNodesAdaptorName)
+ || adaptorNode.getNodeName().equals(
+ treeRecursiveNodesAdaptorName)) {
+ Node treeNode = adaptorNode.getParentNode();
+ String treeName = treeNode.getPrefix() + ":" + TREE_NAME;
+ if (treeNode.getNodeName().equals(treeName)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
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-10
14:09:31 UTC (rev 4095)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-10-10
15:02:43 UTC (rev 4096)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
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;
@@ -28,19 +30,40 @@
*/
public class RichFacesTreeNodesAdaptorTemplate extends VpeAbstractTemplate {
+ private static final String TREE_NAME = "tree";
+
private final static String TREE_NODE_NAME = "treeNode";
- private static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
+ public final static String TREE_NODES_ADAPTOR_NAME = "treeNodesAdaptor";
- private static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
+ public final static String RECURSIVE_TREE_NODES_ADAPTOR_NAME =
"recursiveTreeNodesAdaptor";
- private static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
+ private static final String STYLE_PATH = "/tree/tree.css";
+ public static final String ICON_DIV_LINE = "/tree/divLine.gif";
+
+ private static final String ADAPTER_LINES_STYLE = "background-position: left
center; background-repeat: repeat-y;";
+
+ public static final String ID_ATTR_NAME = "ID";
+
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
Document visualDocument) {
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "treeNodesAdaptor");
Element visualElement = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- addBasicTreeNodeAttributes(visualElement);
+ .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)) {
+ 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);
@@ -63,42 +86,70 @@
Element element = null;
int lenght = nodeList.getLength();
String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_NODES_ADAPTOR_NAME;
+ String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RECURSIVE_TREE_NODES_ADAPTOR_NAME;
VpeChildrenInfo vpeChildrenInfo = null;
for (int i = 0; i < lenght; i++) {
if (!(nodeList.item(i) instanceof Element)) {
continue;
}
element = (Element) nodeList.item(i);
- if (element.getNodeName().equals(treeNodeName)) {
- Element tr = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- Element td = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- tr.appendChild(td);
- vpeChildrenInfo = new VpeChildrenInfo(td);
+ if (element.getNodeName().equals(treeNodeName)
+ || element.getNodeName().equals(
+ recursiveTreeNodesAdaptorName)) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
vpeCreationData.addChildrenInfo(vpeChildrenInfo);
vpeChildrenInfo.addSourceChild(element);
- parentElement.appendChild(tr);
+ } else if (element.getNodeName().equals(treeNodesAdaptorName)) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
}
}
}
/**
- * Set attributes for treeNode
*
- * @param table
+ * @param sourceNode
+ * @return
*/
- private void addBasicTreeNodeAttributes(Element table) {
- if (table == null) {
- return;
+ public boolean isHasParentAdapter(Node sourceNode) {
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_NODES_ADAPTOR_NAME;
+ String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RECURSIVE_TREE_NODES_ADAPTOR_NAME;
+ Node node = sourceNode.getParentNode();
+ if (node.getNodeName().equals(treeNodesAdaptorName)
+ || node.getNodeName().equals(recursiveTreeNodesAdaptorName)) {
+ return true;
}
- table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
- TREE_TABLE_ATR_CELLPADDING_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
- TREE_TABLE_ATR_CELLSPACING_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
- TREE_TABLE_ATR_BORDER_VALUE);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- "dr-tree-full-width");
+ return false;
}
+
+ /**
+ * Get showConnectingLines attribute
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean getShowLinesAttr(Node sourceNode) {
+ String treeName = sourceNode.getPrefix() + ":" + TREE_NAME;
+ do {
+ sourceNode = sourceNode.getParentNode();
+ if (!(sourceNode instanceof Element)) {
+ return true;
+ }
+ } while (!sourceNode.getNodeName().equals(treeName));
+
+ String showLinesParam = ((Element) sourceNode)
+ .getAttribute(RichFacesTreeTemplate.SHOW_LINES_ATTR_NAME);
+
+ boolean showLinesValue = true;
+ if (showLinesParam != null &&
showLinesParam.equalsIgnoreCase("false")) {
+ showLinesValue = false;
+ }
+ return showLinesValue;
+ }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-10-10
14:09:31 UTC (rev 4095)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-10-10
15:02:43 UTC (rev 4096)
@@ -178,8 +178,14 @@
return;
}
NodeList list = node.getChildNodes();
+ Element element = (Element) node;
+ String id = element
+ .getAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME);
if (node.getNodeName().equalsIgnoreCase(HtmlComponentUtil.HTML_TAG_DIV)
- && list.getLength() == 2) {
+ && list.getLength() == 2
+ && !(id
+ .equalsIgnoreCase(RichFacesTreeNodesAdaptorTemplate.TREE_NODES_ADAPTOR_NAME) || id
+ .equalsIgnoreCase(RichFacesTreeNodesAdaptorTemplate.RECURSIVE_TREE_NODES_ADAPTOR_NAME)))
{
Node table1 = list.item(0);
Node table2 = list.item(1);
node.removeChild(table1);