Author: dmaliarevich
Date: 2011-09-12 07:57:46 -0400 (Mon, 12 Sep 2011)
New Revision: 34628
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml
Log:
https://issues.jboss.org/browse/JBIDE-8950 , treeModelAdaptors implementation was added,
with tests.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java 2011-09-12
10:48:36 UTC (rev 34627)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java 2011-09-12
11:57:46 UTC (rev 34628)
@@ -32,657 +32,603 @@
public abstract class RichFacesAbstractTreeTemplate extends VpeAbstractTemplate {
- public static final String TREE = "tree"; //$NON-NLS-1$
- public static final String TREE_NODE = "treeNode"; //$NON-NLS-1$
- public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor";
//$NON-NLS-1$
- public static final String RECURSIVE_TREE_NODES_ADAPTOR =
"recursiveTreeNodesAdaptor"; //$NON-NLS-1$
- public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines";
//$NON-NLS-1$
+ public static final String TREE = "tree"; //$NON-NLS-1$
+ public static final String TREE_NODE = "treeNode"; //$NON-NLS-1$
+ public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor";
//$NON-NLS-1$
+ public static final String RECURSIVE_TREE_NODES_ADAPTOR =
"recursiveTreeNodesAdaptor"; //$NON-NLS-1$
+ public static final String TREE_MODEL_ADAPTOR = "treeModelAdaptor";
//$NON-NLS-1$
+ public static final String TREE_MODEL_RECURSIVE_ADAPTOR =
"treeModelRecursiveAdaptor"; //$NON-NLS-1$
+ public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines";
//$NON-NLS-1$
+ public static final String NODES_NAME = "nodes"; //$NON-NLS-1$
- public static final String DEFAULT_ICON_PARAM_VALUE = "DEFAULT_ICON_PARAM";
//$NON-NLS-1$
- public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam";
//$NON-NLS-1$
- public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE =
"DEFAULT_ICON_EXPANDED_PARAM"; //$NON-NLS-1$
- public static final String UNDEFINED_ICON = "/tree/unresolved.gif";
//$NON-NLS-1$
- public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf";
//$NON-NLS-1$
- public static final String ICON_NODE_WITH_LINES =
"/tree/iconNodeWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_NODE_WITH_LINE =
"/tree/iconNodeWithLine.gif"; //$NON-NLS-1$
- public static final String ICON_EXPANDED_WITH_LINES =
"/tree/iconCollapsedWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif";
//$NON-NLS-1$
- public static final String ICON_EXPANDED_WITHOUT_LINES =
"/tree/iconCollapsed.gif"; //$NON-NLS-1$
- public static final String ICON_NOT_EXPANDED_WITH_LINES =
"/tree/iconNotCollapsedWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_NOT_EXPANDED_WITH_ALL_LINES =
"/tree/iconNotCollapsedWithAllLines.gif"; //$NON-NLS-1$
- public static final String ICON_NOT_EXPANDED_WITHOUT_LINES =
"/tree/iconNotCollapsed.gif"; //$NON-NLS-1$
- public static final String ICON_EXPANDED_ADAPTER_WITH_LINES =
"/tree/iconClosedNodeWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_EXPANDED_ADAPTER_WITHOUT_LINES =
"/tree/iconClosedNode.gif"; //$NON-NLS-1$
- public static final String ICON_LEAF_WITH_LINES =
"/tree/iconLeafWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_RIGHT_LINE = "/tree/rightLine.gif";
//$NON-NLS-1$
- public static final String ICON_LEFT_LINE = "/tree/leftLine.gif";
//$NON-NLS-1$
- public static final String ICON_LINE = "/tree/line.gif"; //$NON-NLS-1$
- public static final String ICON_LEAF_WITHOUT_LINES = "/tree/iconLeaf.gif";
//$NON-NLS-1$
- protected static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME =
"treePictureStyle"; //$NON-NLS-1$
- protected static final String STYLE_CLASS_FOR_NODE_TITLE =
"treeNodeNameStyle"; //$NON-NLS-1$
- protected static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME =
"nodeClass"; //$NON-NLS-1$
- protected static final String NODE_ICON_EXPANDED_ATTR_NAME =
"iconExpanded"; //$NON-NLS-1$
- protected static final String NODE_ICON_ATTR_NAME = "icon"; //$NON-NLS-1$
- protected static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
//$NON-NLS-1$
- protected static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
//$NON-NLS-1$
- protected static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
//$NON-NLS-1$
- protected static final String NODE_LINES_STYLE = "background-position: center;
background-repeat: repeat-y;"; //$NON-NLS-1$
+ public static final String DEFAULT_ICON_PARAM_VALUE = "DEFAULT_ICON_PARAM";
//$NON-NLS-1$
+ public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam";
//$NON-NLS-1$
+ public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE =
"DEFAULT_ICON_EXPANDED_PARAM"; //$NON-NLS-1$
+ public static final String UNDEFINED_ICON = "/tree/unresolved.gif";
//$NON-NLS-1$
+ public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf";
//$NON-NLS-1$
+ public static final String ICON_NODE_WITH_LINES =
"/tree/iconNodeWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NODE_WITH_LINE = "/tree/iconNodeWithLine.gif";
//$NON-NLS-1$
+ public static final String ICON_EXPANDED_WITH_LINES =
"/tree/iconCollapsedWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif";
//$NON-NLS-1$
+ public static final String ICON_EXPANDED_WITHOUT_LINES =
"/tree/iconCollapsed.gif"; //$NON-NLS-1$
+ public static final String ICON_NOT_EXPANDED_WITH_LINES =
"/tree/iconNotCollapsedWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NOT_EXPANDED_WITH_ALL_LINES =
"/tree/iconNotCollapsedWithAllLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NOT_EXPANDED_WITHOUT_LINES =
"/tree/iconNotCollapsed.gif"; //$NON-NLS-1$
+ public static final String ICON_EXPANDED_ADAPTER_WITH_LINES =
"/tree/iconClosedNodeWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_EXPANDED_ADAPTER_WITHOUT_LINES =
"/tree/iconClosedNode.gif"; //$NON-NLS-1$
+ public static final String ICON_LEAF_WITH_LINES =
"/tree/iconLeafWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_RIGHT_LINE = "/tree/rightLine.gif";
//$NON-NLS-1$
+ public static final String ICON_LEFT_LINE = "/tree/leftLine.gif";
//$NON-NLS-1$
+ public static final String ICON_LINE = "/tree/line.gif"; //$NON-NLS-1$
+ public static final String ICON_LEAF_WITHOUT_LINES = "/tree/iconLeaf.gif";
//$NON-NLS-1$
+ protected static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME =
"treePictureStyle"; //$NON-NLS-1$
+ protected static final String STYLE_CLASS_FOR_NODE_TITLE =
"treeNodeNameStyle"; //$NON-NLS-1$
+ protected static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME = "nodeClass";
//$NON-NLS-1$
+ protected static final String NODE_ICON_EXPANDED_ATTR_NAME = "iconExpanded";
//$NON-NLS-1$
+ protected static final String NODE_ICON_ATTR_NAME = "icon"; //$NON-NLS-1$
+ protected static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px";
//$NON-NLS-1$
+ protected static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px";
//$NON-NLS-1$
+ protected static final String TREE_TABLE_ATR_BORDER_VALUE = "0px";
//$NON-NLS-1$
+ protected static final String NODE_LINES_STYLE = "background-position: center;
background-repeat: repeat-y;"; //$NON-NLS-1$
- /**
- * Get showConnectingLines attribute
- *
- * @param sourceNode
- * @return
- */
- protected boolean getShowLinesAttr(Node sourceNode) {
- String treeName = sourceNode.getPrefix() + Constants.COLON + TREE;
- do {
- sourceNode = sourceNode.getParentNode();
- if (!(sourceNode instanceof Element)) {
- return true;
- }
- } while (!sourceNode.getNodeName().equals(treeName));
-
- String showLinesParam = ((Element) sourceNode)
- .getAttribute(SHOW_LINES_ATTR_NAME);
-
- boolean showLinesValue = true;
- if (showLinesParam != null
- && Constants.FALSE.equalsIgnoreCase(showLinesParam)) {
- showLinesValue = false;
+ /**
+ * Get showConnectingLines attribute
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean getShowLinesAttr(Node sourceNode) {
+ String treeName = sourceNode.getPrefix() + Constants.COLON + TREE;
+ do {
+ sourceNode = sourceNode.getParentNode();
+ if (!(sourceNode instanceof Element)) {
+ return true;
+ }
+ } while (!sourceNode.getNodeName().equals(treeName));
+ String showLinesParam = ((Element) sourceNode)
+ .getAttribute(SHOW_LINES_ATTR_NAME);
+ boolean showLinesValue = true;
+ if (showLinesParam != null
+ && Constants.FALSE.equalsIgnoreCase(showLinesParam)) {
+ showLinesValue = false;
+ }
+ return showLinesValue;
}
- return showLinesValue;
- }
- /**
- * Is adapter between treeNodes
- *
- * @param sourceNode
- * @return
- */
- protected boolean isAdapterBetweenNodes(Node sourceNode) {
- Node parentNode = sourceNode.getParentNode();
- NodeList childs = parentNode.getChildNodes();
- Node beforeAdapterNode = null;
- Node afterAdapterNode = null;
- Node adapterNode = null;
- String treeNodeName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODE;
- for (int i = 0; i < childs.getLength(); i++) {
- Node el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
- if (el.equals(sourceNode)) {
- adapterNode = el;
- } else {
- if (el.getNodeName().equals(treeNodeName)) {
- if (adapterNode == null) {
- beforeAdapterNode = el;
- } else {
- afterAdapterNode = el;
- }
+ /**
+ * Is adapter between treeNodes
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isAdapterBetweenNodes(Node sourceNode) {
+ Node parentNode = sourceNode.getParentNode();
+ NodeList childs = parentNode.getChildNodes();
+ Node beforeAdapterNode = null;
+ Node afterAdapterNode = null;
+ Node adapterNode = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ Node el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (el.equals(sourceNode)) {
+ adapterNode = el;
+ } else {
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)) {
+ if (adapterNode == null) {
+ beforeAdapterNode = el;
+ } else {
+ afterAdapterNode = el;
+ }
+ }
+ }
}
-
- }
-
+ if (beforeAdapterNode != null && afterAdapterNode != null) {
+ return true;
+ }
+ return false;
}
- if (beforeAdapterNode != null && afterAdapterNode != null) {
- return true;
- }
- return false;
- }
+ /**
+ * Next element is Adaptor
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isHasNextAdaptorElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ Node lastElement = null;
+ Node el = null;
- /**
- * Next element is Adaptor
- *
- * @param sourceNode
- * @return
- */
- protected boolean isHasNextAdaptorElement(Node sourceNode) {
- Node parentTree = sourceNode.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (lastElement != null) {
+ break;
+ }
+ if (sourceNode.equals(el)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ return true;
+ }
+ return false;
}
- NodeList childs = parentTree.getChildNodes();
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- Node lastElement = null;
- Node el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
+ /**
+ * Has Next element
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isHasNextParentAdaptorElement(Node sourceNode) {
+ Node tree = sourceNode.getParentNode();
+ if (!(tree instanceof Element)) {
+ return true;
+ }
+ Node parentTree = tree.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ Node lastElement = null;
+ Node el = null;
- if (lastElement != null) {
- break;
- }
-
- if (sourceNode.equals(el)) {
- lastElement = el;
- }
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (lastElement != null) {
+ break;
+ }
+ if (el.equals(tree)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ return true;
+ }
+ return false;
}
- if (el.getNodeName().equals(treeNodesAdaptorName)
- || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- return true;
- }
- return false;
- }
- /**
- * Has Next element
- *
- * @param sourceNode
- * @return
- */
- protected boolean isHasNextParentAdaptorElement(Node sourceNode) {
- Node tree = sourceNode.getParentNode();
- if (!(tree instanceof Element)) {
- return true;
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isHasParentAdapter(Node sourceNode) {
+ Node node = sourceNode.getParentNode();
+ if (node.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || node.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || node.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || node.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ return true;
+ }
+ return false;
}
- Node parentTree = tree.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
- }
- NodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- Node lastElement = null;
- Node el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
-
- if (lastElement != null) {
- break;
- }
- if (el.equals(tree)) {
- lastElement = el;
- }
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ protected void parseTree(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement parentElement) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ int lenght = nodeList.getLength();
+ 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().endsWith(Constants.COLON + TREE_NODE)
+ || element.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR))
{
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ } else if (element.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ }
+ }
}
- if (el.getNodeName().equals(treeNodeName)
- || el.getNodeName().equals(treeNodesAdaptorName)
- || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- return true;
- }
- return false;
- }
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ protected void createBasicTree(VpePageContext pageContext,
+ nsIDOMDocument visualDocument, nsIDOMElement treeRow,
+ Node sourceNode, VpeCreationData vpeCreationData) {
+ // creates icon node
+ String backgroundLinePath = null;
- /**
- *
- * @param sourceNode
- * @return
- */
- protected boolean isHasParentAdapter(Node sourceNode) {
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String recursiveTreeNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- Node node = sourceNode.getParentNode();
- if (node.getNodeName().equals(treeNodesAdaptorName)
- || node.getNodeName().equals(recursiveTreeNodesAdaptorName)) {
- return true;
- }
- return false;
- }
+ boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
+ nsIDOMElement iconNode = visualDocument.createElement(HTML.TAG_TD);
+ // creates icon with status of node(collapsed or not) node
+ nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
+ // sets icon node
+ if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
+ && !isHasNextAdaptorElement(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
+ : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINE
+ : ICON_NODE_WITHOUT_LINES);
+ } else if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
+ && isHasNextAdaptorElement(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
+ : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ if (showLinesValue) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LEFT_LINE;
+ iconNode.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
+ + NODE_LINES_STYLE);
+ }
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
(isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)))
+ || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))
+ || (isAdaptorChild(sourceNode) && isOnlyOneNodeInAdaptor(sourceNode))) {
- /**
- *
- * Function for parsing tree by tree nodes;
- *
- * @param pageContext
- * @param sourceNode
- * @param visualDocument
- * @return
- */
- protected 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() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String recursiveTreeNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- VpeChildrenInfo vpeChildrenInfo = null;
- for (int i = 0; i < lenght; i++) {
- if (!(nodeList.item(i) instanceof Element)) {
- continue;
- }
- element = (Element) nodeList.item(i);
- if (element.getNodeName().equals(treeNodeName)
- || element.getNodeName().equals(
- recursiveTreeNodesAdaptorName)) {
- vpeChildrenInfo = new VpeChildrenInfo(parentElement);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- } else if (element.getNodeName().equals(treeNodesAdaptorName)) {
- vpeChildrenInfo = new VpeChildrenInfo(parentElement);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- }
- }
- }
+ if (isAdaptorChild(sourceNode)
+ && isOnlyOneNodeInAdaptor(sourceNode)
+ && !isLastElementAfterAdaptor(sourceNode)
+ && isHasNextParentAdaptorElement(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LINE;
+ setAttributeForPictureNode(
+ pageContext,
+ visualDocument,
+ (Element) sourceNode,
+ td1,
+ NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_NOT_EXPANDED_WITH_ALL_LINES
+ : ICON_NOT_EXPANDED_WITHOUT_LINES);
+ } else {
+ 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);
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
- */
- protected void createBasicTree(VpePageContext pageContext,
- nsIDOMDocument visualDocument, nsIDOMElement treeRow,
- Node sourceNode, VpeCreationData vpeCreationData) {
- // creates icon node
- String backgroundLinePath = null;
+ if (showLinesValue) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LEFT_LINE;
+ iconNode.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
+ + NODE_LINES_STYLE);
+ }
- boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
- nsIDOMElement iconNode = visualDocument.createElement(HTML.TAG_TD);
- // creates icon with status of node(collapsed or not) node
- nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
- // sets icon node
- if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
- && !isHasNextAdaptorElement(sourceNode)) {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LINE;
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
- : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINE
- : ICON_NODE_WITHOUT_LINES);
- } else if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
- && isHasNextAdaptorElement(sourceNode)) {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LINE;
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
- : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- if (showLinesValue) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LEFT_LINE;
- iconNode.setAttribute(HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
- + NODE_LINES_STYLE);
- }
- } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
(isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)))
- || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))
- || (isAdaptorChild(sourceNode) && isOnlyOneNodeInAdaptor(sourceNode))) {
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ }
- if (isAdaptorChild(sourceNode)
- && isOnlyOneNodeInAdaptor(sourceNode)
- && !isLastElementAfterAdaptor(sourceNode)
- && isHasNextParentAdaptorElement(sourceNode)) {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LINE;
- setAttributeForPictureNode(
- pageContext,
- visualDocument,
- (Element) sourceNode,
- td1,
- NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_NOT_EXPANDED_WITH_ALL_LINES
- : ICON_NOT_EXPANDED_WITHOUT_LINES);
- } else {
- 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);
- }
+ if (showLinesValue) {
+ td1.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + backgroundLinePath //$NON-NLS-1$
+ + "); " + NODE_LINES_STYLE); //$NON-NLS-1$
+ }
+ treeRow.appendChild(td1);
+ treeRow.appendChild(iconNode);
+ // creates Tree Node Name Message
+ nsIDOMElement nodeTitle = visualDocument.createElement(HTML.TAG_TD);
+ addBasicNodeTitleAttributes(nodeTitle);
+ // Create mapping to Encode body
+ if (sourceNode.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || sourceNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR))
{
+ Element sourceElement = (Element) sourceNode;
+ String nodesAttrValue = sourceElement.hasAttribute(NODES_NAME) ?
sourceElement.getAttribute(NODES_NAME) : Constants.EMPTY;
+ nsIDOMElement textContainer =
VisualDomUtil.createBorderlessContainer(visualDocument);
+ nsIDOMText text = visualDocument.createTextNode(nodesAttrValue);
+ textContainer.appendChild(text);
+ nodeTitle.appendChild(textContainer);
+ } else {
+ VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+ // Create mapping to Encode body
+ List<Node> children = ComponentUtil.getChildren((Element) sourceNode, true);
+ for (Node child : children) {
+ tdInfo.addSourceChild(child);
+ }
+ 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);
- } 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(HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
- + NODE_LINES_STYLE);
- }
-
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
+ /**
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isLastElement(nsIDOMNode sourceNode) {
+ nsIDOMNode parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ nsIDOMNodeList childs = parentTree.getChildNodes();
+ nsIDOMNode lastElement = null;
+ nsIDOMNode el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ lastElement = el;
+ }
+ }
+ return sourceNode.equals(lastElement);
}
- if (showLinesValue) {
- td1.setAttribute(HTML.ATTR_STYLE,
- "background-image: url(file://" + backgroundLinePath //$NON-NLS-1$
- + "); " + NODE_LINES_STYLE); //$NON-NLS-1$
+ /**
+ * Node is Adaptor child
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorChild(Node sourceNode) {
+ Node parentNode = sourceNode.getParentNode();
+ if (!(parentNode instanceof Element)) {
+ return true;
+ }
+ if (parentNode.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || parentNode.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || parentNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || parentNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR))
{
+ return true;
+ }
+ return false;
}
- treeRow.appendChild(td1);
- treeRow.appendChild(iconNode);
- // creates Tree Node Name Message
- nsIDOMElement nodeTitle = visualDocument.createElement(HTML.TAG_TD);
- addBasicNodeTitleAttributes(nodeTitle);
- // Create mapping to Encode body
- String treeRecursiveNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- if (sourceNode.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- Element sourceElement = (Element) sourceNode;
- String nodes =
sourceElement.hasAttribute(RichFacesRecursiveTreeNodesAdaptorTemplate.NODES_NAME) ?
- sourceElement.getAttribute(RichFacesRecursiveTreeNodesAdaptorTemplate.NODES_NAME)
: Constants.EMPTY;
- nsIDOMElement textContainer = VisualDomUtil
- .createBorderlessContainer(visualDocument);
- nsIDOMText text = visualDocument.createTextNode(nodes);
- textContainer.appendChild(text);
- nodeTitle.appendChild(textContainer);
- } else {
- VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
- // Create mapping to Encode body
- List<Node> children = ComponentUtil.getChildren(
- (Element) sourceNode, false);
- for (Node child : children) {
- tdInfo.addSourceChild(child);
- }
- vpeCreationData.addChildrenInfo(tdInfo);
+ /**
+ * Node is last element
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isLastElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ Node lastElement = null;
+ Node el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ lastElement = el;
+ }
+ }
+ return sourceNode.equals(lastElement);
}
- treeRow.appendChild(nodeTitle);
- }
+ /**
+ * Adds basic attributes to tree
+ *
+ * @param img
+ */
- /**
- *
- * @param parentTree
- * @param sourceNode
- * @return
- */
- protected boolean isLastElement(nsIDOMNode sourceNode) {
- nsIDOMNode parentTree = sourceNode.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
+ private void addBasicAttributesToPicture(nsIDOMElement img) {
+ img.setAttribute(HTML.ATTR_CLASS, TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
}
- nsIDOMNodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_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);
- }
- /**
- * Node is Adaptor child
- *
- * @param sourceNode
- * @return
- */
- private boolean isAdaptorChild(Node sourceNode) {
- Node parentNode = sourceNode.getParentNode();
- if (!(parentNode instanceof Element)) {
- return true;
+ /**
+ * Sets attributes for no node title name
+ *
+ * @param nodeTitle
+ */
+ private void addBasicNodeTitleAttributes(nsIDOMElement nodeTitle) {
+ nodeTitle.setAttribute(HTML.ATTR_CLASS, STYLE_CLASS_FOR_NODE_TITLE);
}
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- if (parentNode.getNodeName().equals(treeNodesAdaptorName)
- || parentNode.getNodeName().equals(
- treeRecursiveNodesAdaptorName)) {
- return true;
+ /**
+ * 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"); //$NON-NLS-1$
+ }
+ nsIDOMElement img = visualDocument.createElement(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, Constants.EMPTY);
+ }
+ // 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);
+ }
}
- return false;
- }
- /**
- * Node is last element
- *
- * @param parentTree
- * @param sourceNode
- * @return
- */
- protected boolean isLastElement(Node sourceNode) {
- Node parentTree = sourceNode.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
+ private boolean isOnlyOneNodeInAdaptor(Node sourceNode) {
+ Node parent = sourceNode.getParentNode();
+ NodeList list = parent.getChildNodes();
+ Node currentNode = null;
+ for (int i = 0; i < list.getLength(); i++) {
+ Node el = list.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)) {
+ if (currentNode == null) {
+ currentNode = el;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ return true;
}
- NodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_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);
- }
- /**
- * Adds basic attributes to tree
- *
- * @param img
- */
-
- private void addBasicAttributesToPicture(nsIDOMElement img) {
- img.setAttribute(HTML.ATTR_CLASS, TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
- }
-
- /**
- * Sets attributes for no node title name
- *
- * @param nodeTitle
- */
- private void addBasicNodeTitleAttributes(nsIDOMElement nodeTitle) {
- nodeTitle.setAttribute(HTML.ATTR_CLASS, STYLE_CLASS_FOR_NODE_TITLE);
- }
-
- /**
- * 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"); //$NON-NLS-1$
+ /**
+ * Node has element after adaptor
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastElementAfterAdaptor(Node sourceNode) {
+ Node nodeAdaptor = sourceNode.getParentNode();
+ if (!(nodeAdaptor instanceof Element)) {
+ return true;
+ }
+ return isLastElement(nodeAdaptor);
}
- nsIDOMElement img = visualDocument.createElement(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, Constants.EMPTY);
- }
- // 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);
- }
- }
- private boolean isOnlyOneNodeInAdaptor(Node sourceNode) {
- Node parent = sourceNode.getParentNode();
- NodeList list = parent.getChildNodes();
- Node currentNode = null;
- String treeNodeName = sourceNode.getPrefix() + Constants.COLON
- + RichFacesTreeTemplate.TREE_NODE_NAME;
- for (int i = 0; i < list.getLength(); i++) {
- Node el = list.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
- if (el.getNodeName().equals(treeNodeName)) {
- if (currentNode == null) {
- currentNode = el;
- } else {
- return false;
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorInTree(Node sourceNode) {
+ Node adaptorNode = sourceNode.getParentNode();
+ if (!(adaptorNode instanceof Element)) {
+ return true;
}
- } else {
+ if (adaptorNode.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || adaptorNode.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || adaptorNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || adaptorNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR))
{
+ Node treeNode = adaptorNode.getParentNode();
+ if (treeNode.getNodeName().endsWith(Constants.COLON + TREE)) {
+ return true;
+ }
+ }
return false;
- }
}
- return true;
- }
- /**
- * Node has element after adaptor
- *
- * @param sourceNode
- * @return
- */
- private boolean isLastElementAfterAdaptor(Node sourceNode) {
- Node nodeAdaptor = sourceNode.getParentNode();
- if (!(nodeAdaptor instanceof Element)) {
- return true;
+ /**
+ * Set attributes for treeNode
+ *
+ * @param table
+ */
+ protected void addBasicTreeNodeAttributes(nsIDOMElement table) {
+ if (table == null) {
+ return;
+ }
+ table.setAttribute(HTML.ATTR_CELLPADDING,
+ TREE_TABLE_ATR_CELLPADDING_VALUE);
+ table.setAttribute(HTML.ATTR_CELLSPACING,
+ TREE_TABLE_ATR_CELLSPACING_VALUE);
+ table.setAttribute(HTML.ATTR_BORDER, TREE_TABLE_ATR_BORDER_VALUE);
+ table.setAttribute(HTML.ATTR_CLASS, "dr-tree-full-width"); //$NON-NLS-1$
}
- return isLastElement(nodeAdaptor);
- }
- /**
- *
- * @param sourceNode
- * @return
- */
- private boolean isAdaptorInTree(Node sourceNode) {
- Node adaptorNode = sourceNode.getParentNode();
- if (!(adaptorNode instanceof Element)) {
- return true;
- }
- String treeNodesAdaptorName = adaptorNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = adaptorNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- if (adaptorNode.getNodeName().equals(treeNodesAdaptorName)
- || adaptorNode.getNodeName().equals(
- treeRecursiveNodesAdaptorName)) {
- Node treeNode = adaptorNode.getParentNode();
- String treeName = treeNode.getPrefix() + Constants.COLON + TREE;
- if (treeNode.getNodeName().equals(treeName)) {
- return true;
- }
- }
- return false;
- }
+ /**
+ * Checks for attributes for node and if such exist convert it's to html
+ * atributes.
+ *
+ * @param sourceNode
+ * @param tableRow
+ */
+ protected void addAttributeToTableNode(Element sourceNode,
+ nsIDOMElement tableRow) {
- /**
- * Set attributes for treeNode
- *
- * @param table
- */
- protected void addBasicTreeNodeAttributes(nsIDOMElement table) {
- if (table == null) {
- return;
+ if (sourceNode.hasAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME)) {
+ tableRow.setAttribute(HTML.ATTR_CLASS,
+ sourceNode.getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME));
+ }
}
- table.setAttribute(HTML.ATTR_CELLPADDING,
- TREE_TABLE_ATR_CELLPADDING_VALUE);
- table.setAttribute(HTML.ATTR_CELLSPACING,
- TREE_TABLE_ATR_CELLSPACING_VALUE);
- table.setAttribute(HTML.ATTR_BORDER, TREE_TABLE_ATR_BORDER_VALUE);
- table.setAttribute(HTML.ATTR_CLASS, "dr-tree-full-width"); //$NON-NLS-1$
- }
- /**
- * Checks for attributes for node and if such exist convert it's to html
- * atributes.
- *
- * @param sourceNode
- * @param tableRow
- */
- protected void addAttributeToTableNode(Element sourceNode,
- nsIDOMElement tableRow) {
-
- if (sourceNode.hasAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME)) {
- tableRow.setAttribute(HTML.ATTR_CLASS,
sourceNode.getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME));
- }
- }
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2011-09-12
10:48:36 UTC (rev 34627)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2011-09-12
11:57:46 UTC (rev 34628)
@@ -28,84 +28,71 @@
* @author dsakovich(a)exadel.com
*
*/
-public class RichFacesRecursiveTreeNodesAdaptorTemplate extends
- RichFacesAbstractTreeTemplate {
+public class RichFacesRecursiveTreeNodesAdaptorTemplate extends
RichFacesAbstractTreeTemplate {
- private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
- public static final String ICON_DIV_LINE = "/tree/divLine.gif";
//$NON-NLS-1$
- private static final String ADAPTER_LINES_STYLE = "background-position: left
center; background-repeat: repeat-y;"; //$NON-NLS-1$
- public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
- public static final String NODES_NAME = "nodes"; //$NON-NLS-1$
+ private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
+ public static final String ICON_DIV_LINE = "/tree/divLine.gif"; //$NON-NLS-1$
+ private static final String ADAPTER_LINES_STYLE = "background-position: left
center; background-repeat: repeat-y;"; //$NON-NLS-1$
+ public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- if (isEmptyNode(sourceNode)) {
- nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML.TAG_TABLE);
- addBasicTreeNodeAttributes(visualElement);
- div.appendChild(visualElement);
- nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ VpeCreationData vpeCreationData = null;
+ if (isEmptyNode(sourceNode)) {
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ nsIDOMElement visualElement = visualDocument.createElement(HTML.TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+ div.appendChild(visualElement);
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
- nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
- addAttributeToTableNode((Element) sourceNode, tableRow);
- visualElement.appendChild(tbody);
- tbody.appendChild(tableRow);
+ nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
+ addAttributeToTableNode((Element) sourceNode, tableRow);
+ visualElement.appendChild(tbody);
+ tbody.appendChild(tableRow);
- VpeCreationData vpeCreationData = new VpeCreationData(div);
- createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
- vpeCreationData);
- return vpeCreationData;
- } else {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
- TREE_NODES_ADAPTOR);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML.TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
- if (isHasParentAdapter(sourceNode)) {
- visualElement.setAttribute(HTML.ATTR_CLASS,
- "dr-tree-h-ic-div"); //$NON-NLS-1$
- if (getShowLinesAttr(sourceNode)
- && (isAdapterBetweenNodes(sourceNode) ||
isHasNextParentAdaptorElement(sourceNode))) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_DIV_LINE;
- visualElement.setAttribute(
- HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
- + ADAPTER_LINES_STYLE);
+ vpeCreationData = new VpeCreationData(div);
+ createBasicTree(pageContext, visualDocument, tableRow, sourceNode,vpeCreationData);
+ } else {
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE_NODES_ADAPTOR);
+ nsIDOMElement visualElement = visualDocument.createElement(HTML.TAG_DIV);
+ visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
+ if (isHasParentAdapter(sourceNode)) {
+ visualElement.setAttribute(HTML.ATTR_CLASS, "dr-tree-h-ic-div");
//$NON-NLS-1$
+ if (getShowLinesAttr(sourceNode)
+ && (isAdapterBetweenNodes(sourceNode) ||
isHasNextParentAdaptorElement(sourceNode))) {
+ String path = RichFacesTemplatesActivator.getPluginResourcePath() + ICON_DIV_LINE;
+ visualElement.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
+ + ADAPTER_LINES_STYLE);
+ }
+ }
+ vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,visualElement);
}
- }
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- return vpeCreationData;
+ return vpeCreationData;
}
- }
- /**
- *
- * @param sourceElement
- * @return
- */
- private boolean isEmptyNode(Node sourceNode) {
-
- NodeList childs = sourceNode.getChildNodes();
- for (int i = 0; i < childs.getLength(); i++) {
- Node el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
- return false;
+ /**
+ *
+ * @param sourceElement
+ * @return
+ */
+ private boolean isEmptyNode(Node sourceNode) {
+ NodeList childs = sourceNode.getChildNodes();
+ for (int i = 0; i < childs.getLength(); i++) {
+ Node el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ return false;
+ }
+ return true;
}
- return true;
- }
-
- @Override
- public void setPseudoContent(VpePageContext pageContext,
- Node sourceContainer, nsIDOMNode visualContainer,
- nsIDOMDocument visualDocument) {
- // Empty
- }
+ @Override
+ public void setPseudoContent(VpePageContext pageContext,
+ Node sourceContainer, nsIDOMNode visualContainer,
+ nsIDOMDocument visualDocument) {
+ // Empty
+ }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2011-09-12
10:48:36 UTC (rev 34627)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2011-09-12
11:57:46 UTC (rev 34628)
@@ -31,144 +31,147 @@
*/
public class RichFacesTreeNodeTemplate extends RichFacesAbstractTreeTemplate {
- /**
- * 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) {
+ /**
+ * 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 div = visualDocument.createElement(HTML.TAG_DIV);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML.TAG_TABLE);
- addBasicTreeNodeAttributes(visualElement);
- div.appendChild(visualElement);
- nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HTML.TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+ div.appendChild(visualElement);
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
- nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
- addAttributeToTableNode((Element) sourceNode, tableRow);
- visualElement.appendChild(tbody);
- tbody.appendChild(tableRow);
+ nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
+ addAttributeToTableNode((Element) sourceNode, tableRow);
+ visualElement.appendChild(tbody);
+ tbody.appendChild(tableRow);
- VpeCreationData vpeCreationData = new VpeCreationData(div);
- createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
- vpeCreationData);
- return vpeCreationData;
- }
+ VpeCreationData vpeCreationData = new VpeCreationData(div);
+ createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
+ vpeCreationData);
+ return vpeCreationData;
+ }
- @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, because tree
- * always shows as expanded and information is it leaf or not contains
- * in model
- */
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- nsIDOMElement expandedIconCell = queryInterface(
- visualNode.getChildNodes().item(0), nsIDOMElement.class);
- nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes().item(0),
- nsIDOMElement.class);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
- } else if (NODE_ICON_ATTR_NAME.equals(name)
- && !isLastElement(visualNode)) {
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0),
- nsIDOMElement.class);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
- } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
- && isLastElement(sourceElement)) {
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0),
- nsIDOMElement.class);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ @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, because tree
+ * always shows as expanded and information is it leaf or not contains
+ * in model
+ */
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ nsIDOMElement expandedIconCell = queryInterface(visualNode
+ .getChildNodes().item(0), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes()
+ .item(0), nsIDOMElement.class);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ } else if (NODE_ICON_ATTR_NAME.equals(name)
+ && !isLastElement(visualNode)) {
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
+ && isLastElement(sourceElement)) {
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ }
}
- }
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMNode visualNode, Object data, String name) {
- /*
- * processed only next attributes iconExpanded and icon, because tree
- * always shows as expanded and information is it leaf or not contains
- * in model
- */
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name) {
+ /*
+ * processed only next attributes iconExpanded and icon, because tree
+ * always shows as expanded and information is it leaf or not contains
+ * in model
+ */
- Element parentElement = (Element) sourceElement.getParentNode();
- boolean showLinesValue = getShowLinesAttr(sourceElement);
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
-
- nsIDOMElement expandedIconCell = queryInterface(visualNode
- .getChildNodes().item(0), nsIDOMElement.class);
- nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes().item(0),
- nsIDOMElement.class);
-
- if (parentElement.hasAttribute(NODE_ICON_EXPANDED_ATTR_NAME)) {
- String parentAttrName = parentElement.getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- } else {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_EXPANDED_WITH_LINES
- : ICON_EXPANDED_WITHOUT_LINES);
- }
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_EXPANDED_PARAM_VALUE);
- } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
- && !isLastElement(sourceElement)) {
-
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0),
- nsIDOMElement.class);
-
- if (parentElement.hasAttribute(NODE_ICON_ATTR_NAME)) {
- String parentAttrName = parentElement.getAttribute(NODE_ICON_ATTR_NAME);
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- } else {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- }
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+ Element parentElement = (Element) sourceElement.getParentNode();
+ boolean showLinesValue = getShowLinesAttr(sourceElement);
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
- && isLastElement(sourceElement)) {
-
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0),
nsIDOMElement.class);
-
- if (parentElement.hasAttribute(NODE_ICON_LEAF_ATTR_NAME)) {
- String parentAttrName = parentElement.getAttribute(NODE_ICON_LEAF_ATTR_NAME);
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- } else {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_LEAF_WITH_LINES
- : ICON_LEAF_WITHOUT_LINES);
- }
- img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
+ nsIDOMElement expandedIconCell = queryInterface(visualNode
+ .getChildNodes().item(0), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes()
+ .item(0), nsIDOMElement.class);
+
+ if (parentElement.hasAttribute(NODE_ICON_EXPANDED_ATTR_NAME)) {
+ String parentAttrName = parentElement
+ .getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ } else {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_EXPANDED_WITH_LINES
+ : ICON_EXPANDED_WITHOUT_LINES);
+ }
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_EXPANDED_PARAM_VALUE);
+ } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
+ && !isLastElement(sourceElement)) {
+
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+
+ if (parentElement.hasAttribute(NODE_ICON_ATTR_NAME)) {
+ String parentAttrName = parentElement
+ .getAttribute(NODE_ICON_ATTR_NAME);
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ } else {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ }
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
+ && isLastElement(sourceElement)) {
+
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+
+ if (parentElement.hasAttribute(NODE_ICON_LEAF_ATTR_NAME)) {
+ String parentAttrName = parentElement
+ .getAttribute(NODE_ICON_LEAF_ATTR_NAME);
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ } else {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
+ }
+ img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
+ }
}
- }
-
-}
+}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2011-09-12
10:48:36 UTC (rev 34627)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2011-09-12
11:57:46 UTC (rev 34628)
@@ -27,33 +27,28 @@
*/
public class RichFacesTreeNodesAdaptorTemplate extends RichFacesAbstractTreeTemplate {
- private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
- public static final String ICON_DIV_LINE = "/tree/divLine.gif";
//$NON-NLS-1$
- private static final String ADAPTER_LINES_STYLE = "background-position: left
center; background-repeat: repeat-y;"; //$NON-NLS-1$
- public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
+ private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
+ public static final String ICON_DIV_LINE = "/tree/divLine.gif"; //$NON-NLS-1$
+ private static final String ADAPTER_LINES_STYLE = "background-position: left
center; background-repeat: repeat-y;"; //$NON-NLS-1$
+ public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE_NODES_ADAPTOR);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML .TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
- if (isHasParentAdapter(sourceNode)) {
- visualElement.setAttribute(HTML.ATTR_CLASS,
- "dr-tree-h-ic-div"); //$NON-NLS-1$
- if (getShowLinesAttr(sourceNode)
- && (isAdapterBetweenNodes(sourceNode) ||
isHasNextParentAdaptorElement(sourceNode))) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_DIV_LINE;
- visualElement.setAttribute(HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
- + ADAPTER_LINES_STYLE);
- }
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE_NODES_ADAPTOR);
+ nsIDOMElement visualElement = visualDocument.createElement(HTML .TAG_DIV);
+ visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
+ if (isHasParentAdapter(sourceNode)) {
+ visualElement.setAttribute(HTML.ATTR_CLASS,"dr-tree-h-ic-div");
//$NON-NLS-1$
+ if (getShowLinesAttr(sourceNode)
+ && (isAdapterBetweenNodes(sourceNode) ||
isHasNextParentAdaptorElement(sourceNode))) {
+ String path = RichFacesTemplatesActivator.getPluginResourcePath() + ICON_DIV_LINE;
+ visualElement.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$
//$NON-NLS-2$
+ + ADAPTER_LINES_STYLE);
+ }
+ }
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData, visualElement);
+ return vpeCreationData;
}
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- return vpeCreationData;
- }
}
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 2011-09-12
10:48:36 UTC (rev 34627)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2011-09-12
11:57:46 UTC (rev 34628)
@@ -34,296 +34,273 @@
* @author dsakovich(a)exadel.com
*
*/
-public class RichFacesTreeTemplate extends VpeAbstractTemplate {
+public class RichFacesTreeTemplate extends RichFacesAbstractTreeTemplate{
- /** Resurces */
+ private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
+ private static final String ICON_ATTR = "icon"; //$NON-NLS-1$
+ private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass";
//$NON-NLS-1$
+ private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded";
//$NON-NLS-1$
- public static final String TREE= "tree"; //$NON-NLS-1$
- public static final String TREE_NODE_NAME = "treeNode"; //$NON-NLS-1$
- public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor";
//$NON-NLS-1$
- public static final String RECURSIVE_TREE_NODES_ADAPTOR =
"recursiveTreeNodesAdaptor"; //$NON-NLS-1$
- public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines";
//$NON-NLS-1$
- private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
- private static final String ICON_ATTR = "icon"; //$NON-NLS-1$
- private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass";
//$NON-NLS-1$
- private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded";
//$NON-NLS-1$
+ /**
+ * 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(HTML.TAG_DIV);
+ Element sourceElement = (Element) sourceNode;
- /**
- * 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(HTML.TAG_DIV);
- Element sourceElement = (Element) sourceNode;
-
- if (sourceElement.hasAttribute(HTML.ATTR_STYLE)) {
- String style = sourceElement.getAttribute(HTML.ATTR_STYLE);
- visualElement.setAttribute(HTML.ATTR_STYLE, style);
+ if (sourceElement.hasAttribute(HTML.ATTR_STYLE)) {
+ String style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+ visualElement.setAttribute(HTML.ATTR_STYLE, style);
+ }
+
+ if (sourceElement.hasAttribute(HTML.ATTR_CLASS)) {
+ String styleClass = sourceElement.getAttribute(HTML.ATTR_CLASS);
+ visualElement.setAttribute(HTML.ATTR_CLASS, styleClass);
+ }
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ vpeCreationData.addChildrenInfo(new VpeChildrenInfo(null));
+
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
+ visualElement);
+ setStylesAttributesToTree(visualElement, (Element) sourceNode);
+ return vpeCreationData;
}
-
- if (sourceElement.hasAttribute(HTML.ATTR_CLASS)) {
- String styleClass = sourceElement.getAttribute(HTML.ATTR_CLASS);
- visualElement.setAttribute(HTML.ATTR_CLASS, styleClass);
- }
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- vpeCreationData.addChildrenInfo(new VpeChildrenInfo(null));
-
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- setStylesAttributesToTree(visualElement, (Element) sourceNode);
- return vpeCreationData;
- }
- /**
- * Sets to tree basic style attributes
- *
- * @param tree
- * @param sourceNode
- */
- private void setStylesAttributesToTree(nsIDOMElement treeTable,
- Element sourceNode) {
-
+ /**
+ * Sets to tree basic style attributes
+ *
+ * @param tree
+ * @param sourceNode
+ */
+ private void setStylesAttributesToTree(nsIDOMElement treeTable,
+ Element sourceNode) {
if (sourceNode.hasAttribute(HTML.ATTR_STYLE)) {
String styleAttr = sourceNode.getAttribute(HTML.ATTR_STYLE);
- setAttributeToTree(treeTable, HTML.ATTR_STYLE,
- removeFromStyleWithAndHeight(styleAttr));
- treeTable
- .setAttribute(HTML.ATTR_STYLE, styleAttr);
+ setAttributeToTree(treeTable, HTML.ATTR_STYLE,
+ removeFromStyleWithAndHeight(styleAttr));
+ treeTable.setAttribute(HTML.ATTR_STYLE, styleAttr);
}
-
if (sourceNode.hasAttribute(TREE_STYLE_CLASS_ATR_NAME)) {
- String styleClassAttr = sourceNode.getAttribute(TREE_STYLE_CLASS_ATR_NAME);
- setAttributeToTree(treeTable, HTML.ATTR_CLASS,
- styleClassAttr);
+ String styleClassAttr = sourceNode
+ .getAttribute(TREE_STYLE_CLASS_ATR_NAME);
+ setAttributeToTree(treeTable, HTML.ATTR_CLASS, styleClassAttr);
}
- }
+ }
- /**
- *
- * @param styleArgs
- * @return
- */
- private String removeFromStyleWithAndHeight(String styleArgs) {
- StringBuffer result = new StringBuffer();
- String[] mas = styleArgs.split(Constants.SEMICOLON);
- for (String styleAttr : mas) {
- if ((styleAttr.indexOf(HTML.ATTR_WIDTH) != -1)
- || (styleAttr.indexOf(HTML.ATTR_HEIGHT) != -1)) {
- continue;
- }
- result.append(styleAttr + Constants.SEMICOLON);
+ /**
+ *
+ * @param styleArgs
+ * @return
+ */
+ private String removeFromStyleWithAndHeight(String styleArgs) {
+ StringBuffer result = new StringBuffer();
+ String[] mas = styleArgs.split(Constants.SEMICOLON);
+ for (String styleAttr : mas) {
+ if ((styleAttr.indexOf(HTML.ATTR_WIDTH) != -1)
+ || (styleAttr.indexOf(HTML.ATTR_HEIGHT) != -1)) {
+ continue;
+ }
+ result.append(styleAttr + Constants.SEMICOLON);
+ }
+ return result.toString();
}
- return result.toString();
- }
- /**
- * Sets to tree tables attributes
- *
- * @param node
- * @param sourceNode
- * @param attrValue
- */
- private void setAttributeToTree(nsIDOMNode node, String attrName,
- String attrValue) {
- try {
- nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
- if (node.getNodeName().equalsIgnoreCase(
- HTML.TAG_TABLE)) {
- element.setAttribute(attrName, attrValue);
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- setAttributeToTree(list2.item(i), attrName, attrValue);
- }
- } catch (XPCOMException exception) {
- // Ignore
- return;
+ /**
+ * Sets to tree tables attributes
+ *
+ * @param node
+ * @param sourceNode
+ * @param attrValue
+ */
+ private void setAttributeToTree(nsIDOMNode node, String attrName,
+ String attrValue) {
+ try {
+ nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_TABLE)) {
+ element.setAttribute(attrName, attrValue);
+ }
+ nsIDOMNodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ setAttributeToTree(list2.item(i), attrName, attrValue);
+ }
+ } catch (XPCOMException exception) {
+ // Ignore
+ return;
+ }
}
- }
- /**
- * 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>
- */
+ /**
+ * 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>
+ */
- @Override
- public void validate(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData data) {
- super.validate(pageContext, sourceNode, visualDocument, data);
- revertTableRows(data.getNode());
- }
+ @Override
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+ super.validate(pageContext, sourceNode, visualDocument, data);
+ revertTableRows(data.getNode());
+ }
- /**
- * Revert tree elements in right order.
- *
- * @param node
- */
- private void revertTableRows(nsIDOMNode node) {
-
- try {
- nsIDOMNodeList list = node.getChildNodes();
- nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
- String id = element.hasAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME) ?
- element.getAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME) :
- Constants.EMPTY;
- if (node.getNodeName().equalsIgnoreCase(
- HTML.TAG_DIV)
- && list.getLength() == 2
- && !(id
- .equalsIgnoreCase(TREE_NODES_ADAPTOR) || id
- .equalsIgnoreCase(RECURSIVE_TREE_NODES_ADAPTOR))) {
- nsIDOMNode table1 = list.item(0);
- nsIDOMNode table2 = list.item(1);
- node.removeChild(table1);
- node.removeChild(table2);
- node.appendChild(table2);
- node.appendChild(table1);
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- revertTableRows(list2.item(i));
- }
- } catch (XPCOMException e) {
- //Ignore
- return;
+ /**
+ * Revert tree elements in right order.
+ *
+ * @param node
+ */
+ private void revertTableRows(nsIDOMNode node) {
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
+ String id = element
+ .hasAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME) ? element
+ .getAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME)
+ : Constants.EMPTY;
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_DIV)
+ && list.getLength() == 2
+ && !(id.equalsIgnoreCase(TREE_NODES_ADAPTOR)
+ || id.equalsIgnoreCase(TREE_MODEL_ADAPTOR)
+ || id.equalsIgnoreCase(TREE_MODEL_RECURSIVE_ADAPTOR)
+ || id.equalsIgnoreCase(RECURSIVE_TREE_NODES_ADAPTOR))) {
+ nsIDOMNode table1 = list.item(0);
+ nsIDOMNode table2 = list.item(1);
+ node.removeChild(table1);
+ node.removeChild(table2);
+ node.appendChild(table2);
+ node.appendChild(table1);
+ }
+ nsIDOMNodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ revertTableRows(list2.item(i));
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
+ }
}
- }
- /**
- *
- * 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() + Constants.COLON + TREE_NODE_NAME;
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + RECURSIVE_TREE_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) {
-
- 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;
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ @Override
+ 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();
+ 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().endsWith(Constants.COLON + TREE_NODE)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR))
{
+ if (div == null) {
+ 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 boolean recreateAtAttrChange(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;
+ @Override
+ public boolean recreateAtAttrChange(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;
}
- return false;
- }
- @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, HTML.ATTR_CLASS,
- value);
- } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HTML.ATTR_STYLE,
- removeFromStyleWithAndHeight(value));
- nsIDOMElement visualElement = queryInterface(visualNode, nsIDOMElement.class);
- visualElement.setAttribute(
- HTML.ATTR_STYLE, 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, HTML.ATTR_CLASS, value);
+ } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HTML.ATTR_STYLE,
+ removeFromStyleWithAndHeight(value));
+ nsIDOMElement visualElement = queryInterface(visualNode,
+ nsIDOMElement.class);
+ visualElement.setAttribute(HTML.ATTR_STYLE, 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, HTML.ATTR_CLASS,
- Constants.EMPTY);
- } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HTML.ATTR_STYLE,
- Constants.EMPTY);
+ @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, HTML.ATTR_CLASS, Constants.EMPTY);
+ } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HTML.ATTR_STYLE, Constants.EMPTY);
+ }
}
- }
- /**
- * 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(HTML.TAG_DIV);
- div.setAttribute(HTML.ATTR_CLASS, "dr-tree-h-ic-div"); //$NON-NLS-1$
- return div;
- }
-
-}
+ /**
+ * 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(HTML.TAG_DIV);
+ div.setAttribute(HTML.ATTR_CLASS, "dr-tree-h-ic-div"); //$NON-NLS-1$
+ return div;
+ }
+}
\ No newline at end of file
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 2011-09-12
10:48:36 UTC (rev 34627)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2011-09-12
11:57:46 UTC (rev 34628)
@@ -393,7 +393,7 @@
</vpe:tag>
<vpe:tag name="rich:hashParam" case-sensitive="yes">
- <vpe:template children="no" modify="no">
+ <vpe:template children="yes" modify="no">
</vpe:template>
</vpe:tag>
@@ -968,7 +968,6 @@
</vpe:template>
</vpe:tag>
-
<vpe:tag name="rich:tree" case-sensitive="yes">
<vpe:template children="yes" modify="no"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeTemplate">
@@ -991,6 +990,30 @@
</vpe:template>
</vpe:tag>
+<vpe:tag name="rich:treeModelAdaptor" 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:treeModelRecursiveAdaptor"
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">
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml 2011-09-12
10:48:36 UTC (rev 34627)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml 2011-09-12
11:57:46 UTC (rev 34628)
@@ -1,6 +1,6 @@
<tests>
<test id="project">
- <DIV ID="treeNodesAdaptor" >
+ <DIV ID="treeNodesAdaptor">
<DIV>
<TABLE CELLSPACING="0px" CELLPADDING="0px"
BORDER="0px"
CLASS="dr-tree-full-width">
@@ -8,20 +8,19 @@
<TR>
<TD
STYLE="/background-image: url\(.*resources//tree/line.gif\);
background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
</TD>
<TD
STYLE="/background-image: url\(.*resources//tree/leftLine.gif\);
background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Project: #{project.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form.
</SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -36,20 +35,19 @@
<TR>
<TD
STYLE="/background-image: url\(.*resources//tree/line.gif\);
background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
</TD>
<TD
STYLE="/background-image: url\(.*resources//tree/leftLine.gif\);
background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Source directory: #{srcDir.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form.
</SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -70,14 +68,14 @@
</TD>
<TD
STYLE="/background-image: url\(.*resources//tree/leftLine.gif\);
background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Package: #{pkg.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form.
</SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -97,14 +95,14 @@
RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
</TD>
<TD>
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconLeafWithLines.gif/"
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconLeafWithLines.gif/"
RICHFACESTREENODEPARAM="iconLeaf" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Class: #{class.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form.
</SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -116,4 +114,97 @@
</DIV>
</DIV>
</test>
+
+ <test id="tMRA">
+
+ <DIV ID="treeNodesAdaptor">
+ <DIV>
+ <TABLE CELLSPACING="0px" CELLPADDING="0px"
BORDER="0px"
+ CLASS="dr-tree-full-width">
+ <TBODY>
+ <TR>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/line.gif\);
background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
+
+ </TD>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/leftLine.gif\);
background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
+
+ </TD>
+ <TD CLASS="treeNodeNameStyle">
+ <SPAN CLASS="vpe-text">
+ #{item.shortPath}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ <DIV ID="treeNodesAdaptor" CLASS="dr-tree-h-ic-div">
+ <DIV>
+ <TABLE CELLSPACING="0px" CELLPADDING="0px"
BORDER="0px"
+ CLASS="dr-tree-full-width">
+ <TBODY>
+ <TR>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/rightLine.gif\);
background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle"
+ SRC="/.*resources/tree/iconNotCollapsedWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
+
+ </TD>
+ <TD>
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconLeafWithLines.gif/"
+ RICHFACESTREENODEPARAM="iconLeaf" />
+
+ </TD>
+ <TD CLASS="treeNodeNameStyle">
+ <SPAN CLASS="vpe-text">
+ #{item}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </DIV>
+ </test>
+
+ <test id="tMA">
+
+ <DIV ID="treeNodesAdaptor" CLASS="dr-tree-h-ic-div">
+ <DIV>
+ <TABLE CELLSPACING="0px" CELLPADDING="0px"
BORDER="0px"
+ CLASS="dr-tree-full-width">
+ <TBODY>
+ <TR>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/rightLine.gif\);
background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle"
+ SRC="/.*resources/tree/iconNotCollapsedWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
+
+ </TD>
+ <TD>
+ <IMG CLASS="treePictureStyle"
SRC="/.*resources/tree/iconLeafWithLines.gif/"
+ RICHFACESTREENODEPARAM="iconLeaf" />
+
+ </TD>
+ <TD CLASS="treeNodeNameStyle">
+ <SPAN CLASS="vpe-text">
+ #{item}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </test>
+
</tests>
\ No newline at end of file