Author: dsakovich
Date: 2007-09-26 20:53:13 -0400 (Wed, 26 Sep 2007)
New Revision: 3833
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
Removed:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeaf.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeafWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLines.gif
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-847 Add templates for rich:treeNodesAdaptor and
rich:recursiveTreeNodesAdaptor
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconClosedNodeWithLines.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeaf.gif
===================================================================
(Binary files differ)
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconLeafWithLines.gif
===================================================================
(Binary files differ)
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNodeWithLines.gif
===================================================================
(Binary files differ)
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsed.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithLines.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/leftLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/line.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
===================================================================
(Binary files differ)
Property changes on:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/rightLine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css 2007-09-27
00:50:58 UTC (rev 3832)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/tree.css 2007-09-27
00:53:13 UTC (rev 3833)
@@ -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:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-09-27
00:53:13 UTC (rev 3833)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+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,
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement 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,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement 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)) {
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ nsIDOMElement 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(nsIDOMElement 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:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-09-27
00:50:58 UTC (rev 3832)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-09-27
00:53:13 UTC (rev 3833)
@@ -7,13 +7,14 @@
*
* Contributors:
* Exadel, Inc. and 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;
@@ -27,373 +28,554 @@
import org.w3c.dom.NodeList;
/**
- * Creates VPE content for rich:treeNode
+ * Create template for rich:treeNodes element
*
- * @author Max Areshkau
+ * @author dsakovich(a)exadel.com
*
*/
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/iconLeafWithLines.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,
- nsIDOMDocument visualDocument) {
- nsIDOMElement 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";
+
+ public static final String ICON_LINE = "/tree/line.gif";
+
+ public static final String ICON_LEAF_WITHOUT_LINES = "/tree/iconLeaf.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_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,
+ nsIDOMDocument visualDocument) {
+
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+
+ nsIDOMElement tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+
+ nsIDOMElement 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,
+ nsIDOMElement tableRow) {
+
+ String attrValue = sourceNode
+ .getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME);
+ if ((attrValue != null) && (attrValue.length() > 0)) {
+ tableRow.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, attrValue);
}
+ }
- /**
- * Checks for attributes for node and if such exist convert it's to html
- * atributes.
- *
- * @param sourceNode
- * @param tableRow
- */
- private void addAttributeToTableNode(Element sourceNode, nsIDOMElement tableRow) {
+ /**
+ * 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,
+ nsIDOMDocument visualDocument, Element sourceNode,
+ nsIDOMElement iconCell, String nodeAttrName, String defaultImage) {
+ if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
+ System.out.println("call setAttributeForPictureNode");
+ }
+ nsIDOMElement 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) {
+ Node parentElement = sourceNode.getParentNode();
+ if (parentElement instanceof Element) {
+ imgName = ((Element) parentElement).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);
+ }
+ }
- String attrValue = sourceNode
- .getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME);
- if ((attrValue != null) && (attrValue.length() > 0)) {
- tableRow.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- attrValue);
- }
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ private void createBasicTree(VpePageContext pageContext,
+ nsIDOMDocument visualDocument, nsIDOMElement treeRow,
+ Node sourceNode, VpeCreationData vpeCreationData) {
+ // creates icon node
+ String backgroundLinePath = null;
+ if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
+ System.out.println("call createBasicTree");
}
+ boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
- /**
- * 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,
- nsIDOMDocument visualDocument, Element sourceNode, nsIDOMElement iconCell,
- String nodeAttrName, String defaultImage) {
- nsIDOMElement 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);
- }
+ nsIDOMElement iconNode = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ // creates icon with status of node(collapsed or not) node
+ nsIDOMElement td1 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+
+ // sets icon node
+ if (!isLastElement(sourceNode) && isAdaptorChild(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_LINE
+ : ICON_NODE_WITHOUT_LINES);
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
isLastElementAfterAdaptor(sourceNode))
+ || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))) {
+ backgroundLinePath = 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);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_LEAF_ATTR_NAME,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
+ } else {
+ backgroundLinePath = 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);
+
+ if (showLinesValue) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath()
+ + ICON_LEFT_LINE;
+ iconNode.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + path + "); "
+ + NODE_LINES_STYLE);
+ }
+
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
}
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
+ if (showLinesValue) {
+ td1.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ "background-image: url(file://" + backgroundLinePath
+ + "); " + NODE_LINES_STYLE);
+ }
+ treeRow.appendChild(td1);
+ treeRow.appendChild(iconNode);
+ // creates Tree Node Name Message
+ nsIDOMElement nodeTitle = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ addBasicNodeTitleAttributes(nodeTitle);
+ // Create mapping to Encode body
+ VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+
+ // Create mapping to Encode body
+ List<Node> children = ComponentUtil.getChildren((Element) sourceNode,
+ false);
+ for (Node child : children) {
+ tdInfo.addSourceChild(child);
+ }
+ vpeCreationData.addChildrenInfo(tdInfo);
+ treeRow.appendChild(nodeTitle);
+
+ }
+
+ /**
+ * Sets attributes for no node title name
+ *
+ * @param nodeTitle
+ */
+ private void addBasicNodeTitleAttributes(nsIDOMElement nodeTitle) {
+ nodeTitle.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ STYLE_CLASS_FOR_NODE_TITLE);
+ }
+
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode 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
*/
- private void createBasicTree(VpePageContext pageContext,
- nsIDOMDocument visualDocument, nsIDOMElement treeRow, Node sourceNode,
- VpeCreationData vpeCreationData) {
- // creates icon node
- nsIDOMElement 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
- nsIDOMElement td1 = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) expandedIconCell
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
- // sets attribute for icon expanded picture or not
- 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);
- }
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
+ } else if (NODE_ICON_ATTR_NAME.equals(name)
+ && !isLastElement(visualNode)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- treeRow.appendChild(td1);
- treeRow.appendChild(iconNode);
- // creates Tree Node Name Message
- nsIDOMElement nodeTitle = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- addBasicNadeTitleAttributes(nodeTitle);
- // Create mapping to Encode body
- VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
+ && isLastElement(sourceElement)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- // 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);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, "");
}
+ }
- /**
- * Sets attributes for no node title name
- *
- * @param nodeTitle
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode 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 void addBasicNadeTitleAttributes(nsIDOMElement nodeTitle) {
- nodeTitle.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- STYLE_CLASS_FOR_NODE_TITLE);
+
+ boolean showLinesValue = getShowLinesAttr(sourceElement);
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) expandedIconCell
+ .getChildNodes().item(0).queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ 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)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ 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)) {
+ nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes()
+ .item(1).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes()
+ .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ 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,
- nsIDOMDocument visualDocument, nsIDOMNode 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)) {
- nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode.getChildNodes()
- . item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) expandedIconCell.getChildNodes()
- .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- } else if (NODE_ICON_ATTR_NAME.equals(name)
- && !isLastElement(visualNode.getParentNode(), visualNode)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- 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)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, "");
- }
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorChild(Node sourceNode) {
+ Node parentNode = sourceNode.getParentNode();
+ if (!(parentNode instanceof Element)) {
+ return true;
}
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument, nsIDOMNode 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)) {
- nsIDOMElement expandedIconCell = (nsIDOMElement) visualNode.getChildNodes()
- .item(0).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) expandedIconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- 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)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- 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);
+ String treeNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = sourceNode.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ if (parentNode.getNodeName().equals(treeNodesAdaptorName)
+ || parentNode.getNodeName().equals(
+ treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
- } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
- && isLastElement(sourceElement.getParentNode(), sourceElement)) {
- nsIDOMElement iconCell = (nsIDOMElement) visualNode.getChildNodes().item(1)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMElement img = (nsIDOMElement) iconCell.getChildNodes().item(0)
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- 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);
- }
+ /**
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastElement(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.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ lastElement = el;
+ }
+ }
+ return sourceNode.equals(lastElement);
+ }
- /**
- *
- * @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);
+ /**
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastElement(nsIDOMNode sourceNode) {
+ nsIDOMNode parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
}
-
- /**
- *
- * @param parentTree
- * @param currentNode
- * @return
- */
- private boolean isLastElement(nsIDOMNode parentTree, nsIDOMNode currentNode) {
- nsIDOMNodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + ":"
- + RichFacesTreeTemplate.TREE_NODE_NAME;
- nsIDOMNode lastElement = null;
- nsIDOMNode 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);
+ nsIDOMNodeList 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;
+ nsIDOMNode lastElement = null;
+ nsIDOMNode el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().equals(treeNodeName)
+ || el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ lastElement = el;
+ }
}
+ return sourceNode.equals(lastElement);
+ }
- /**
- * Adds basic attributes to tree
- *
- * @param img
- */
+ /**
+ * Adds basic attributes to tree
+ *
+ * @param img
+ */
- private void addBasicAttributesToPicture(nsIDOMElement img) {
- img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
+ private void addBasicAttributesToPicture(nsIDOMElement img) {
+ img.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
+ }
+
+ /**
+ * Set attributes for treeNode
+ *
+ * @param table
+ */
+ private void addBasicTreeNodeAttributes(nsIDOMElement 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 isLastElementAfterAdaptor(Node sourceNode) {
+ Node nodeAdaptor = sourceNode.getParentNode();
+ if (!(nodeAdaptor instanceof Element)) {
+ return true;
+ }
+ return isLastElement(nodeAdaptor);
+ }
}
Copied:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
(from rev 3575,
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java)
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
(rev 0)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-09-27
00:53:13 UTC (rev 3833)
@@ -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.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+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,
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement 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,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement 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)) {
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ nsIDOMElement 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(nsIDOMElement 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");
+ }
+}
Deleted:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java 2007-09-27
00:50:58 UTC (rev 3832)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesTemplate.java 2007-09-27
00:53:13 UTC (rev 3833)
@@ -1,16 +0,0 @@
-package org.jboss.tools.jsf.vpe.richfaces.template;
-
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
-import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.w3c.dom.Node;
-
-public class RichFacesTreeNodesTemplate extends VpeAbstractTemplate {
-
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- return null;
- }
-
-}
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-09-27
00:50:58 UTC (rev 3832)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-09-27
00:53:13 UTC (rev 3833)
@@ -7,7 +7,7 @@
*
* 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;
@@ -23,391 +23,292 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+
/**
* 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,
- nsIDOMDocument visualDocument) {
- // sets css for tree on page
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "tree");
- nsIDOMElement visualElement = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- nsIDOMElement treeRow = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- nsIDOMElement 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,
+ nsIDOMDocument visualDocument) {
+ // sets css for tree on page
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "tree");
+ nsIDOMElement 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(nsIDOMElement 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(nsIDOMElement 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(nsIDOMNode node, String attrName, String attrValue) {
- if (!(node instanceof nsIDOMElement)) {
- return;
- }
- if (node.getNodeName().equalsIgnoreCase(
- HtmlComponentUtil.HTML_TAG_TABLE)) {
- ((nsIDOMElement)node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).setAttribute(attrName,
attrValue);
- }
- nsIDOMNodeList 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,
- nsIDOMDocument visualDocument, VpeCreationData data) {
- super.validate(pageContext, sourceNode, visualDocument, data);
- data.getChildrenInfoList().get(0);
- 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,
- nsIDOMNode node) {
- if (!(node instanceof nsIDOMElement)) {
- return;
- }
- if (node.getNodeName().equalsIgnoreCase(HtmlComponentUtil.HTML_TAG_IMG)) {
- String srcAttr = ((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(RichFacesTreeNodeTemplate.ICON_PARAM_NAME);
- if (RichFacesTreeNodeTemplate.DEFAULT_ICON_EXPANDED_PARAM_VALUE
- .equals(srcAttr)) {
- setImgForNode(pageContex, sourceNode, (nsIDOMElement)
node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- 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, (nsIDOMElement)
node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- 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, (nsIDOMElement)
node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME,
- RichFacesTreeNodeTemplate.ICON_LEAF_WITH_LINES,
- RichFacesTreeNodeTemplate.ICON_LEAF_WITHOUT_LINES);
- }
- }
- nsIDOMNodeList 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(nsIDOMNode node, String attrName,
+ String attrValue) {
+ if (!(node instanceof nsIDOMElement)) {
+ return;
}
-
- /**
- * Sets icon fro node
- *
- * @param img
- * @param sourceNode
- */
- private void setImgForNode(VpePageContext pageContext, Element sourceNode,
- nsIDOMElement 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)) {
+ ((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .setAttribute(attrName, attrValue);
}
-
- /**
- * Revert tree elements in right order.
- *
- * @param node
- */
- private void revertTableRows(nsIDOMNode node) {
-
- //if (!(node instanceof nsIDOMElement)) {
- // return;
- //}
-
- nsIDOMNodeList list = node.getChildNodes();
- if (node.getNodeName().equalsIgnoreCase(
- HtmlComponentUtil.HTML_TAG_TABLE)
- && list.getLength() == 2) {
- nsIDOMNode tr1 = list.item(0);
- nsIDOMNode tr2 = list.item(1);
- node.removeChild(tr1);
- node.removeChild(tr2);
- node.appendChild(tr2);
- node.appendChild(tr1);
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- revertTableRows(list2.item(i));
- }
+ nsIDOMNodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ setAttributeToTree(list2.item(i), attrName, attrValue);
}
+ }
- /**
- *
- * Function for parsing tree by tree nodes;
- *
- * @param pageContext
- * @param sourceNode
- * @param visualDocument
- * @return
- */
- public void parseTree(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
- nsIDOMElement cell) {
- // work arroud, becouse getChielsByName returns always null;
- NodeList nodeList = sourceNode.getChildNodes();
- Element element = null;
- nsIDOMElement tree = null;
- nsIDOMElement childTree = null;
- nsIDOMElement 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) {
+ /**
+ * 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,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+ super.validate(pageContext, sourceNode, visualDocument, data);
+ revertTableRows(data.getNode());
+ }
- tree = createBasicTree(visualDocument);
- vpeChildrenInfo = new VpeChildrenInfo(tree);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- childLast = tree;
- continue;
- } else if (childTree == null) {
+ /**
+ * Revert tree elements in right order.
+ *
+ * @param node
+ */
+ private void revertTableRows(nsIDOMNode node) {
- childTree = createBasicTree(visualDocument);
- appendChildTree(childLast, childTree, visualDocument);
- vpeChildrenInfo = new VpeChildrenInfo(childTree);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- childLast = childTree;
- continue;
- }
- }
- }
- if (tree != null) {
- cell.appendChild(tree);
- }
+ nsIDOMNodeList list = node.getChildNodes();
+ if (node.getNodeName().equalsIgnoreCase(HtmlComponentUtil.HTML_TAG_DIV)
+ && list.getLength() == 2) {
+ nsIDOMNode table1 = list.item(0);
+ nsIDOMNode table2 = list.item(1);
+ node.removeChild(table1);
+ node.removeChild(table2);
+ node.appendChild(table2);
+ node.appendChild(table1);
}
-
- /**
- * Appends child node to tree
- *
- * @param parentNode
- * @param childNode
- * @param visualDocument
- */
- private void appendChildTree(nsIDOMElement parentNode, nsIDOMElement childNode,
- nsIDOMDocument visualDocument) {
- nsIDOMElement tr = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TR);
- nsIDOMElement emptyCell = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TD);
- nsIDOMElement 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);
+ nsIDOMNodeList 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,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement parentDiv) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ nsIDOMElement div = null;
+ nsIDOMElement childTree = null;
+ nsIDOMElement 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) {
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMNode 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));
- ((nsIDOMElement)
visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)).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);
+ vpeChildrenInfo = new VpeChildrenInfo(parentDiv);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ div = createBasicTree(visualDocument);
+ childLast = parentDiv;
+ continue;
+ } else if (childTree == null) {
+
+ vpeChildrenInfo = new VpeChildrenInfo(div);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ childLast.appendChild(div);
+ childLast = div;
+ div = createBasicTree(visualDocument);
+ continue;
}
- }
-
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument, nsIDOMNode 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);
- }
+ }
}
-
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
- */
- private nsIDOMElement createBasicTree(nsIDOMDocument visualDocument) {
- // create table
- nsIDOMElement tree = visualDocument
- .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- addBasicTreeAttributes(tree);
- return tree;
+ }
+
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement 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;
+ }
- /**
- * Sets some attributes which necessary for displaying table as tree
- *
- * @param tree
- */
- private void addBasicTreeAttributes(nsIDOMElement 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);
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode 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, nsIDOMDocument visualDocument,
+ nsIDOMNode 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 nsIDOMElement createBasicTree(nsIDOMDocument visualDocument) {
+
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tree-h-ic-div");
+ return div;
+ }
+
}
Modified:
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-27
00:50:58 UTC (rev 3832)
+++
branches/jbosstools_xulrunner/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-09-27
00:53:13 UTC (rev 3833)
@@ -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,8 +74,33 @@
<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: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.RichFacesRecursiveTreeNodesAdaptorTemplate">
+ <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"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodeTemplate">
@@ -592,6 +619,23 @@
<span style="display:none">
</span>
</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:pseudoContent defaultText="yes" />
+ </vpe:template>
</vpe:tag>
</vpe:templates>
\ No newline at end of file