Author: dsakovich
Date: 2007-09-26 13:46:45 -0400 (Wed, 26 Sep 2007)
New Revision: 3819
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
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/RichFacesTreeNodesAdaptorTemplate.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLines.gif
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/RichFacesTreeNodeTemplate.java
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/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-847 Add rich:treeNodesAdaptor,
rich:recursiveTreeNodesAdaptor
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLines.gif
===================================================================
(Binary files differ)
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.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-09-26
16:57:31 UTC (rev 3818)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css 2007-09-26
17:46:45 UTC (rev 3819)
@@ -1,10 +1,24 @@
.treePictureStyle {
width: 22px;
- height: 100%;
+ height: 22px;
}
-.treeNodeNameStyle{
- width : 100%;
- vertical-align : middle;
- text-align : left;
+.treeNodeNameStyle {
+ width: 100%;
+ vertical-align: middle;
+ text-align: left;
}
+
+.dr-tree-h-ic-div {
+ margin-left: 8px;
+ padding-left: 14px;
+}
+
+.dr-tree-full-width {
+ width: 100%;
+}
+
+.dr-tree-h-ic-line-position {
+ background-position: center;
+ background-repeat: repeat-y;
+}
Added:
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
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-09-26
17:46:45 UTC (rev 3819)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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");
+ }
+
+}
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-09-26
16:57:31 UTC (rev 3818)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-09-26
17:46:45 UTC (rev 3819)
@@ -7,13 +7,14 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
import java.util.List;
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;
@@ -31,329 +32,506 @@
*/
public class RichFacesTreeNodeTemplate extends VpeAbstractTemplate {
- public static final String DEFAULT_ICON_PARAM_VALUE = "DEFAULT_ICON_PARAM";
+ public static final String DEFAULT_ICON_PARAM_VALUE =
"DEFAULT_ICON_PARAM";
- public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam";
+ public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam";
- public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE =
"DEFAULT_ICON_EXPANDED_PARAM";
+ public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE =
"DEFAULT_ICON_EXPANDED_PARAM";
- public static final String UNDEFINED_ICON = "/tree/unresolved.gif";
+ public static final String UNDEFINED_ICON = "/tree/unresolved.gif";
- public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf";
+ public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf";
- public static final String ICON_NODE_WITH_LINES =
"/tree/iconNodeWithLines.gif";
+ public static final String ICON_NODE_WITH_LINES =
"/tree/iconNodeWithLines.gif";
- public static final String ICON_EXPANDED_WITH_LINES =
"/tree/iconCollapsedWithLines.gif";
+ public static final String ICON_NODE_WITH_LINE =
"/tree/iconNodeWithLine.gif";
- public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif";
+ public static final String ICON_EXPANDED_WITH_LINES =
"/tree/iconCollapsedWithLines.gif";
- public static final String ICON_EXPANDED_WITHOUT_LINES =
"/tree/iconCollapsed.gif";
+ public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif";
- public static final String ICON_LEAF_WITH_LINES = "/tree/iconLeaf.gif";
+ public static final String ICON_EXPANDED_WITHOUT_LINES =
"/tree/iconCollapsed.gif";
- public static final String ICON_LEAF_WITHOUT_LINES =
"/tree/iconLeafWithLines.gif";
+ public static final String ICON_NOT_EXPANDED_WITH_LINES =
"/tree/iconNotCollapsedWithLines.gif";
- private static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME =
"treePictureStyle";
+ public static final String ICON_NOT_EXPANDED_WITHOUT_LINES =
"/tree/iconNotCollapsed.gif";
- private static final String STYLE_CLASS_FOR_NODE_TITLE = "treeNodeNameStyle";
+ public static final String ICON_EXPANDED_ADAPTER_WITH_LINES =
"/tree/iconClosedNodeWithLines.gif";
- private static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME = "nodeClass";
+ public static final String ICON_EXPANDED_ADAPTER_WITHOUT_LINES =
"/tree/iconClosedNode.gif";
- private static final String NODE_ICON_EXPANDED_ATTR_NAME = "iconExpanded";
+ public static final String ICON_LEAF_WITH_LINES = "/tree/iconLeaf.gif";
- private static final String NODE_ICON_ATTR_NAME = "icon";
+ public static final String ICON_RIGHT_LINE = "/tree/rightLine.gif";
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- Document visualDocument) {
- Element tableRow = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- addAttributeToTableNode((Element) sourceNode, tableRow);
- VpeCreationData vpeCreationData = new VpeCreationData(tableRow);
- createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
- vpeCreationData);
- return vpeCreationData;
- }
+ public static final String ICON_LEFT_LINE = "/tree/leftLine.gif";
- /**
- * Checks for attributes for node and if such exist convert it's to html
- * atributes.
- *
- * @param sourceNode
- * @param tableRow
- */
- private void addAttributeToTableNode(Element sourceNode, Element tableRow) {
+ public static final String ICON_LINE = "/tree/line.gif";
- String attrValue = sourceNode
- .getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME);
- if ((attrValue != null) && (attrValue.length() > 0)) {
- tableRow.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- attrValue);
- }
+ public static final String ICON_LEAF_WITHOUT_LINES =
"/tree/iconLeafWithLines.gif";
+
+ private static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME =
"treePictureStyle";
+
+ private static final String STYLE_CLASS_FOR_NODE_TITLE =
"treeNodeNameStyle";
+
+ private static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME =
"nodeClass";
+
+ private static final String NODE_ICON_EXPANDED_ATTR_NAME = "iconExpanded";
+
+ private static final String NODE_ICON_ATTR_NAME = "icon";
+
+ 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";
+
+ private static final String TREE_NODES_ADAPTOR_NAME = "treeNodesAdaptor";
+
+ private static final String TREE_NODES_RECURSIVE_ADAPTOR_NAME =
"recursiveTreeNodesAdaptor";
+
+ private static final String TREE_NAME = "tree";
+
+ private static final String NODE_LINES_STYLE = "background-position: center;
background-repeat: repeat-y;";
+
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+
+ Element visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+
+ Element tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+
+ Element tableRow = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ addAttributeToTableNode((Element) sourceNode, tableRow);
+ visualElement.appendChild(tbody);
+ tbody.appendChild(tableRow);
+
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
+ vpeCreationData);
+ return vpeCreationData;
+ }
+
+ /**
+ * Checks for attributes for node and if such exist convert it's to html
+ * atributes.
+ *
+ * @param sourceNode
+ * @param tableRow
+ */
+ private void addAttributeToTableNode(Element sourceNode, Element tableRow) {
+
+ String attrValue = sourceNode
+ .getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME);
+ if ((attrValue != null) && (attrValue.length() > 0)) {
+ tableRow.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, attrValue);
}
+ }
- /**
- * Used for setting images into tree nodes
- *
- * @param pageContext
- * page context
- * @param visualDocument
- * visual document
- * @param sourceNode
- * treeNode element
- * @param iconCell
- * cell were image should be setted
- * @param nodeAttrName
- * image attr name( icon, iconExpanded, ...)
- * @param defaultImage
- * (image by default)
- */
- private void setAttributeForPictureNode(VpePageContext pageContext,
- Document visualDocument, Element sourceNode, Element iconCell,
- String nodeAttrName, String defaultImage) {
- Element img = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_IMG);
- addBasicAttributesToPicture(img);
- iconCell.appendChild(img);
- // get image from treeNode
- String imgName = sourceNode.getAttribute(nodeAttrName);
- // if in tree node image doesn't exist we get image attr from tree
- if (imgName == null || imgName.length() == 0) {
- imgName = ((Element) sourceNode.getParentNode())
- .getAttribute(nodeAttrName);
- } else {
- img.setAttribute(ICON_PARAM_NAME, "");
- }
- // if we can't get attribute from parent we use default attribute
- addBasicAttributesToPicture(img);
- iconCell.appendChild(img);
- if (imgName == null || imgName.length() == 0) {
- ComponentUtil.setImg(img, defaultImage);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img, imgName,
- UNDEFINED_ICON);
- }
- if (nodeAttrName.equals(NODE_ICON_EXPANDED_ATTR_NAME)) {
- img
- .setAttribute(ICON_PARAM_NAME,
- DEFAULT_ICON_EXPANDED_PARAM_VALUE);
- } else if (nodeAttrName.equals(NODE_ICON_ATTR_NAME)) {
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
- } else if (nodeAttrName.equals(NODE_ICON_LEAF_ATTR_NAME)) {
- img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
- }
+ /**
+ * Used for setting images into tree nodes
+ *
+ * @param pageContext
+ * page context
+ * @param visualDocument
+ * visual document
+ * @param sourceNode
+ * treeNode element
+ * @param iconCell
+ * cell were image should be setted
+ * @param nodeAttrName
+ * image attr name( icon, iconExpanded, ...)
+ * @param defaultImage
+ * (image by default)
+ */
+ private void setAttributeForPictureNode(VpePageContext pageContext,
+ Document visualDocument, Element sourceNode, Element iconCell,
+ String nodeAttrName, String defaultImage) {
+ if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
+ System.out.println("call setAttributeForPictureNode");
}
+ Element img = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_IMG);
+ addBasicAttributesToPicture(img);
+ iconCell.appendChild(img);
+ // get image from treeNode
+ String imgName = sourceNode.getAttribute(nodeAttrName);
+ // if in tree node image doesn't exist we get image attr from tree
+ if (imgName == null || imgName.length() == 0) {
+ imgName = ((Element) sourceNode.getParentNode())
+ .getAttribute(nodeAttrName);
+ } else {
+ img.setAttribute(ICON_PARAM_NAME, "");
+ }
+ // if we can't get attribute from parent we use default attribute
+ addBasicAttributesToPicture(img);
+ iconCell.appendChild(img);
+ if (imgName == null || imgName.length() == 0) {
+ ComponentUtil.setImg(img, defaultImage);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img, imgName,
+ UNDEFINED_ICON);
+ }
+ if (nodeAttrName.equals(NODE_ICON_EXPANDED_ATTR_NAME)) {
+ img
+ .setAttribute(ICON_PARAM_NAME,
+ DEFAULT_ICON_EXPANDED_PARAM_VALUE);
+ } else if (nodeAttrName.equals(NODE_ICON_ATTR_NAME)) {
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+ } else if (nodeAttrName.equals(NODE_ICON_LEAF_ATTR_NAME)) {
+ img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
+ }
+ }
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
- */
- private void createBasicTree(VpePageContext pageContext,
- Document visualDocument, Element treeRow, Node sourceNode,
- VpeCreationData vpeCreationData) {
- // creates icon node
- Element iconNode = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- String showLinesParam = ((Element) sourceNode.getParentNode())
- .getAttribute(RichFacesTreeTemplate.SHOW_LINES_ATTR_NAME);
- boolean showLinesValue = true;
- if (showLinesParam != null &&
showLinesParam.equalsIgnoreCase("false")) {
- showLinesValue = false;
- }
- // creates icon with status of node(collapsed or not) node
- Element td1 = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ private void createBasicTree(VpePageContext pageContext,
+ Document visualDocument, Element treeRow, Node sourceNode,
+ VpeCreationData vpeCreationData) {
+ // creates icon node
+ String backgroundImagePath;
+ if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
+ System.out.println("call createBasicTree");
+ }
+ boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
- // sets attribute for icon expanded picture or not
+ Element iconNode = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ // creates icon with status of node(collapsed or not) node
+ Element td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // sets icon node
+ if (!isLastElement(sourceNode.getParentNode(), sourceNode)) {
+ // sets attribute for icon expanded picture or not
+
+ if (!isAdaptorsChild(sourceNode.getParentNode())) {
+ backgroundImagePath = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_RIGHT_LINE;
setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_EXPANDED_WITH_LINES
- : ICON_EXPANDED_WITHOUT_LINES);
- // sets icon node
- if (!isLastElement(sourceNode.getParentNode(), sourceNode)) {
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- } else {
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_LEAF_ATTR_NAME,
- showLinesValue == true ? ICON_LEAF_WITH_LINES
- : ICON_LEAF_WITHOUT_LINES);
+ (Element) sourceNode, td1,
+ NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_WITH_LINES
+ : ICON_EXPANDED_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_LEFT_LINE;
+ if (showLinesValue) {
+ iconNode.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + path + "); "
+ + NODE_LINES_STYLE);
}
- treeRow.appendChild(td1);
- treeRow.appendChild(iconNode);
- // creates Tree Node Name Message
- Element nodeTitle = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- addBasicNadeTitleAttributes(nodeTitle);
- // Create mapping to Encode body
- VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+ } else {
+ backgroundImagePath = 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_LINE
+ : ICON_NODE_WITHOUT_LINES);
+ }
- // Create mapping to Encode body
- List<Node> children = ComponentUtil.getChildren((Element) sourceNode,
- false);
- for (Node child : children) {
- tdInfo.addSourceChild(child);
+ } else {
+ backgroundImagePath = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_RIGHT_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_NOT_EXPANDED_WITH_LINES
+ : ICON_NOT_EXPANDED_WITHOUT_LINES);
+ if (isAdaptorsChild(sourceNode.getParentNode())) {
+ if (!isLastNodesAdaptor(sourceNode)) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_LEFT_LINE;
+ if (showLinesValue) {
+ iconNode.setAttribute(
+ HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + path + "); "
+ + NODE_LINES_STYLE);
+ }
+
}
- vpeCreationData.addChildrenInfo(tdInfo);
- treeRow.appendChild(nodeTitle);
+ }
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_LEAF_ATTR_NAME,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
}
+ if (showLinesValue) {
+ td1.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + backgroundImagePath
+ + "); " + NODE_LINES_STYLE);
- /**
- * Sets attributes for no node title name
- *
- * @param nodeTitle
- */
- private void addBasicNadeTitleAttributes(Element nodeTitle) {
- nodeTitle.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- STYLE_CLASS_FOR_NODE_TITLE);
}
+ treeRow.appendChild(td1);
+ treeRow.appendChild(iconNode);
+ // creates Tree Node Name Message
+ Element nodeTitle = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ addBasicNodeTitleAttributes(nodeTitle);
+ // Create mapping to Encode body
+ VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- 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
- * in model
- */
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- Element expandedIconCell = (Element) visualNode.getChildNodes()
- .item(0);
- Element img = (Element) expandedIconCell.getChildNodes().item(0);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- } else if (NODE_ICON_ATTR_NAME.equals(name)
- && !isLastElement(visualNode.getParentNode(), visualNode)) {
- Element iconCell = (Element) visualNode.getChildNodes().item(1);
- Element img = (Element) iconCell.getChildNodes().item(0);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
- && isLastElement(sourceElement.getParentNode(), sourceElement)) {
- Element iconCell = (Element) visualNode.getChildNodes().item(1);
- Element img = (Element) iconCell.getChildNodes().item(0);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- }
+ // Create mapping to Encode body
+ List<Node> children = ComponentUtil.getChildren((Element) sourceNode,
+ false);
+ for (Node child : children) {
+ tdInfo.addSourceChild(child);
}
+ vpeCreationData.addChildrenInfo(tdInfo);
+ treeRow.appendChild(nodeTitle);
+ }
- @Override
- public void removeAttribute(VpePageContext pageContext,
- 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
- * in model
- */
- String showLinesParam = ((Element) sourceElement.getParentNode())
- .getAttribute(RichFacesTreeTemplate.SHOW_LINES_ATTR_NAME);
- boolean showLinesValue = true;
- if (showLinesParam != null &&
showLinesParam.equalsIgnoreCase("false")) {
- showLinesValue = false;
- }
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- Element expandedIconCell = (Element) visualNode.getChildNodes()
- .item(0);
- Element img = (Element) expandedIconCell.getChildNodes().item(0);
- String parentAttrName = ((Element) sourceElement.getParentNode())
- .getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
- if (parentAttrName == null || parentAttrName.length() == 0) {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_EXPANDED_WITH_LINES
- : ICON_EXPANDED_WITHOUT_LINES);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- }
- img
- .setAttribute(ICON_PARAM_NAME,
- DEFAULT_ICON_EXPANDED_PARAM_VALUE);
- } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
- && !isLastElement(sourceElement.getParentNode(), sourceElement)) {
- Element iconCell = (Element) visualNode.getChildNodes().item(1);
- Element img = (Element) iconCell.getChildNodes().item(0);
- String parentAttrName = ((Element) sourceElement.getParentNode())
- .getAttribute(NODE_ICON_ATTR_NAME);
- if (parentAttrName == null || parentAttrName.length() == 0) {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- }
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+ /**
+ * Sets attributes for no node title name
+ *
+ * @param nodeTitle
+ */
+ private void addBasicNodeTitleAttributes(Element nodeTitle) {
+ nodeTitle.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ STYLE_CLASS_FOR_NODE_TITLE);
+ }
- } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
- && isLastElement(sourceElement.getParentNode(), sourceElement)) {
- Element iconCell = (Element) visualNode.getChildNodes().item(1);
- Element img = (Element) iconCell.getChildNodes().item(0);
- String parentAttrName = ((Element) sourceElement.getParentNode())
- .getAttribute(NODE_ICON_LEAF_ATTR_NAME);
- if (parentAttrName == null || parentAttrName.length() == 0) {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_LEAF_WITH_LINES
- : ICON_LEAF_WITHOUT_LINES);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- }
- img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
- }
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ 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
+ * in model
+ */
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ Element expandedIconCell = (Element) visualNode.getChildNodes()
+ .item(0);
+ Element img = (Element) expandedIconCell.getChildNodes().item(0);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
+ } else if (NODE_ICON_ATTR_NAME.equals(name)
+ && !isLastElement(visualNode.getParentNode(), visualNode)) {
+ Element iconCell = (Element) visualNode.getChildNodes().item(1);
+ Element img = (Element) iconCell.getChildNodes().item(0);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
+ && isLastElement(sourceElement.getParentNode(), sourceElement)) {
+ Element iconCell = (Element) visualNode.getChildNodes().item(1);
+ Element img = (Element) iconCell.getChildNodes().item(0);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
}
+ }
- /**
- *
- * @param parentTree
- * @param currentNode
- * @return
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ 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
+ * in model
*/
- private boolean isLastElement(Node parentTree, Node currentNode) {
- NodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + ":"
- + RichFacesTreeTemplate.TREE_NODE_NAME;
- Node lastElement = null;
- Node el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (el.getNodeName().equals(treeNodeName)) {
- lastElement = el;
- }
- }
- return currentNode.equals(lastElement);
+
+ boolean showLinesValue = getShowLinesAttr(sourceElement);
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ Element expandedIconCell = (Element) visualNode.getChildNodes()
+ .item(0);
+ Element img = (Element) expandedIconCell.getChildNodes().item(0);
+ String parentAttrName = ((Element) sourceElement.getParentNode())
+ .getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
+ if (parentAttrName == null || parentAttrName.length() == 0) {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_EXPANDED_WITH_LINES
+ : ICON_EXPANDED_WITHOUT_LINES);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ }
+ img
+ .setAttribute(ICON_PARAM_NAME,
+ DEFAULT_ICON_EXPANDED_PARAM_VALUE);
+ } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
+ && !isLastElement(sourceElement.getParentNode(), sourceElement)) {
+ Element iconCell = (Element) visualNode.getChildNodes().item(1);
+ Element img = (Element) iconCell.getChildNodes().item(0);
+ String parentAttrName = ((Element) sourceElement.getParentNode())
+ .getAttribute(NODE_ICON_ATTR_NAME);
+ if (parentAttrName == null || parentAttrName.length() == 0) {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ }
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
+ && isLastElement(sourceElement.getParentNode(), sourceElement)) {
+ Element iconCell = (Element) visualNode.getChildNodes().item(1);
+ Element img = (Element) iconCell.getChildNodes().item(0);
+ String parentAttrName = ((Element) sourceElement.getParentNode())
+ .getAttribute(NODE_ICON_LEAF_ATTR_NAME);
+ if (parentAttrName == null || parentAttrName.length() == 0) {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ }
+ img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
}
+ }
- /**
- * Adds basic attributes to tree
- *
- * @param img
- */
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorsChild(Node sourceNode) {
+ String treeNodesAdaptor = sourceNode.getPrefix() + ":"
+ + TREE_NODES_ADAPTOR_NAME;
+ String recursiveTreeNodesAdaptor = sourceNode.getPrefix() + ":"
+ + TREE_NODES_RECURSIVE_ADAPTOR_NAME;
+ if (sourceNode.getNodeName().equals(treeNodesAdaptor)
+ || sourceNode.getNodeName().equals(recursiveTreeNodesAdaptor)) {
+ return true;
+ }
+ return false;
+ }
- private void addBasicAttributesToPicture(Element img) {
- img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
+ /**
+ *
+ * @param parentTree
+ * @param currentNode
+ * @return
+ */
+ private boolean isLastElement(Node parentTree, Node currentNode) {
+ NodeList childs = parentTree.getChildNodes();
+ String treeNodeName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODE_NAME;
+ Node lastElement = null;
+ Node el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().equals(treeNodeName)) {
+ lastElement = el;
+ }
}
+ return currentNode.equals(lastElement);
+ }
+
+ /**
+ * Adds basic attributes to tree
+ *
+ * @param img
+ */
+
+ private void addBasicAttributesToPicture(Element img) {
+ img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
+ }
+
+ /**
+ * 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");
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastNodesAdaptor(Node sourceNode) {
+ Node nodeAdaptor = sourceNode.getParentNode();
+ if (!(nodeAdaptor instanceof Element)) {
+ return true;
+ }
+ Node parentNode = nodeAdaptor.getParentNode();
+ if (!(parentNode instanceof Element)) {
+ return true;
+ }
+ Node lastNode = parentNode.getLastChild();
+ return lastNode.equals(nodeAdaptor);
+ }
}
Added:
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
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-09-26
17:46:45 UTC (rev 3819)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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:treeNodesAdaptor element
+ *
+ * @author dsakovich(a)exadel.com
+ *
+ */
+public class RichFacesTreeNodesAdaptorTemplate 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");
+ }
+}
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-09-26
16:57:31 UTC (rev 3818)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-09-26
17:46:45 UTC (rev 3819)
@@ -1,13 +1,13 @@
-/*******************************************************************************
- * Copyright (c) 2007 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+/*******************************************************************************
+ * 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;
@@ -24,381 +24,286 @@
/**
* Create template for rich:tree element.
*
- * @author Max Areshkau
+ * @author dsakovich(a)exadel.com
*
*/
public class RichFacesTreeTemplate extends VpeAbstractTemplate {
- /** Resurces */
+ /** Resurces */
- public static final String TREE_NODE_NAME = "treeNode";
+ public static final String TREE_NODE_NAME = "treeNode";
- public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines";
+ public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor";
- private static final String STYLE_PATH = "/tree/tree.css";
+ public static final String TREE_RECURSIVE_NODES_ADAPTOR =
"recursiveTreeNodesAdaptor";
- private static final String ICON_ATTR = "icon";
+ public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines";
- private static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
+ private static final String STYLE_PATH = "/tree/tree.css";
- private static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
+ private static final String ICON_ATTR = "icon";
- private static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
+ private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass";
- private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass";
+ private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded";
- private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded";
-
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- Document visualDocument) {
- // sets css for tree on page
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "tree");
- Element visualElement = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- Element treeRow = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- Element treeCell = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- addBasicTreeAttributes(visualElement);
- treeRow.appendChild(treeCell);
- visualElement.appendChild(treeRow);
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- treeCell);
- setStylesAttributesToTree(visualElement, (Element) sourceNode);
- return vpeCreationData;
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument) {
+ // sets css for tree on page
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "tree");
+ Element visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ Element sourceElement = (Element) sourceNode;
+ String style = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ if (style != null) {
+ visualElement
+ .setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
}
-
- /**
- * Sets to tree basic style attributes
- *
- * @param tree
- * @param sourceNode
- */
- private void setStylesAttributesToTree(Element treeTable, Element sourceNode) {
- String styleAttr = sourceNode
- .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
- if (styleAttr != null && styleAttr.length() != 0) {
- setAttributeToTree(treeTable, HtmlComponentUtil.HTML_STYLE_ATTR,
- removeFromStyleWithAndHeight(styleAttr));
- treeTable
- .setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, styleAttr);
- }
- String styleClassAttr = sourceNode
- .getAttribute(TREE_STYLE_CLASS_ATR_NAME);
- if ((styleClassAttr != null) && (styleClassAttr.length() != 0)) {
- setAttributeToTree(treeTable, HtmlComponentUtil.HTML_CLASS_ATTR,
- styleClassAttr);
- }
+ String styleClass = sourceElement
+ .getAttribute(HtmlComponentUtil.HTML_CLASS_ATTR);
+ if (styleClass != null) {
+ visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ styleClass);
}
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
+ visualElement);
+ setStylesAttributesToTree(visualElement, (Element) sourceNode);
+ return vpeCreationData;
+ }
- /**
- *
- * @param styleArgs
- * @return
- */
- private String removeFromStyleWithAndHeight(String styleArgs) {
- StringBuffer result = new StringBuffer();
- String[] mas = styleArgs.split(";");
- for (String styleAttr : mas) {
- if ((styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_WIDTH) != -1)
- || (styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_HEIGHT) != -1)) {
- continue;
- }
- result.append(styleAttr + ";");
- }
- return result.toString();
+ /**
+ * Sets to tree basic style attributes
+ *
+ * @param tree
+ * @param sourceNode
+ */
+ private void setStylesAttributesToTree(Element treeTable, Element sourceNode) {
+ String styleAttr = sourceNode
+ .getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ if (styleAttr != null && styleAttr.length() != 0) {
+ setAttributeToTree(treeTable, HtmlComponentUtil.HTML_STYLE_ATTR,
+ removeFromStyleWithAndHeight(styleAttr));
+ treeTable
+ .setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, styleAttr);
}
-
- /**
- * Sets to tree tables attributes
- *
- * @param node
- * @param sourceNode
- * @param attrValue
- */
- private void setAttributeToTree(Node node, String attrName, String attrValue) {
- if (!(node instanceof Element)) {
- return;
- }
- if (node.getNodeName().equalsIgnoreCase(
- HtmlComponentUtil.HTML_TAG_TABLE)) {
- ((Element) node).setAttribute(attrName, attrValue);
- }
- NodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- setAttributeToTree(list2.item(i), attrName, attrValue);
- }
+ String styleClassAttr = sourceNode
+ .getAttribute(TREE_STYLE_CLASS_ATR_NAME);
+ if ((styleClassAttr != null) && (styleClassAttr.length() != 0)) {
+ setAttributeToTree(treeTable, HtmlComponentUtil.HTML_CLASS_ATTR,
+ styleClassAttr);
}
+ }
- /**
- * Is invoked after construction of all child nodes of the current visual
- * node.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param data
- * Object <code>VpeCreationData</code>, built by a method
- * <code>create</code>
- */
- public void validate(VpePageContext pageContext, Node sourceNode,
- Document visualDocument, VpeCreationData data) {
- super.validate(pageContext, sourceNode, visualDocument, data);
- revertTableRows(data.getNode());
+ /**
+ *
+ * @param styleArgs
+ * @return
+ */
+ private String removeFromStyleWithAndHeight(String styleArgs) {
+ StringBuffer result = new StringBuffer();
+ String[] mas = styleArgs.split(";");
+ for (String styleAttr : mas) {
+ if ((styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_WIDTH) != -1)
+ || (styleAttr.indexOf(HtmlComponentUtil.HTML_ATR_HEIGHT) != -1)) {
+ continue;
+ }
+ result.append(styleAttr + ";");
}
+ return result.toString();
+ }
- /**
- * Recursive go throw three and checks if icon was seted for node or not
- *
- * @param node
- */
- private void correctImage(VpePageContext pageContex, Element sourceNode,
- Node node) {
- if (!(node instanceof Element)) {
- return;
- }
- if (node.getNodeName().equalsIgnoreCase(HtmlComponentUtil.HTML_TAG_IMG)) {
- String srcAttr = ((Element) node)
- .getAttribute(RichFacesTreeNodeTemplate.ICON_PARAM_NAME);
- if (RichFacesTreeNodeTemplate.DEFAULT_ICON_EXPANDED_PARAM_VALUE
- .equals(srcAttr)) {
- setImgForNode(pageContex, sourceNode, (Element) node,
- ICON_COLLAPSED_ATTR_NAME,
- RichFacesTreeNodeTemplate.ICON_EXPANDED_WITH_LINES,
- RichFacesTreeNodeTemplate.ICON_EXPANDED_WITHOUT_LINES);
- } else if (RichFacesTreeNodeTemplate.DEFAULT_ICON_PARAM_VALUE
- .equals(srcAttr)) {
- setImgForNode(pageContex, sourceNode, (Element) node,
- ICON_ATTR,
- RichFacesTreeNodeTemplate.ICON_NODE_WITH_LINES,
- RichFacesTreeNodeTemplate.ICON_NODE_WITHOUT_LINES);
- } else if (RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
- .equals(srcAttr)) {
- setImgForNode(pageContex, sourceNode, (Element) node,
- RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME,
- RichFacesTreeNodeTemplate.ICON_LEAF_WITH_LINES,
- RichFacesTreeNodeTemplate.ICON_LEAF_WITHOUT_LINES);
- }
- }
- NodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- correctImage(pageContex, sourceNode, list2.item(i));
- }
+ /**
+ * Sets to tree tables attributes
+ *
+ * @param node
+ * @param sourceNode
+ * @param attrValue
+ */
+ private void setAttributeToTree(Node node, String attrName, String attrValue) {
+ if (!(node instanceof Element)) {
+ return;
}
-
- /**
- * Sets icon fro node
- *
- * @param img
- * @param sourceNode
- */
- private void setImgForNode(VpePageContext pageContext, Element sourceNode,
- Element img, String attrName, String iconWithLines,
- String iconWithoutLines) {
- String treeIconAttr = sourceNode.getAttribute(attrName);
- if (treeIconAttr != null && treeIconAttr.length() > 0) {
- ComponentUtil.setImgFromResources(pageContext, img, treeIconAttr,
- RichFacesTreeNodeTemplate.UNDEFINED_ICON);
- return;
- }
- String showConnectingLinesAttr = sourceNode
- .getAttribute(SHOW_LINES_ATTR_NAME);
- if (showConnectingLinesAttr != null
- && showConnectingLinesAttr.length() > 0
- && showConnectingLinesAttr.equalsIgnoreCase("false")) {
- ComponentUtil.setImg(img, iconWithoutLines);
- } else {
- ComponentUtil.setImg(img, iconWithLines);
- }
+ if (node.getNodeName().equalsIgnoreCase(
+ HtmlComponentUtil.HTML_TAG_TABLE)) {
+ ((Element) node).setAttribute(attrName, attrValue);
}
+ NodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ setAttributeToTree(list2.item(i), attrName, attrValue);
+ }
+ }
- /**
- * Revert tree elements in right order.
- *
- * @param node
- */
- private void revertTableRows(Node node) {
- if (!(node instanceof Element)) {
- return;
- }
- NodeList list = node.getChildNodes();
- if (node.getNodeName().equalsIgnoreCase(
- HtmlComponentUtil.HTML_TAG_TABLE)
- && list.getLength() == 2) {
- Node tr1 = list.item(0);
- Node tr2 = list.item(1);
- node.removeChild(tr1);
- node.removeChild(tr2);
- node.appendChild(tr2);
- node.appendChild(tr1);
- }
- NodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- revertTableRows(list2.item(i));
- }
+ /**
+ * Is invoked after construction of all child nodes of the current visual
+ * node.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param data
+ * Object <code>VpeCreationData</code>, built by a method
+ * <code>create</code>
+ */
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ Document visualDocument, VpeCreationData data) {
+ super.validate(pageContext, sourceNode, visualDocument, data);
+ revertTableRows(data.getNode());
+ }
+
+ /**
+ * Revert tree elements in right order.
+ *
+ * @param node
+ */
+ private void revertTableRows(Node node) {
+ if (!(node instanceof Element)) {
+ return;
}
+ NodeList list = node.getChildNodes();
+ if (node.getNodeName().equalsIgnoreCase(HtmlComponentUtil.HTML_TAG_DIV)
+ && list.getLength() == 2) {
+ Node table1 = list.item(0);
+ Node table2 = list.item(1);
+ node.removeChild(table1);
+ node.removeChild(table2);
+ node.appendChild(table2);
+ node.appendChild(table1);
+ }
+ NodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ revertTableRows(list2.item(i));
+ }
+ }
- /**
- *
- * 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 cell) {
- // work arroud, becouse getChielsByName returns always null;
- NodeList nodeList = sourceNode.getChildNodes();
- Element element = null;
- Element tree = null;
- Element childTree = null;
- Element childLast = 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);
- childTree = null;
- if (element.getNodeName().equals(treeNodeName)) {
- if (tree == null) {
+ /**
+ *
+ * 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 parentDiv) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ Element div = null;
+ Element childTree = null;
+ Element childLast = null;
+ int lenght = nodeList.getLength();
+ String treeNodeName = sourceNode.getPrefix() + ":" + TREE_NODE_NAME;
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_NODES_ADAPTOR;
+ String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + TREE_RECURSIVE_NODES_ADAPTOR;
+ VpeChildrenInfo vpeChildrenInfo = null;
+ for (int i = 0; i < lenght; i++) {
+ if (!(nodeList.item(i) instanceof Element)) {
+ continue;
+ }
+ element = (Element) nodeList.item(i);
+ childTree = null;
+ if (element.getNodeName().equals(treeNodeName)
+ || element.getNodeName().equals(treeNodesAdaptorName)
+ || element.getNodeName().equals(
+ recursiveTreeNodesAdaptorName)) {
+ if (div == null) {
- tree = createBasicTree(visualDocument);
- vpeChildrenInfo = new VpeChildrenInfo(tree);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- childLast = tree;
- continue;
- } else if (childTree == null) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentDiv);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ div = createBasicTree(visualDocument);
+ childLast = parentDiv;
+ continue;
+ } else if (childTree == null) {
- childTree = createBasicTree(visualDocument);
- appendChildTree(childLast, childTree, visualDocument);
- vpeChildrenInfo = new VpeChildrenInfo(childTree);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- childLast = childTree;
- continue;
- }
- }
+ vpeChildrenInfo = new VpeChildrenInfo(div);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ childLast.appendChild(div);
+ childLast = div;
+ div = createBasicTree(visualDocument);
+ continue;
}
- if (tree != null) {
- cell.appendChild(tree);
- }
+ }
}
+ }
- /**
- * Appends child node to tree
- *
- * @param parentNode
- * @param childNode
- * @param visualDocument
- */
- private void appendChildTree(Element parentNode, Element childNode,
- Document visualDocument) {
- Element tr = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- Element emptyCell = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- Element treeCell = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- treeCell.setAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN, "2");
- tr.appendChild(emptyCell);
- tr.appendChild(treeCell);
- treeCell.appendChild(childNode);
- parentNode.appendChild(tr);
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Node visualNode,
+ Object data, String name, String value) {
+ if (ICON_COLLAPSED_ATTR_NAME.equals(name)
+ || SHOW_LINES_ATTR_NAME.equals(name)
+ || ICON_ATTR.equals(name)
+ || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
+ .equals(name)) {
+ return true;
}
+ return false;
+ }
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- Document visualDocument, Node visualNode, Object data, String name,
- String value) {
- if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
- value);
- } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
- removeFromStyleWithAndHeight(value));
- ((Element) visualNode).setAttribute(
- HtmlComponentUtil.HTML_STYLE_ATTR, value);
- } else if (ICON_COLLAPSED_ATTR_NAME.equals(name)
- || SHOW_LINES_ATTR_NAME.equals(name)
- || ICON_ATTR.equals(name)
- || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
- .equals(name)) {
- correctImage(pageContext, sourceElement, visualNode);
- }
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ Document visualDocument, Node visualNode, Object data, String name,
+ String value) {
+ if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
+ value);
+ } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
+ removeFromStyleWithAndHeight(value));
+ ((Element) visualNode).setAttribute(
+ HtmlComponentUtil.HTML_STYLE_ATTR, value);
}
+ }
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, Document visualDocument, Node visualNode,
- Object data, String name) {
- if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
- "");
- } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
- "");
- } else if (ICON_COLLAPSED_ATTR_NAME.equals(name)
- || SHOW_LINES_ATTR_NAME.equals(name)
- || ICON_ATTR.equals(name)
- || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
- .equals(name)) {
- correctImage(pageContext, sourceElement, visualNode);
- }
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, Document visualDocument, Node visualNode,
+ Object data, String name) {
+ if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_CLASS_ATTR,
+ "");
+ } else if (HtmlComponentUtil.HTML_STYLE_ATTR.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HtmlComponentUtil.HTML_STYLE_ATTR,
+ "");
}
+ }
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
- */
- private Element createBasicTree(Document visualDocument) {
- // create table
- Element tree = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- addBasicTreeAttributes(tree);
- return tree;
- }
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ private Element createBasicTree(Document visualDocument) {
- /**
- * Sets some attributes which necessary for displaying table as tree
- *
- * @param tree
- */
- private void addBasicTreeAttributes(Element tree) {
- if (tree == null) {
- return;
- }
- tree.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR,
- TREE_TABLE_ATR_CELLSPACING_VALUE);
- tree.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR,
- TREE_TABLE_ATR_CELLPADDING_VALUE);
- tree.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR,
- TREE_TABLE_ATR_BORDER_VALUE);
- }
+ Element div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tree-h-ic-div");
+ return div;
+ }
+
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-26
16:57:31 UTC (rev 3818)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-26
17:46:45 UTC (rev 3819)
@@ -43,6 +43,8 @@
<vpe:drag start-enable="yes" />
<vpe:drop container="yes">
<vpe:container-child tag-name="treeNode" />
+ <vpe:container-child tag-name="treeNodesAdaptor" />
+ <vpe:container-child tag-name="recursiveTreeNodesAdaptor" />
</vpe:drop>
</vpe:dnd>
<vpe:textFormating>
@@ -72,6 +74,38 @@
<vpe:pseudoContent defaultText="yes" />
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="rich:treeNodesAdaptor" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodesAdaptorTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes">
+ <vpe:container-child tag-name="treeNode" />
+ </vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:recursiveTreeNodesAdaptor"
case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodesAdaptorTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes">
+ <vpe:container-child tag-name="treeNode" />
+ </vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
<vpe:tag name="rich:treeNode" case-sensitive="yes">
<vpe:template children="yes" modify="yes"