alexruiz / fest-swing-1.x

FEST Functional Swing Testing
http://fest.easytesting.org
109 stars 34 forks source link

JTableHeaderLocation.columnName() doesn't work for reordered columns #17

Open jedwards1211 opened 11 years ago

jedwards1211 commented 11 years ago

Hi Alex, this is my first contribution to FEST, woohoo :)

Here's the code I'm referring to (in https://github.com/alexruiz/fest-swing-1.x/blob/master/fest-swing/src/main/java/org/fest/swing/driver/JTableHeaderLocation.java):

  @RunsInCurrentThread
  private String columnName(@Nonnull JTableHeader tableHeader, int index) {
    return tableHeader.getTable().getModel().getColumnName(index);
  }

columnName(2) would return the name of the column at model index 2. Correct me if I'm wrong, but it should be returning the name of the column at view index 2, which may be different if the view columns have been reordered.

This should fix it:

  @RunsInCurrentThread
  private String columnName(@Nonnull JTableHeader tableHeader, int index) {
    return tableHeader.getTable().getColumnName(index);
  }
manasouza commented 11 years ago

Good point! I already been annoyed by this model/view JTable concepts....guess must be monitored cases when we have to apply convertColumnIndexToModel(int) and convertColumnIndexToView(int)....maybe we'll need two methods, one for each case...

jedwards1211 commented 11 years ago

Well in this case, it must use the view index, or it may click a column with a different name... On Apr 14, 2013 10:07 AM, "Manassés Souza" notifications@github.com wrote:

Good point! I already been annoyed by this model/view JTable concepts....guess must be monitored cases when we have to apply convertColumnIndexToModel(int) and convertColumnIndexToView(int)....maybe we'll need two methods, one for each case...

— Reply to this email directly or view it on GitHubhttps://github.com/alexruiz/fest-swing-1.x/issues/17#issuecomment-16352494 .