[seam-commits] Seam SVN: r10095 - in trunk: src/excel/org/jboss/seam/excel/jxl and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Feb 26 18:13:10 EST 2009
Author: nickarls
Date: 2009-02-26 18:13:10 -0500 (Thu, 26 Feb 2009)
New Revision: 10095
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Excel.xml
trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java
Log:
JBSEAM-3878
changes to force-type handling
Modified: trunk/doc/Seam_Reference_Guide/en-US/Excel.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Excel.xml 2009-02-26 21:06:38 UTC (rev 10094)
+++ trunk/doc/Seam_Reference_Guide/en-US/Excel.xml 2009-02-26 23:13:10 UTC (rev 10095)
@@ -3172,6 +3172,27 @@
</itemizedlist>
</section>
</section>
+ <section id="excel.i18n">
+ <title>Internationalization</title>
+ <para>
+ There are only two resources bundle keys used, both for invalid data format and both take a
+ parameter (the invalid value)
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>org.jboss.seam.excel.not_a_number</literal>
+ — When a value thought to be a number could not be treated as such
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>org.jboss.seam.excel.not_a_date</literal>
+ — When a value thought to be a date could not be treated as such
+ </para>
+ </listitem>
+ </itemizedlist>
+ </section>
<section id="excel.links">
<title>Links and further documentation</title>
<para>
Modified: trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java 2009-02-26 21:06:38 UTC (rev 10094)
+++ trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java 2009-02-26 23:13:10 UTC (rev 10095)
@@ -28,6 +28,7 @@
import jxl.write.WriteException;
import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.core.ResourceBundle;
import org.jboss.seam.excel.ExcelWorkbookException;
import org.jboss.seam.excel.css.CellStyle;
import org.jboss.seam.excel.css.ColumnStyle;
@@ -123,12 +124,12 @@
* @return The cell format
* @throws WriteException if the creation failed
*/
- public WritableCellFormat createCellFormat(UICell uiCell) throws WriteException
+ public WritableCellFormat createCellFormat(UICell uiCell, CellType cellType) throws WriteException
{
WritableCellFormat cellFormat = null;
CellStyle cellStyle = new CellStyle(parser.getCascadedStyleMap(uiCell));
- CellType cellType = cellStyle.forceType != null ? CellType.valueOf(cellStyle.forceType) : uiCell.getDataType();
+// CellType cellType = cellStyle.forceType != null ? CellType.valueOf(cellStyle.forceType) : uiCell.getDataType();
switch (cellType)
{
case text:
@@ -479,7 +480,7 @@
CellInfo cellInfo = new CellInfo();
cellInfo.setCellFeatures(createCellFeatures(uiCell));
cellInfo.setCellType(getCellDataType(uiCell));
- cellInfo.setCellFormat(getCellFormat(uiCell));
+ cellInfo.setCellFormat(getCellFormat(uiCell, cellInfo.getCellType()));
return cellInfo;
}
@@ -545,7 +546,8 @@
CellType cellDataType = cellInfoCache.getCachedCellType(uiCell.getId());
if (cellDataType == null)
{
- cellDataType = uiCell.getDataType();
+ CellStyle cellStyle = new CellStyle(parser.getCascadedStyleMap(uiCell));
+ cellDataType = cellStyle.forceType != null ? CellType.valueOf(cellStyle.forceType) : uiCell.getDataType();
cellInfoCache.setCachedCellType(uiCell.getId(), cellDataType);
}
return cellDataType;
@@ -558,7 +560,7 @@
* @param uiCell The cell to format
* @return The cell format
*/
- private WritableCellFormat getCellFormat(UICell uiCell)
+ private WritableCellFormat getCellFormat(UICell uiCell, CellType cellType)
{
if (log.isTraceEnabled())
{
@@ -569,7 +571,7 @@
{
try
{
- cellFormat = createCellFormat(uiCell);
+ cellFormat = createCellFormat(uiCell, cellType);
}
catch (WriteException e)
{
@@ -687,13 +689,15 @@
try {
return new jxl.write.Number(column, row, Double.parseDouble(data.toString()), cellFormat);
} catch (NumberFormatException e) {
- return new Label(column, row, "#not a number#", cellFormat);
+ String message = Interpolator.instance().interpolate(ResourceBundle.instance().getString("org.jboss.seam.excel.not_a_number"), data.toString());
+ return new Label(column, row, message, cellFormat);
}
case date:
try {
return new DateTime(column, row, (Date) data, cellFormat);
} catch (ClassCastException e) {
- return new Label(column, row, "#not a date#", cellFormat);
+ String message = Interpolator.instance().interpolate(ResourceBundle.instance().getString("org.jboss.seam.excel.not_a_date"), data.toString());
+ return new Label(column, row, message, cellFormat);
}
case formula:
return new Formula(column, row, data.toString(), cellFormat);
More information about the seam-commits
mailing list