You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/05/15 01:31:54 UTC
svn commit: r170182 - in /incubator/beehive/trunk/netui/src:
tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/
tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/
tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/
tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/
tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/
util/org/apache/beehive/netui/util/
Author: ekoneil
Date: Sat May 14 16:31:52 2005
New Revision: 170182
URL: http://svn.apache.org/viewcvs?rev=170182&view=rev
Log:
Complete the Javadoc for the public data grid API.
BB: self
DRT: NetUI pass
BVT: NetUI pass
Modified:
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/DataGridConfig.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterModel.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterOperation.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterTypeHint.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/IDataGridMessageKeys.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/PagerRenderer.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/StyleModel.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/Sort.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortDirection.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortStrategy.java
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/DataGridConfig.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/DataGridConfig.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/DataGridConfig.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/DataGridConfig.java Sat May 14 16:31:52 2005
@@ -73,11 +73,10 @@
/**
* <p>
- * Create a concrete {@link SortModel} implementation for a data grid. This instance is used by the grid
- * to manage grid's sort state.
+ * Create a {@link SortModel} instance used to store the {@link Sort} state for a data grid.
* </p>
- * @param sorts the {@link List} of sorts for a data grid
- * @return the {@link SortModel} for a grid
+ * @param sorts the current {@link List} of sorts for a data grid
+ * @return the {@link SortModel}
*/
public abstract SortModel createSortModel(List/*<Sort>*/ sorts);
@@ -90,14 +89,56 @@
*/
public abstract Filter createFilter();
+ /**
+ * <p>
+ * Create a {@link FilterModel} instance used to store the {@link Filter} state for a data grid.
+ * </p>
+ * @param filters the current {@link List} of filters for a data grid
+ * @return a {@link FilterModel}
+ */
public abstract FilterModel createFilterModel(List/*<Filter>*/ filters);
+ /**
+ * <p>
+ * Create a {@link PagerModel} instance used to store the current paging state for a data grid.
+ * </p>
+ * @return a {@link PagerModel}
+ */
public abstract PagerModel createPagerModel();
+ /**
+ * <p>
+ * Create a {@link DataGridStateCodec} instance used to obtain services for handling data grid state.
+ * </p>
+ * @param request the current {@link ServletRequest}
+ * @param gridName the name of a data grid whose {@link DataGridStateCodec} to obtain
+ * @return a {@link DataGridStateCodec}
+ */
public abstract DataGridStateCodec createStateCodec(ServletRequest request, String gridName);
+ /**
+ * <p>
+ * Create the default {@link DataGridResourceProvider}. A resource provider is an implementation of
+ * the {@link DataGridResourceProvider} which is used during data grid rendering to obtain strings
+ * for messages, paths, etc. The default resource provider simply exposes the default data grid
+ * messages stored in the properties file located at:
+ * <pre>
+ * org.apache.beehive.netui.databinding.datagrid.runtime.util.data-grid-default.properties
+ * </pre>
+ * </p>
+ * @return a {@link DataGridResourceProvider}
+ */
public abstract DataGridResourceProvider getDefaultResourceProvider();
+ /**
+ * <p>
+ * Create a DataGridConfig-specific implementation of a {@link DataGridResourceProvider}. The DataGridConfig
+ * instance should use the provided resource bundle path to create a {@link DataGridResourceProvider} which
+ * will expose those messages into the data grid for rendering.
+ * </p>
+ * @param resourceBundle the resource bundle to use for grid messages
+ * @return a {@link DataGridResourceProvider}
+ */
public abstract DataGridResourceProvider getResourceProvider(String resourceBundle);
/**
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterModel.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterModel.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterModel.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterModel.java Sat May 14 16:31:52 2005
@@ -21,17 +21,33 @@
import java.util.List;
/**
- *
+ * <p>
+ * The FilterModel class supports grouping a data grid's {@link Filter} objects into a single JavaBean that
+ * implements functionality for interacting with them together.
+ * </p>
+ * <p>
+ * The list of {@link Filter} objects in a FilterModel are ordered. This class provides methods that
+ * can be used to find all the filters for a data grid and to determine if a given filter expression is sorted.
+ * </p>
*/
public class FilterModel
implements java.io.Serializable {
private List/*<Filter>*/ _filters = null;
+ /**
+ * Construct an a filter model given a {@link List} of {@link Filter} instances.
+ *
+ * @param filters the filters for a data grid.
+ */
public FilterModel(List/*<Filter>*/ filters) {
_filters = filters;
}
+ /**
+ * Get the {@link List} of filters for a data grid.
+ * @return a data grid's fitlers
+ */
public List/*<Filter>*/ getFilters() {
if(_filters == null)
return null;
@@ -39,12 +55,27 @@
return _filters;
}
+ /**
+ * Get a {@link List} of {@link Filter} objects. The list returned will contain
+ * all of the {@link Filter} objects whose {@link Filter#getFilterExpression()} matches the given
+ * <code>filterExpression</code>.
+ * @param filterExpression the expression whose matching filters to find
+ * @return <code>null</code> if no matching {@link Filter} objects are found; a {@link List} of {@link Filter}
+ * objects otherwise.
+ */
public List/*<Filter>*/ getFilters(String filterExpression) {
if(_filters == null || filterExpression == null)
return null;
else return lookupFilters(filterExpression);
}
+ /**
+ * Utility method that checks to see if the given <code>filterExpression</code> matches any of the current
+ * {@link Filter} instances.
+ * @param filterExpression the filter expression to check
+ * @return <code>true</code> if at least one filter matches the <code>filterExpression</code>; <code>false</code>
+ * otherwise.
+ */
public boolean isFiltered(String filterExpression) {
if(_filters == null || filterExpression == null)
return false;
@@ -54,6 +85,12 @@
else return false;
}
+ /**
+ * Internal method used to lookup {@link Filter} instances by <code>filterExpression</code>.
+ * @param filterExpression the filter expression whose filters to find
+ * @return <code>null</code> if no matching {@link Filter} objects are found; a {@link List} of {@link Filter}
+ * objects otherwise.
+ */
private List/*<Filter>*/ lookupFilters(String filterExpression) {
assert filterExpression != null;
assert !filterExpression.equals("");
@@ -67,6 +104,6 @@
filters.add(filter);
}
- return filters;
+ return filters.size() > 0 ? filters : null;
}
}
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterOperation.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterOperation.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterOperation.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterOperation.java Sat May 14 16:31:52 2005
@@ -18,7 +18,12 @@
package org.apache.beehive.netui.databinding.datagrid.api.filter;
/**
- *
+ * <p>
+ * A filter operation is an abstract representation of an operation that can be performed when filtering a data set.
+ * The operations that can be performed are not provided here; rather subclasses and external utilities can create
+ * FilterOperation instances that map to concrete operations for query languages like XQuery or SQL. The
+ * process for performing this mapping is left to filtering utilities.
+ * </p>
*/
public class FilterOperation
implements java.io.Serializable {
@@ -28,6 +33,14 @@
private String _resourceKey;
private FilterOperationHint _operationHint;
+ /**
+ * Construct a FilterOperation given a set of metadata about the filter.
+ * @param id the operation identifier
+ * @param abbreviation the abbreviation for the filter
+ * @param resourceKey a resource key used to lookup a readable String for a filter operation
+ * @param operationHint a hint for the operation that classifies the operation into a language independent
+ * operation category.
+ */
public FilterOperation(int id, String abbreviation, String resourceKey, FilterOperationHint operationHint) {
_id = id;
_abbreviation = abbreviation;
@@ -35,18 +48,35 @@
_resourceKey = resourceKey;
}
+ /**
+ * Get the filter operation's id.
+ * @return the id
+ */
public int getId() {
return _id;
}
+ /**
+ * Get the filter operation's abbreviation
+ * @return the abbreviation
+ */
public String getAbbreviation() {
return _abbreviation;
}
+ /**
+ * Get the filter operation's resource key. Discoverying the readable text for an operation is left
+ * to the client or other filtering utilities.
+ * @return the resource key
+ */
public String getResourceKey() {
return _resourceKey;
}
+ /**
+ * Get the filter operation's {@link FilterOperationHint}.
+ * @return the operation hint
+ */
public FilterOperationHint getOperationHint() {
return _operationHint;
}
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterTypeHint.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterTypeHint.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterTypeHint.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/filter/FilterTypeHint.java Sat May 14 16:31:52 2005
@@ -20,35 +20,82 @@
import org.apache.beehive.netui.util.Bundle;
/**
- *
+ * <p>
+ * The FilterTypeHint is used by a {@link Filter} object in order to provide metadata about the type of
+ * the data in a data set represented by a filter expression. When used on a {@link Filter}, infrastructure
+ * used to build or perform querying using {@link Filter} instances can use type hints in order to build
+ * or perform filtering correctly. For example, when using {@link Filter} instances with SQL, a type
+ * hint can be used to know when to quote a value inside of a <i>WHERE</i> clause.
+ * </p>
*/
public class FilterTypeHint
implements java.io.Serializable {
+ /**
+ * String value for a date type hint.
+ */
private static final String STR_DATE = "DATE";
+
+ /**
+ * String value for a string type hint.
+ */
private static final String STR_STRING = "STRING";
+
+ /**
+ * String value for a numeric type hint.
+ */
private static final String STR_NUMERIC = "NUMERIC";
+ /**
+ * Filter type hint representing a date type.
+ */
public static final FilterTypeHint DATE = new FilterTypeHint(STR_DATE);
+
+ /**
+ * Filter type hint representing a string type.
+ */
public static final FilterTypeHint STRING = new FilterTypeHint(STR_STRING);
+
+ /**
+ * Filter type hint representing a numeric type.
+ */
public static final FilterTypeHint NUMERIC = new FilterTypeHint(STR_NUMERIC);
private String _hint = null;
- FilterTypeHint(String hint) {
+ /**
+ * Private constructor.
+ *
+ * @param hint
+ */
+ private FilterTypeHint(String hint) {
_hint = hint;
}
+ /**
+ * Get the type hint string.
+ * @return the type hint string
+ */
public String getHint() {
return _hint;
}
+ /**
+ * Get the default filter type hint. This is {@link #STRING}.
+ * @return the default type hint
+ */
public static FilterTypeHint getDefault() {
return STRING;
}
- /* todo: this is static; consider providing on a concrete / overridable object */
+ /**
+ * Given a String, lookup a FilterTypeHint for the String. Valid
+ * @param hint the String to use when looking up a filter type hint
+ * @return the type hint
+ * @throws IllegalArgumentException if the given <code>hint</code> doesn't match a know type hint
+ */
public static FilterTypeHint getTypeHint(String hint) {
+ /* todo: this is static; consider providing on a concrete / overridable object */
if(STRING.getHint().equals(hint))
return STRING;
else if(NUMERIC.getHint().equals(hint))
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/pager/PagerModel.java Sat May 14 16:31:52 2005
@@ -20,12 +20,38 @@
import org.apache.beehive.netui.util.Bundle;
/**
- *
+ * <p>
+ * The PagerModel is a JavaBean that represents the page state of a data grid. In the default implementation,
+ * the page state consists of three pieces of data:
+ * <ul>
+ * <li>the current row</li>
+ * <li>current page</li>
+ * <li>the href / action used to page through data</li>
+ * </ul>
+ * This pager model implementation is row based which means that the notion of the current page
+ * is based on which row is at the top of a page. Row numbering starts at zero and continues to page size.
+ * For example, in a data grid on its first page and with a page size of 10, the rows 0-9 will be displayed. The
+ * next page would contain rows 10-11 and so on.
+ * </p>
+ * <p>
+ * The pager model provides JavaBean-style access to the properties of a pager. In addition, it provides read-only
+ * access to information about the row to use in order to navigate to a specific page. To navigate to the previous
+ * page, the {@link #getRowForPreviousPage()} will return the row number that will appear at the top of the previous
+ * page. In order to build effective paging UI, it is also often useful to know the absolute page number.
+ * As with row numbers, page numbers are zero based. For example, if a data set displayed in a data grid has 30
+ * records and the grid is on page a page displaying rows 10-19, the current page is 1. When displaying this value
+ * in UI, it is often useful to display it as:
+ * <pre>
+ * Page 2 of 3
+ * </pre>
+ * Random page access can also be accomplished using the {@link #encodeRowForPage(int)} method which will return
+ * the row number to display when jumping to a specific page in a grid.
+ * </p>
*/
public class PagerModel
implements java.io.Serializable {
- private static final int DEFAULT_PAGE_SIZE = 10;
+ public static final int DEFAULT_PAGE_SIZE = 10;
public static final int DEFAULT_ROW = 0;
private String _pageHref = null;
@@ -35,32 +61,64 @@
private Integer _explicitPageSize = null;
private Integer _defaultPageSize = null;
+ /**
+ * Default constructor. This initializes the current row to the default row value {@link #DEFAULT_ROW}.
+ */
public PagerModel() {
_currentRow = new Integer(DEFAULT_ROW);
}
+ /**
+ * Get the action used when building URLs for navigating to another page.
+ * @return the action name or <code>null</code> if no action name is set
+ */
public String getPageAction() {
return _pageAction;
}
+ /**
+ * Set the action used to navigate to another page.
+ * @param pageAction the action name
+ */
public void setPageAction(String pageAction) {
_pageAction = pageAction;
}
+ /**
+ * Get the href used when building URLs for navigating to another page.
+ * @return the href or <code>null</code> if no href is set
+ */
public String getPageHref() {
return _pageHref;
}
+ /**
+ * Set the href used to navigate to another page.
+ * @param pageHref the href
+ */
public void setPageHref(String pageHref) {
_pageHref = pageHref;
}
+ /**
+ * Get the default page size. If no page size has been set via {@link #setDefaultPageSize(int)} this
+ * value is {@link #DEFAULT_PAGE_SIZE}
+ * @return the default page size
+ */
public int getDefaultPageSize() {
if(_defaultPageSize != null)
return _defaultPageSize.intValue();
else return DEFAULT_PAGE_SIZE;
}
+ /**
+ * Set the default page size. The default page size is used when no other page size has been set and is useful
+ * when clients wish to occasionally override the page size but wish to have the default page size set
+ * differently than the PagerModel's default.
+ *
+ * @param pageSize the new page size
+ * @throws IllegalArgumentException if the page size is less than 1
+ */
public void setDefaultPageSize(int pageSize) {
if(pageSize < 1)
throw new IllegalArgumentException(Bundle.getErrorString("PagerModel_IllegalDefaultPageSize"));
@@ -68,20 +126,39 @@
_defaultPageSize = new Integer(pageSize);
}
+ /**
+ * Set the data set size. In order to calculate paging state for the last page such as the
+ * state returned for {@link #getRowForLastPage()} the default PagerModel implementation must
+ * know the total size of the data set.
+ *
+ * @return the size
+ */
public int getDataSetSize() {
if(_dataSetSize == null)
return 0;
else return _dataSetSize.intValue();
}
+ /**
+ * Set the data set size.
+ * @param dataSetSize the size
+ */
public void setDataSetSize(int dataSetSize) {
_dataSetSize = new Integer(dataSetSize);
}
+ /**
+ * Get the current page size.
+ * @return the page size
+ */
public int getPageSize() {
return _explicitPageSize != null ? _explicitPageSize.intValue() : getDefaultPageSize();
}
+ /**
+ * Sets the page size and overrides the default page size if one has been set.
+ * @param pageSize the specific page size
+ */
public void setPageSize(int pageSize) {
if(pageSize < 1)
throw new IllegalArgumentException(Bundle.getErrorString("PagerModel_IllegalPageSize"));
@@ -89,6 +166,11 @@
_explicitPageSize = new Integer(pageSize);
}
+ /**
+ * Get the page number given the current page size and current row. The page number is zero based and should be
+ * adjusted by one when being displayed to users.
+ * @return the page number
+ */
public int getPage() {
int row = getRow();
assert row % getPageSize() == 0 : "Invalid current row \"" + row + "\" for page size \"" + getPageSize() + "\"";
@@ -96,11 +178,24 @@
return row / getPageSize();
}
- /* todo: need to check that the new 'current' page is in range given the first/last boundaries */
+ /**
+ * Set a specific page. This will change the current row to match the given page value.
+ *
+ * @param page the new page
+ * @throws IllegalArgumentException if the given page is less than zero
+ */
public void setPage(int page) {
+ if(page < 0)
+ throw new IllegalArgumentException(Bundle.getErrorString("PagerModel_IllegalPage"));
+
+ /* todo: need to check that the new 'current' page is in range given the first/last boundaries */
_currentRow = new Integer(page * getPageSize());
}
+ /**
+ * Get the current row. If no row has been specified, the default row is returned.
+ * @return the current row
+ */
public int getRow() {
if(_currentRow != null) {
int row = _currentRow.intValue();
@@ -118,10 +213,31 @@
else return DEFAULT_ROW;
}
+ /**
+ * Set the current row.
+ * @param row the new row
+ * @throws IllegalArgumentException if the given row is less than zero
+ */
public void setRow(int row) {
+ if(row < 0)
+ throw new IllegalArgumentException(Bundle.getErrorString("PagerModel_IllegalRow"));
+
_currentRow = new Integer(row);
}
+ /**
+ * <p>
+ * Get the last row for the current page of data. This value is useful when displaying paging UI like:
+ * <pre>
+ * Row 11 through 20 of 60
+ * </pre>
+ * The last row on the page is returned as a zero-based number from the beginning of the data set. In the
+ * case above, the value returned is <code>19</code> and is converted to <code>20</code> for readability
+ * by adding one. If the current page is only partially filled, this method will return the value for a partial page.
+ * For example, with a data set of size 4 on a page of size 10, the value <code>3</code> would be returned.
+ * </p>
+ * @return the last row for the current page
+ */
public int getLastRowForPage() {
int row = getRow();
if(_dataSetSize != null) {
@@ -132,19 +248,38 @@
else return row + getPageSize() - 1;
}
+ /**
+ * Get the row used to display the first page.
+ * @return the row for the first page
+ */
public int getRowForFirstPage() {
return DEFAULT_ROW;
}
+ /**
+ * Get the row used to display the previous page. Note, a return value of less than zero means that the previous
+ * page does not exist as it would scroll off the beginning of the data set and is invalid.
+ * @return the row for the previous page
+ */
public int getRowForPreviousPage() {
int value = getRow() - getPageSize();
return value > -1 ? value : -1;
}
+ /**
+ * Get the row used to display the next page. Note, if this value is greater than the size of the data set
+ * it would scroll off the end of the data set and is invalid.
+ * @return the row for the previous page
+ */
public int getRowForNextPage() {
return getRow() + getPageSize();
}
+ /**
+ * Get the row used to display the last page. This requires tha the data set size has been set via
+ * @return the row for the last page
+ * @throws IllegalStateException when the size of the data set has not been set
+ */
public int getRowForLastPage() {
Integer lastRow = internalGetLastRow();
if(lastRow != null)
@@ -152,33 +287,73 @@
else throw new IllegalStateException(Bundle.getErrorString("PagerModel_CantCalculateLastPage"));
}
+ /**
+ * Get the row needed to jump to the given <code>page</code>
+ * @param page the new page
+ * @return the row used to jump to the new page
+ * @throws IllegalArgumentException if the given page value is less than zero
+ */
public int encodeRowForPage(int page) {
+ if(page < 0)
+ throw new IllegalArgumentException(Bundle.getErrorString("PagerModel_IllegalPage"));
+
return page * getPageSize();
}
+ /**
+ * Get the total number of pages. This value is useful when displaying the total number of pages in UI like:
+ * <pre>
+ * Page 4 of 10
+ * </pre>
+ * This method returns an absolute count of the number of pages which could be displayed given the
+ * size of the data set and the current page size. This method requires the PagerModel know the
+ * total size of the data set.
+ * @return the number of pages
+ * @throws IllegalStateException when the size of the data set has not been set
+ */
public int getPageCount() {
if(_dataSetSize != null)
return (int)Math.ceil(_dataSetSize.doubleValue()/(double)getPageSize());
else throw new IllegalStateException(Bundle.getErrorString("PagerModel_CantCalculateLastPage"));
}
+ /**
+ * Get the page number of the first page.
+ * @return the first page
+ */
public int getFirstPage() {
return 0;
}
+ /**
+ * Get the page number of the previous page.
+ * @return the previous page
+ */
public int getPreviousPage() {
int previousPageRow = getRowForPreviousPage();
return previousPageRow == -1 ? previousPageRow : (int)(previousPageRow / getPageSize());
}
+ /**
+ * Get the page number for the next page.
+ * @return the next page
+ */
public int getNextPage() {
return (int)(getRowForNextPage() / getPageSize());
}
+ /**
+ * Get the page number for the last page.
+ * @return the last page
+ */
public int getLastPage() {
return (int)(Math.floor(getRowForLastPage() / getPageSize()));
}
+ /**
+ * Internal method used to calculate the last row given a data set size.
+ * @return the last row or <code>null</code> if the last row can not be calculated
+ */
private Integer internalGetLastRow() {
if(_dataSetSize != null) {
/*
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/DataGridTagModel.java Sat May 14 16:31:52 2005
@@ -39,8 +39,6 @@
* the {@link javax.servlet.jsp.PageContext} in a JSP. This bean exposes state and services
* which can be data bound by an expression language in a JSP.
* </p>
- * <p>
- * </p>
*/
public class DataGridTagModel {
@@ -243,56 +241,131 @@
_pagerRenderer.setDataGridTagModel(this);
}
+ /**
+ * Get the {@link DataGridResourceProvider} used to provide string messages, paths, etc during
+ * data grid rendering.
+ *
+ * @return the {@link DataGridResourceProvider}
+ */
public DataGridResourceProvider getResourceProvider() {
return _resourceProvider;
}
+ /**
+ * Set the {@link DataGridResourceProvider} used to render the data grid.
+ * @param resourceProvider the new resource provider
+ */
public void setResourceProvider(DataGridResourceProvider resourceProvider) {
_resourceProvider = resourceProvider;
}
+ /**
+ * Check to see if the data grid will render its pager UI by default. The location for the default UI
+ * is controlled by the JSP tag doing the rendering.
+ * @return <code>true</code> if default rendering is enabled; <code>false</code> otherwise.
+ */
public boolean isDisableDefaultPagerRendering() {
return _disableDefaultPagerRendering;
}
+ /**
+ * Set a boolean to enable or disable rendering the pager UI by default. If <code>true</code>, the
+ * data grid rendering tags will produce the pager markup in some default location. If <code>false</code>
+ * the default pager rendering will be disabled. The default location is determined by the tags
+ * doing the rendering.
+ * @param disableDefaultPagerRendering boolean for enabling or disabling rendering the pager in the default location
+ */
public void setDisableDefaultPagerRendering(boolean disableDefaultPagerRendering) {
_disableDefaultPagerRendering = disableDefaultPagerRendering;
}
+ /**
+ * <p>
+ * Get the flag for whether to render the data grid using HTML row groups. Row groups include the HTML
+ * <code>thead</code>, <code>tbody</code>, and <code>tfoot</code> tags. If row group rendering is enabled,
+ * the HTML produced by the data grid will be contained inside of these tags and rendered in the correct
+ * order in the produced HTML. More detail on row groups can be found
+ * <a href="http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.2.3">here</a>.
+ * </p>
+ * @return <code>true</code> if row groups will be rendered; <code>false</code> otherwise
+ */
public boolean isRenderRowGroups() {
return _renderRowGroups;
}
+ /**
+ * Set whether to render the data grid using HTML row groups. For more detail, see {@link #isRenderRowGroups()}.
+ *
+ * @param renderRowGroups <code>true</code> if rendering row groups; <code>false</code> otherwise
+ */
public void setRenderRowGroups(boolean renderRowGroups) {
_renderRowGroups = renderRowGroups;
}
+ /**
+ * Get the instance of {@link TableRenderer} that is used to render HTML table markup for a data grid.
+ * @return the {@link TableRenderer}
+ */
public TableRenderer getTableRenderer() {
return _tableRenderer;
}
+ /**
+ * Set the {@link TableRenderer} used to render HTML table markup for a data grid.
+ * @param tableRenderer the {@link TableRenderer} to use for rendering
+ */
public void setTableRenderer(TableRenderer tableRenderer) {
_tableRenderer = tableRenderer;
}
+ /**
+ * Get the {@link StyleModel} used to create style classes during data grid rendering.
+ * @return the {@link StyleModel}
+ */
public StyleModel getStyleModel() {
return _styleModel;
}
+ /**
+ * Set the {@link StyleModel} used to create style classes during data grid rendering.
+ * @param styleModel the {@link StyleModel}
+ */
public void setStyleModel(StyleModel styleModel) {
_styleModel = styleModel;
}
+ /**
+ * Get a message given a resource string name <code>key</code>.
+ * @param key the message key
+ * @return the value of the message
+ */
public String getMessage(String key) {
assert _resourceProvider != null : "Received a null resource provider";
return _resourceProvider.getMessage(key);
}
+ /**
+ * Format a message given a resource string name <code>key</code> and a set of
+ * formatting arguments <code>args</code>.
+ * @param key the message key
+ * @param args the arguments used when formatting the message
+ * @return the formatted message
+ */
public String formatMessage(String key, Object[] args) {
assert _resourceProvider != null : "Received a null resource provider";
return _resourceProvider.formatMessage(key, args);
}
+ /**
+ * <p>
+ * This method provides support for overriding the messages available in the {@link DataGridResourceProvider} on a
+ * per-message basis. The key and value parameters here will override (or add) a message available via
+ * the {@link DataGridResourceProvider} without requiring an entire Java properties file or custom
+ * {@link DataGridResourceProvider} implementation.
+ * </p>
+ * @param key the key of the message to override
+ * @param value the new value for the message key
+ */
public void addResourceOverride(String key, String value) {
OverridableDataGridResourceProvider overrideResourceProvider = null;
if(!(_resourceProvider instanceof OverridableDataGridResourceProvider)) {
@@ -307,11 +380,36 @@
overrideResourceProvider.addResourceOverride(key, value);
}
+ /**
+ * <p>
+ * Get the resourrce path used when creating HTML image links during data grid rendering. The value of the
+ * default resource path is the {@link javax.servlet.http.HttpServletRequest#getContextPath()} combined
+ * with the value of the data grid message stringn obtained with the key {@link IDataGridMessageKeys#DATAGRID_RESOURCE_PATH}.
+ * </p>
+ * @return the string resource path
+ */
public String getResourcePath() {
/* todo: fix the message here to format with the context path */
return _request.getContextPath() + "/" + getMessage(IDataGridMessageKeys.DATAGRID_RESOURCE_PATH);
}
+ /**
+ * <p>
+ * Get the image paths used for the given {@link SortDirection}. The image paths are discovered
+ * by using the following mapping.
+ * <br/>
+ * <table>
+ * <tr><td>Sort direction</td><td>Message key</td></tr>
+ * <tr><td><code>{@link SortDirection#ASCENDING}</code></td><td><code>{@link IDataGridMessageKeys#SORT_ASC_IMAGE_PATH}</code></td></tr>
+ * <tr><td><code>{@link SortDirection#DESCENDING}</code></td><td><code>{@link IDataGridMessageKeys#SORT_DESC_IMAGE_PATH}</code></td></tr>
+ * <tr><td><code>{@link SortDirection#NONE}</code></td><td><code>{@link IDataGridMessageKeys#SORT_NONE_IMAGE_PATH}</code></td></tr>
+ * </table>
+ * The value for the message is obtained by looking up a value in the {@link DataGridResourceProvider} obtained
+ * via {@link #getResourceProvider()} using the message key in the table above.
+ * </p>
+ * @param sortDirection the {@link SortDirection} used to lookup an image path
+ * @return the string image used to represent a sort direction graphically
+ */
public String getSortImagePath(SortDirection sortDirection) {
/* todo: move to the DataGridConfig object */
if(sortDirection == SortDirection.ASCENDING)
@@ -324,6 +422,12 @@
}
}
+ /**
+ * Get the default image path used when constructing links to sort images. This value
+ * is taken from the resource String available via the {@link DataGridResourceProvider}
+ * obtained using {@link #getResourceProvider()} using the {@link IDataGridMessageKeys#SORT_NONE_IMAGE_PATH} key.
+ * @return the String path
+ */
public String getDefaultSortImagePath() {
return getMessage(IDataGridMessageKeys.SORT_NONE_IMAGE_PATH);
}
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/IDataGridMessageKeys.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/IDataGridMessageKeys.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/IDataGridMessageKeys.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/IDataGridMessageKeys.java Sat May 14 16:31:52 2005
@@ -18,27 +18,108 @@
package org.apache.beehive.netui.databinding.datagrid.api.rendering;
/**
- *
+ * <p>
+ * This interfaces exposes a set of message keys that are used by the data grid when
+ * looking-up message values for text and other strings during rendering.
+ * </p>
+ * <p>
+ * Custom resource bundles implemented with Java property files can be exposed via a
+ * {@link org.apache.beehive.netui.databinding.datagrid.api.DataGridResourceProvider}. Such property files
+ * should contain message keys whose values match the values of the messages keys defined here.
+ * </p>
*/
public interface IDataGridMessageKeys {
+ /**
+ * <p>
+ * String key for the message displayed when no data is available in the data set to which
+ * a data grid is bound.
+ * <br/>
+ * <b>Default value:</b><i>No data to display</i>
+ */
String DATAGRID_MSG_NODATA = "datagrid.msg.nodata";
+ /**
+ * <p>
+ * String key for the root resource path used when building a URL to resources such as images rendered
+ * in a data grid.
+ * <br/>
+ * <b>Default value:</b><i>resources/beehive/version1/images</i>
+ * </p>
+ */
String DATAGRID_RESOURCE_PATH = "datagrid.resource.path";
+ /**
+ * <p>
+ * String key for the name of an image used when rendering the ascending sort direction.
+ * <br/>
+ * <b>Default value:</b><i>/sortdown.gif</i>
+ * </p>
+ */
String SORT_ASC_IMAGE_PATH = "sort.asc.img";
+ /**
+ * <p>
+ * String key for the name of an image used when rendering the descending sort direction.
+ * <br/>
+ * <b>Default value:</b><i>/sortup.gif</i>
+ * </p>
+ */
String SORT_DESC_IMAGE_PATH = "sort.desc.img";
+ /**
+ * <p>
+ * String key for the name of an image used when rendering the no sort direction.
+ * <br/>
+ * <b>Default value:</b><i>/sortup.gif</i>
+ * </p>
+ */
String SORT_NONE_IMAGE_PATH = "sort.none.img";
+ /**
+ * <p>
+ * String key for the text displayed when rendering a link for paging to the first page of a data set.
+ * <br/>
+ * <b>Default value:</b><i>First</i>
+ * </p>
+ */
String PAGER_MSG_FIRST = "pager.msg.first";
+ /**
+ * <p>
+ * String key for the text displayed when rendering a link for paging to the logical next page of a data set.
+ * <br/>
+ * <b>Default value:</b><i>Next</i>
+ * </p>
+ */
String PAGER_MSG_NEXT = "pager.msg.next";
+ /**
+ * <p>
+ * String key for the text displayed when rendering a link for paging to the logical previous page of a data set.
+ * <br/>
+ * <b>Default value:</b><i>Previous</i>
+ * </p>
+ */
String PAGER_MSG_PREVIOUS = "pager.msg.previous";
+ /**
+ * <p>
+ * String key for the text displayed when rendering a link for paging to the last page of a data set.
+ * <br/>
+ * <b>Default value:</b><i>Last</i>
+ * </p>
+ */
String PAGER_MSG_LAST = "pager.msg.last";
+ /**
+ * <p>
+ * String key for the text displayed in a pager label when showing Page # of #.
+ * <br/>
+ * <b>Default value:</b><i>Page {0} of {1}</i>
+ * The <code>{0}</code> is substituted with a 1-based value for the current page. The <code>{1}</code> is
+ * substituted with a 1-based value for the last page.
+ * </p>
+ */
String PAGER_FMT_BANNER = "pager.fmt.banner";
}
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/PagerRenderer.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/PagerRenderer.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/PagerRenderer.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/PagerRenderer.java Sat May 14 16:31:52 2005
@@ -34,7 +34,12 @@
import org.apache.beehive.netui.util.Bundle;
/**
- *
+ * <p>
+ * This is the base class for data grid pager renderers. Subclasses can be used by the data grid to
+ * render custom pager markup overriding one or both of the {@link #internalRender()} and {@link #noDataRender()}
+ * methods. Additional methods are implemented here as a convenience and may be overriden by
+ * subclasses needing to change their behavior.
+ * </p>
*/
public abstract class PagerRenderer {
@@ -47,15 +52,33 @@
private TagRenderingBase _anchorTag = null;
private AnchorTag.State _anchorState = new AnchorTag.State();
- public void setDataGridTagModel(DataGridTagModel gridModel) {
- assert gridModel != null;
+ /**
+ * <p>
+ * Set the {@link DataGridTagModel} with which this pager renderer instance is associated. Pager renderer
+ * instances should not be shared between data grids without setting a {@link DataGridTagModel} for
+ * each data grid.
+ * @param dataGridTagModel the {@link DataGridTagModel}
+ */
+ public void setDataGridTagModel(DataGridTagModel dataGridTagModel) {
+ assert dataGridTagModel != null;
- _gridModel = gridModel;
+ _gridModel = dataGridTagModel;
_pagerModel = _gridModel.getState().getPagerModel();
_request = JspUtil.getRequest(_gridModel.getJspContext());
_anchorTag = TagRenderingBase.Factory.getRendering(TagRenderingBase.ANCHOR_TAG, _request);
}
+ /**
+ * <p>
+ * This method should be called when the pager is to be rendered. The result will be the String that
+ * represents the result of rendering.
+ * </p>
+ * <p>
+ * If there is no data in the data set, the method {@link #noDataRender()} will be invoked. Otherwise,
+ * the {@link #internalRender()} method will be called.
+ * </p>
+ * @return a string containing markup rendered by the pager
+ */
public String render() {
if(_gridModel.getDataSet().getSize() == 0)
return noDataRender();
@@ -63,22 +86,42 @@
return internalRender();
}
+ /**
+ * Get the {@link PagerModel} that contains the current pager state.
+ * @return the {@link PagerModel}
+ */
protected PagerModel getPagerModel() {
return _pagerModel;
}
+ /**
+ * Get the {@link DataGridTagModel} to which this pager is associated.
+ * @return the {@link DataGridTagModel}
+ */
protected DataGridTagModel getDataGridTagModel() {
return _gridModel;
}
+ /**
+ * Render the pager. This method is invoked when there is data available in the data set.
+ * @return a string containing markup rendered by the pager
+ */
protected String internalRender() {
return EMPTY_STRING;
}
+ /**
+ * Render the pager. This method is invoked when there is no data available in the data set.
+ * @return a string containing markup rendered by the pager
+ */
protected String noDataRender() {
return _gridModel.getMessage(IDataGridMessageKeys.DATAGRID_MSG_NODATA);
}
+ /**
+ * Build an HTML anchor that contains URL state for navigating to the first page of a data set.
+ * @return the HTML markup for anchor to the first page
+ */
protected String buildLiveFirstLink() {
InternalStringBuilder builder = new InternalStringBuilder();
AbstractRenderAppender appender = new StringBuilderRenderAppender(builder);
@@ -88,10 +131,21 @@
return builder.toString();
}
+ /**
+ * Build literal text for the string displayed when there is no first page for the data set. This
+ * text is generally used when the {@link PagerModel} is already on the first page. By default, this text is
+ * obtained using the {@link IDataGridMessageKeys#PAGER_MSG_FIRST} message key.
+ * @return the text for the first page link
+ */
protected String buildDeadFirstLink() {
return _gridModel.getMessage(IDataGridMessageKeys.PAGER_MSG_FIRST);
}
+ /**
+ * Build an HTML anchor that contains URL state for navigating to the previous page of a data set. The
+ * previous page is calculated relative to the current location in the {@link PagerModel}
+ * @return the HTML markup for anchor to the previous page
+ */
protected String buildLivePreviousLink() {
InternalStringBuilder builder = new InternalStringBuilder();
AbstractRenderAppender appender = new StringBuilderRenderAppender(builder);
@@ -101,10 +155,21 @@
return builder.toString();
}
+ /**
+ * Build literal text for the string displayed when there is no previous page for the data set. This
+ * text is generally used when the {@link PagerModel} is on the first page. By default, this text is
+ * obtained using the {@link IDataGridMessageKeys#PAGER_MSG_PREVIOUS} message key.
+ * @return the text for the previous page link
+ */
protected String buildDeadPreviousLink() {
return _gridModel.getMessage(IDataGridMessageKeys.PAGER_MSG_PREVIOUS);
}
+ /**
+ * Build an HTML anchor that contains URL state for navigating to the next page of a data set. The
+ * next page is calculated relative to the current location in the {@link PagerModel}
+ * @return the HTML markup for anchor to the next page
+ */
protected String buildLiveNextPageLink() {
InternalStringBuilder builder = new InternalStringBuilder();
AbstractRenderAppender appender = new StringBuilderRenderAppender(builder);
@@ -112,10 +177,20 @@
return builder.toString();
}
+ /**
+ * Build literal text for the string displayed when there is no next page for the data set. This
+ * text is generally used when the {@link PagerModel} is on the last page. By default, this text is
+ * obtained using the {@link IDataGridMessageKeys#PAGER_MSG_NEXT} message key.
+ * @return the text for the next page link
+ */
protected String buildDeadNextLink() {
return _gridModel.getMessage(IDataGridMessageKeys.PAGER_MSG_NEXT);
}
+ /**
+ * Build an HTML anchor that contains URL state for navigating to the last page of a data set.
+ * @return the HTML markup for anchor to the last page
+ */
protected String buildLiveLastLink() {
InternalStringBuilder builder = new InternalStringBuilder();
AbstractRenderAppender appender = new StringBuilderRenderAppender(builder);
@@ -123,10 +198,22 @@
return builder.toString();
}
+ /**
+ * Build literal text for the string displayed when there is no last page for the data set. This
+ * text is generally used when the {@link PagerModel} is on the last page. By default, this text is
+ * obtained using the {@link IDataGridMessageKeys#PAGER_MSG_LAST} message key.
+ * @return the text for the last page link
+ */
protected String buildDeadLastLink() {
return _gridModel.getMessage(IDataGridMessageKeys.PAGER_MSG_LAST);
}
+ /**
+ * Build the anchor
+ * @param appender
+ * @param queryParams
+ * @param labelKey
+ */
protected final void buildAnchor(AbstractRenderAppender appender, Map queryParams, String labelKey) {
assert appender != null;
assert queryParams != null;
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/StyleModel.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/StyleModel.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/StyleModel.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/rendering/StyleModel.java Sat May 14 16:31:52 2005
@@ -22,7 +22,9 @@
import java.util.List;
/**
- *
+ * <p>
+ * JavaBean base class that creates HTML style class names used to render various HTML elements in the data grid.
+ * </p>
*/
public abstract class StyleModel {
@@ -32,51 +34,141 @@
private String _stylePrefix = null;
+ /**
+ * Default constructor.
+ */
public StyleModel() {
}
+ /**
+ * Constructor that takes a style prefix string. If a style prefix is provided, StyleModel subclasses
+ * should use this as a prefix to any style names that are produced.
+ *
+ * @param stylePrefix the prefix to use for styles
+ */
public StyleModel(String stylePrefix) {
_stylePrefix = stylePrefix;
}
+ /**
+ * Set the style prefix.
+ * @param stylePrefix the style prefix
+ */
public void setStylePrefix(String stylePrefix) {
_stylePrefix = stylePrefix;
}
+ /**
+ * Get the style prefix
+ * @return the style prefix
+ */
public String getStylePrefix() {
return _stylePrefix;
}
+ /**
+ * Get the style class for an HTML table tag.
+ * @return the style class
+ */
public abstract String getTableClass();
+ /**
+ * Get the style class for an HTML caption tag.
+ * @return the style class
+ */
public abstract String getCaptionClass();
+ /**
+ * Get the style class for an HTML thead tag.
+ * @return the style class
+ */
public abstract String getTableHeadClass();
+ /**
+ * Get the style class for an HTML tfoot tag.
+ * @return the style class
+ */
public abstract String getTableFootClass();
+ /**
+ * Get the style class for an HTML tr tag rendered in the grid's header.
+ * @return the style class
+ */
public abstract String getHeaderRowClass();
+ /**
+ * Get the style class for an HTML tr tag rendered in the grid's footer.
+ * @return the style class
+ */
public abstract String getFooterRowClass();
+ /**
+ * Get the style class for an HTML tr tag rendered in a grid row. This style class will be used on
+ * even numbered rows.
+ * @return the style class
+ */
public abstract String getRowClass();
+ /**
+ * Get the style class for an HTML tr tag rendered in a grid row. This style class will be used on
+ * odd numbered rows.
+ * @return the style class
+ */
public abstract String getAltRowClass();
+ /**
+ * Get the style class for an HTML td tag rendered for a grid cell.
+ * @return the style class
+ */
public abstract String getDataCellClass();
+ /**
+ * Get the style class for an HTML th tag rendered for a grid's header cell.
+ * @return the style class
+ */
public abstract String getHeaderCellClass();
+ /**
+ * Get the style class for an HTML th tag for a grid's header cell whose data is sorted.
+ * @return the style class
+ */
public abstract String getHeaderCellSortedClass();
+ /**
+ * Get the style class for an HTML th tag for a grid's header cell that is sortable.
+ * @return the style class
+ */
public abstract String getHeaderCellSortableClass();
+ /**
+ * Get the style class for an HTML th tag for a grid's header cell that is filtered.
+ * @return the style class
+ */
public abstract String getHeaderCellFilteredClass();
+ /**
+ * Get the style class for an HTML td tag for a grid cell that is sorted.
+ * @return the style class
+ */
public abstract String getDataCellSortedClass();
+ /**
+ * Get the style class for an HTML td tag for a grid cell that is filtered.
+ * @return the style class
+ */
public abstract String getDataCellFilteredClass();
+ /**
+ * Build the value of the HTML style class attribute from the {@link List} of style classes. The style classes
+ * are converted into a string in their list order. For example, a list with contents:
+ * <pre>
+ * foo,bar,baz
+ * </pre>
+ * will be convereted into a style class whose value is <code>foo,bar,baz</code>
+ *
+ * @param styleClasses the classes to render into a style class value
+ * @return the string style class or an empty string if no style classes are provided
+ */
public String buildStyleClassValue(List/*<String>*/ styleClasses) {
if(styleClasses == null)
return EMPTY;
@@ -98,6 +190,11 @@
else return buf.toString();
}
+ /**
+ * Given a base style class name, this method adds a style prefix to produce a complete style class.
+ * @param baseStyle the core style class name
+ * @return the style class
+ */
protected String buildStyleClass(String baseStyle) {
if(_stylePrefix != null)
return prefix(baseStyle);
@@ -105,6 +202,11 @@
}
/* @todo: perf - could cache the style names once they've been produced */
+ /**
+ * Utility method to concatenate the given style class name and the style prefix.
+ * @param style the core style name
+ * @return the style class
+ */
private final String prefix(String style) {
InternalStringBuilder sb = new InternalStringBuilder(16);
sb.append(_stylePrefix);
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/Sort.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/Sort.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/Sort.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/Sort.java Sat May 14 16:31:52 2005
@@ -57,18 +57,34 @@
_sortDirection = sortDirection;
}
+ /**
+ * Get the sort expression
+ * @return the sort expression
+ */
public String getSortExpression() {
return _sortExpression;
}
+ /**
+ * Set the sort expression
+ * @param expression the sort expression
+ */
public void setSortExpression(String expression) {
_sortExpression = expression;
}
+ /**
+ * Get the {@link SortDirection}
+ * @return the sort direction
+ */
public SortDirection getDirection() {
return _sortDirection;
}
+ /**
+ * Set the {@link SortDirection}
+ * @param sortDirection the sort direction
+ */
public void setDirection(SortDirection sortDirection) {
_sortDirection = sortDirection;
}
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortDirection.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortDirection.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortDirection.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortDirection.java Sat May 14 16:31:52 2005
@@ -24,18 +24,40 @@
* or {@link #NONE}.
* </p>
* <p>
- * The SortDirection class should be used to specify the direction of a sort on a {@link Sort} instance.
+ * The SortDirection class is used to specify the direction of sorting on a {@link Sort} JavaBean instance.
* </p>
*/
public class SortDirection
implements java.io.Serializable {
+ /**
+ * Int value representing an ascending sort.
+ */
public static final int INT_ASCENDING = 0;
+
+ /**
+ * Int value representing a descending sort.
+ */
public static final int INT_DESCENDING = 1;
+
+ /**
+ * Int value representing no sort.
+ */
public static final int INT_NONE = 2;
+ /**
+ * Direction representing ascending.
+ */
public static final SortDirection ASCENDING = new SortDirection(INT_ASCENDING);
+
+ /**
+ * Direction representing descending.
+ */
public static final SortDirection DESCENDING = new SortDirection(INT_DESCENDING);
+
+ /**
+ * Direction representing no sort direction
+ * */
public static final SortDirection NONE = new SortDirection(INT_NONE);
private int _val;
@@ -44,6 +66,11 @@
_val = val;
}
+ /**
+ * Convert this sort direction to a readable String. Note, this does not return the query language
+ * operator -- only text for the direction itself.
+ * @return the readable direction name
+ */
public String toString() {
switch(_val) {
case INT_ASCENDING:
@@ -59,6 +86,11 @@
throw new IllegalStateException(message);
}
+ /**
+ * Equals method.
+ * @param value value to check
+ * @return <code>true</code> if this direction matches the <code>value</code>; <code>false</code> otherwise.
+ */
public boolean equals(Object value) {
if(value == this)
return true;
@@ -68,10 +100,19 @@
return ((SortDirection)value)._val == _val;
}
+ /**
+ * Hash code.
+ * @return the hash code
+ */
public int hashCode() {
return _val;
}
+ /**
+ * The direction's int value.
+ *
+ * @return the direction's value
+ */
public int getValue() {
return _val;
}
Modified: incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortStrategy.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortStrategy.java?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortStrategy.java (original)
+++ incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/api/sort/SortStrategy.java Sat May 14 16:31:52 2005
@@ -18,12 +18,24 @@
package org.apache.beehive.netui.databinding.datagrid.api.sort;
/**
- *
+ * <p>
+ * A SortStrategy is an implementation for the state machine which is used to cycle through sort directions.
+ * </p>
*/
public abstract class SortStrategy
implements java.io.Serializable {
+ /**
+ * Get the default {@link SortDirection}.
+ * @return the default {@link SortDirection}
+ */
public abstract SortDirection getDefaultDirection();
+ /**
+ * Given a <code>direction</code> compute the next {@link SortDirection}. Implementations
+ * are free to use arbitrary logic to compute the next direction.
+ * @param direction the current sort direction
+ * @return the next sort direction
+ */
public abstract SortDirection nextDirection(SortDirection direction);
}
Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties?rev=170182&r1=170181&r2=170182&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties (original)
+++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/util/netui.properties Sat May 14 16:31:52 2005
@@ -649,6 +649,8 @@
DataGridStateFactory_nullDataGridConfig=Unable to create a DataGridCodec with a null DataGridConfig
PagerModel_IllegalDefaultPageSize=Illegal default page size; the default page size must be greater than zero.
PagerModel_IllegalPageSize=Can not set a page size that is less than one.
+PagerModel_IllegalPage=Can not set the current page to a value less than zero.
+PagerModel_IllegalRow=Can not set the current row to a value less than zero.
PagerModel_CantCalculateLastPage=Unable to calculate the last page for the pager. The size of the data set is unknown.
CellModel_FormatterThrewException=A formatter of type \"{0}\" threw an exception {1}
DataGridTagModel_InvalidStateTransition=Unable to make the specified render state transition