Fwd: Custom Filters

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Custom Filters

Jesse Wilson


Begin forwarded message:

> From: <[hidden email]>
> Date: July 28, 2005 12:58:27 PM PDT
> To: [hidden email]
> Subject: Custom Filters
> Message-Id: <[hidden email]>
>
> Hi again!
>
> J,
>
> Problem: Filter and Update the list in the
> actionPerformed() event of the ComboBox component
>
>
> How to implement the filer and update action in
> actionPerformed()
>
>     /**
>       * Listens to the combo box.
>       */
>     public void actionPerformed(ActionEvent e) {
>         String data;
>         data = (String) cSelect.getSelectedItem();
>         System.out.println("data: "+ data);
>
>         //Matcher newMatcher = new
> GenericForUsersMatcher(cSelectedList,column);
>         //fireChanged(newMatcher);
>
>
>         handleFilterChanged();
>     }
> tkns;

I think this solution requires 2 classes:
  - Create your own MatcherEditor that extends AbstractMatcherEditor.
When the combo box is changed, handle that itemChanged() event
by calling matcherChanged(Matcher)
  - The parameter to matcherChanged() is a class that you create that
implements Matcher. You need to create a new matcher instance
every time the selection is changed.

Two classes are annoying but it is necessary so that we can
separate the filter changing logic from the item matching logic.
Otherwise we can run into problems where the filter is changing
while items are being matched and the data is in an inconsistent state!

Cheers,
Jesse





smime.p7s (3K) Download Attachment