Author: nbelaevski
Date: 2010-12-03 10:36:35 -0500 (Fri, 03 Dec 2010)
New Revision: 20364
Added:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java
Removed:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java
Modified:
trunk/ui/iteration/ui/src/main/config/faces-config.xml
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
Log:
-
https://jira.jboss.org/browse/RF-9729
- Fixed incorrect condition in isLeaf()
Modified: trunk/ui/iteration/ui/src/main/config/faces-config.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/config/faces-config.xml 2010-12-03 15:35:08 UTC (rev
20363)
+++ trunk/ui/iteration/ui/src/main/config/faces-config.xml 2010-12-03 15:36:35 UTC (rev
20364)
@@ -6,6 +6,21 @@
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
version="2.0">
+ <converter>
+
<converter-id>org.richfaces.DeclarativeModelSequenceKeyConverter</converter-id>
+
<converter-class>org.richfaces.convert.DeclarativeModelSequenceKeyConverter</converter-class>
+ </converter>
+
+ <converter>
+
<converter-id>org.richfaces.IntegerSequenceRowKeyConverter</converter-id>
+
<converter-class>org.richfaces.convert.IntegerSequenceRowKeyConverter</converter-class>
+ </converter>
+
+ <converter>
+
<converter-id>org.richfaces.ObjectSequenceRowKeyConverter</converter-id>
+
<converter-class>org.richfaces.convert.ObjectSequenceRowKeyConverter</converter-class>
+ </converter>
+
<faces-config-extension>
<cdk:faces-event>
<cdk:event-class>org.richfaces.event.TreeToggleEvent</cdk:event-class>
Deleted:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java 2010-12-03
15:35:08 UTC (rev 20363)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java 2010-12-03
15:36:35 UTC (rev 20364)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.convert;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.IntegerConverter;
-
-import org.richfaces.component.AbstractTree;
-import org.richfaces.component.DeclarativeTreeDataModelWalker;
-import org.richfaces.model.DeclarativeModelKey;
-import org.richfaces.model.SequenceRowKey;
-/**
- * @author Nick Belaevski
- *
- */
-public class DeclarativeModelKeySequenceRowKeyConverter extends
SequenceRowKeyConverter<DeclarativeModelKey> {
-
- private final class KeyConvertingWalker extends DeclarativeTreeDataModelWalker {
-
- private final FacesContext context;
-
- private DeclarativeModelKey[] convertedSimpleKeys;
-
- private int keysIdx;
-
- private KeyConvertingWalker(AbstractTree rootComponent, FacesContext context) {
- super(rootComponent);
- this.context = context;
- }
-
- @Override
- protected DeclarativeModelKey convertKey(Object nodes, DeclarativeModelKey
declarativeModelKey) {
- DeclarativeModelKey convertedKey;
-
- if (nodes instanceof Iterable<?>) {
- String modelKeyAsString = (String) declarativeModelKey.getModelKey();
- Object modelKey = INTEGER_CONVERTER.getAsObject(context,
getRootComponent(), modelKeyAsString);
- convertedKey = new DeclarativeModelKey(declarativeModelKey.getModelId(),
modelKey);
- } else {
- convertedKey = declarativeModelKey;
- }
-
- convertedSimpleKeys[keysIdx++] = convertedKey;
-
- return super.convertKey(nodes, convertedKey);
- }
-
- @Override
- public void walk(SequenceRowKey key) {
- convertedSimpleKeys = new DeclarativeModelKey[key.getSimpleKeys().length];
- keysIdx = 0;
- super.walk(key);
- }
-
- public DeclarativeModelKey[] getConvertedSimpleKeys() {
- return convertedSimpleKeys;
- }
- }
-
- private static final Converter INTEGER_CONVERTER = new IntegerConverter();
-
- public DeclarativeModelKeySequenceRowKeyConverter() {
- super(DeclarativeModelKey.class, new
DeclarativeModelKeyConverter(ConverterUtil.stringConverter()));
- }
-
- @Override
- public Object getAsObject(FacesContext context, UIComponent component, String value)
throws ConverterException {
- SequenceRowKey key = (SequenceRowKey) super.getAsObject(context, component,
value);
-
- if (key != null) {
-
- KeyConvertingWalker walker = new KeyConvertingWalker((AbstractTree)
component, context);
- walker.walk(key);
-
- key = new SequenceRowKey((Object[]) walker.getConvertedSimpleKeys());
- }
-
- return key;
- }
-
-}
Copied:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java
(from rev 20337,
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java)
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java
(rev 0)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelSequenceKeyConverter.java 2010-12-03
15:36:35 UTC (rev 20364)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.IntegerConverter;
+
+import org.richfaces.component.AbstractTree;
+import org.richfaces.component.DeclarativeTreeDataModelWalker;
+import org.richfaces.model.DeclarativeModelKey;
+import org.richfaces.model.SequenceRowKey;
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class DeclarativeModelSequenceKeyConverter extends
SequenceRowKeyConverter<DeclarativeModelKey> {
+
+ private final class KeyConvertingWalker extends DeclarativeTreeDataModelWalker {
+
+ private final FacesContext context;
+
+ private DeclarativeModelKey[] convertedSimpleKeys;
+
+ private int keysIdx;
+
+ private KeyConvertingWalker(AbstractTree rootComponent, FacesContext context) {
+ super(rootComponent);
+ this.context = context;
+ }
+
+ @Override
+ protected DeclarativeModelKey convertKey(Object nodes, DeclarativeModelKey
declarativeModelKey) {
+ DeclarativeModelKey convertedKey;
+
+ if (nodes instanceof Iterable<?>) {
+ String modelKeyAsString = (String) declarativeModelKey.getModelKey();
+ Object modelKey = INTEGER_CONVERTER.getAsObject(context,
getRootComponent(), modelKeyAsString);
+ convertedKey = new DeclarativeModelKey(declarativeModelKey.getModelId(),
modelKey);
+ } else {
+ convertedKey = declarativeModelKey;
+ }
+
+ convertedSimpleKeys[keysIdx++] = convertedKey;
+
+ return super.convertKey(nodes, convertedKey);
+ }
+
+ @Override
+ public void walk(SequenceRowKey key) {
+ convertedSimpleKeys = new DeclarativeModelKey[key.getSimpleKeys().length];
+ keysIdx = 0;
+ super.walk(key);
+ }
+
+ public DeclarativeModelKey[] getConvertedSimpleKeys() {
+ return convertedSimpleKeys;
+ }
+ }
+
+ public static final String CONVERTER_ID =
"org.richfaces.DeclarativeModelSequenceKeyConverter";
+
+ private static final Converter INTEGER_CONVERTER = new IntegerConverter();
+
+ public DeclarativeModelSequenceKeyConverter() {
+ super(DeclarativeModelKey.class, new
DeclarativeModelKeyConverter(ConverterUtil.stringConverter()));
+ }
+
+ @Override
+ public Object getAsObject(FacesContext context, UIComponent component, String value)
throws ConverterException {
+ SequenceRowKey key = (SequenceRowKey) super.getAsObject(context, component,
value);
+
+ if (key != null) {
+
+ KeyConvertingWalker walker = new KeyConvertingWalker((AbstractTree)
component, context);
+ walker.walk(key);
+
+ key = new SequenceRowKey((Object[]) walker.getConvertedSimpleKeys());
+ }
+
+ return key;
+ }
+
+}
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java 2010-12-03
15:35:08 UTC (rev 20363)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java 2010-12-03
15:36:35 UTC (rev 20364)
@@ -29,6 +29,8 @@
*/
public class IntegerSequenceRowKeyConverter extends
SequenceRowKeyConverter<Integer> {
+ public static final String CONVERTER_ID =
"org.richfaces.IntegerSequenceRowKeyConverter";
+
public IntegerSequenceRowKeyConverter() {
super(Integer.class, new IntegerConverter());
}
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java 2010-12-03
15:35:08 UTC (rev 20363)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java 2010-12-03
15:36:35 UTC (rev 20364)
@@ -31,6 +31,8 @@
*/
public class ObjectSequenceRowKeyConverter extends SequenceRowKeyConverter<Object>
{
+ public static final String CONVERTER_ID =
"org.richfaces.ObjectSequenceRowKeyConverter";
+
private static final Converter NO_OP_CONVERTER = new Converter() {
public String getAsString(FacesContext context, UIComponent component, Object
value) {
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-12-03
15:35:08 UTC (rev 20363)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-12-03
15:36:35 UTC (rev 20364)
@@ -30,7 +30,7 @@
import org.richfaces.component.DeclarativeTreeDataModelWalker;
import org.richfaces.component.TreeModelAdaptor;
import org.richfaces.component.TreeModelRecursiveAdaptor;
-import org.richfaces.convert.DeclarativeModelKeySequenceRowKeyConverter;
+import org.richfaces.convert.DeclarativeModelSequenceKeyConverter;
import org.richfaces.model.iterators.DeclarativeTreeDataModelCompositeTuplesIterator;
import com.google.common.base.Predicates;
@@ -42,7 +42,7 @@
*/
public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<Object>
implements DeclarativeTreeModel<Object> {
- private static final Converter DEFAULT_CONVERTER = new
DeclarativeModelKeySequenceRowKeyConverter();
+ private static final Converter DEFAULT_CONVERTER = new
DeclarativeModelSequenceKeyConverter();
private AbstractTree tree;
@@ -67,7 +67,7 @@
return true;
}
- return Iterables.contains(currentComponent.getChildren(),
Predicates.instanceOf(TreeModelAdaptor.class));
+ return !Iterables.contains(currentComponent.getChildren(),
Predicates.instanceOf(TreeModelAdaptor.class));
}
public Iterator<TreeDataModelTuple> children() {