Seems to me like the row editor should do the same thing as the display
code (namely calling the renderer, which includes formatting) after
storing/retrieving the data.  I would think that should be sufficient.

~Roger Whitcomb

-----Original Message-----
From: Sandro Martini [mailto:sandro.mart...@gmail.com] 
Sent: Monday, October 22, 2012 9:18 AM
To: u...@pivot.apache.org; Developers - Apache Pivot
Subject: Re: Adding $ symbol for each cell entry in a tableview

Including developers mailing list because there is a small question for
Pivot Developers (but of course comments and suggestions are welcome
from anyone):

after some tests, to me it seems that when the table row editor starts /
ends the edit phase, data is get from the table row and here data lose
its currency formatting.


I have to open a jira issue for this, for 2.0.3.


Just as idea, in TableViewRowEditor, in both methods beginEdit and
endEdit there is a small block of code:

            List<Object> tableData =
(List<Object>)tableView.getTableData();
            Object tableRow = tableData.get(rowIndex);


maybe to simplify, we could think to move this block in a dedicated
method (maybe with an additional argument that say whick event is, if
begin or end), so others could override only this ... to simplify things
for who need this.
Or find a way (but the same inside an overridden version of those
methods) to re-apply the right format at the end of edit.

Otherwise we could at least verify if extending the Pivot class and use
a custom version of both methods, if works as a good workaround, and
move to 2.0.4 ...


A better solution could be to add a listener for this kind of event, and
if there is one, use it ... but maybe this for 2.1 .


Last, a quick workaround (but not-so-good, I know) for the given test
application, could be in CurrencyCellRenderer (the custom cell rendered
of the sample) to extend the else case inside the toString method, and
try to convert to number the given strings and reapply the format, and
call the toString method only as last choice.


What do you think ?


Bye,
Sandro



2012/10/22 Sandro Martini <sandro.mart...@gmail.com>:
> Hi all,
> after some tests I think there is some problem in the row editor, 
> because it's true, for example if I use this (inside your example):
>
> SamplePage.java
>                 tableData = new HashMap<String, Float>();
>                     tableData.put(Integer.toString(i), new Float(i + 
> 0.5));  // test with this the first time currency symbol is show in 
> any cell (the same replacing Float with Integer)
>
> first time:
> CurrencyCellRenderer: cellData = 0.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 1.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 2.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 3.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 4.5
> CurrencyCellRenderer: cellData instanceof Number = true
> CurrencyCellRenderer: cellData = 5.5
>
>
> but after editing a row, it disappears ... and cell contents are no 
> more instanceof Number .
>
> Using this instead:
> //                rowEditor.getCellEditors().put(Integer.toString(i),
> textInput);
>                 rowEditor.getCellEditors().put(Integer.toString(i), 
> null); you are not able to edit cell contents, but the format of 
> strings is good even after the tentative edit.
> And last, using a TextArea instead gives another result ...
>
>
> Probably there is something in TableViewRowEditor to fix or to extend.
>
> In the meantime you can try adding a custom version of row editor, 
> with support for currency columns.
>
>
> A fix for this must go in 2.0.3.
> But first I have to look at it  better ... at least if/how there is a 
> good workaround (could be to extend row editor).
>
>
> Let's update,
> Sandro

Reply via email to