Author: nbelaevski
Date: 2009-04-08 12:05:05 -0400 (Wed, 08 Apr 2009)
New Revision: 13439
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java
Log:
https://jira.jboss.org/jira/browse/RF-6639
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-04-08
14:47:30 UTC (rev 13438)
+++
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-04-08
16:05:05 UTC (rev 13439)
@@ -208,7 +208,7 @@
private Object setupVariable(Object variable, FacesContext context) {
if (var != null) {
- Map map = context.getExternalContext().getRequestMap();
+ Map<String, Object> map = context.getExternalContext().getRequestMap();
return map.put(var, variable);
}
@@ -258,8 +258,8 @@
public boolean isLeaf() {
if (isRowAvailable()) {
StackEntry lastEntry = (StackEntry) stackEntries.getLast();
- for (Iterator iterator = lastEntry.model.getInternalModelsIterator();
iterator.hasNext();) {
- StackingTreeModel stackingTreeModel = (StackingTreeModel) iterator.next();
+ for (Iterator<StackingTreeModel> iterator =
lastEntry.model.getInternalModelsIterator(); iterator.hasNext();) {
+ StackingTreeModel stackingTreeModel = iterator.next();
if (!stackingTreeModel.isEmpty()) {
return false;
@@ -301,9 +301,9 @@
new Visitor1(dataVisitor));
if (treeRange == null || treeRange.processChildren(argumentKey)) {
- Iterator iterator = this.getInternalModelsIterator();
+ Iterator<StackingTreeModel> iterator = this.getInternalModelsIterator();
while (iterator.hasNext()) {
- final StackingTreeModel model = (StackingTreeModel) iterator.next();
+ final StackingTreeModel model = iterator.next();
getRoot().setRowKey(context, argumentKey);
final ExtendedDataModel scalarModel = model.getDataModel();
@@ -357,11 +357,11 @@
return (StackingTreeModel) models.get(id);
}
- private Iterator getInternalModelsIterator() {
+ private Iterator<StackingTreeModel> getInternalModelsIterator() {
return new FilterIterator(getModelsIterator(), ACTIVE_MODEL_PREDICATE);
}
- public Iterator getModelsIterator() {
+ public Iterator<StackingTreeModel> getModelsIterator() {
return models.values().iterator();
}
@@ -601,4 +601,8 @@
ConvertableKeyModel convertable = (ConvertableKeyModel) getDataModel();
return convertable.getKeyAsObject(context, string, component, converter);
}
+
+ public String getId() {
+ return id;
+ }
}
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java 2009-04-08
14:47:30 UTC (rev 13438)
+++
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java 2009-04-08
16:05:05 UTC (rev 13439)
@@ -20,7 +20,9 @@
*/
package org.richfaces.model;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
@@ -43,20 +45,34 @@
protected abstract StackingTreeModel createStackingTreeModel();
- public StackingTreeModel getStackingModel() {
- StackingTreeModel stackingTreeModel = createStackingTreeModel();
+ private List<StackingTreeModel> createChildModelsList() {
+ List<StackingTreeModel> childModels = new ArrayList<StackingTreeModel>();
+
if (getChildCount() > 0) {
- Iterator children = getChildren().iterator();
+ Iterator<UIComponent> children = getChildren().iterator();
while (children.hasNext()) {
- UIComponent component = (UIComponent) children.next();
+ UIComponent component = children.next();
if (component instanceof StackingTreeModelProvider) {
StackingTreeModelProvider provider = (StackingTreeModelProvider) component;
-
- stackingTreeModel.addStackingModel(provider.getStackingModel());
+ childModels.add(provider.getStackingModel());
}
}
}
+ return childModels;
+ }
+
+ protected void addChildModels(StackingTreeModel model, List<StackingTreeModel>
childModels) {
+ for (StackingTreeModel childModel : childModels) {
+ model.addStackingModel(childModel);
+ }
+ }
+
+ public StackingTreeModel getStackingModel() {
+ StackingTreeModel stackingTreeModel = createStackingTreeModel();
+
+ addChildModels(stackingTreeModel, createChildModelsList());
+
return stackingTreeModel;
}
}