Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8102504

Provide an easy way to keep TreeItems sorted

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:

      Description

      Would be good to have an easy way to keep the TreeItems of a TreeView sorted if for example a comparator could be supplied at the treeview level.

      Currently, if you have an ordered list of TreeItems (e.g. alphabetically) and you want to add another node in the right location, the only options I can think of are:

      - call FXCollections.sort(item.getChildren()) after adding a child node - which I am not sure how would it behave if one of the items that get reordered was selected.
      - calculate the index of the node to be inserted programatically and insert it in the right position

      Additionally, if one wants to change the sort order for all nodes in the tree (e.g. from ascending to ascending or sort by a different criteria), one has to recursively apply the new sorting to all children.

      Would be great if a Comparator could be provided at the tree level and was responsible to keep all nodes sorted as specified by the comparator for add, addAll, setAll operations and also if it would resort all nodes when updating the comparator.





        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              atechnolojfx Anahata Technologies (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: