You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/01/12 18:18:56 UTC
svn commit: r368415 [2/5] - in /jakarta/tapestry/trunk/contrib/src:
java/org/apache/tapestry/contrib/inspector/
java/org/apache/tapestry/contrib/jdbc/ java/org/apache/tapestry/contrib/link/
java/org/apache/tapestry/contrib/palette/ java/org/apache/tape...
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/TableView.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -45,64 +45,66 @@
import org.apache.tapestry.event.PageEvent;
/**
- * A low level Table component that wraps all other low level Table components. This component
- * carries the {@link org.apache.tapestry.contrib.table.model.ITableModel}that is used by the other
- * Table components. Please see the documentation of
- * {@link org.apache.tapestry.contrib.table.model.ITableModel}if you need to know more about how a
- * table is represented.
+ * A low level Table component that wraps all other low level Table components.
+ * This component carries the
+ * {@link org.apache.tapestry.contrib.table.model.ITableModel}that is used by
+ * the other Table components. Please see the documentation of
+ * {@link org.apache.tapestry.contrib.table.model.ITableModel}if you need to
+ * know more about how a table is represented.
* <p>
* This component also handles the saving of the state of the model using an
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}to determine what part
- * of the model is to be saved and an
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}to determine how to
- * save it.
+ * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}to
+ * determine what part of the model is to be saved and an
+ * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}to
+ * determine how to save it.
* <p>
- * Upon the beginning of a new request cycle when the table model is first needed, the model is
- * obtained using the following process:
+ * Upon the beginning of a new request cycle when the table model is first
+ * needed, the model is obtained using the following process:
* <ul>
- * <li>The persistent state of the table is loaded. If the tableSessionStoreManager binding has not
- * been bound, the state is loaded from a persistent property within the component (it is null at
- * the beginning). Otherwise the supplied
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}is used to load the
- * persistent state.
+ * <li>The persistent state of the table is loaded. If the
+ * tableSessionStoreManager binding has not been bound, the state is loaded from
+ * a persistent property within the component (it is null at the beginning).
+ * Otherwise the supplied
+ * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}is
+ * used to load the persistent state.
* <li>The table model is recreated using the
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}that could be supplied
- * using the tableSessionStateManager binding (but has a default value and is therefore not
- * required).
- * <li>If the {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}returns
+ * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}that
+ * could be supplied using the tableSessionStateManager binding (but has a
+ * default value and is therefore not required).
+ * <li>If the
+ * {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}returns
* null, then a table model is taken from the tableModel binding. Thus, if the
- * {@link org.apache.tapestry.contrib.table.model.common.NullTableSessionStateManager}is used, the
- * table model would be taken from the tableModel binding every time.
+ * {@link org.apache.tapestry.contrib.table.model.common.NullTableSessionStateManager}is
+ * used, the table model would be taken from the tableModel binding every time.
* </ul>
- * Just before the rendering phase the persistent state of the model is saved in the session. This
- * process occurs in reverse:
+ * Just before the rendering phase the persistent state of the model is saved in
+ * the session. This process occurs in reverse:
* <ul>
* <li>The persistent state of the model is taken via the
* {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager}.
- * <li>If the tableSessionStoreManager binding has not been bound, the persistent state is saved as
- * a persistent page property. Otherwise the supplied
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}is used to save the
- * persistent state. Use of the
- * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}is usually necessary
- * when tables with the same model have to be used across multiple pages, and hence the state has to
- * be saved in the Visit, rather than in a persistent component property.
+ * <li>If the tableSessionStoreManager binding has not been bound, the
+ * persistent state is saved as a persistent page property. Otherwise the
+ * supplied
+ * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}is
+ * used to save the persistent state. Use of the
+ * {@link org.apache.tapestry.contrib.table.model.ITableSessionStoreManager}is
+ * usually necessary when tables with the same model have to be used across
+ * multiple pages, and hence the state has to be saved in the Visit, rather than
+ * in a persistent component property.
* </ul>
* <p>
* <p>
- * Please see the Component Reference for details on how to use this component. [ <a
- * href="../../../../../../../ComponentReference/contrib.TableView.html">Component Reference </a>]
+ * Please see the Component Reference for details on how to use this component. [
+ * <a
+ * href="../../../../../../../ComponentReference/contrib.TableView.html">Component
+ * Reference </a>]
*
* @author mindbridge
*/
-public abstract class TableView extends BaseComponent implements PageDetachListener,
- PageBeginRenderListener, ITableModelSource
+public abstract class TableView extends BaseComponent implements PageDetachListener, PageBeginRenderListener,
+ ITableModelSource
{
- /** @since 4.0 */
- public abstract TableColumnModelSource getModelSource();
- /** @since 4.0 */
- public abstract IAdvancedTableColumnSource getColumnSource();
-
// Component properties
private ITableSessionStateManager m_objDefaultSessionStateManager = null;
@@ -113,6 +115,20 @@
private ITableModel m_objCachedTableModelValue;
+ /**
+ * The component constructor. Invokes the component member initializations.
+ */
+ public TableView()
+ {
+ initialize();
+ }
+
+ /** @since 4.0 */
+ public abstract TableColumnModelSource getModelSource();
+
+ /** @since 4.0 */
+ public abstract IAdvancedTableColumnSource getColumnSource();
+
// enhanced parameter methods
public abstract ITableModel getTableModelValue();
@@ -150,14 +166,6 @@
public abstract void setClientAppState(Serializable sessionState);
/**
- * The component constructor. Invokes the component member initializations.
- */
- public TableView()
- {
- initialize();
- }
-
- /**
* Invokes the component member initializations.
*
* @see org.apache.tapestry.event.PageDetachListener#pageDetached(PageEvent)
@@ -177,8 +185,9 @@
}
/**
- * Resets the table by removing any stored table state. This means that the current column to
- * sort on and the current page will be forgotten and all data will be reloaded.
+ * Resets the table by removing any stored table state. This means that the
+ * current column to sort on and the current page will be forgotten and all
+ * data will be reloaded.
*/
public void reset()
{
@@ -188,8 +197,7 @@
public ITableModel getCachedTableModelValue()
{
- if (m_objCachedTableModelValue == null)
- m_objCachedTableModelValue = getTableModelValue();
+ if (m_objCachedTableModelValue == null) m_objCachedTableModelValue = getTableModelValue();
return m_objCachedTableModelValue;
}
@@ -209,15 +217,13 @@
}
// if the session state does not help, get the model from the binding
- if (m_objTableModel == null)
- m_objTableModel = getCachedTableModelValue();
+ if (m_objTableModel == null) m_objTableModel = getCachedTableModelValue();
- // if the model from the binding is null, build a model from source and columns
- if (m_objTableModel == null)
- m_objTableModel = generateTableModel(null);
+ // if the model from the binding is null, build a model from source and
+ // columns
+ if (m_objTableModel == null) m_objTableModel = generateTableModel(null);
- if (m_objTableModel == null)
- throw new ApplicationRuntimeException(TableMessages.missingTableModel(this));
+ if (m_objTableModel == null) throw new ApplicationRuntimeException(TableMessages.missingTableModel(this));
return m_objTableModel;
}
@@ -238,47 +244,41 @@
}
// update the page size if set in the parameter
- if (isParameterBound("pageSize"))
- objState.getPagingState().setPageSize(getPageSize());
+ if (isParameterBound("pageSize")) objState.getPagingState().setPageSize(getPageSize());
// get the column model. if not possible, return null.
ITableColumnModel objColumnModel = getTableColumnModel();
- if (objColumnModel == null)
- return null;
+ if (objColumnModel == null) return null;
Object objSourceValue = getSource();
- if (objSourceValue == null)
- return null;
+ if (objSourceValue == null) return null;
// if the source parameter is of type {@link IBasicTableModel},
// create and return an appropriate wrapper
if (objSourceValue instanceof IBasicTableModel)
- return new BasicTableModelWrap((IBasicTableModel) objSourceValue, objColumnModel,
- objState);
+ return new BasicTableModelWrap((IBasicTableModel)objSourceValue, objColumnModel, objState);
// otherwise, the source parameter must contain the data to be displayed
ITableDataModel objDataModel = null;
if (objSourceValue instanceof Object[])
- objDataModel = new SimpleListTableDataModel((Object[]) objSourceValue);
+ objDataModel = new SimpleListTableDataModel((Object[])objSourceValue);
else if (objSourceValue instanceof List)
- objDataModel = new SimpleListTableDataModel((List) objSourceValue);
+ objDataModel = new SimpleListTableDataModel((List)objSourceValue);
else if (objSourceValue instanceof Collection)
- objDataModel = new SimpleListTableDataModel((Collection) objSourceValue);
+ objDataModel = new SimpleListTableDataModel((Collection)objSourceValue);
else if (objSourceValue instanceof Iterator)
- objDataModel = new SimpleListTableDataModel((Iterator) objSourceValue);
+ objDataModel = new SimpleListTableDataModel((Iterator)objSourceValue);
if (objDataModel == null)
- throw new ApplicationRuntimeException(TableMessages.invalidTableSource(
- this,
- objSourceValue));
+ throw new ApplicationRuntimeException(TableMessages.invalidTableSource(this, objSourceValue));
return new SimpleTableModel(objDataModel, objColumnModel, objState);
}
/**
- * Returns the table column model as specified by the 'columns' binding. If the value of the
- * 'columns' binding is of a type different than ITableColumnModel, this method makes the
- * appropriate conversion.
+ * Returns the table column model as specified by the 'columns' binding. If
+ * the value of the 'columns' binding is of a type different than
+ * ITableColumnModel, this method makes the appropriate conversion.
*
* @return The table column model as specified by the 'columns' binding
*/
@@ -286,18 +286,14 @@
{
Object objColumns = getColumns();
- if (objColumns == null)
- return null;
+ if (objColumns == null) return null;
- if (objColumns instanceof ITableColumnModel)
- {
- return (ITableColumnModel) objColumns;
- }
+ if (objColumns instanceof ITableColumnModel) { return (ITableColumnModel)objColumns; }
if (objColumns instanceof Iterator)
{
// convert to List
- Iterator objColumnsIterator = (Iterator) objColumns;
+ Iterator objColumnsIterator = (Iterator)objColumns;
List arrColumnsList = new ArrayList();
addAll(arrColumnsList, objColumnsIterator);
objColumns = arrColumnsList;
@@ -306,30 +302,27 @@
if (objColumns instanceof List)
{
// validate that the list contains only ITableColumn instances
- List arrColumnsList = (List) objColumns;
+ List arrColumnsList = (List)objColumns;
int nColumnsNumber = arrColumnsList.size();
- for (int i = 0; i < nColumnsNumber; i++)
+ for(int i = 0; i < nColumnsNumber; i++)
{
if (!(arrColumnsList.get(i) instanceof ITableColumn))
throw new ApplicationRuntimeException(TableMessages.columnsOnlyPlease(this));
}
- //objColumns = arrColumnsList.toArray(new ITableColumn[nColumnsNumber]);
+ // objColumns = arrColumnsList.toArray(new
+ // ITableColumn[nColumnsNumber]);
return new SimpleTableColumnModel(arrColumnsList);
}
- if (objColumns instanceof ITableColumn[])
- {
- return new SimpleTableColumnModel((ITableColumn[]) objColumns);
- }
+ if (objColumns instanceof ITableColumn[]) { return new SimpleTableColumnModel((ITableColumn[])objColumns); }
if (objColumns instanceof String)
{
- String strColumns = (String) objColumns;
+ String strColumns = (String)objColumns;
if (getBinding("columns").isInvariant())
{
// if the binding is invariant, create the columns only once
- if (m_objColumnModel == null)
- m_objColumnModel = generateTableColumnModel(strColumns);
+ if (m_objColumnModel == null) m_objColumnModel = generateTableColumnModel(strColumns);
return m_objColumnModel;
}
@@ -342,16 +335,17 @@
private void addAll(List arrColumnsList, Iterator objColumnsIterator)
{
- while (objColumnsIterator.hasNext())
+ while(objColumnsIterator.hasNext())
arrColumnsList.add(objColumnsIterator.next());
}
/**
- * Generate a table column model out of the description string provided. Entries in the
- * description string are separated by commas. Each column entry is of the format name,
- * name:expression, or name:displayName:expression. An entry prefixed with ! represents a
- * non-sortable column. If the whole description string is prefixed with *, it represents
- * columns to be included in a Form.
+ * Generate a table column model out of the description string provided.
+ * Entries in the description string are separated by commas. Each column
+ * entry is of the format name, name:expression, or
+ * name:displayName:expression. An entry prefixed with ! represents a
+ * non-sortable column. If the whole description string is prefixed with *,
+ * it represents columns to be included in a Form.
*
* @param strDesc
* the description of the column model to be generated
@@ -361,13 +355,13 @@
{
IComponent objColumnSettingsContainer = getColumnSettingsContainer();
IAdvancedTableColumnSource objColumnSource = getColumnSource();
-
+
return getModelSource().generateTableColumnModel(objColumnSource, strDesc, this, objColumnSettingsContainer);
}
/**
- * The default session state manager to be used in case no such manager is provided by the
- * corresponding parameter.
+ * The default session state manager to be used in case no such manager is
+ * provided by the corresponding parameter.
*
* @return the default session state manager
*/
@@ -379,7 +373,8 @@
}
/**
- * Invoked when there is a modification of the table state and it needs to be saved
+ * Invoked when there is a modification of the table state and it needs to
+ * be saved.
*
* @see org.apache.tapestry.contrib.table.model.ITableModelSource#fireObservedStateChange()
*/
@@ -389,8 +384,9 @@
}
/**
- * Ensures that the table state is saved before the render phase begins in case there are
- * modifications for which {@link #fireObservedStateChange()}has not been invoked.
+ * Ensures that the table state is saved before the render phase begins in
+ * case there are modifications for which {@link #fireObservedStateChange()}has
+ * not been invoked.
*
* @see org.apache.tapestry.event.PageBeginRenderListener#pageBeginRender(org.apache.tapestry.event.PageEvent)
*/
@@ -398,15 +394,15 @@
{
// 'suspenders': save the table model if it has been already loaded.
// this means that if a change has been made explicitly in a listener,
- // it will be saved. this is the last place before committing the changes
+ // it will be saved. this is the last place before committing the
+ // changes
// where a save can occur
- if (m_objTableModel != null)
- saveSessionState();
+ if (m_objTableModel != null) saveSessionState();
}
/**
- * Saves the table state using the SessionStateManager to determine what to save and the
- * SessionStoreManager to determine where to save it.
+ * Saves the table state using the SessionStateManager to determine what to
+ * save and the SessionStoreManager to determine where to save it.
*/
protected void saveSessionState()
{
@@ -423,15 +419,13 @@
protected Serializable loadSessionState()
{
ITableSessionStoreManager objManager = getTableSessionStoreManager();
- if (objManager != null)
- return objManager.loadState(getPage().getRequestCycle());
- String strPersist = getPersist();
- if (strPersist.equals("client") || strPersist.equals("client:page"))
- return getClientState();
- else if (strPersist.equals("client:app"))
- return getClientAppState();
- else
- return getSessionState();
+ if (objManager != null) return objManager.loadState(getPage().getRequestCycle());
+ String strPersist = getPersist();
+ if (strPersist.equals("client") || strPersist.equals("client:page"))
+ return getClientState();
+ else if (strPersist.equals("client:app"))
+ return getClientAppState();
+ else return getSessionState();
}
/**
@@ -445,20 +439,20 @@
ITableSessionStoreManager objManager = getTableSessionStoreManager();
if (objManager != null)
objManager.saveState(getPage().getRequestCycle(), objState);
- else {
- String strPersist = getPersist();
- if (strPersist.equals("client") || strPersist.equals("client:page"))
- setClientState(objState);
- else if (strPersist.equals("client:app"))
- setClientAppState(objState);
- else
- setSessionState(objState);
+ else
+ {
+ String strPersist = getPersist();
+ if (strPersist.equals("client") || strPersist.equals("client:page"))
+ setClientState(objState);
+ else if (strPersist.equals("client:app"))
+ setClientAppState(objState);
+ else setSessionState(objState);
}
}
/**
- * Make sure that the values stored in the model are useable and correct. The changes made here
- * are not saved.
+ * Make sure that the values stored in the model are useable and correct.
+ * The changes made here are not saved.
*/
protected void validateValues()
{
@@ -483,10 +477,11 @@
}
/**
- * Stores a pointer to this component in the Request Cycle while rendering so that wrapped
- * components have access to it.
+ * Stores a pointer to this component in the Request Cycle while rendering
+ * so that wrapped components have access to it.
*
- * @see org.apache.tapestry.BaseComponent#renderComponent(IMarkupWriter, IRequestCycle)
+ * @see org.apache.tapestry.BaseComponent#renderComponent(IMarkupWriter,
+ * IRequestCycle)
*/
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
@@ -500,4 +495,4 @@
cycle.setAttribute(ITableModelSource.TABLE_MODEL_SOURCE_ATTRIBUTE, objOldValue);
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnComponent.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnComponent.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnComponent.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnComponent.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,135 +29,119 @@
import org.apache.tapestry.util.ComponentAddress;
/**
- * A component that renders the default column header.
- *
- * If the current column is sortable, it renders the header as a link.
- * Clicking on the link causes the table to be sorted on that column.
- * Clicking on the link again causes the sorting order to be reversed.
+ * A component that renders the default column header. If the current column is
+ * sortable, it renders the header as a link. Clicking on the link causes the
+ * table to be sorted on that column. Clicking on the link again causes the
+ * sorting order to be reversed.
*
* @author mindbridge
*/
-public abstract class SimpleTableColumnComponent
- extends BaseComponent
- implements ITableRendererListener, PageDetachListener
+public abstract class SimpleTableColumnComponent extends BaseComponent implements ITableRendererListener,
+ PageDetachListener
{
- // transient
- private ITableColumn m_objColumn;
- private ITableModelSource m_objModelSource;
-
- public SimpleTableColumnComponent()
- {
- init();
- }
-
- /**
- * @see org.apache.tapestry.event.PageDetachListener#pageDetached(PageEvent)
- */
- public void pageDetached(PageEvent arg0)
- {
- init();
- }
-
- private void init()
- {
- m_objColumn = null;
- m_objModelSource = null;
- }
+ // transient
+ private ITableColumn m_objColumn;
+ private ITableModelSource m_objModelSource;
+
+ public SimpleTableColumnComponent()
+ {
+ init();
+ }
+
+ /**
+ * @see org.apache.tapestry.event.PageDetachListener#pageDetached(PageEvent)
+ */
+ public void pageDetached(PageEvent arg0)
+ {
+ init();
+ }
+
+ private void init()
+ {
+ m_objColumn = null;
+ m_objModelSource = null;
+ }
/**
- * @see org.apache.tapestry.contrib.table.model.ITableRendererListener#initializeRenderer(IRequestCycle, ITableModelSource, ITableColumn, Object)
+ * @see org.apache.tapestry.contrib.table.model.ITableRendererListener#initializeRenderer(IRequestCycle,
+ * ITableModelSource, ITableColumn, Object)
*/
- public void initializeRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource,
- ITableColumn objColumn,
- Object objRow)
+ public void initializeRenderer(IRequestCycle objCycle, ITableModelSource objSource, ITableColumn objColumn,
+ Object objRow)
{
m_objModelSource = objSource;
m_objColumn = objColumn;
}
- public ITableModel getTableModel()
- {
- return m_objModelSource.getTableModel();
- }
-
- public boolean getColumnSorted()
- {
- return m_objColumn.getSortable();
- }
-
- public String getDisplayName()
- {
- if (m_objColumn instanceof SimpleTableColumn) {
- SimpleTableColumn objSimpleColumn = (SimpleTableColumn) m_objColumn;
- return objSimpleColumn.getDisplayName();
+ public ITableModel getTableModel()
+ {
+ return m_objModelSource.getTableModel();
+ }
+
+ public boolean getColumnSorted()
+ {
+ return m_objColumn.getSortable();
+ }
+
+ public String getDisplayName()
+ {
+ if (m_objColumn instanceof SimpleTableColumn)
+ {
+ SimpleTableColumn objSimpleColumn = (SimpleTableColumn)m_objColumn;
+ return objSimpleColumn.getDisplayName();
}
return m_objColumn.getColumnName();
- }
+ }
+
+ public boolean getIsSorted()
+ {
+ ITableSortingState objSortingState = getTableModel().getSortingState();
+ String strSortColumn = objSortingState.getSortColumn();
+ return m_objColumn.getColumnName().equals(strSortColumn);
+ }
+
+ public IAsset getSortImage()
+ {
+ IAsset objImageAsset;
+
+ IRequestCycle objCycle = getPage().getRequestCycle();
+ ITableSortingState objSortingState = getTableModel().getSortingState();
+ if (objSortingState.getSortOrder() == ITableSortingState.SORT_ASCENDING)
+ {
+ objImageAsset = (IAsset)objCycle.getAttribute(TableColumns.TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
+ if (objImageAsset == null) objImageAsset = getAsset("sortUp");
+ }
+ else
+ {
+ objImageAsset = (IAsset)objCycle.getAttribute(TableColumns.TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
+ if (objImageAsset == null) objImageAsset = getAsset("sortDown");
+ }
+
+ return objImageAsset;
+ }
- public boolean getIsSorted()
- {
- ITableSortingState objSortingState = getTableModel().getSortingState();
- String strSortColumn = objSortingState.getSortColumn();
- return m_objColumn.getColumnName().equals(strSortColumn);
- }
-
- public IAsset getSortImage()
- {
- IAsset objImageAsset;
-
- IRequestCycle objCycle = getPage().getRequestCycle();
- ITableSortingState objSortingState = getTableModel().getSortingState();
- if (objSortingState.getSortOrder()
- == ITableSortingState.SORT_ASCENDING)
- {
- objImageAsset =
- (IAsset) objCycle.getAttribute(
- TableColumns.TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
- if (objImageAsset == null)
- objImageAsset = getAsset("sortUp");
- }
- else
- {
- objImageAsset =
- (IAsset) objCycle.getAttribute(
- TableColumns.TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
- if (objImageAsset == null)
- objImageAsset = getAsset("sortDown");
- }
-
- return objImageAsset;
- }
-
- public Object[] getColumnSelectedParameters()
- {
- return new Object[] {
- new ComponentAddress(m_objModelSource),
- m_objColumn.getColumnName()};
- }
-
- public void columnSelected(IRequestCycle objCycle)
- {
- Object[] arrArgs = objCycle.getListenerParameters();
- ComponentAddress objAddr = (ComponentAddress) arrArgs[0];
- String strColumnName = (String) arrArgs[1];
-
- ITableModelSource objSource =
- (ITableModelSource) objAddr.findComponent(objCycle);
- ITableModel objModel = objSource.getTableModel();
-
- ITableSortingState objState = objModel.getSortingState();
- if (strColumnName.equals(objState.getSortColumn()))
- objState.setSortColumn(strColumnName, !objState.getSortOrder());
- else
- objState.setSortColumn(
- strColumnName,
- ITableSortingState.SORT_ASCENDING);
-
- // ensure that the change is saved
- objSource.fireObservedStateChange();
- }
+ public Object[] getColumnSelectedParameters()
+ {
+ return new Object[] { new ComponentAddress(m_objModelSource), m_objColumn.getColumnName() };
+ }
+
+ public void columnSelected(IRequestCycle objCycle)
+ {
+ Object[] arrArgs = objCycle.getListenerParameters();
+ ComponentAddress objAddr = (ComponentAddress)arrArgs[0];
+ String strColumnName = (String)arrArgs[1];
+
+ ITableModelSource objSource = (ITableModelSource)objAddr.findComponent(objCycle);
+ ITableModel objModel = objSource.getTableModel();
+
+ ITableSortingState objState = objModel.getSortingState();
+ if (strColumnName.equals(objState.getSortColumn()))
+ objState.setSortColumn(strColumnName, !objState.getSortOrder());
+ else objState.setSortColumn(strColumnName, ITableSortingState.SORT_ASCENDING);
+
+ // ensure that the change is saved
+ objSource.fireObservedStateChange();
+ }
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnFormComponent.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnFormComponent.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnFormComponent.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/components/inserted/SimpleTableColumnFormComponent.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -26,111 +26,98 @@
import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn;
/**
- * A component that renders the default column header in a form.
- *
- * If the current column is sortable, it renders the header as a link.
- * Clicking on the link causes the table to be sorted on that column.
- * Clicking on the link again causes the sorting order to be reversed.
- *
- * This component renders links that cause the form to be submitted.
- * This ensures that the updated data in the other form fields is preserved.
+ * A component that renders the default column header in a form. If the current
+ * column is sortable, it renders the header as a link. Clicking on the link
+ * causes the table to be sorted on that column. Clicking on the link again
+ * causes the sorting order to be reversed. This component renders links that
+ * cause the form to be submitted. This ensures that the updated data in the
+ * other form fields is preserved.
*
* @author mindbridge
*/
-public abstract class SimpleTableColumnFormComponent
- extends BaseComponent
- implements ITableRendererListener
+public abstract class SimpleTableColumnFormComponent extends BaseComponent implements ITableRendererListener
{
public abstract ITableColumn getTableColumn();
+
public abstract void setTableColumn(ITableColumn objColumn);
public abstract ITableModelSource getTableModelSource();
+
public abstract void setTableModelSource(ITableModelSource objSource);
public abstract String getSelectedColumnName();
/**
- * @see org.apache.tapestry.contrib.table.model.ITableRendererListener#initializeRenderer(IRequestCycle, ITableModelSource, ITableColumn, Object)
+ * @see org.apache.tapestry.contrib.table.model.ITableRendererListener#initializeRenderer(IRequestCycle,
+ * ITableModelSource, ITableColumn, Object)
*/
- public void initializeRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource,
- ITableColumn objColumn,
- Object objRow)
+ public void initializeRenderer(IRequestCycle objCycle, ITableModelSource objSource, ITableColumn objColumn,
+ Object objRow)
{
setTableModelSource(objSource);
setTableColumn(objColumn);
}
- public ITableModel getTableModel()
- {
- return getTableModelSource().getTableModel();
- }
-
- public boolean getColumnSorted()
- {
- return getTableColumn().getSortable();
- }
+ public ITableModel getTableModel()
+ {
+ return getTableModelSource().getTableModel();
+ }
+
+ public boolean getColumnSorted()
+ {
+ return getTableColumn().getSortable();
+ }
- public String getDisplayName()
- {
+ public String getDisplayName()
+ {
ITableColumn objColumn = getTableColumn();
-
- if (objColumn instanceof SimpleTableColumn) {
- SimpleTableColumn objSimpleColumn = (SimpleTableColumn) objColumn;
- return objSimpleColumn.getDisplayName();
+
+ if (objColumn instanceof SimpleTableColumn)
+ {
+ SimpleTableColumn objSimpleColumn = (SimpleTableColumn)objColumn;
+ return objSimpleColumn.getDisplayName();
}
return objColumn.getColumnName();
- }
+ }
- public boolean getIsSorted()
- {
- ITableSortingState objSortingState = getTableModel().getSortingState();
- String strSortColumn = objSortingState.getSortColumn();
- return getTableColumn().getColumnName().equals(strSortColumn);
- }
-
- public IAsset getSortImage()
- {
- IAsset objImageAsset;
-
- IRequestCycle objCycle = getPage().getRequestCycle();
- ITableSortingState objSortingState = getTableModel().getSortingState();
- if (objSortingState.getSortOrder()
- == ITableSortingState.SORT_ASCENDING)
- {
- objImageAsset =
- (IAsset) objCycle.getAttribute(
- TableColumns.TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
- if (objImageAsset == null)
- objImageAsset = getAsset("sortUp");
- }
- else
- {
- objImageAsset =
- (IAsset) objCycle.getAttribute(
- TableColumns.TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
- if (objImageAsset == null)
- objImageAsset = getAsset("sortDown");
- }
+ public boolean getIsSorted()
+ {
+ ITableSortingState objSortingState = getTableModel().getSortingState();
+ String strSortColumn = objSortingState.getSortColumn();
+ return getTableColumn().getColumnName().equals(strSortColumn);
+ }
+
+ public IAsset getSortImage()
+ {
+ IAsset objImageAsset;
- return objImageAsset;
- }
+ IRequestCycle objCycle = getPage().getRequestCycle();
+ ITableSortingState objSortingState = getTableModel().getSortingState();
+ if (objSortingState.getSortOrder() == ITableSortingState.SORT_ASCENDING)
+ {
+ objImageAsset = (IAsset)objCycle.getAttribute(TableColumns.TABLE_COLUMN_ARROW_UP_ATTRIBUTE);
+ if (objImageAsset == null) objImageAsset = getAsset("sortUp");
+ }
+ else
+ {
+ objImageAsset = (IAsset)objCycle.getAttribute(TableColumns.TABLE_COLUMN_ARROW_DOWN_ATTRIBUTE);
+ if (objImageAsset == null) objImageAsset = getAsset("sortDown");
+ }
- public void columnSelected(IRequestCycle objCycle)
- {
+ return objImageAsset;
+ }
+
+ public void columnSelected(IRequestCycle objCycle)
+ {
String strColumnName = getSelectedColumnName();
- ITableSortingState objState = getTableModel().getSortingState();
- if (strColumnName.equals(objState.getSortColumn()))
- objState.setSortColumn(strColumnName, !objState.getSortOrder());
- else
- objState.setSortColumn(
- strColumnName,
- ITableSortingState.SORT_ASCENDING);
-
- // ensure that the change is saved
- getTableModelSource().fireObservedStateChange();
- }
+ ITableSortingState objState = getTableModel().getSortingState();
+ if (strColumnName.equals(objState.getSortColumn()))
+ objState.setSortColumn(strColumnName, !objState.getSortOrder());
+ else objState.setSortColumn(strColumnName, ITableSortingState.SORT_ASCENDING);
+
+ // ensure that the change is saved
+ getTableModelSource().fireObservedStateChange();
+ }
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumn.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumn.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumn.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumn.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2005 The Apache Software Foundation
+// Copyright 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -16,13 +16,19 @@
import org.apache.tapestry.IComponent;
+/**
+ * @author mindbridge ?
+ */
public interface IAdvancedTableColumn extends ITableColumn
{
- ITableRendererSource getColumnRendererSource();
- void setColumnRendererSource(ITableRendererSource columnRendererSource);
- ITableRendererSource getValueRendererSource();
- void setValueRendererSource(ITableRendererSource valueRendererSource);
-
- void loadSettings(IComponent objSettingsContainer);
+ ITableRendererSource getColumnRendererSource();
+
+ void setColumnRendererSource(ITableRendererSource columnRendererSource);
+
+ ITableRendererSource getValueRendererSource();
+
+ void setValueRendererSource(ITableRendererSource valueRendererSource);
+
+ void loadSettings(IComponent objSettingsContainer);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumnSource.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumnSource.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumnSource.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IAdvancedTableColumnSource.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2005 The Apache Software Foundation
+// Copyright 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-/*
- * Created on Jun 4, 2005
- */
package org.apache.tapestry.contrib.table.model;
-
-public interface IAdvancedTableColumnSource
+/**
+ * @author mindbridge ?
+ */
+public interface IAdvancedTableColumnSource
{
- IAdvancedTableColumn generateTableColumn(String strName, String strDisplayName,
- boolean bSortable, String strExpression);
+
+ IAdvancedTableColumn generateTableColumn(String strName, String strDisplayName, boolean bSortable,
+ String strExpression);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IFullTableModel.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IFullTableModel.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IFullTableModel.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/IFullTableModel.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,15 +17,18 @@
import java.util.Iterator;
/**
- * An extension of ITableModel that provides the ability to get the full
- * list of row objects, rather than just the displayed ones.
+ * An extension of ITableModel that provides the ability to get the full list of
+ * row objects, rather than just the displayed ones.
*
* @author mb
*/
-public interface IFullTableModel extends ITableModel {
- /**
- * Iterates over all of the rows in the model
- * @return Iterator the iterator for access to the data
- */
- Iterator getRows();
+public interface IFullTableModel extends ITableModel
+{
+
+ /**
+ * Iterates over all of the rows in the model
+ *
+ * @return Iterator the iterator for access to the data
+ */
+ Iterator getRows();
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumn.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumn.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumn.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumn.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,69 +20,74 @@
import org.apache.tapestry.IRequestCycle;
/**
- * The interface defining a table column.
- *
- * A column is responsible for presenting a particular part of the data
- * from the objects in the table. This is done via the getValueRender() method.
- *
- * A column may be sortable, in which case it defines the way in which the
- * objects in the table must be sorted by providing a Comparator.
+ * The interface defining a table column. A column is responsible for presenting
+ * a particular part of the data from the objects in the table. This is done via
+ * the getValueRender() method. A column may be sortable, in which case it
+ * defines the way in which the objects in the table must be sorted by providing
+ * a Comparator.
*
* @author mindbridge
*/
public interface ITableColumn
{
- /**
- * Method getColumnName provides the name of the column.
- *
- * The column name must be unique and is generally used for the identification
- * of the column. It does not have to be the same as the display name
- * via which the column is identified to the user (see the getColumnRender() method).
- * @return String the name of the column
- */
- String getColumnName();
-
- /**
- * Method getSortable declares whether the column allows sorting.
- * If the column allows sorting, it must also return a valid Comparator
- * via the getComparator() method.
- * @return boolean whether the column is sortable or not
- */
- boolean getSortable();
-
- /**
- * Method getComparator returns the Comparator to be used to sort
- * the data in the table according to this column. The Comparator must
- * accept two different rows, compare them according to this column,
- * and return the appropriate value.
- * @return Comparator the Comparator used to sort the table data
- */
- Comparator getComparator();
-
- /**
- * Method getColumnRenderer provides a renderer that takes care of rendering
- * the column in the table header. If the column is sortable, the renderer
- * may provide a mechanism to sort the table in an ascending or descending
- * manner.
- * @param objCycle the current request cycle
- * @param objSource a component that can provide the table model (typically TableView)
- * @return IRender the renderer to present the column header
- */
- IRender getColumnRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource);
-
- /**
- * Method getValueRenderer provides a renderer for presenting the value of a
- * particular row in the current column.
- *
- * @param objCycle the current request cycle
- * @param objSource a component that can provide the table model (typically TableView)
- * @param objRow the row data
- * @return IRender the renderer to present the value of the row in this column
- */
- IRender getValueRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource,
- Object objRow);
+
+ /**
+ * Method getColumnName provides the name of the column. The column name
+ * must be unique and is generally used for the identification of the
+ * column. It does not have to be the same as the display name via which the
+ * column is identified to the user (see the getColumnRender() method).
+ *
+ * @return String the name of the column
+ */
+ String getColumnName();
+
+ /**
+ * Method getSortable declares whether the column allows sorting. If the
+ * column allows sorting, it must also return a valid Comparator via the
+ * getComparator() method.
+ *
+ * @return boolean whether the column is sortable or not
+ */
+ boolean getSortable();
+
+ /**
+ * Method getComparator returns the Comparator to be used to sort the data
+ * in the table according to this column. The Comparator must accept two
+ * different rows, compare them according to this column, and return the
+ * appropriate value.
+ *
+ * @return Comparator the Comparator used to sort the table data
+ */
+ Comparator getComparator();
+
+ /**
+ * Method getColumnRenderer provides a renderer that takes care of rendering
+ * the column in the table header. If the column is sortable, the renderer
+ * may provide a mechanism to sort the table in an ascending or descending
+ * manner.
+ *
+ * @param objCycle
+ * the current request cycle
+ * @param objSource
+ * a component that can provide the table model (typically
+ * TableView)
+ * @return IRender the renderer to present the column header
+ */
+ IRender getColumnRenderer(IRequestCycle objCycle, ITableModelSource objSource);
+
+ /**
+ * Method getValueRenderer provides a renderer for presenting the value of a
+ * particular row in the current column.
+ *
+ * @param objCycle
+ * the current request cycle
+ * @param objSource
+ * a component that can provide the table model (typically
+ * TableView)
+ * @param objRow
+ * the row data
+ * @return IRender the renderer to present the value of the row in this
+ * column
+ */
+ IRender getValueRenderer(IRequestCycle objCycle, ITableModelSource objSource, Object objRow);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumnModel.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumnModel.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumnModel.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableColumnModel.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -23,22 +23,28 @@
*/
public interface ITableColumnModel
{
- /**
- * Method getColumnCount.
- * @return int the number of columns in the model
- */
- int getColumnCount();
-
- /**
- * Method getColumn.
- * @param strName the name of the requested column
- * @return ITableColumn the column with the given name. null if no such column exists.
- */
- ITableColumn getColumn(String strName);
-
- /**
- * Method getColumns.
- * @return Iterator an iterator of all columns in the model
- */
- Iterator getColumns();
+
+ /**
+ * Method getColumnCount.
+ *
+ * @return int the number of columns in the model
+ */
+ int getColumnCount();
+
+ /**
+ * Method getColumn.
+ *
+ * @param strName
+ * the name of the requested column
+ * @return ITableColumn the column with the given name. null if no such
+ * column exists.
+ */
+ ITableColumn getColumn(String strName);
+
+ /**
+ * Method getColumns.
+ *
+ * @return Iterator an iterator of all columns in the model
+ */
+ Iterator getColumns();
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableDataModel.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableDataModel.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableDataModel.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableDataModel.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,38 +17,44 @@
import java.util.Iterator;
/**
- * A model of the table's data
- * This model need not be used. Implementations may choose to
- * access data via an abstraction.
+ * A model of the table's data This model need not be used. Implementations may
+ * choose to access data via an abstraction.
*
* @author mindbridge
*/
public interface ITableDataModel
{
- /**
- * Method getRowCount.
- * @return int the number of rows in the model
- */
- int getRowCount();
-
- /**
- * Iterates over all of the rows in the model
- * @return Iterator the iterator for access to the data
- */
- Iterator getRows();
-
- /**
- * Method addTableDataModelListener
- * Adds a listener that is notified when the data in the model is changed
- * @param objListener the listener to add
- */
+
+ /**
+ * Method getRowCount.
+ *
+ * @return int the number of rows in the model
+ */
+ int getRowCount();
+
+ /**
+ * Iterates over all of the rows in the model
+ *
+ * @return Iterator the iterator for access to the data
+ */
+ Iterator getRows();
+
+ /**
+ * Method addTableDataModelListener Adds a listener that is notified when
+ * the data in the model is changed
+ *
+ * @param objListener
+ * the listener to add
+ */
void addTableDataModelListener(ITableDataModelListener objListener);
- /**
- * Method removeTableDataModelListener.
- * Removes a listener that is notified when the data in the model is changed
- * @param objListener the listener to remove
- */
+ /**
+ * Method removeTableDataModelListener. Removes a listener that is notified
+ * when the data in the model is changed
+ *
+ * @param objListener
+ * the listener to remove
+ */
void removeTableDataModelListener(ITableDataModelListener objListener);
-
+
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModel.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModel.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModel.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModel.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,37 +17,48 @@
import java.util.Iterator;
/**
- * The main interface defining the abstraction containing the table data and state
+ * The main interface defining the abstraction containing the table data and
+ * state
*
* @author mindbridge
*/
public interface ITableModel
{
- /**
- * Method getColumnModel.
- * @return ITableColumnModel the column model of the table
- */
- ITableColumnModel getColumnModel();
-
- /**
- * Method getSortingState.
- * @return ITableSortingState the sorting state of the table
- */
- ITableSortingState getSortingState();
- /**
- * Method getPagingState.
- * @return ITablePagingState the paging state of the table
- */
- ITablePagingState getPagingState();
-
- /**
- * Method getPageCount.
- * @return int the number of pages this table would have given the current data and paging state
- */
- int getPageCount();
- /**
- * Method getCurrentPageRows.
- * @return Iterator the rows in the current table page given the current data, sorting, and paging state
- */
- Iterator getCurrentPageRows();
+
+ /**
+ * Method getColumnModel.
+ *
+ * @return ITableColumnModel the column model of the table
+ */
+ ITableColumnModel getColumnModel();
+
+ /**
+ * Method getSortingState.
+ *
+ * @return ITableSortingState the sorting state of the table
+ */
+ ITableSortingState getSortingState();
+
+ /**
+ * Method getPagingState.
+ *
+ * @return ITablePagingState the paging state of the table
+ */
+ ITablePagingState getPagingState();
+
+ /**
+ * Method getPageCount.
+ *
+ * @return int the number of pages this table would have given the current
+ * data and paging state
+ */
+ int getPageCount();
+
+ /**
+ * Method getCurrentPageRows.
+ *
+ * @return Iterator the rows in the current table page given the current
+ * data, sorting, and paging state
+ */
+ Iterator getCurrentPageRows();
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModelSource.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModelSource.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModelSource.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableModelSource.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,29 +17,32 @@
import org.apache.tapestry.IComponent;
/**
- * A Tapestry component that provides the current table model.
- * This interface is used for obtaining the table model source by
- * components wrapped by it, as well as by external renderers,
- * such as those provided by the column implementations
+ * A Tapestry component that provides the current table model. This interface is
+ * used for obtaining the table model source by components wrapped by it, as
+ * well as by external renderers, such as those provided by the column
+ * implementations
*
* @author mindbridge
*/
public interface ITableModelSource extends IComponent
{
+
final static String TABLE_MODEL_SOURCE_ATTRIBUTE = "org.apache.tapestry.contrib.table.model.ITableModelSource";
- /**
- * Returns the table model currently used
- * @return ITableModel the current table model
- */
- ITableModel getTableModel();
-
- /**
- * Notifies the model source that the model state has changed, and
- * that it should consider saving it.<p>
- * This method was added to allow using the table within a Block when
- * the pageBeginRender() listener of the implementation will not be called
- * and automatic state storage will therefore be hard to implement.
- */
+ /**
+ * Returns the table model currently used
+ *
+ * @return ITableModel the current table model
+ */
+ ITableModel getTableModel();
+
+ /**
+ * Notifies the model source that the model state has changed, and that it
+ * should consider saving it.
+ * <p>
+ * This method was added to allow using the table within a Block when the
+ * pageBeginRender() listener of the implementation will not be called and
+ * automatic state storage will therefore be hard to implement.
+ */
void fireObservedStateChange();
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITablePagingState.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITablePagingState.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITablePagingState.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITablePagingState.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -21,29 +21,38 @@
*/
public interface ITablePagingState
{
- /**
- * Method getPageSize provides the size of a page in a number of records.
- * This value may be meaningless if the model uses a different method for pagination.
- * @return int the current page size
- */
- int getPageSize();
-
- /**
- * Method setPageSize updates the size of a page in a number of records.
- * This value may be meaningless if the model uses a different method for pagination.
- * @param nPageSize the new page size
- */
- void setPageSize(int nPageSize);
-
- /**
- * Gets the currently selected page. The page number is counted from 0.
- * @return int the current active page
- */
- int getCurrentPage();
-
- /**
- * Sets the newly selected page. The page number is counted from 0.
- * @param nPage the new active page
- */
- void setCurrentPage(int nPage);
+
+ /**
+ * Method getPageSize provides the size of a page in a number of records.
+ * This value may be meaningless if the model uses a different method for
+ * pagination.
+ *
+ * @return int the current page size
+ */
+ int getPageSize();
+
+ /**
+ * Method setPageSize updates the size of a page in a number of records.
+ * This value may be meaningless if the model uses a different method for
+ * pagination.
+ *
+ * @param nPageSize
+ * the new page size
+ */
+ void setPageSize(int nPageSize);
+
+ /**
+ * Gets the currently selected page. The page number is counted from 0.
+ *
+ * @return int the current active page
+ */
+ int getCurrentPage();
+
+ /**
+ * Sets the newly selected page. The page number is counted from 0.
+ *
+ * @param nPage
+ * the new active page
+ */
+ void setCurrentPage(int nPage);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererListener.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererListener.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererListener.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererListener.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -18,16 +18,12 @@
import org.apache.tapestry.IRequestCycle;
/**
- *
* @see org.apache.tapestry.contrib.table.model.common.AbstractTableColumn
* @author mindbridge
* @since 2.3
*/
public interface ITableRendererListener extends IComponent
{
- void initializeRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource,
- ITableColumn objColumn,
- Object objRow);
+
+ void initializeRenderer(IRequestCycle objCycle, ITableModelSource objSource, ITableColumn objColumn, Object objRow);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererSource.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererSource.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererSource.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRendererSource.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,9 +20,10 @@
import org.apache.tapestry.IRequestCycle;
/**
- * This interface provides a renderer to present the data in a table column.
- * It is usually used by the {@link org.apache.tapestry.contrib.table.model.ITableColumn}
- * implementations via aggregation.
+ * This interface provides a renderer to present the data in a table column. It
+ * is usually used by the
+ * {@link org.apache.tapestry.contrib.table.model.ITableColumn} implementations
+ * via aggregation.
*
* @see org.apache.tapestry.contrib.table.model.common.AbstractTableColumn
* @author mindbridge
@@ -30,17 +31,17 @@
*/
public interface ITableRendererSource extends Serializable
{
- /**
- * Returns a renderer to present the data of the row in the given column. <p>
- * This method can also be used to return a renderer to present the
- * heading of the column. In such a case the row passed would be null.
- *
- * @see org.apache.tapestry.contrib.table.model.ITableColumn#getValueRenderer(IRequestCycle, ITableModelSource, Object)
- */
- public IRender getRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource,
- ITableColumn objColumn,
- Object objRow);
+
+ /**
+ * Returns a renderer to present the data of the row in the given column.
+ * <p>
+ * This method can also be used to return a renderer to present the heading
+ * of the column. In such a case the row passed would be null.
+ *
+ * @see org.apache.tapestry.contrib.table.model.ITableColumn#getValueRenderer(IRequestCycle,
+ * ITableModelSource, Object)
+ */
+ public IRender getRenderer(IRequestCycle objCycle, ITableModelSource objSource, ITableColumn objColumn,
+ Object objRow);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRowSource.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRowSource.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRowSource.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableRowSource.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -15,19 +15,20 @@
package org.apache.tapestry.contrib.table.model;
/**
- * A Tapestry component that provides the current row value.
- * This interface is used for obtaining the row source by components
- * wrapped by the row source
+ * A Tapestry component that provides the current row value. This interface is
+ * used for obtaining the row source by components wrapped by the row source
*
* @author mindbridge
*/
public interface ITableRowSource
{
+
final static String TABLE_ROW_SOURCE_ATTRIBUTE = "org.apache.tapestry.contrib.table.model.ITableRowSource";
- /**
- * Method getTableRow
- * @return Object the current table row object
- */
+ /**
+ * Method getTableRow
+ *
+ * @return Object the current table row object
+ */
Object getTableRow();
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStateManager.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStateManager.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStateManager.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStateManager.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -17,28 +17,33 @@
import java.io.Serializable;
/**
- * An interface responsible for determining <b>what</b> data would be stored
- * in the session between requests.
- * It could be only the table state, it could be entire table including the data,
- * or it could be nothing at all.
- * It is all determined by the implemention of this interface.
+ * An interface responsible for determining <b>what</b> data would be stored in
+ * the session between requests. It could be only the table state, it could be
+ * entire table including the data, or it could be nothing at all. It is all
+ * determined by the implemention of this interface.
*
* @author mindbridge
*/
public interface ITableSessionStateManager
{
- /**
- * Method getSessionState extracts the "persistent" portion of the table model
- * @param objModel the table model to extract the session state from
- * @return Object the session state to be saved between the requests
- */
- Serializable getSessionState(ITableModel objModel);
+ /**
+ * Method getSessionState extracts the "persistent" portion of the table
+ * model
+ *
+ * @param objModel
+ * the table model to extract the session state from
+ * @return Object the session state to be saved between the requests
+ */
+ Serializable getSessionState(ITableModel objModel);
- /**
- * Method recreateTableModel recreates a table model from the saved session state
- * @param objState the saved session state
- * @return ITableModel the recreated table model
- */
- ITableModel recreateTableModel(Serializable objState);
+ /**
+ * Method recreateTableModel recreates a table model from the saved session
+ * state
+ *
+ * @param objState
+ * the saved session state
+ * @return ITableModel the recreated table model
+ */
+ ITableModel recreateTableModel(Serializable objState);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStoreManager.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStoreManager.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStoreManager.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSessionStoreManager.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -19,23 +19,30 @@
import org.apache.tapestry.IRequestCycle;
/**
- * An interface responsible for determining <b>where</b> the session state
- * will be saved between requests.
- *
+ * An interface responsible for determining <b>where</b> the session state will
+ * be saved between requests.
+ *
* @author mindbridge
*/
public interface ITableSessionStoreManager
{
- /**
- * Method saveState saves the session sate
- * @param objCycle the current request cycle
- * @param objState the session state to be saved
- */
- void saveState(IRequestCycle objCycle, Serializable objState);
- /**
- * Method loadState loads the session state
- * @param objCycle the current request cycle
- * @return Object the loaded sessions state
- */
- Serializable loadState(IRequestCycle objCycle);
+
+ /**
+ * Method saveState saves the session sate
+ *
+ * @param objCycle
+ * the current request cycle
+ * @param objState
+ * the session state to be saved
+ */
+ void saveState(IRequestCycle objCycle, Serializable objState);
+
+ /**
+ * Method loadState loads the session state
+ *
+ * @param objCycle
+ * the current request cycle
+ * @return Object the loaded sessions state
+ */
+ Serializable loadState(IRequestCycle objCycle);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSortingState.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSortingState.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSortingState.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/ITableSortingState.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -21,25 +21,33 @@
*/
public interface ITableSortingState
{
- static final boolean SORT_ASCENDING = false;
- static final boolean SORT_DESCENDING = true;
- /**
- * Method getSortColumn defines the column that the table should be sorted upon
- * @return String the name of the sorting column or null if the table is not sorted
- */
- String getSortColumn();
-
- /**
- * Method getSortOrder defines the direction of the table sorting
- * @return boolean the sorting order (see constants)
- */
- boolean getSortOrder();
-
- /**
- * Method setSortColumn updates the table sorting column and order
- * @param strName the name of the column to sort by
- * @param bOrder the sorting order (see constants)
- */
- void setSortColumn(String strName, boolean bOrder);
+ static final boolean SORT_ASCENDING = false;
+ static final boolean SORT_DESCENDING = true;
+
+ /**
+ * Method getSortColumn defines the column that the table should be sorted
+ * upon
+ *
+ * @return String the name of the sorting column or null if the table is not
+ * sorted
+ */
+ String getSortColumn();
+
+ /**
+ * Method getSortOrder defines the direction of the table sorting
+ *
+ * @return boolean the sorting order (see constants)
+ */
+ boolean getSortOrder();
+
+ /**
+ * Method setSortColumn updates the table sorting column and order
+ *
+ * @param strName
+ * the name of the column to sort by
+ * @param bOrder
+ * the sorting order (see constants)
+ */
+ void setSortColumn(String strName, boolean bOrder);
}
Modified: jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/common/AbstractTableColumn.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/common/AbstractTableColumn.java?rev=368415&r1=368414&r2=368415&view=diff
==============================================================================
--- jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/common/AbstractTableColumn.java (original)
+++ jakarta/tapestry/trunk/contrib/src/java/org/apache/tapestry/contrib/table/model/common/AbstractTableColumn.java Thu Jan 12 09:18:25 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -27,8 +27,9 @@
import org.apache.tapestry.valid.RenderString;
/**
- * A base implementation of {@link org.apache.tapestry.contrib.table.model.ITableColumn}
- * that allows renderers to be set via aggregation.
+ * A base implementation of
+ * {@link org.apache.tapestry.contrib.table.model.ITableColumn} that allows
+ * renderers to be set via aggregation.
*
* @see org.apache.tapestry.contrib.table.model.ITableRendererSource
* @author mindbridge
@@ -36,203 +37,203 @@
*/
public class AbstractTableColumn implements IAdvancedTableColumn, Serializable
{
- private static final long serialVersionUID = 1L;
- /**
- * The suffix of the name of the Block that will be used as the column renderer
- * for this column
+ /**
+ * The suffix of the name of the Block that will be used as the column
+ * renderer for this column.
*/
public static final String COLUMN_RENDERER_BLOCK_SUFFIX = "ColumnHeader";
/**
- * The suffix of the name of the Block that will be used as the value renderer
- * for this column
+ * The suffix of the name of the Block that will be used as the value
+ * renderer for this column.
*/
public static final String VALUE_RENDERER_BLOCK_SUFFIX = "ColumnValue";
-
- private String m_strColumnName;
- private boolean m_bSortable;
- private Comparator m_objComparator;
-
- private ITableRendererSource m_objColumnRendererSource;
- private ITableRendererSource m_objValueRendererSource;
-
- public AbstractTableColumn()
- {
- this("", false, null);
- }
-
- public AbstractTableColumn(
- String strColumnName,
- boolean bSortable,
- Comparator objComparator)
- {
- this(strColumnName, bSortable, objComparator, null, null);
- }
-
- public AbstractTableColumn(
- String strColumnName,
- boolean bSortable,
- Comparator objComparator,
- ITableRendererSource objColumnRendererSource,
- ITableRendererSource objValueRendererSource)
- {
- setColumnName(strColumnName);
- setSortable(bSortable);
- setComparator(objComparator);
- setColumnRendererSource(objColumnRendererSource);
- setValueRendererSource(objValueRendererSource);
- }
-
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableColumn#getColumnName()
- */
- public String getColumnName()
- {
- return m_strColumnName;
- }
-
- /**
- * Sets the columnName.
- * @param columnName The columnName to set
- */
- public void setColumnName(String columnName)
- {
- m_strColumnName = columnName;
- }
-
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableColumn#getSortable()
- */
- public boolean getSortable()
- {
- return m_bSortable;
- }
-
- /**
- * Sets whether the column is sortable.
- * @param sortable The sortable flag to set
- */
- public void setSortable(boolean sortable)
- {
- m_bSortable = sortable;
- }
-
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableColumn#getComparator()
- */
- public Comparator getComparator()
- {
- return m_objComparator;
- }
-
- /**
- * Sets the comparator.
- * @param comparator The comparator to set
- */
- public void setComparator(Comparator comparator)
- {
- m_objComparator = comparator;
- }
-
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableColumn#getColumnRenderer(IRequestCycle, ITableModelSource)
- */
- public IRender getColumnRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource)
- {
- ITableRendererSource objRendererSource =
- getColumnRendererSource();
- if (objRendererSource == null)
- {
- // log error
- return new RenderString("");
- }
-
- return objRendererSource.getRenderer(objCycle, objSource, this, null);
- }
-
- /**
- * @see org.apache.tapestry.contrib.table.model.ITableColumn#getValueRenderer(IRequestCycle, ITableModelSource, Object)
- */
- public IRender getValueRenderer(
- IRequestCycle objCycle,
- ITableModelSource objSource,
- Object objRow)
- {
- ITableRendererSource objRendererSource = getValueRendererSource();
- if (objRendererSource == null)
- {
- // log error
- return new RenderString("");
- }
-
- return objRendererSource.getRenderer(
- objCycle,
- objSource,
- this,
- objRow);
- }
-
- /**
- * Returns the columnRendererSource.
- * @return ITableColumnRendererSource
- */
- public ITableRendererSource getColumnRendererSource()
- {
- return m_objColumnRendererSource;
- }
-
- /**
- * Sets the columnRendererSource.
- * @param columnRendererSource The columnRendererSource to set
- */
- public void setColumnRendererSource(ITableRendererSource columnRendererSource)
- {
- m_objColumnRendererSource = columnRendererSource;
- }
-
- /**
- * Returns the valueRendererSource.
- *
- * @return the valueRendererSource of this column
- */
- public ITableRendererSource getValueRendererSource()
- {
- return m_objValueRendererSource;
- }
-
- /**
- * Sets the valueRendererSource.
- *
- * @param valueRendererSource The valueRendererSource to set
- */
- public void setValueRendererSource(ITableRendererSource valueRendererSource)
- {
- m_objValueRendererSource = valueRendererSource;
- }
-
- /**
- * Use the column name to get the column and value renderer sources
- * from the provided component.
- * Use the column and value renderer sources for all columns if necessary.
- *
- * @param objSettingsContainer the component from which to get the settings
+
+ private static final long serialVersionUID = 1L;
+
+ private String m_strColumnName;
+ private boolean m_bSortable;
+ private Comparator m_objComparator;
+
+ private ITableRendererSource m_objColumnRendererSource;
+ private ITableRendererSource m_objValueRendererSource;
+
+ public AbstractTableColumn()
+ {
+ this("", false, null);
+ }
+
+ public AbstractTableColumn(String strColumnName, boolean bSortable, Comparator objComparator)
+ {
+ this(strColumnName, bSortable, objComparator, null, null);
+ }
+
+ public AbstractTableColumn(String strColumnName, boolean bSortable, Comparator objComparator,
+ ITableRendererSource objColumnRendererSource, ITableRendererSource objValueRendererSource)
+ {
+ setColumnName(strColumnName);
+ setSortable(bSortable);
+ setComparator(objComparator);
+ setColumnRendererSource(objColumnRendererSource);
+ setValueRendererSource(objValueRendererSource);
+ }
+
+ /**
+ * @see org.apache.tapestry.contrib.table.model.ITableColumn#getColumnName()
+ */
+ public String getColumnName()
+ {
+ return m_strColumnName;
+ }
+
+ /**
+ * Sets the columnName.
+ *
+ * @param columnName
+ * The columnName to set
+ */
+ public void setColumnName(String columnName)
+ {
+ m_strColumnName = columnName;
+ }
+
+ /**
+ * @see org.apache.tapestry.contrib.table.model.ITableColumn#getSortable()
+ */
+ public boolean getSortable()
+ {
+ return m_bSortable;
+ }
+
+ /**
+ * Sets whether the column is sortable.
+ *
+ * @param sortable
+ * The sortable flag to set
+ */
+ public void setSortable(boolean sortable)
+ {
+ m_bSortable = sortable;
+ }
+
+ /**
+ * @see org.apache.tapestry.contrib.table.model.ITableColumn#getComparator()
+ */
+ public Comparator getComparator()
+ {
+ return m_objComparator;
+ }
+
+ /**
+ * Sets the comparator.
+ *
+ * @param comparator
+ * The comparator to set
+ */
+ public void setComparator(Comparator comparator)
+ {
+ m_objComparator = comparator;
+ }
+
+ /**
+ * @see org.apache.tapestry.contrib.table.model.ITableColumn#getColumnRenderer(IRequestCycle,
+ * ITableModelSource)
+ */
+ public IRender getColumnRenderer(IRequestCycle objCycle, ITableModelSource objSource)
+ {
+ ITableRendererSource objRendererSource = getColumnRendererSource();
+ if (objRendererSource == null)
+ {
+ // log error
+ return new RenderString("");
+ }
+
+ return objRendererSource.getRenderer(objCycle, objSource, this, null);
+ }
+
+ /**
+ * @see org.apache.tapestry.contrib.table.model.ITableColumn#getValueRenderer(IRequestCycle,
+ * ITableModelSource, Object)
+ */
+ public IRender getValueRenderer(IRequestCycle objCycle, ITableModelSource objSource, Object objRow)
+ {
+ ITableRendererSource objRendererSource = getValueRendererSource();
+ if (objRendererSource == null)
+ {
+ // log error
+ return new RenderString("");
+ }
+
+ return objRendererSource.getRenderer(objCycle, objSource, this, objRow);
+ }
+
+ /**
+ * Returns the columnRendererSource.
+ *
+ * @return ITableColumnRendererSource
+ */
+ public ITableRendererSource getColumnRendererSource()
+ {
+ return m_objColumnRendererSource;
+ }
+
+ /**
+ * Sets the columnRendererSource.
+ *
+ * @param columnRendererSource
+ * The columnRendererSource to set
+ */
+ public void setColumnRendererSource(ITableRendererSource columnRendererSource)
+ {
+ m_objColumnRendererSource = columnRendererSource;
+ }
+
+ /**
+ * Returns the valueRendererSource.
+ *
+ * @return the valueRendererSource of this column
+ */
+ public ITableRendererSource getValueRendererSource()
+ {
+ return m_objValueRendererSource;
+ }
+
+ /**
+ * Sets the valueRendererSource.
+ *
+ * @param valueRendererSource
+ * The valueRendererSource to set
+ */
+ public void setValueRendererSource(ITableRendererSource valueRendererSource)
+ {
+ m_objValueRendererSource = valueRendererSource;
+ }
+
+ /**
+ * Use the column name to get the column and value renderer sources from the
+ * provided component. Use the column and value renderer sources for all
+ * columns if necessary.
+ *
+ * @param objSettingsContainer
+ * the component from which to get the settings
*/
public void loadSettings(IComponent objSettingsContainer)
{
- IComponent objColumnRendererSource = (IComponent) objSettingsContainer.getComponents().get(getColumnName() + COLUMN_RENDERER_BLOCK_SUFFIX);
- if (objColumnRendererSource == null)
- objColumnRendererSource = (IComponent) objSettingsContainer.getComponents().get(COLUMN_RENDERER_BLOCK_SUFFIX);
+ IComponent objColumnRendererSource = (IComponent)objSettingsContainer.getComponents().get(
+ getColumnName() + COLUMN_RENDERER_BLOCK_SUFFIX);
+ if (objColumnRendererSource == null)
+ objColumnRendererSource = (IComponent)objSettingsContainer.getComponents()
+ .get(COLUMN_RENDERER_BLOCK_SUFFIX);
if (objColumnRendererSource != null && objColumnRendererSource instanceof Block)
- setColumnRendererSource(new BlockTableRendererSource((Block) objColumnRendererSource));
+ setColumnRendererSource(new BlockTableRendererSource((Block)objColumnRendererSource));
- IComponent objValueRendererSource = (IComponent) objSettingsContainer.getComponents().get(getColumnName() + VALUE_RENDERER_BLOCK_SUFFIX);
+ IComponent objValueRendererSource = (IComponent)objSettingsContainer.getComponents().get(
+ getColumnName() + VALUE_RENDERER_BLOCK_SUFFIX);
if (objValueRendererSource == null)
- objValueRendererSource = (IComponent) objSettingsContainer.getComponents().get(VALUE_RENDERER_BLOCK_SUFFIX);
+ objValueRendererSource = (IComponent)objSettingsContainer.getComponents().get(VALUE_RENDERER_BLOCK_SUFFIX);
if (objValueRendererSource != null && objValueRendererSource instanceof Block)
- setValueRendererSource(new BlockTableRendererSource((Block) objValueRendererSource));
+ setValueRendererSource(new BlockTableRendererSource((Block)objValueRendererSource));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org