Revision: 10614
Author: gwt.mirror...@gmail.com
Date: Fri Sep 2 09:17:24 2011
Log: Add support for additional header styles for CellTable.
Review at http://gwt-code-reviews.appspot.com/1538803
Review by: jlaba...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10614
Modified:
/trunk/user/src/com/google/gwt/user/cellview/client/Column.java
/trunk/user/src/com/google/gwt/user/cellview/client/DefaultHeaderOrFooterBuilder.java
/trunk/user/src/com/google/gwt/user/cellview/client/Header.java
=======================================
--- /trunk/user/src/com/google/gwt/user/cellview/client/Column.java Mon
Aug 8 09:10:15 2011
+++ /trunk/user/src/com/google/gwt/user/cellview/client/Column.java Fri
Sep 2 09:17:24 2011
@@ -173,7 +173,7 @@
* {@link #getCellStyleNames(Context, Object)} directly.
* </p>
*
- * @param styleNames the extra style names to applyin a space-separated
list,
+ * @param styleNames the extra style names to apply in a space-separated
list,
* or {@code null} if there are no extra styles for this cell
*/
public void setCellStyleNames(String styleNames) {
=======================================
---
/trunk/user/src/com/google/gwt/user/cellview/client/DefaultHeaderOrFooterBuilder.java
Wed Aug 31 03:58:11 2011
+++
/trunk/user/src/com/google/gwt/user/cellview/client/DefaultHeaderOrFooterBuilder.java
Fri Sep 2 09:17:24 2011
@@ -102,6 +102,7 @@
if (isSorted) {
classesBuilder.append(sortedStyle);
}
+ appendExtraStyles(prevHeader, classesBuilder);
// Render the header.
TableCellBuilder th =
@@ -144,6 +145,7 @@
// The first and last columns could be the same column.
classesBuilder.append(" ").append(
isFooter ? style.lastColumnFooter() : style.lastColumnHeader());
+ appendExtraStyles(prevHeader, classesBuilder);
// Render the last header.
TableCellBuilder th =
tr.startTH().colSpan(prevColspan).className(classesBuilder.toString());
@@ -159,4 +161,20 @@
return true;
}
-}
+
+ /**
+ * Append the extra style names for the header.
+ * @param header the header that may contain extra styles, it can be null
+ * @param classesBuilder the string builder for the TD classes
+ */
+ private <H> void appendExtraStyles(Header<H> header, StringBuilder
classesBuilder) {
+ if (header == null) {
+ return;
+ }
+ String headerStyleNames = header.getHeaderStyleNames();
+ if (headerStyleNames != null) {
+ classesBuilder.append(" ");
+ classesBuilder.append(headerStyleNames);
+ }
+ }
+}
=======================================
--- /trunk/user/src/com/google/gwt/user/cellview/client/Header.java Wed
Dec 1 05:40:20 2010
+++ /trunk/user/src/com/google/gwt/user/cellview/client/Header.java Fri
Sep 2 09:17:24 2011
@@ -31,6 +31,7 @@
private final Cell<H> cell;
+ private String headerStyleNames = null;
private ValueUpdater<H> updater;
/**
@@ -51,6 +52,18 @@
return cell;
}
+ /**
+ * Get extra style names that should be applied to a cell in this
header. May be overriden to
+ * get value dependent styles by calling {@link #getValue}.
+ *
+ * @return the extra styles of the given row in a space-separated list,
or
+ * {@code null} if there are no extra styles for the cells in
this
+ * header
+ */
+ public String getHeaderStyleNames() {
+ return headerStyleNames;
+ }
+
/**
* Get the key for the header value. By default, the key is the same as
the
* value. Override this method to return a custom key.
@@ -89,6 +102,21 @@
cell.render(context, getValue(), sb);
}
+ /**
+ * Set extra style names that should be applied to every cell in this
header.
+ *
+ * <p>
+ * If you want to apply style names based on the header value, override
+ * {@link #getHeaderStyleNames(Object)} directly.
+ * </p>
+ *
+ * @param styleNames the extra style names to apply in a space-separated
list,
+ * or {@code null} if there are no extra styles for this cell
+ */
+ public void setHeaderStyleNames(String styleNames) {
+ this.headerStyleNames = styleNames;
+ }
+
/**
* Set the {@link ValueUpdater}.
*
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors