coderazzi / tablefilter-swing

TableFilter is a set of Swing components to support user-driven filtering on table.
https://coderazzi.net/tablefilter
MIT License
7 stars 2 forks source link

The plugin doesn't work for JTree tables #46

Closed coderazzi closed 4 years ago

coderazzi commented 4 years ago

Original report by Mohit (Bitbucket: [Mohit Kumar Meena](https://bitbucket.org/Mohit Kumar Meena), ).


When a table uses JTree implementation, plugins fails to deliver filter functionality for the table’s first column. It is due to the fact that first column of JTree has hierarchical structure. On applying filtering on first column it always displays first value and link to other column shows incorrectly.

coderazzi commented 4 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


Hi, Mohit, thanks for your feedback. Would you have some code I can use to reproduce quickly the issue? Best, L.

coderazzi commented 4 years ago

Original comment by Mohit (Bitbucket: [Mohit Kumar Meena](https://bitbucket.org/Mohit Kumar Meena), ).


Added zip file with the code.

coderazzi commented 4 years ago

Original comment by Mohit (Bitbucket: [Mohit Kumar Meena](https://bitbucket.org/Mohit Kumar Meena), ).


attached zip contains the example which can also be found at https://www.comp.nus.edu.sg/~cs3283/ftp/Java/swingConnect/tech_topics/tables-trees/tables-trees.html

The only change that I made is added table to TableFilter

coderazzi commented 4 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


Hi, Mohit

I have checked the example you sent, and the table filter library is working properly. What is not working is the table cell renderer that you are using to display the first column (the tree).

I have modified your example to have automatically filters enabled:

new TableFilterHeader(treeTable, AutoChoices.ENABLED);

(but this is obviously not needed).

This will look like:

You can see that there are several files, on row 2, 4 (and more down). If I apply the filter Type=File, the information in all the columns except the first one is fine. But the first column is just displaying the initial rows of the tree, as many are needed. That is, the renderer that you are using is displaying the view rows, not the model rows.

I guess that the JTreeTable code you are using is from any version of Java before 1.6.0, when the RowFilter functionality was added to Swing. You would need to provide your own proper cell renderer for the first column.

Cheers,

L.

coderazzi commented 4 years ago

Original comment by coderazzi coderazzi (Bitbucket: coderazzi, GitHub: coderazzi).


The library works as expected. It is the JTreeTable provided implementation that fails to render properly the filtered out rows.