0

I have the following test code below:

    tvNodes.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    tvNodes.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<TreeItem<Node>>() {
                @Override
                public void onChanged(Change<? extends TreeItem<Node>> c) {
                    while (c.next()) {
                        log.debug("From {} To {} (Removed: {}, Added: {}, Replaced: {}, List: {})", c.getFrom(), c.getTo(), c.wasRemoved(), c.wasAdded(), c.wasReplaced(), c.getList());
                        if (c.wasAdded()) {
                            for (var added : c.getAddedSubList()) {
                                log.debug("\tADDED ITEM: {}", added);
                            }
                        }
                        if (c.wasRemoved()) {
                            for (var removed : c.getRemoved()) {
                                log.debug("\tREMOVED ITEM: {} ({})", removed.getValue(), c.getRemovedSize());
                            }
                        }
                        if (c.wasReplaced()) {
                            log.debug("\tWAS REPLACED {} to {}", c.getFrom(), c.getTo());
                        }
                        if (c.wasPermutated()) {
                            log.debug("\tWAS PERMUTATED {} to {}", c.getFrom(), c.getTo());
                        }
                    }
                }
            });

When transitioning from a "full selection" to a "single item selection" (Circle 8)

From:

Full Selection

To:

Single Selection

I expected to receive two change events (Remove). The first event returns items from Circle (3) to Circle (7) and the second event returns items from Circle (9) to Circle (11).

Actual Results:

The first event returns the first half as expected, but the second event returns items 4,5,6 instead of 9, 10 and 11.

From 0 To 0 (Removed: true, Added: false, Replaced: false, List: [TreeItem [ value: Circle (8) ]])
    REMOVED ITEM: Circle (3) (5)
    REMOVED ITEM: Circle (4) (5)
    REMOVED ITEM: Circle (5) (5)
    REMOVED ITEM: Circle (6) (5)
    REMOVED ITEM: Circle (7) (5)
From 1 To 1 (Removed: true, Added: false, Replaced: false, List: [TreeItem [ value: Circle (8) ]])
    REMOVED ITEM: Circle (4) (3)
    REMOVED ITEM: Circle (5) (3)
    REMOVED ITEM: Circle (6) (3)

Is this a bug or am processing the results incorrectly? I'm currently using JDK 15.0.036 with OpenJFX 15

Rafael Ibasco
  • 1,342
  • 3
  • 14
  • 19
  • your expectation is correct, afaics - you might consider reporting a bug (yet another or maybe it's already known .. could be related to https://github.com/openjdk/jfx/pull/353) – kleopatra Nov 23 '20 at 07:43
  • would you happen to know how I could create an account in bugs.openjdk.java.net? I cannot seem to find any info about it on their page. – Rafael Ibasco Nov 24 '20 at 09:10
  • hmm .. don't think that you need an account, it's the same as for every java bug: https://bugreport.java.com/bugreport/ – kleopatra Nov 24 '20 at 10:54

0 Answers0