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

Suggestion: enable multi-choice filter #30

Open coderazzi opened 12 years ago

coderazzi commented 12 years ago

Original report by altmany (Bitbucket: altmany, GitHub: altmany).


At the moment (4.4.0), the filter choices use a simple ComboBox that enables selection
of only a single filter choice. 

I would like to suggest implementing a multi-selection filter using checkboxes in the
combo's popup panel, that would enable users to select multiple choices for filtering
(like Excel 2010). 

Perhaps it could be a sub-class of ChoiceRenderer, or perhaps even better - a settable
boolean property (default=false=single-selection behavior, just like the current implementation,
for full backward compatibility):

   public boolean isMultiSelectionAllowed()
   public void setMultiSelectionAllowed(boolean)

(please accept my apologies if this is already implemented somewhere and I failed to
notice)

Original issue reported on code.google.com by altmany on 2012-10-03 23:18:07

coderazzi commented 12 years ago

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


Hey, that is a very good idea. 

Implementation-wise, it does not fit very well with the current model, so I guess I
will need some long time to get through it...

Thanks for the suggestion!

Original issue reported on code.google.com by coderazzi on 2012-10-04 00:43:05

coderazzi commented 9 years ago

Original comment by Anonymous.


I think this is old, but… are you still working on this project?

I would be really insterested in multi-choice filter, like in https://github.com/eugener/oxbow

However, your UI is much more refined and usable, especially the way it shows within
the table.

The mentionned project provides a CheckedList that could be used to draw checkboxes
within the list. However, the code needs to be adapted since it is displayed in a popup
that will be dismissed on each click.

I already worked on a JMultiComboBox, but the logic is directly plugged in as a JComboBox
inherited classes, so it would be a lot of work to adapt it to a single PopupMenu.

Original issue reported on code.google.com by ZeGlandos on 2015-01-19 16:38:34

coderazzi commented 9 years ago

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


Hi, I'd like to consider this project as alive, but low demanding :-) I am covering
any bugs that impact the functionality, and I definitely use the tablefilter on my
projects, but I am quite reluctant to include new functionality.

The impact of this multiselection filter is rather large: it only affects the GUI,
indeed, but impacts all the core GUI components, including key navigation, basic user
interaction, etc. Honestly, I lack now the time to do it properly and cover all possible
regressions. 

But if you feel like coding it yourself, I could definitely assist / support you.

 Lu/

Original issue reported on code.google.com by coderazzi on 2015-01-19 22:25:51

coderazzi commented 9 years ago

Original comment by Anonymous.


Indeed.

I've started to hack it, and after successfully drawing a checkbox in the list. This
is kind of an easy part, except that I had to understand the whole code for that (in
FilterListCellRenderer).

But then, I realized that the logic of a single selected element is everywhere in PopupComponent.
The MouseHandler should be the entry point to the currently clicked element, but the
rest of the code assumes that there is only one selected element: the renderer (not
so bad), the choiceSelected method (we could create a Proxy object?), and some other.
But it implies to hack the logic. A better way should be to use multi-selection list
everywhere, even when there is only one…

Anyway, there is a lot of work, I don't know if I'll have time for this…

Original issue reported on code.google.com by ZeGlandos on 2015-01-20 15:20:41

coderazzi commented 9 years ago

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


Well, indeed the PopupComponent assumes a single selection, but extending its interface
to support multiple choices shouldn't be the problem; the FilterListCellRenderer can
be extended to support checkboxes, and overall there is probably more work to ensure
than no bugs are included in the system than implementing the new functionality itself.

However, the whole interface (API and GUI) requires major thinking. For example:

-What is shown on the editor when multiple choices are selected? Currently, we just
show the selected one, so it is not a problem at all.

-API: we have currently a setContent method to define the choice. It is enough to just
pass a collection to this method?

The filtering itself already implements OR logic. In fact, in the very first versions
of tablefilter, the user could enter complex boolean expressions on the filters, such
as choice 1 OR choice 2 AND choice 3....

In any case, I would definitely not hack the solution. As you say, using multi-selection
as base model seems definitely the best approach.

Original issue reported on code.google.com by coderazzi on 2015-01-21 00:05:43