tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components TableView.java
Date Mon, 03 May 2004 16:03:57 GMT
hlship      2004/05/03 09:03:56

  Modified:    contrib/src/org/apache/tapestry/contrib/table/model/simple
                        SimpleListTableDataModel.java
               examples/Workbench/src/org/apache/tapestry/workbench/table
                        LocaleSelection.java
               doc/src/UsersGuide jars.xml
               contrib/src/org/apache/tapestry/contrib/table/components
                        TableView.java
  Log:
  Remove dependencies on Jakarta digester, collections and beanutils.
  
  Revision  Changes    Path
  1.5       +74 -69    jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/simple/SimpleListTableDataModel.java
  
  Index: SimpleListTableDataModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/model/simple/SimpleListTableDataModel.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleListTableDataModel.java	19 Feb 2004 17:37:51 -0000	1.4
  +++ SimpleListTableDataModel.java	3 May 2004 16:03:56 -0000	1.5
  @@ -21,7 +21,6 @@
   import java.util.Iterator;
   import java.util.List;
   
  -import org.apache.commons.collections.CollectionUtils;
   import org.apache.tapestry.contrib.table.model.CTableDataModelEvent;
   import org.apache.tapestry.contrib.table.model.common.AbstractTableDataModel;
   import org.apache.tapestry.contrib.table.model.common.ArrayIterator;
  @@ -35,17 +34,17 @@
    */
   public class SimpleListTableDataModel extends AbstractTableDataModel implements Serializable
   {
  -	private List m_arrRows;
  +    private List m_arrRows;
   
  -	public SimpleListTableDataModel(Object[] arrRows)
  -	{
  -		this(Arrays.asList(arrRows));
  -	}
  -
  -	public SimpleListTableDataModel(List arrRows)
  -	{
  -		m_arrRows = arrRows;
  -	}
  +    public SimpleListTableDataModel(Object[] arrRows)
  +    {
  +        this(Arrays.asList(arrRows));
  +    }
  +
  +    public SimpleListTableDataModel(List arrRows)
  +    {
  +        m_arrRows = arrRows;
  +    }
   
       public SimpleListTableDataModel(Collection arrRows)
       {
  @@ -55,61 +54,67 @@
       public SimpleListTableDataModel(Iterator objRows)
       {
           m_arrRows = new ArrayList();
  -        CollectionUtils.addAll(m_arrRows, objRows);
  +        addAll(m_arrRows, objRows);
  +    }
  +
  +    private void addAll(List arrRows, Iterator objRows)
  +    {
  +        while (objRows.hasNext())
  +            arrRows.add(objRows.next());
       }
   
  -	/**
  -	 * @see org.apache.tapestry.contrib.table.model.ITableDataModel#getRowCount()
  -	 */
  -	public int getRowCount()
  -	{
  -		return m_arrRows.size();
  -	}
  +    /**
  +     * @see org.apache.tapestry.contrib.table.model.ITableDataModel#getRowCount()
  +     */
  +    public int getRowCount()
  +    {
  +        return m_arrRows.size();
  +    }
   
  -	/**
  -	 * Returns the row element at the given position
  +    /**
  +     * Returns the row element at the given position
        * @param nRow the index of the element to return
  -	 */
  -	public Object getRow(int nRow)
  -	{
  -		if (nRow < 0 || nRow >= m_arrRows.size())
  -		{
  -			// error message
  -			return null;
  -		}
  -		return m_arrRows.get(nRow);
  -	}
  +     */
  +    public Object getRow(int nRow)
  +    {
  +        if (nRow < 0 || nRow >= m_arrRows.size())
  +        {
  +            // error message
  +            return null;
  +        }
  +        return m_arrRows.get(nRow);
  +    }
   
  -	/**
  -	 * Returns an Iterator with the elements from the given range
  +    /**
  +     * Returns an Iterator with the elements from the given range
        * @param nFrom the start of the range (inclusive)
        * @param nTo the stop of the range (exclusive)
  -	 */
  -	public Iterator getRows(int nFrom, int nTo)
  -	{
  -		return new ArrayIterator(m_arrRows.toArray(), nFrom, nTo);
  -	}
  -
  -	/**
  -	 * @see org.apache.tapestry.contrib.table.model.ITableDataModel#getRows()
  -	 */
  -	public Iterator getRows()
  -	{
  -		return m_arrRows.iterator();
  -	}
  +     */
  +    public Iterator getRows(int nFrom, int nTo)
  +    {
  +        return new ArrayIterator(m_arrRows.toArray(), nFrom, nTo);
  +    }
   
  -	/**
  -	 * Method addRow.
  +    /**
  +     * @see org.apache.tapestry.contrib.table.model.ITableDataModel#getRows()
  +     */
  +    public Iterator getRows()
  +    {
  +        return m_arrRows.iterator();
  +    }
  +
  +    /**
  +     * Method addRow.
        * Adds a row object to the model at its end
  -	 * @param objRow the row object to add
  -	 */
  -	public void addRow(Object objRow)
  -	{
  -		m_arrRows.add(objRow);
  -
  -		CTableDataModelEvent objEvent = new CTableDataModelEvent();
  -		fireTableDataModelEvent(objEvent);
  -	}
  +     * @param objRow the row object to add
  +     */
  +    public void addRow(Object objRow)
  +    {
  +        m_arrRows.add(objRow);
  +
  +        CTableDataModelEvent objEvent = new CTableDataModelEvent();
  +        fireTableDataModelEvent(objEvent);
  +    }
   
       public void addRows(Collection arrRows)
       {
  @@ -119,18 +124,18 @@
           fireTableDataModelEvent(objEvent);
       }
   
  -	/**
  -	 * Method removeRow.
  +    /**
  +     * Method removeRow.
        * Removes a row object from the model
  -	 * @param objRow the row object to remove
  -	 */
  -	public void removeRow(Object objRow)
  -	{
  -		m_arrRows.remove(objRow);
  -
  -		CTableDataModelEvent objEvent = new CTableDataModelEvent();
  -		fireTableDataModelEvent(objEvent);
  -	}
  +     * @param objRow the row object to remove
  +     */
  +    public void removeRow(Object objRow)
  +    {
  +        m_arrRows.remove(objRow);
  +
  +        CTableDataModelEvent objEvent = new CTableDataModelEvent();
  +        fireTableDataModelEvent(objEvent);
  +    }
   
       public void removeRows(Collection arrRows)
       {
  
  
  
  1.9       +8 -3      jakarta-tapestry/examples/Workbench/src/org/apache/tapestry/workbench/table/LocaleSelection.java
  
  Index: LocaleSelection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Workbench/src/org/apache/tapestry/workbench/table/LocaleSelection.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LocaleSelection.java	2 Mar 2004 22:32:05 -0000	1.8
  +++ LocaleSelection.java	3 May 2004 16:03:56 -0000	1.9
  @@ -20,7 +20,6 @@
   import java.util.Locale;
   import java.util.Set;
   
  -import org.apache.commons.collections.CollectionUtils;
   import org.apache.tapestry.BaseComponent;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.contrib.table.model.ITableColumn;
  @@ -58,9 +57,15 @@
       public void localesSelected(Locale[] arrLocales)
       {
           Set objLocaleSet = getLocaleSet();
  -        CollectionUtils.addAll(objLocaleSet, arrLocales);
  +        addAll(objLocaleSet, arrLocales);
           // ensure that the framework knows about the change and the set is persisted
           setLocaleSet(objLocaleSet);
  +    }
  +
  +    private void addAll(Set objLocaleSet, Locale[] arrLocales)
  +    {
  +        for (int i = 0; i < arrLocales.length; i++)
  +            objLocaleSet.add(arrLocales[i]);
       }
   
       public ITableColumn getCurrencyColumn()
  
  
  
  1.2       +2 -2      jakarta-tapestry/doc/src/UsersGuide/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/doc/src/UsersGuide/jars.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jars.xml	2 Mar 2004 22:35:34 -0000	1.1
  +++ jars.xml	3 May 2004 16:03:56 -0000	1.2
  @@ -64,7 +64,7 @@
   		<listitem>
   		<para>
   		Frameworks needed when compiling the framework and at runtime.  This is
  -		several other &Jakarta; frameworks (including &BSF; and &BCEL;), plus
  +		several other &Jakarta; frameworks (including &BSF;), plus
   		the &OGNL; and &Javassist; frameworks.
   		</para>
   		</listitem>
  
  
  
  1.16      +18 -10    jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableView.java
  
  Index: TableView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/table/components/TableView.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TableView.java	30 Apr 2004 15:17:10 -0000	1.15
  +++ TableView.java	3 May 2004 16:03:56 -0000	1.16
  @@ -20,7 +20,6 @@
   import java.util.Iterator;
   import java.util.List;
   
  -import org.apache.commons.collections.CollectionUtils;
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.tapestry.BaseComponent;
   import org.apache.tapestry.IBinding;
  @@ -162,7 +161,7 @@
        */
       public void reset()
       {
  -		initialize();
  +        initialize();
           storeSessionState(null);
       }
   
  @@ -242,12 +241,15 @@
           ITableDataModel objDataModel = null;
           if (objSourceValue instanceof Object[])
               objDataModel = new SimpleListTableDataModel((Object[]) objSourceValue);
  -        else if (objSourceValue instanceof List)
  -            objDataModel = new SimpleListTableDataModel((List) objSourceValue);
  -        else if (objSourceValue instanceof Collection)
  -            objDataModel = new SimpleListTableDataModel((Collection) objSourceValue);
  -        else if (objSourceValue instanceof Iterator)
  -            objDataModel = new SimpleListTableDataModel((Iterator) objSourceValue);
  +        else
  +            if (objSourceValue instanceof List)
  +                objDataModel = new SimpleListTableDataModel((List) objSourceValue);
  +            else
  +                if (objSourceValue instanceof Collection)
  +                    objDataModel = new SimpleListTableDataModel((Collection) objSourceValue);
  +                else
  +                    if (objSourceValue instanceof Iterator)
  +                        objDataModel = new SimpleListTableDataModel((Iterator) objSourceValue);
   
           if (objDataModel == null)
               throw new ApplicationRuntimeException(
  @@ -283,7 +285,7 @@
               // convert to List
               Iterator objColumnsIterator = (Iterator) objColumns;
               List arrColumnsList = new ArrayList();
  -            CollectionUtils.addAll(arrColumnsList, objColumnsIterator);
  +            addAll(arrColumnsList, objColumnsIterator);
               objColumns = arrColumnsList;
           }
   
  @@ -324,6 +326,12 @@
   
           throw new ApplicationRuntimeException(
               TableUtils.format("invalid-table-columns", getExtendedId(), objColumns.getClass()));
  +    }
  +
  +    private void addAll(List arrColumnsList, Iterator objColumnsIterator)
  +    {
  +        while (objColumnsIterator.hasNext())
  +            arrColumnsList.add(objColumnsIterator.next());
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message