|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Auto-filter a la "Excel"?Hi
I was looking around this forum to find some pointers or example of code that could let us emulate the "Auto-filter" functionality form Excel. On a given event (say right click?) on a JTable Header, a JList would appear and the set of possible values in this column displayed and selected. One could unselect them all or just select a few and on closing of this "filter" panel, only those rows would be displayed. This sounds like a job for a FilteredList but has anybody done it in JDK5? There is a fair amount of work to display etc... so rather than re-inventing the wheel, I was wondering if anyone had done something similar and would be willing to share it or explain a bit? Many thanks for GlazedLists! Thanks a lot Best regards from London (the English one) Benoit |
|
|
Re: Auto-filter a la "Excel"?Benoit,
No work has been done specifically to support this, though it sounds like "generally useful behaviour", and one that could have a home in the GL core. If you've got the time, we can design something together via this channel... I'll be back online fulltime in 3 weeks, but Holger would probably be able to help you out too.... James On Tue, May 27, 2008 at 2:26 PM, Benoitx <benoitx@...> wrote:
|
|
|
Re: Auto-filter a la "Excel"?Dear James & All,
Thanks for replying. I went ahead and started on some exploratory work… it nearly works but the glitches that I am experiencing will surely show the depth of my ignorance. I have 2 types of issues, one with Swing and the other with GlazedLists. First of all, the scope of this exercise. I am using an extension to the EventTableModel. When a user clicks (right button) on the jtable header I would like a small JList to appear. By default everything should be selected; when the user selects some items and press ok, the table will be filtered. Our application is using Swing and MDI with the table created in a JInternalFrame. I have a solution which is work-in-progress, you can see the current result on: http://www.objectlab.co.uk/jfree/jtable-filter.png SWING Issues 1/ Which container to use? For the panel with the JList? I have used a JWindow as it was the only one that seemed working…(JFrame appears like another window) Basically, how do you overlay a panel on top of a header and part of the JTable? 2/ How to position the Window/Panel? I have picked up the MouseEvent point but how can one detect the top-left corner of the COLUMN header? 3/ for some reason, I *had* to make the JWindow always on top (otherwise it would disappear as soon as it gets clicked on). This leads to some ugly effect if you then bring another application on top… as the little filter panel stays on top of anything on your machine!!! 4/ I tried to add a focus listener on the JWindow and dispose of the window when it loses the focus (reasonable assumption I guess) but the JWindow does not pickup any focus event: window.addFocusListener(new FocusAdapter() { public void focusLost(final FocusEvent e) { window.dispose(); } }); GLAZED LISTS Deisgn & Issues 1/ I wanted this functionality to be totally transparent, ie current users of the EventTable would not need to do anything, so the idea was to override the EventTableModel and give it a FilterList when it is created. Unfortunately, once a list is given to an EventTableModel it appears that there is no way to get back the list (the table should listen for events in order to refresh the list of existing values)? The list is wrapped up in a swingThreadSource transformed list… Why can’t we get the source in order to apply the filter? 2/ Current solution creates a sub-class of EventTableModel which creates a FilterList and passes it to the EventTableModel, it also retains a link to the FilterList and can give it to the MouseListener code on the table header so that a Matcher can be applied to the filter list. 3/ on pressing the header, the column property name is found and we’re using the Spirng BeanWrapper to fetch all valid data from the list, put those in a Set (to remove duplicates). Once the list of items is prepared, a new Matcher is created (also using a BeanWrapper to access values of each beans given the column name). My questions really relates to the fact that usually one creates an EventList, then a SortedList and gives the SortedList to the EventTableModel. Some of our tables have also a FilterList (with textfield) but it is always a SortedList given to the EventTableModel… so we end-up with the possibility of having 2 filter lists on the dataset… and also having no way to use the FilterList from the table model outside the table (say for a chart too). It would be good if my sub-class of EventTableModel could look at the list given and see if it is the result of a FilterList… and keep a reference to it… As you can see my main issues are related to Swing… any suggestion would be welcome! I have no problem sending the non-generic/hack code in order to design a better solution… Thanks a lot Benoit
|
|
|
Re: Auto-filter a la "Excel"?Hi *,
Quick update: I have sorted most of my Swing basic problems (using a sub-class of JDialog to display the list), keeping 2 sets of data (available and selected). I can send the stuff over if required. One thing is missing... how to display a little icon on the header to say that it was filtered... Or may be change the header colour for that column only??? Suggestions? Thanks Benoit
|
| Free Forum Powered by Nabble | Forum Help |