A DESCRIPTION OF THE PROBLEM :
base.reorder(x, y) changes content of a filteredList fl build on tabPane.getTabs()
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Tab lib1 = new Tab("lib1");
Tab lib2 = new Tab("lib2");
Tab other = new Tab("other");
TabPane tabPane = new TabPane(lib1, other, lib2);
TabObservableList<Tab> base = (TabObservableList) tabPane.getTabs();
FilteredList<Tab> filtered = new FilteredList<>(base, tab -> tab.getText().startsWith("lib"));
base.reorder(lib1, other);
// following outputs "true", but should be "false"
System.out.println(other == filtered.getFirst());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
filtered is list of lib1, lib2
ACTUAL -
filtered is list of other, lib2
---------- BEGIN SOURCE ----------
package org.jabref.gui.javafx;
import java.util.List;
import javafx.collections.transformation.FilteredList;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import com.sun.javafx.scene.control.TabObservableList;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testfx.framework.junit5.ApplicationExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@ExtendWith(ApplicationExtension.class)
public class TabObservableListFilteredTest {
@Test
public void filteredListDetectsPermutation() {
Tab lib1 = new Tab("lib1");
Tab lib2 = new Tab("lib2");
Tab other = new Tab("other");
TabPane tabPane = new TabPane(lib1, other, lib2);
TabObservableList<Tab> base = (TabObservableList) tabPane.getTabs();
FilteredList<Tab> filtered = new FilteredList<>(base, tab -> tab.getText().startsWith("lib"));
assertEquals(List.of(lib1, lib2), filtered);
base.reorder(lib1, other);
assertNotEquals(other, filtered.getFirst()); // This should not fail
assertEquals(List.of(lib2, lib1), filtered);
}
}
---------- END SOURCE ----------
base.reorder(x, y) changes content of a filteredList fl build on tabPane.getTabs()
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Tab lib1 = new Tab("lib1");
Tab lib2 = new Tab("lib2");
Tab other = new Tab("other");
TabPane tabPane = new TabPane(lib1, other, lib2);
TabObservableList<Tab> base = (TabObservableList) tabPane.getTabs();
FilteredList<Tab> filtered = new FilteredList<>(base, tab -> tab.getText().startsWith("lib"));
base.reorder(lib1, other);
// following outputs "true", but should be "false"
System.out.println(other == filtered.getFirst());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
filtered is list of lib1, lib2
ACTUAL -
filtered is list of other, lib2
---------- BEGIN SOURCE ----------
package org.jabref.gui.javafx;
import java.util.List;
import javafx.collections.transformation.FilteredList;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import com.sun.javafx.scene.control.TabObservableList;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testfx.framework.junit5.ApplicationExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@ExtendWith(ApplicationExtension.class)
public class TabObservableListFilteredTest {
@Test
public void filteredListDetectsPermutation() {
Tab lib1 = new Tab("lib1");
Tab lib2 = new Tab("lib2");
Tab other = new Tab("other");
TabPane tabPane = new TabPane(lib1, other, lib2);
TabObservableList<Tab> base = (TabObservableList) tabPane.getTabs();
FilteredList<Tab> filtered = new FilteredList<>(base, tab -> tab.getText().startsWith("lib"));
assertEquals(List.of(lib1, lib2), filtered);
base.reorder(lib1, other);
assertNotEquals(other, filtered.getFirst()); // This should not fail
assertEquals(List.of(lib2, lib1), filtered);
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8359025 FilteredList fails to update correctly during permutation operations
-
- Closed
-