[SortedList] should provide a sort() method

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 8u20
    • Component/s: javafx
    • Environment:

      Windows 7 64bit, JDK 8u20 Build b23 64bit

      If the sorting of a SortedList depends on other data then the source list there is no nice way to sort the SortedList again if the other data has been changed.

      A (not very nice) workaround is to set a new Comparator for the SortedList every time the other data has been changed:

      IntegerProperty counter = new SimpleIntegerProperty();
      SortedList<String> sortedList = new SortedList<>(mySourceList);
      sortedList.setComparator(new Comparator<String>() {
      @Override
      public int compare(String o1, String o2) {
      int result = 0;
      // Compare based on counter
      return result;
      }
      });
      myListView.setItems(sortedList.sorted());

      counter.addListener(o -> sortedList.setComparator(new Comparator<String>() {
      @Override
      public int compare(String o1, String o2) {
      int result = 0;
      // Compare based on counter
      return result;
      }
      }));

            Assignee:
            Unassigned
            Reporter:
            Andreas Liebelt
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Imported: