glazedlists
  1. glazedlists
  2. GLAZEDLISTS-507

[Solved] Dynamic multi-criteria filtering

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      507

      Description

      Hello everyone,

      I appreciate the smart GlazedList but today I was stuck at a problem during the
      migration.

      In fact, I have developped a table (which extends JTable of JDK6) with
      customized header like "excel": there is a filter text field for each column.
      When user input keywords in these text fields, the content of the table is
      dynamically filtered.

      Note: the criteria of each filter field applies ONLY to the corresponding
      column.

      After search in the forum, I found this:
      -----------------
      SortedList sortedList = new SortedList(eventModel);
      TextFilterList filterByLanguage = new TextFilterList(sortedList, new
      String[]

      {"language"}

      , txtLanguage);
      TextFilterList filterByCode = new TextFilterList(filterByLanguage, new
      String[]

      {"code"}

      , txtCode);
      ----------------

      The only problem is: I don't know how to change the "txtLanguage" and "txtCode"
      dynamically and how to require the model to re-filter?

      I have read the turorial but haven't found a solution

      Any help will be appreciated. Thanks!

        Activity

        Hide
        revever added a comment -

        With JXTable of swingx, I have done as following:

        1. for each filter text-field, I create a "PatternFilter":
        >>> PatternFilter filter=new PatternFilter(keywords, 0, columnIndex);
        this will create a filter for the column "columnIndex".

        2. encapsulates all the filters in a "FilterPipeline"
        >>> jxtable.setFilters(new FilterPipeline(new PatternFilter[]

        {afilter, bfilter...}

        ))
        and this will trigger a filter action.

        Is there something alike for GlazedList? Thanks.

        Show
        revever added a comment - With JXTable of swingx, I have done as following: 1. for each filter text-field, I create a "PatternFilter": >>> PatternFilter filter=new PatternFilter(keywords, 0, columnIndex); this will create a filter for the column "columnIndex". 2. encapsulates all the filters in a "FilterPipeline" >>> jxtable.setFilters(new FilterPipeline(new PatternFilter[] {afilter, bfilter...} )) and this will trigger a filter action. Is there something alike for GlazedList? Thanks.
        Hide
        revever added a comment -

        Created an attachment (id=58)
        MultiCriteriaFilter implementation

        Show
        revever added a comment - Created an attachment (id=58) MultiCriteriaFilter implementation
        Hide
        revever added a comment -

        Well, I have advanced very much. (SEE the attached file).
        There is only one little thing which could be improved but I don't have the
        solution for now.

        My table is filtered and sorted at the same time. The code is below:
        -------------
        EventList<T> eventList = GlazedLists.threadSafeList(new BasicEventList<T>());
        FilterList filterList = new FilterList<T>(eventList);
        SortedList<T> sortedList = new SortedList<T>(filterList, comparator);
        EventTableModel<T> model = new EventTableModel<T>(sortedList, format);
        ...
        -------------

        In order to trigger the sort, I need:
        -------------
        SortedList sortedList = (SortedList)model.getList();
        FilterList filterList = sortedList.source; //here doesn't work
        filterList.setMatcher(updatedMatcher);
        -------------

        BUT the 'source' is protected in the class 'SortedList' and there is no getter
        for this field and this class 'SortedList' is final (so I can't extend it). I
        have to pass the 'filterList' as parameter everywhere in my solution

        Do I miss something?

        Show
        revever added a comment - Well, I have advanced very much. (SEE the attached file). There is only one little thing which could be improved but I don't have the solution for now. My table is filtered and sorted at the same time. The code is below: ------------- EventList<T> eventList = GlazedLists.threadSafeList(new BasicEventList<T>()); FilterList filterList = new FilterList<T>(eventList); SortedList<T> sortedList = new SortedList<T>(filterList, comparator); EventTableModel<T> model = new EventTableModel<T>(sortedList, format); ... ------------- In order to trigger the sort, I need: ------------- SortedList sortedList = (SortedList)model.getList(); FilterList filterList = sortedList.source; //here doesn't work filterList.setMatcher(updatedMatcher); ------------- BUT the 'source' is protected in the class 'SortedList' and there is no getter for this field and this class 'SortedList' is final (so I can't extend it). I have to pass the 'filterList' as parameter everywhere in my solution Do I miss something?

          People

          • Assignee:
            jessewilson
            Reporter:
            revever
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: