benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

JTableCellFixture references old value after row filter applies #186

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From Michael Hüttermann:

I have a frame containing a table and an input text. I assigned a row
sorter to my table:

  TableRowSorter<TableModel> sorter;
  JTable table = new JTable(tm);
  TableModel tm = new DefaultTableModel(5, 2);
  sorter = new TableRowSorter<TableModel>(tm);
  table.setRowSorter(sorter);

... and I have an input text field with a document listener added.
Changing the value of the text field (adding characters, removing
characters) is applied on the table .. the newFilter() method is
called when editing the text field.

   protected final void newFilter() {
       try {

sorter.setRowFilter(RowFilter.regexFilter(myFilter.getText(), 0));
       } catch (java.util.regex.PatternSyntaxException e) {
           /* */
       }
   }

When I enter text in the textfield via FEST
window.textBox(FILTERTEXT_NAME).enterText("a");

I expect that only those table positions are displayed beginning with
"a".

Unfortunately
window.table(TABLE_NAME).cell(row(0).column(0)).value().substring(0,1);
delivers the OLD, original value of the cell. But the row filter did
its job and the content of the table changed. Only table positions
where the content of the first cell begins with "a" are displayed.
FEST accesses the old value, not the new value of the cell (0,0).

Original issue reported on code.google.com by Alex.Rui...@gmail.com on 25 Jul 2008 at 2:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This is a JDK 6-specific bug. The problem is in FEST's class 
BasicJTableCellReader,
which is calling 'table.getModel().getValueAt(int row, int column)'. This call
returns the same value as 'table.getValueAt(int row, int column)'. But in JDK 6,
'table.getValueAt' calls 'convertRowIndexToModel' (introduced in JDK 6) to get 
the
correct index of the first visible row. The fix involves calling 
'table.getValueAt'
instead of 'table.getModel().getValueAt'.

This bug is fixed and will be present in our next release.

Original comment by Alex.Rui...@gmail.com on 25 Jul 2008 at 4:32

GoogleCodeExporter commented 9 years ago
Thanks!!!

Original comment by michael....@googlemail.com on 25 Jul 2008 at 8:32

GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 2:10