Author: dsakovich
Date: 2007-10-18 07:46:12 -0400 (Thu, 18 Oct 2007)
New Revision: 4328
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithAllLines.gif
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-847 Fix treeNodeAdaptor and recursiveNodeAdaptor
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithAllLines.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tree/iconNotCollapsedWithAllLines.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-10-18
11:46:08 UTC (rev 4327)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2007-10-18
11:46:12 UTC (rev 4328)
@@ -50,12 +50,10 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
- "recursiveTreeNodesAdaptor");
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, "treeNodesAdaptor");
nsIDOMElement visualElement = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME,
- RECURSIVE_TREE_NODES_ADAPTOR_NAME);
+ visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR_NAME);
if (isHasParentAdapter(sourceNode)) {
visualElement.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
"dr-tree-h-ic-div");
@@ -165,7 +163,11 @@
* @return
*/
private boolean isHasNextParentAdaptorElement(Node sourceNode) {
- Node parentTree = sourceNode.getParentNode();
+ Node tree = sourceNode.getParentNode();
+ if (!(tree instanceof Element)) {
+ return true;
+ }
+ Node parentTree = tree.getParentNode();
if (!(parentTree instanceof Element)) {
return true;
}
@@ -188,10 +190,11 @@
if (lastElement != null) {
break;
}
- if (el.equals(sourceNode)) {
+ if (el.equals(tree)) {
lastElement = el;
}
}
+
if (el.getNodeName().equals(treeNodeName)
|| el.getNodeName().equals(treeNodesAdaptorName)
|| el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
@@ -239,4 +242,5 @@
}
return false;
}
+
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-10-18
11:46:08 UTC (rev 4327)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2007-10-18
11:46:12 UTC (rev 4328)
@@ -57,6 +57,8 @@
public static final String ICON_NOT_EXPANDED_WITH_LINES =
"/tree/iconNotCollapsedWithLines.gif";
+ public static final String ICON_NOT_EXPANDED_WITH_ALL_LINES =
"/tree/iconNotCollapsedWithAllLines.gif";
+
public static final String ICON_NOT_EXPANDED_WITHOUT_LINES =
"/tree/iconNotCollapsed.gif";
public static final String ICON_EXPANDED_ADAPTER_WITH_LINES =
"/tree/iconClosedNodeWithLines.gif";
@@ -224,9 +226,6 @@
// creates icon with status of node(collapsed or not) node
nsIDOMElement td1 = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TD);
-
- Element element = (Element) sourceNode;
- String id = element.getAttribute("id");
// sets icon node
if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
&& !isHasNextAdaptorElement(sourceNode)) {
@@ -262,20 +261,37 @@
"background-image: url(file://" + path + "); "
+ NODE_LINES_STYLE);
}
- } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
(isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)) /*
- * &&
- * (isAdaptorInTree(sourceNode) ==
- * isLastElementAfterAdaptor(sourceNode))
- */)
- || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))) {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_RIGHT_LINE;
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) &&
(isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)))
+ || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))
+ || (isAdaptorChild(sourceNode) && isOnlyOneNodeInAdaptor(sourceNode))) {
+
+ 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, 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);
@@ -668,4 +684,73 @@
}
return false;
}
+
+ private boolean isOnlyOneNodeInAdaptor(Node sourceNode) {
+ Node parent = sourceNode.getParentNode();
+ NodeList list = parent.getChildNodes();
+ Node currentNode = null;
+ String treeNodeName = sourceNode.getPrefix() + ":"
+ + 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;
+ }
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Has Next element
+ *
+ * @param sourceNode
+ * @return
+ */
+ private 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();
+ String treeNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_NODES_ADAPTOR;
+ String treeRecursiveNodesAdaptorName = parentTree.getPrefix() + ":"
+ + RichFacesTreeTemplate.TREE_RECURSIVE_NODES_ADAPTOR;
+ Node lastElement = null;
+ Node el = null;
+
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+
+ if (lastElement != null) {
+ break;
+ }
+ if (el.equals(tree)) {
+ lastElement = el;
+ }
+ }
+
+ if (el.getNodeName().equals(treeNodesAdaptorName)
+ || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
+ return true;
+ }
+ return false;
+ }
+
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-10-18
11:46:08 UTC (rev 4327)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2007-10-18
11:46:12 UTC (rev 4328)
@@ -204,6 +204,7 @@
/**
* Is adapter between treeNodes
+ *
* @param sourceNode
* @return
*/
@@ -234,7 +235,7 @@
}
}
-
+
if (beforeAdapterNode != null && afterAdapterNode != null) {
return true;
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-10-18
11:46:08 UTC (rev 4327)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2007-10-18
11:46:12 UTC (rev 4328)
@@ -178,40 +178,12 @@
super.validate(pageContext, sourceNode, visualDocument, data);
revertTableRows(data.getNode());
}
-
- public void checkConnectingLines(nsIDOMNode node) {
- try {
- nsIDOMNodeList list = node.getChildNodes();
- nsIDOMElement element = (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- String id = element
- .getAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME);
- if (id == null)
- id = "";
- if (node.getNodeName().equalsIgnoreCase(
- HtmlComponentUtil.HTML_TAG_DIV)) {
-
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- revertTableRows(list2.item(i));
- }
- } catch (XPCOMException e) {
- return;
- }
- }
-
/**
* Revert tree elements in right order.
*
* @param node
*/
- /**
- * Revert tree elements in right order.
- *
- * @param node
- */
private void revertTableRows(nsIDOMNode node) {
try {