Author: nbelaevski
Date: 2009-02-10 18:03:06 -0500 (Tue, 10 Feb 2009)
New Revision: 12622
Added:
trunk/framework/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java
trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java
Log:
https://jira.jboss.org/jira/browse/RF-4809
Added:
trunk/framework/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java
(rev 0)
+++
trunk/framework/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java 2009-02-10
23:03:06 UTC (rev 12622)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * This class provides the solution for "false leaves" issue of cacheable
trees
+ *
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class CacheableSwingTreeNodeImpl extends SwingTreeNodeImpl {
+
+ private boolean notLeaf = false;
+
+ @Override
+ public boolean isLeaf() {
+ return !this.notLeaf && super.isLeaf();
+ }
+
+ public void setNotLeaf(boolean notLeaf) {
+ this.notLeaf = notLeaf;
+ }
+}
Added: trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java
(rev 0)
+++
trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java 2009-02-10
23:03:06 UTC (rev 12622)
@@ -0,0 +1,48 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * This class provides the solution for "false leaves" issue of cacheable
trees
+ *
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class CacheableTreeNodeImpl<T> extends TreeNodeImpl<T> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5918388225735277820L;
+
+ private boolean notLeaf = false;
+
+ @Override
+ public boolean isLeaf() {
+ return !this.notLeaf && super.isLeaf();
+ }
+
+ public void setNotLeaf(boolean notLeaf) {
+ this.notLeaf = notLeaf;
+ }
+}
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java 2009-02-10
19:33:19 UTC (rev 12621)
+++
trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java 2009-02-10
23:03:06 UTC (rev 12622)
@@ -37,7 +37,7 @@
public TreeNode handleMissingNode(TreeNode parentNode,
Object pathSegment) {
- TreeNode childNode = new TreeNodeImpl();
+ TreeNodeImpl childNode = new CacheableTreeNodeImpl();
if (parentNode != null) {
parentNode.addChild(pathSegment, childNode);
@@ -55,7 +55,9 @@
@Override
protected void setDefaultNodeData(TreeNode node, Object data) {
if (node != null) {
- ((TreeNodeImpl) node).setData(data);
+ CacheableTreeNodeImpl cacheableTreeNode = (CacheableTreeNodeImpl) node;
+ cacheableTreeNode.setData(data);
+ cacheableTreeNode.setNotLeaf(!isLeaf());
}
}
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java 2009-02-10
19:33:19 UTC (rev 12621)
+++
trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java 2009-02-10
23:03:06 UTC (rev 12622)
@@ -39,7 +39,7 @@
public TreeNode handleMissingNode(TreeNode parent,
Object pathSegment) {
- SwingTreeNodeImpl childNode = new SwingTreeNodeImpl();
+ SwingTreeNodeImpl childNode = new CacheableSwingTreeNodeImpl();
if (parent != null) {
SwingTreeNodeImpl parentNode = (SwingTreeNodeImpl) parent;
@@ -69,7 +69,9 @@
@Override
protected void setDefaultNodeData(TreeNode node, Object data) {
- ((SwingTreeNodeImpl) node).setData(data);
+ CacheableSwingTreeNodeImpl cacheableTreeNode = (CacheableSwingTreeNodeImpl) node;
+ cacheableTreeNode.setData(data);
+ cacheableTreeNode.setNotLeaf(!isLeaf());
}
}