Author: nbelaevski
Date: 2009-07-23 13:02:30 -0400 (Thu, 23 Jul 2009)
New Revision: 14988
Removed:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/impl/
root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/entity/
root/framework/trunk/impl/src/test/java/org/richfaces/model/impl/expressive/
Log:
Moving component APIs into ui-sandbox
Deleted:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,76 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - 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.component.util;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponent;
-
-import org.richfaces.component.Column;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ColumnUtil {
-
- /**
- * Extract sort expression from the column
- *
- * @param column
- * @return logical representation of sort field assigned to column component given
- * In case of EL-expression, an expression string is returned instead of value - so that
EL-expression can be evaluated later;
- * If there's literal value of dedicated attribute is specified, return it;
- * If attribute is not set, fall aback to component id
- */
-
- public static String getColumnSorting(UIComponent column) {
-
- UIComponent component = (UIComponent) column;
-
- ValueExpression binding = component.getValueExpression("sortExpression");
-
- if (binding != null) {
- return binding.getExpressionString();
- }
-
- if (component instanceof Column) {
- Column col = (Column) component;
- String sorting = col.getSortExpression();
-
- if (sorting != null) {
- return sorting;
- }
- }
-
-
- return component.getId();
- }
-
-
- public static boolean isSortable(UIComponent component) {
- if (component instanceof Column) {
- return ((Column) component).isSortable();
- }
- return
Boolean.valueOf(String.valueOf(component.getAttributes().get("sortable")));
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,209 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SerializableDataModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Implementation stores last loaded data, so no additional requests to db will be
performed
- * Acts as a proxy between the component and original data model
- * @author Maksim Kaszynski
- *
- */
-public class DataModelCache extends ScrollableTableDataModel {
-
- private static Log log = LogFactory.getLog(DataModelCache.class);
-
- private static class DataRange {
- private int startRow;
- private int endRow;
- private SortOrder sortOrder;
- private List loadedData;
-
- public DataRange(int startRow, int endRow, SortOrder sortOrder,
- List loadedData) {
- super();
- this.startRow = startRow;
- this.endRow = endRow;
- this.sortOrder = sortOrder;
- this.loadedData = loadedData;
- }
-
- public boolean match(int s, int e, SortOrder sortOrder) {
- return s == startRow
- && e == endRow
- && sortOrdersMatch(sortOrder, this.sortOrder);
- }
-
- private boolean sortOrdersMatch(SortOrder sortOrder1, SortOrder sortOrder2) {
- boolean result = sortOrder1 == sortOrder2;
-
- if (sortOrder1 != null && sortOrder2 != null) {
- result = sortOrder1.equals(sortOrder2);
- }
-
- return result;
- }
-
- }
-
- private Map secondaryMapping = new HashMap();
-
- private DataRange dataRange;
-
- private ScrollableTableDataModel scrollableTableDataModel;
-
- private int rowCount = Integer.MIN_VALUE;
-
- public DataModelCache(ScrollableTableDataModel scrollableTableDataModel) {
- super();
- this.scrollableTableDataModel = scrollableTableDataModel;
-
- if (log.isTraceEnabled()) {
- log.trace("initializing with " + scrollableTableDataModel);
- }
- }
-
- public void addDataModelListener(DataModelListener listener) {
- scrollableTableDataModel.addDataModelListener(listener);
- }
-
- public DataModelListener[] getDataModelListeners() {
- return scrollableTableDataModel.getDataModelListeners();
- }
-
- public Object getObjectById(Object id) {
-
- if (log.isDebugEnabled()) {
- log.debug("Trying to get object by id" + id);
- }
- //First try to find data in inner cache
- //If not found - get it from original model
- Object cached = secondaryMapping.get(id);
-
- if (cached == null) {
-
- if (log.isDebugEnabled()) {
- log.debug("Cache miss " + id + " falling back to original
model");
- }
-
- cached = scrollableTableDataModel.getObjectById(id);
- secondaryMapping.put(id, cached);
-
- }
-
- if (log.isDebugEnabled()) {
- log.debug("At last found element " + cached);
- }
-
- return cached;
- }
-
- public int getRowCount() {
- if (rowCount == Integer.MIN_VALUE) {
- rowCount = scrollableTableDataModel.getRowCount();
- }
- return rowCount;
- }
-
- public Object getRowData() {
- Object secondaryMapped = secondaryMapping.get(getRowKey());
-
- if (secondaryMapped == null) {
- secondaryMapped = super.getRowData();
- }
- return secondaryMapped;
- }
-
- public int getRowIndex() {
- return scrollableTableDataModel.getRowIndex();
- }
-
- public Object getRowKey() {
- return scrollableTableDataModel.getRowKey();
- }
-
- public SerializableDataModel getSerializableModel(Range range) {
- return scrollableTableDataModel.getSerializableModel(range);
- }
-
- public Object getWrappedData() {
- return scrollableTableDataModel.getWrappedData();
- }
-
- public boolean isRowAvailable() {
- return secondaryMapping.containsKey(getRowKey()) || super.isRowAvailable();
- }
-
- public List loadData(int startRow, int endRow, SortOrder sortOrder) {
- if (dataRange == null || !dataRange.match(startRow, endRow, sortOrder)) {
- List data = scrollableTableDataModel.loadData(startRow, endRow, sortOrder);
- dataRange = new DataRange(startRow, endRow, sortOrder, data);
- }
- return dataRange.loadedData;
- }
-
- public void removeDataModelListener(DataModelListener listener) {
- scrollableTableDataModel.removeDataModelListener(listener);
- }
-
- public void setRowIndex(int arg0) {
- scrollableTableDataModel.setRowIndex(arg0);
- }
-
- public void setRowKey(Object key) {
- scrollableTableDataModel.setRowKey(key);
- super.setRowKey(key);
- }
-
- public void setWrappedData(Object arg0) {
- scrollableTableDataModel.setWrappedData(arg0);
- }
-
- public Object getId(Object o) {
- return scrollableTableDataModel.getId(o);
- }
-
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- // TODO Auto-generated method stub
- super.walk(context, visitor, range, argument);
- }
- /*
- * FIXME: see superclass
- @Override
- public void setSortOrder(SortOrder sortOrder) {
- scrollableTableDataModel.setSortOrder(sortOrder);
- }
- */
-}
Deleted:
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,284 +0,0 @@
-/**
-* License Agreement.
-*
-* JBoss RichFaces - Ajax4jsf Component Library
-*
-* Copyright (C) 2008 CompuGROUP Holding AG
-*
-* 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;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Data model class for table components.<br>
- * Usage:
- * <pre>
- * ExtendedTableDataModel<SomeDataType> dataModel = new
ExtendedTableDataModel<SomeDataType>(new DataProvider
<SomeDataType>());
- * </pre>
- * @author pawelgo
- *
- */
-public class ExtendedTableDataModel<T> extends ExtendedDataModel implements
Serializable{
-
- private static final long serialVersionUID = 7374505108088114161L;
-
- private static final Log log = LogFactory.getLog(ExtendedTableDataModel.class);
-
- private DataProvider<T> dataProvider;
- private Object rowKey;
- private List<Object> wrappedKeys = null;
- //private boolean detached = false;
- private Map<Object, T> wrappedData = new HashMap<Object, T>();
-
- public ExtendedTableDataModel(DataProvider<T> dataProvider) {
- this.dataProvider = dataProvider;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.SerializableDataModel#update()
- */
-// public void update() {
-// ;
-// }
-
- /**
- * This method never called from framework.
- * (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- /**
- * This method normally called by Visitor before request Data Row.
- * (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- rowKey = key;
- }
-
- /**
- * This is main part of Visitor pattern. Method called by framework many times during
request processing.
- * (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext,
org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- int rowC = getRowCount();
- int firstRow = ((SequenceRange) range).getFirstRow();
- int numberOfRows = ((SequenceRange) range).getRows();
- if (numberOfRows <= 0) {
- numberOfRows = rowC;
- }
- if (wrappedKeys != null) { // Is this serialized model
- // Here we just ignore current Rage and use whatever data was saved in serialized
model.
- // Such approach uses much more getByPk() operations, instead of just one request by
range.
- // Concrete case may be different from that, so you can just load data from data
provider by range.
- // We are using wrappedKeys list only to preserve actual order of items.
- for (Object key : wrappedKeys) {
- setRowKey(key);
- visitor.process(context, key, argument);
- }
- } else { // if not serialized, than we request data from data provider
- wrappedKeys = new ArrayList<Object>();
- int endRow = firstRow + numberOfRows;
- if (endRow > rowC){
- endRow = rowC;
- }
- for (T item : loadData(firstRow, endRow)) {
- Object key = getKey(item);
- wrappedKeys.add(key);
- wrappedData.put(key, item);
- visitor.process(context, key, argument);
- }
- }
- }//walk
-
- /**
- * Load range of data items from the source.
- * Starting from startRow, and up to but excluding endRow
- * @param startRow
- * @param endRow
- * @return list of ordered data
- */
- protected List<T> loadData(int startRow, int endRow) {
- if (log.isDebugEnabled())
- log.debug("load data from range: " + startRow + " - " + endRow);
- if (startRow < 0){
- startRow = 0;
- throw new IllegalArgumentException("Illegal start index value: " +
startRow);
- }
- int rowCount = getRowCount();
- if (endRow > rowCount){
- endRow = rowCount;
- throw new IllegalArgumentException("Illegal end index value: " + endRow);
- }
- //load all from provider and get sublist
- return dataProvider.getItemsByRange(startRow, endRow);
- //return dataProvider.getItemsByRange(0, rowCount).subList(startRow, endRow);
- }//loadData
-
- /**
- * This method must return actual data rows count from the Data Provider. It is used by
pagination control
- * to determine total number of data items.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- private Integer rowCount; // better to buffer row count locally
-
- public int getRowCount() {
- if (rowCount == null) {
- rowCount = new Integer(dataProvider.getRowCount());
- } else {
- return rowCount.intValue();
- }
- return rowCount.intValue();
- //return dataProvider.getRowCount();
- }
-
- /**
- * This is main way to obtain data row. It is intensively used by framework.
- * We strongly recommend use of local cache in that method.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- public T getRowData() {
- if (rowKey == null) {
- return null;
- } else {
- return getObjectByKey(rowKey);
- }
- }
-
- @SuppressWarnings("unchecked")
- public Object getKey(T o) {
- return dataProvider.getKey(o);
- }
-
- public T getObjectByKey(Object key) {
- T t = wrappedData.get(key);
- if (t == null){
- t = dataProvider.getItemByKey(key);
- wrappedData.put(key, t);
- }
- return t;
- }
-
- private Integer rowIndex;
-
- /**
- * Unused rudiment from old JSF staff. (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- //throw new UnsupportedOperationException();
- return rowIndex.intValue();
- }
-
- /**
- * Unused rudiment from old JSF staff.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- //throw new UnsupportedOperationException();
- this.rowIndex = rowIndex;
- }
-
- /**
- * Unused rudiment from old JSF staff.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Unused rudiment from old JSF staff.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Never called by framework.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- return getRowData() != null;
- }
-
- /**
- * This method suppose to produce SerializableDataModel that will be
- * serialized into View State and used on a post-back. In current
- * implementation we just mark current model as serialized. In more
- * complicated cases we may need to transform data to actually serialized
- * form.
- */
-// public SerializableDataModel getSerializableModel(Range range) {
-// if (wrappedKeys != null) {
-// detached = true;
-// // Some activity to detach persistent data from wrappedData map may be taken here.
-// // In that specific case we are doing nothing.
-// return this;
-// } else {
-// return null;
-// }
-// }
-
- /**
- * Resets internal cached data. Call this method to reload data from data
- * provider on first access for data.
- */
- public void reset(){
- wrappedKeys = null;
- wrappedData.clear();
- rowCount = null;
- rowIndex = -1;
- rowKey = null;
- }
-
- public DataProvider<T> getDataProvider() {
- return dataProvider;
- }
-
- public void setDataProvider(DataProvider<T> dataProvider) {
- this.dataProvider = dataProvider;
- }
-
-}
Deleted:
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,131 +0,0 @@
-/**
-* License Agreement.
-*
-* JBoss RichFaces - Ajax4jsf Component Library
-*
-* Copyright (C) 2008 CompuGROUP Holding AG
-*
-* 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;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author pawelgo
- *
- */
-public class ExtendedTableDataModifiableModel<T> extends ModifiableModel {
-
- //private static final Log log =
LogFactory.getLog(ExtendedTableDataModifiableModel.class);
-
- private ExtendedTableDataModel<T> orgModel;
- private boolean sortNeeded = true;
- private boolean filterNeeded = true;
-
- @SuppressWarnings("unchecked")
- public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider, String var)
{
- super(new ExtendedTableDataModel<T>(dataProvider), var);
- this.orgModel = (ExtendedTableDataModel<T>)this.originalModel;
- }
-
- public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider) {
- this(dataProvider, null);
- }
-
- @SuppressWarnings("unchecked")
- public ExtendedTableDataModifiableModel(ExtendedTableDataModel<T> dataModel,
String var) {
- super(dataModel, var);
- this.orgModel = dataModel;
- }
-
- @Override
- public Object getRowKey() {
- return originalModel.getRowKey();
- }
-
- @Override
- public void setRowKey(Object key) {
- originalModel.setRowKey(key);
- }
-
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = getRowCount();
- int currentRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- visitor.process(context, rowKeys.get(currentRow), argument);
- }
- }
-
- /**
- * Resets internal cached data. Call this method to reload data from data
- * provider on first access for data.
- */
- public void reset(){
- orgModel.reset();
- rowKeys = null;
- sortNeeded = true;
- filterNeeded = true;
- }
-
- public Object getKey(T o) {
- return orgModel.getKey(o);
- }
-
- public T getObjectByKey(Object key) {
- return orgModel.getObjectByKey(key);
- }
-
- @Override
- public void modify(List<FilterField> filterFields, List<SortField2>
sortFields) {
- if (sortNeeded || filterNeeded){
- if (var == null){
- throw new IllegalStateException("\"var\" model attribute can not be
null.");
- }
- super.modify(filterFields, sortFields);
- sortNeeded = false;
- filterNeeded = false;
- }
- }
-
- public void resetSort(){
- sortNeeded = true;
- }
-
- public void resetFilter(){
- filterNeeded = true;
- }
-
- public void setVar(String var){
- this.var = var;
- }
-}
Deleted:
root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,162 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ListSequenceDataModel extends ExtendedDataModel {
-
- private List<?> list;
- private int index;
-
- public ListSequenceDataModel(List<?> list) {
- setWrappedData(list);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- @Override
- public Object getRowKey() {
- if(index<0){
- return null;
- }
- return new Integer(index);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- @Override
- public void setRowKey(Object key) {
- if(null == key){
- index = -1;
- } else {
- setRowIndex(((Integer) key).intValue());
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext,
org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = list !=null ? list.size() : -1;
- int currentRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- setRowIndex(currentRow);
- visitor.process(context, new Integer(currentRow), argument);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- if (list == null) {
- return (-1);
- }
- return list.size();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- @Override
- public Object getRowData() {
- if (!isRowAvailable()) {
- throw new IllegalArgumentException();
- } else {
- return list.get(index);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- @Override
- public int getRowIndex() {
- return index;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- @Override
- public Object getWrappedData() {
- return list;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- @Override
- public boolean isRowAvailable() {
- return list != null && 0 <= index && index < list.size();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- @Override
- public void setRowIndex(int rowIndex) {
- if (rowIndex < -1) {
- throw new IllegalArgumentException();
- }
- index = rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- @Override
- public void setWrappedData(Object data) {
- if (data == null) {
- list = null;
- setRowIndex(-1);
- } else {
- list = (List<?>) data;
- setRowIndex(0);
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,277 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-import org.ajax4jsf.model.SerializableDataModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.model.impl.expressive.JavaBeanWrapper;
-import org.richfaces.model.impl.expressive.ObjectWrapperFactory;
-import org.richfaces.model.impl.expressive.WrappedBeanComparator2;
-import org.richfaces.model.impl.expressive.WrappedBeanFilter;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ModifiableModel extends ExtendedDataModel implements Modifiable, LocaleAware
{
-
- protected class RowKeyWrapperFactory extends ObjectWrapperFactory {
-
- private class ExtendedJavaBeanWrapper extends JavaBeanWrapper {
-
- private Object key;
-
- public ExtendedJavaBeanWrapper(Object key, Object o, Map<Object, Object> props)
{
- super(o, props);
- this.key = key;
- }
-
- public Object getKey() {
- return key;
- }
- }
-
- public RowKeyWrapperFactory(FacesContext context, String var,
- List<? extends Field> sortOrder) {
- super(context, var, sortOrder);
- }
-
- @Override
- public JavaBeanWrapper wrapObject(Object key) {
- originalModel.setRowKey(key);
- JavaBeanWrapper wrapObject = super.wrapObject(originalModel.getRowData());
- return new ExtendedJavaBeanWrapper(key, wrapObject.getWrappedObject(),
wrapObject.getProperties());
- }
-
- @Override
- public Object unwrapObject(Object wrapper) {
- return ((ExtendedJavaBeanWrapper) wrapper).getKey();
- }
- }
-
- private static final Log log = LogFactory.getLog(ModifiableModel.class);
-
- protected List<Object> rowKeys;
-
- protected ExtendedDataModel originalModel;
-
- protected String var;
-
- protected Locale locale = null;
-
- public ModifiableModel(ExtendedDataModel originalModel, String var) {
- this.originalModel = originalModel;
- this.var = var;
- }
-
- @Override
- public void addDataModelListener(DataModelListener listener) {
- originalModel.addDataModelListener(listener);
- }
-
- @Override
- public DataModelListener[] getDataModelListeners() {
- return originalModel.getDataModelListeners();
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- @Override
- public Object getRowKey() {
- Object originalModelKey = originalModel.getRowKey();
- int idx = rowKeys.indexOf(originalModelKey);
-
- if (originalModelKey != null || idx >= 0) {
- return idx;
- } else {
- return null;
- }
- }
-
- @Override
- public void setRowKey(Object key) {
- Object originalKey = null;
- if(key != null){
- int i = (Integer)key;
- if (i >= 0 && i < rowKeys.size()) {
- originalKey = rowKeys.get(i);
- }
- }
- originalModel.setRowKey(originalKey);
- }
-
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = getRowCount();
- int currentRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- visitor.process(context, currentRow, argument);
- }
- }
-
- @Override
- public int getRowCount() {
- if (rowKeys == null) {
- return -1;
- } else {
- return rowKeys.size();
- }
- }
-
- @Override
- public Object getRowData() {
- return originalModel.getRowData();
- }
-
- @Override
- public int getRowIndex() {
- return rowKeys.indexOf(originalModel.getRowKey());
- }
-
- @Override
- public Object getWrappedData() {
- return originalModel.getWrappedData();
- }
-
- @Override
- public boolean isRowAvailable() {
- return originalModel.isRowAvailable();
- }
-
- @Override
- public void setRowIndex(int rowIndex) {
- Object originalKey = null;
- if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
- originalKey = rowKeys.get(rowIndex);
- }
- originalModel.setRowKey(originalKey);
- }
-
- @Override
- public void setWrappedData(Object data) {
- originalModel.setWrappedData(data);
- }
-
- @Override
- public SerializableDataModel getSerializableModel(Range range) {
- return originalModel.getSerializableModel(range);
- }
-
- @Override
- public void removeDataModelListener(DataModelListener listener) {
- originalModel.removeDataModelListener(listener);
- }
-
-
- public void modify(List<FilterField> filterFields, List<SortField2>
sortFields) {
- int rowCount = originalModel.getRowCount();
-
- if (rowCount > 0) {
- rowKeys = new ArrayList<Object>(rowCount);
- } else {
- rowKeys = new ArrayList<Object>();
- }
-
- FacesContext context = FacesContext.getCurrentInstance();
- try {
-
- originalModel.walk(context, new DataVisitor() {
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
- originalModel.setRowKey(rowKey);
- if (originalModel.isRowAvailable()) {
- rowKeys.add(rowKey);
- }
- }
- }, new SequenceRange(0, -1),
- null);
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- }
-
- filter(filterFields);
- sort(sortFields);
-
- }
-
- protected List<Object> filter(List<FilterField> filterFields) {
- if (filterFields != null && !filterFields.isEmpty()) {
- FacesContext context = FacesContext.getCurrentInstance();
- List <Object> filteredCollection = new ArrayList<Object>();
- ObjectWrapperFactory wrapperFactory = new RowKeyWrapperFactory(context, var,
filterFields);
-
- WrappedBeanFilter wrappedBeanFilter = new WrappedBeanFilter(filterFields, locale);
- wrapperFactory.wrapList(rowKeys);
- for (Object object : rowKeys) {
- if(wrappedBeanFilter.accept((JavaBeanWrapper)object)) {
- filteredCollection.add(object);
- }
- }
- rowKeys = filteredCollection;
- wrapperFactory.unwrapList(rowKeys);
- }
- return rowKeys;
- }
-
- protected void sort(List<SortField2> sortFields) {
- if (sortFields != null && !sortFields.isEmpty()) {
- FacesContext context = FacesContext.getCurrentInstance();
- ObjectWrapperFactory wrapperFactory = new RowKeyWrapperFactory(
- context, var, sortFields);
-
- WrappedBeanComparator2 wrappedBeanComparator = new WrappedBeanComparator2(
- sortFields, locale);
- wrapperFactory.wrapList(rowKeys);
- Collections.sort(rowKeys, wrappedBeanComparator);
- wrapperFactory.unwrapList(rowKeys);
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,4 +0,0 @@
-/**
- * Models implementation classes
- */
-package org.richfaces.model;
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,87 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import javax.el.ValueExpression;
-
-import junit.framework.TestCase;
-
-import org.easymock.classextension.EasyMock;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class FilterFieldTest extends TestCase {
-
- private Field field;
- private ValueExpression expression;
-
- /**
- * @param name
- */
- public FilterFieldTest(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- expression = EasyMock.createNiceMock(ValueExpression.class);
- field = new FilterField(expression);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- field = null;
- expression = null;
- super.tearDown();
- }
-
- /**
- * Test method for {@link
org.richfaces.model.FilterField#FilterField(javax.el.ValueExpression)}.
- */
- public final void testFilterField() {
- Field filterField = new FilterField(expression);
- assertEquals(filterField, field);
- }
-
- /**
- * Test method for {@link org.richfaces.model.Field#hashCode()}.
- */
- public final void testHashCode() {
- Field filterField = new FilterField(expression);
- assertEquals(filterField.hashCode(), field.hashCode());
- }
-
- /**
- * Test method for {@link org.richfaces.model.Field#equals(java.lang.Object)}.
- */
- public final void testEqualsObject() {
- Field filterField = new FilterField(null);
- assertFalse(filterField.equals(field));
- filterField.setExpression(expression);
- assertTrue(filterField.equals(field));
- }
-
- /**
- * Test method for {@link org.richfaces.model.Field#getExpression()}.
- */
- public final void testGetExpression() {
- assertSame(field.getExpression(), expression);
- }
-
- /**
- * Test method for {@link
org.richfaces.model.Field#setExpression(javax.el.ValueExpression)}.
- */
- public final void testSetExpression() {
- field.setExpression(null);
- assertNull(field.getExpression());
- }
-
-}
Deleted:
root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,133 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.SequenceRange;
-
-import junit.framework.TestCase;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ListSequenceDataModelTest extends TestCase {
-
- private List<Integer> list;
- private ListSequenceDataModel model;
- private ListSequenceDataModel nullModel;
-
- /**
- * @param name
- */
- public ListSequenceDataModelTest(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- list = new ArrayList<Integer>();
- for (int i = 0; i < 10; i++) {
- list.add(new Integer(i));
- }
- model = new ListSequenceDataModel(list);
- nullModel = new ListSequenceDataModel(null);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- nullModel = null;
- model = null;
- list = null;
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#isRowAvailable()}.
- */
- public final void testIsRowAvailable() {
- assertFalse(nullModel.isRowAvailable());
- assertTrue(model.isRowAvailable());
- model.setRowIndex(-1);
- assertFalse(model.isRowAvailable());
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#getRowCount()}.
- */
- public final void testGetRowCount() {
- assertEquals(model.getRowCount(), list.size());
- assertEquals(nullModel.getRowCount(), -1);
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#setRowIndex()}
- * and {@link org.richfaces.model.ListSequenceDataModel#getRowIndex()}.
- */
- public final void testRowIndex() {
- int i = 3;
- model.setRowIndex(i);
- assertEquals(model.getRowIndex(), i);
- }
-
- /**
- * Test method for {@link
org.richfaces.model.ListSequenceDataModel#setRowKey(java.lang.Object)}
- * and {@link org.richfaces.model.ListSequenceDataModel#getRowKey(java.lang.Object)}.
- */
- public final void testRowKey() {
- Integer i = 3;
- model.setRowKey(i);
- assertEquals(model.getRowKey(), i);
- model.setRowKey(null);
- assertNull(model.getRowKey());
- }
-
- /**
- * Test method for {@link
org.richfaces.model.ListSequenceDataModel#walk(javax.faces.context.FacesContext,
org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)}
- * and {@link org.richfaces.model.ListSequenceDataModel#getRowData()}.
- */
- public final void testWalk() {
- DataVisitor visitor = new DataVisitor(){
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
- Object key = model.getRowKey();
- model.setRowKey(rowKey);
- assertEquals(model.getRowData(), list.get(((Integer)rowKey).intValue()));
- model.setRowKey(key);
- }
- };
- try {
- SequenceRange range = new SequenceRange(0, -1);
- model.walk(null, visitor, range, null);
- range = new SequenceRange(0, 5);
- model.walk(null, visitor, range, null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test method for {@link
org.richfaces.model.ListSequenceDataModel#ListSequenceDataModel(java.util.List)},
- * {@link org.richfaces.model.ListSequenceDataModel#setWrappedData(java.lang.Object)}
- * and {@link org.richfaces.model.ListSequenceDataModel#getWrappedData()} .
- */
- public final void testListSequenceDataModel() {
- assertNull(nullModel.getWrappedData());
- ListSequenceDataModel dataModel = new ListSequenceDataModel(list);
- assertSame(dataModel.getWrappedData(), model.getWrappedData());
-
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,170 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author shura
- *
- */
-public class MockDataModel extends ExtendedDataModel {
-
- public static final int ROWS = 10;
-
- private int rowIndex = 0;
-
- private int minRow = 0;
-
- private int maxRow = ROWS;
-
- private Object wrappedData;
- /**
- * @return the maxRow
- */
- public int getMaxRow() {
- return maxRow;
- }
-
- /**
- * @param maxRow the maxRow to set
- */
- public void setMaxRow(int maxRow) {
- this.maxRow = maxRow;
- }
-
- /**
- * @return the minRow
- */
- public int getMinRow() {
- return minRow;
- }
-
- /**
- * @param minRow the minRow to set
- */
- public void setMinRow(int minRow) {
- this.minRow = minRow;
- }
-
-
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
- int first=0;
- int count=ROWS;
- if (range instanceof MockRange) {
- MockRange mockRange = (MockRange) range;
- count = mockRange.getCount();
- } else if (range instanceof SequenceRange) {
- SequenceRange seqRange = (SequenceRange) range;
- first = seqRange.getFirstRow();
- int rows = seqRange.getRows();
- if(rows>0){
- count = rows+first;
- }
- }
- for(int row = first; row < count && row < ROWS;row++){
- visitor.process(context, new Integer(row), argument);
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- // TODO Auto-generated method stub
- return rowIndex<0?null:new Integer(rowIndex);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- if(null == key){
- rowIndex = -1;
- } else {
- rowIndex = ((Integer) key).intValue();
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- public int getRowCount() {
- // TODO Auto-generated method stub
- return getMaxRow();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- public Object getRowData() {
- // TODO Auto-generated method stub
- return isRowAvailable()?String.valueOf(rowIndex):null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- // TODO Auto-generated method stub
- return wrappedData;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- // TODO Auto-generated method stub
- return rowIndex>=getMinRow() && rowIndex<getMaxRow();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- wrappedData = data;
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java 2009-07-23
17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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;
-
-import org.ajax4jsf.model.Range;
-
-/**
- * @author shura
- *
- */
-public class MockRange implements Range {
-
- private int count;
-
- public MockRange(int count) {
- this.count = count;
- }
-
- public int getCount(){
- return count;
- }
-}
Deleted:
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,107 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.SequenceRange;
-import org.easymock.classextension.EasyMock;
-import org.richfaces.test.AbstractFacesTest;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ModifiableModelTest extends AbstractFacesTest {
-
- private ModifiableModel model;
- private ExtendedDataModel originalModel;
- private String var;
- private List<FilterField> filterFields;
- private List<SortField2> sortFields;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- var = "var";
- originalModel = new MockDataModel();
- filterFields = new LinkedList<FilterField>();
- sortFields = new LinkedList<SortField2>();
- model = new ModifiableModel(originalModel, var);
- model.modify(filterFields, sortFields);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- public void tearDown() throws Exception {
- model = null;
- var = null;
- filterFields = null;
- sortFields = null;
- originalModel = null;
- super.tearDown();
- }
-
- /**
- * Test method for {@link
org.richfaces.model.ModifiableModel#walk(javax.faces.context.FacesContext,
org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)}.
- */
- public final void testWalk() {
- SequenceRange range = new SequenceRange(0, -1);
- DataVisitor visitor = new DataVisitor(){
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
- Object key = model.getRowKey();
- model.setRowKey(rowKey);
- Object key2 = originalModel.getRowKey();
- originalModel.setRowKey(rowKey);
- assertEquals(model.getRowData(), originalModel.getRowData());
- model.setRowKey(key);
- originalModel.setRowKey(key2);
- }
- };
- try {
- model.walk(null, visitor, range, null);
- ValueExpression expression =
- facesContext.getApplication().getExpressionFactory().createValueExpression(Boolean.TRUE,
Boolean.class);
- filterFields.add(new FilterField(expression));
- sortFields.add(new SortField2(expression, Ordering.ASCENDING));
- model.walk(null, visitor, range, null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test method for {@link
org.richfaces.model.ModifiableModel#addDataModelListener(javax.faces.model.DataModelListener)}.
- */
- public final void testAddDataModelListenerDataModelListener() {
- DataModelListener mockedListener = EasyMock.createNiceMock(DataModelListener.class);
- model.addDataModelListener(mockedListener);
- assertEquals(model.getDataModelListeners()[0], mockedListener);
- }
-
- /**
- * Test method for {@link
org.richfaces.model.ModifiableModel#removeDataModelListener(javax.faces.model.DataModelListener)}.
- */
- public final void testRemoveDataModelListenerDataModelListener() {
- DataModelListener mockedListener = EasyMock.createNiceMock(DataModelListener.class);
- model.addDataModelListener(mockedListener);
- assertSame(model.getDataModelListeners()[0], mockedListener);
- model.removeDataModelListener(mockedListener);
- assertEquals(model.getDataModelListeners().length, 0);
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,99 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import javax.el.ValueExpression;
-
-import junit.framework.TestCase;
-
-import org.easymock.classextension.EasyMock;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class SortField2Test extends TestCase {
-
- private SortField2 field;
- private ValueExpression expression;
- private Ordering ordering;
- /**
- * @param name
- */
- public SortField2Test(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- expression = EasyMock.createNiceMock(ValueExpression.class);
- ordering = Ordering.ASCENDING;
- field = new SortField2(expression, ordering);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- field = null;
- ordering = null;
- expression = null;
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#hashCode()}.
- */
- public final void testHashCode() {
- Field sortField = new SortField2(expression, ordering);
- assertEquals(sortField.hashCode(), field.hashCode());
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#equals(java.lang.Object)}.
- */
- public final void testEqualsObject() {
- SortField2 sortField = new SortField2(null);
- assertFalse(sortField.equals(field));
- sortField.setExpression(expression);
- sortField.setOrdering(ordering);
- assertTrue(sortField.equals(field));
- }
-
- /**
- * Test method for {@link
org.richfaces.model.SortField2#SortField2(javax.el.ValueExpression)}.
- */
- public final void testSortField2ValueExpression() {
- SortField2 sortField2 = new SortField2(expression);
- field.setOrdering(null);
- assertEquals(sortField2, field);
- }
-
- /**
- * Test method for {@link
org.richfaces.model.SortField2#SortField2(javax.el.ValueExpression,
org.richfaces.model.Ordering)}.
- */
- public final void testSortField2ValueExpressionOrdering() {
- SortField2 sortField2 = new SortField2(expression, ordering);
- assertEquals(sortField2, field);
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#getOrdering()}.
- */
- public final void testGetOrdering() {
- assertEquals(field.getOrdering(), ordering);
- }
-
- /**
- * Test method for {@link
org.richfaces.model.SortField2#setOrdering(org.richfaces.model.Ordering)}.
- */
- public final void testSetOrdering() {
- field.setOrdering(null);
- assertNull(field.getOrdering());
- }
-
-}
Deleted:
root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-07-23
17:00:43 UTC (rev 14987)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-07-23
17:02:30 UTC (rev 14988)
@@ -1,450 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.richfaces.model.entity.Directory;
-import org.richfaces.model.entity.File;
-import org.richfaces.model.entity.Named;
-import org.richfaces.model.entity.Project;
-import org.richfaces.test.AbstractFacesTest;
-
-
-/**
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 30.07.2007
- *
- */
-public class StackingTreeDataModelTest extends AbstractFacesTest {
-
- private StackingTreeModel stackingTreeModel;
- private StackingTreeModel projectsModel;
- private StackingTreeModel directoriesModel;
- private StackingTreeModel filesModel;
-
- private Object projectRequestObject;
- private Object directoryRequestObject;
- private Object fileRequestObject;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- this.stackingTreeModel = new StackingTreeModel();
- projectsModel = new StackingTreeModel("project", "project", new
StackingTreeModelDataProvider() {
-
- private Map<String, Project> data = null;
-
- public Object getData() {
- if (data == null) {
- data = new LinkedHashMap<String, Project>();
- Project projectA = new Project("projectA", 10);
-
- Directory adir1 = new Directory("ADir1", 50);
-
- adir1.addFile(new File("AFile1", 60));
- adir1.addFile(new File("AFile2", 61));
-
- Directory adir2 = new Directory("ADir2", 101);
-
- projectA.addDirectory(adir1);
- projectA.addDirectory(adir2);
-
- data.put(projectA.getName(), projectA);
-
- Project projectB = new Project("projectB", 501);
-
- Directory bdir1 = new Directory("BDir1", 600);
- Directory bdir2 = new Directory("BDir2", 700);
- Directory bdir3 = new Directory("BDir3", 801);
-
- projectB.addDirectory(bdir1);
- projectB.addDirectory(bdir2);
- projectB.addDirectory(bdir3);
-
- data.put(projectB.getName(), projectB);
- }
- return data;
- }
- });
- final ValueBinding dirVB =
application.createValueBinding("#{project.directories}");
- directoriesModel = new StackingTreeModel("directory", "directory",
new StackingTreeModelDataProvider() {
- public Object getData() {
- return dirVB.getValue(facesContext);
- }
- });
- final ValueBinding fileVB =
application.createValueBinding("#{directory.files}");
- filesModel = new StackingTreeModel("file", "file", new
StackingTreeModelDataProvider() {
- public Object getData() {
- return fileVB.getValue(facesContext);
- }
- });
- directoriesModel.addStackingModel(filesModel);
- projectsModel.addStackingModel(directoriesModel);
- this.stackingTreeModel.addStackingModel(projectsModel);
-
- projectRequestObject = new Object();
- directoryRequestObject = new Object();
- fileRequestObject = new Object();
-
- Map<String, Object> requestMap =
facesContext.getExternalContext().getRequestMap();
- requestMap.put("project", projectRequestObject);
- requestMap.put("directory", directoryRequestObject);
- requestMap.put("file", fileRequestObject);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- this.stackingTreeModel = null;
- this.projectsModel = null;
- this.directoriesModel = null;
- this.filesModel = null;
-
- this.projectRequestObject = null;
- this.directoryRequestObject = null;
- this.fileRequestObject = null;
- }
-
- public void testWalk() throws Exception {
- StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
- this.stackingTreeModel.walk(facesContext, visitor1, null, null);
- assertEquals(9, visitor1.getCounter());
- this.stackingTreeModel.setRowKey(null);
- assertFalse(this.stackingTreeModel.isRowAvailable());
-
- Map<String, Object> requestMap =
facesContext.getExternalContext().getRequestMap();
- assertSame(this.projectRequestObject, requestMap.get("project"));
- assertSame(this.directoryRequestObject, requestMap.get("directory"));
- assertSame(this.fileRequestObject, requestMap.get("file"));
- }
-
- public void testBadKey() throws Exception {
- StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
- this.stackingTreeModel.walk(facesContext, visitor1, null, null);
- this.stackingTreeModel.setRowKey(new ListRowKey(new
StackingTreeModelKey("project", "projectA")));
- assertTrue(this.stackingTreeModel.isRowAvailable());
- assertNotNull(this.stackingTreeModel.getRowData());
-
- assertNull(this.stackingTreeModel.getTreeNode());
- assertFalse(this.stackingTreeModel.isLeaf());
-
- this.stackingTreeModel.setRowKey(new ListRowKey(new
StackingTreeModelKey("project", "projectAAAAA")));
- assertFalse(this.stackingTreeModel.isRowAvailable());
- try {
- Object rowData = this.stackingTreeModel.getRowData();
- assertNull(rowData);
- //FIXME: Maksim - bad keys happen for a reason
- //fail();
- } catch (Exception e) {
-
- }
-
- try {
- boolean leaf = this.stackingTreeModel.isLeaf();
- assertTrue(leaf);
- //FIXME: Maksim - bad keys happen for a reason
- //fail();
- } catch (Exception e) {
-
- }
-
- try {
- TreeNode node = this.stackingTreeModel.getTreeNode();
- assertNull(node);
- //FIXME: Maksim - bad keys happen for a reason
- //fail();
- } catch (Exception e) {
-
- }
- }
-
- public void testActiveData() throws Exception {
- final ValueBinding fileVB =
application.createValueBinding("#{directory.files}");
- StackingTreeModel localFilesModel = new StackingTreeModel("file",
"file", new StackingTreeModelDataProvider() {
- public Object getData() {
- return fileVB.getValue(facesContext);
- }
-
- }) {
- protected boolean isActiveData() {
- Map requestMap = facesContext.getExternalContext().getRequestMap();
- Object object = requestMap.get("file");
- assertNotNull(object);
- File file = (File) object;
- if (file.getTag() == 61) {
- return false;
- }
-
- return super.isActiveData();
- }
- };
- directoriesModel.removeStackingModel(filesModel);
- directoriesModel.addStackingModel(localFilesModel);
-
- stackingTreeModel.walk(facesContext, new StackingTreeDataModelTestVisitor3(), null,
null);
- }
-
- public void testKey() throws Exception {
- StackingTreeModelKey key = new StackingTreeModelKey("aaa", new Integer(10));
- StackingTreeModelKey key2 = new StackingTreeModelKey("aaa", new
Integer(11));
- StackingTreeModelKey key3 = new StackingTreeModelKey("aaa", new
Integer(10));
- StackingTreeModelKey key4 = new StackingTreeModelKey("bbb", new
Integer(10));
-
- assertFalse(key.equals(new StackingTreeModelKey("aaa", new Integer(0)) {}
));
-
- assertTrue(key.equals(key3));
- assertTrue(key3.equals(key));
- assertTrue(key2.equals(key2));
- assertTrue(key4.equals(key4));
-
- assertTrue(key.hashCode() == key3.hashCode());
- assertTrue(key3.hashCode() == key.hashCode());
- assertTrue(key2.hashCode() == key2.hashCode());
- assertTrue(key4.hashCode() == key4.hashCode());
-
- assertFalse(key.equals(key2));
- assertFalse(key3.equals(key2));
- assertFalse(key2.equals(key));
- assertFalse(key2.equals(key3));
-
- assertFalse(key.hashCode() == key2.hashCode());
- assertFalse(key3.hashCode() == key2.hashCode());
- assertFalse(key2.hashCode() == key.hashCode());
- assertFalse(key2.hashCode() == key3.hashCode());
-
- assertFalse(key4.equals(key));
- assertFalse(key4.equals(key2));
- assertFalse(key4.equals(key3));
-
- assertFalse(key4.hashCode() == key.hashCode());
- assertFalse(key4.hashCode() == key2.hashCode());
- assertFalse(key4.hashCode() == key3.hashCode());
-
- assertFalse(key.equals(key4));
- assertFalse(key2.equals(key4));
- assertFalse(key3.equals(key4));
-
- assertFalse(new StackingTreeModelKey("aaa", new Integer(10)).equals(null));
- assertFalse(new StackingTreeModelKey("aaa", null).equals(null));
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(null));
- assertFalse(new StackingTreeModelKey(null, null).equals(null));
-
- assertFalse(key.hashCode() == key4.hashCode());
- assertFalse(key2.hashCode() == key4.hashCode());
- assertFalse(key3.hashCode() == key4.hashCode());
-
- assertFalse(key.hashCode() == 0);
- assertFalse(key2.hashCode() == 0);
- assertFalse(key3.hashCode() == 0);
- assertFalse(key4.hashCode() == 0);
-
- assertTrue(new StackingTreeModelKey(null, new Integer(11)).equals(new
StackingTreeModelKey(null, new Integer(11))));
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new
StackingTreeModelKey(null, new Integer(11))));
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new
StackingTreeModelKey("aaa", new Integer(10))));
-
- assertTrue(new StackingTreeModelKey(null, new Integer(11)).hashCode() == new
StackingTreeModelKey(null, new Integer(11)).hashCode());
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new
StackingTreeModelKey(null, new Integer(11)).hashCode());
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new
StackingTreeModelKey("aaa", new Integer(10)).hashCode());
-
- assertTrue(new StackingTreeModelKey("aaa", null).equals(new
StackingTreeModelKey("aaa", null)));
- assertFalse(new StackingTreeModelKey("aaa", null).equals(new
StackingTreeModelKey("bbb", null)));
- assertFalse(new StackingTreeModelKey("aaa", null).equals(new
StackingTreeModelKey("aaa", new Integer(10))));
-
- assertTrue(new StackingTreeModelKey("aaa", null).hashCode() == new
StackingTreeModelKey("aaa", null).hashCode());
- assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new
StackingTreeModelKey("bbb", null).hashCode());
- assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new
StackingTreeModelKey("aaa", new Integer(10)).hashCode());
- }
-
- class StackingTreeDataModelTestVisitor1 implements DataVisitor, LastElementAware {
-
- private boolean last;
- private int tag = 0;
- private int counter = 0;
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- StackingTreeDataModelTestVisitor2 visitor2 = new StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor2, null, new ListRowKey(new
StackingTreeModelKey("project", "projectA")),
- argument, false);
-
- assertEquals(5, visitor2.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor20 = new
StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor20, new TreeRange() {
-
- public boolean processChildren(TreeRowKey rowKey) {
- return false;
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return false;
- }
-
- }, new ListRowKey(new StackingTreeModelKey("project",
"projectA")),
- argument, false);
-
- assertEquals(0, visitor20.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor21 = new
StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor21, new TreeRange() {
-
- public boolean processChildren(TreeRowKey rowKey) {
- return false;
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return true;
- }
-
- }, new ListRowKey(new StackingTreeModelKey("project",
"projectA")),
- argument, false);
-
- assertEquals(1, visitor21.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor22 = new
StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor22, null, new ListRowKey(new
StackingTreeModelKey("project", "projectB")),
- argument, false);
-
- assertEquals(4, visitor22.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor23 = new
StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor23, new TreeRange() {
-
- private boolean rootProcessed = false;
-
- public boolean processChildren(TreeRowKey rowKey) {
- boolean result = rootProcessed;
- rootProcessed = true;
- return !result;
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return true;
- }
-
- }, new ListRowKey(new StackingTreeModelKey("project",
"projectB")),
- argument, false);
-
- assertEquals(4, visitor23.getCounter());
-
- stackingTreeModel.setRowKey(rowKey);
-
- assertSame(rowKey, stackingTreeModel.getRowKey());
-
- assertNull(stackingTreeModel.getTreeNode());
- Object rowData = stackingTreeModel.getRowData();
- assertNotNull(rowData);
- assertTrue(rowData instanceof Named);
-
- Named named = (Named) rowData;
-
- int currentTag = named.getTag();
- assertTrue(currentTag > tag);
- this.tag = currentTag;
-
- if (this.tag % 10 == 1) {
- assertTrue(last);
- } else {
- assertFalse(last);
- }
-
- if (named instanceof Directory) {
- if ("ADir1".equals(named.getName())) {
- assertFalse(stackingTreeModel.isLeaf());
- } else {
- assertTrue(stackingTreeModel.isLeaf());
- }
- } else if (named instanceof Project) {
- assertFalse(stackingTreeModel.isLeaf());
- } else if (named instanceof File) {
- assertTrue(stackingTreeModel.isLeaf());
- } else {
- fail();
- }
-
- counter++;
- }
-
- public void resetLastElement() {
- this.last = false;
- }
-
- public void setLastElement() {
- this.last = true;
- }
-
- public int getCounter() {
- return counter;
- }
- }
-
- class StackingTreeDataModelTestVisitor2 implements DataVisitor {
- private int counter = 0;
- private int tag = 0;
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- stackingTreeModel.setRowKey(rowKey);
- Object rowData = stackingTreeModel.getRowData();
- assertNotNull(rowData);
- Named named = (Named) rowData;
-
- int currentTag = named.getTag();
- assertTrue(currentTag > tag);
- tag = currentTag;
- counter++;
- }
-
- public int getCounter() {
- return counter;
- }
- }
-
- class StackingTreeDataModelTestVisitor3 implements DataVisitor, LastElementAware {
-
- private boolean last;
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- stackingTreeModel.setRowKey(rowKey);
- Named named = (Named) stackingTreeModel.getRowData();
- int tag = named.getTag();
-
- if (tag == 60) {
- assertTrue(last);
- }
- assertFalse(tag == 61);
- }
-
- public void resetLastElement() {
- this.last = false;
- }
-
- public void setLastElement() {
- this.last = true;
- }
- }
-}
-