-
Bug
-
Resolution: Unresolved
-
P4
-
jfx16
doc of Event.copyFor:
"Creates and returns a copy of this event with the specified event source and target."
formulated as test (can be run in EventAnyTest):
@Test
public void testCopyFor() {
Object sourceForCopy = new Object();
Event copiedEvent = event.copyFor(sourceForCopy, event.getTarget());
assertEquals("copied " + event.getClass().getName() + " must have copied source\n",
sourceForCopy, copiedEvent.getSource());
}
- fails for TreeItem.TreeModificationEvent, all EditEvents (TreeTable, Tree, List)
- passes for CheckBoxTreeItem.TreeModificationEvent, ScrollToEvent, SortEvent, Tree/TableColumn.CellEditEvent
Culprit is a shadowing field source which is returned in the overridden getSource, f.i for ListView.EditEvent:
final ListView<T> source;
public EditEvent(ListView<T> source, ..)
super(source, ..)
this.source = source;
...
}
@Override public ListView<T> getSource() {
return source;
}
fix would be to remove the new field and the override. This will break client code relying on the incorrect source being a ListView always - but such code would be plain wrong anyway.
"Creates and returns a copy of this event with the specified event source and target."
formulated as test (can be run in EventAnyTest):
@Test
public void testCopyFor() {
Object sourceForCopy = new Object();
Event copiedEvent = event.copyFor(sourceForCopy, event.getTarget());
assertEquals("copied " + event.getClass().getName() + " must have copied source\n",
sourceForCopy, copiedEvent.getSource());
}
- fails for TreeItem.TreeModificationEvent, all EditEvents (TreeTable, Tree, List)
- passes for CheckBoxTreeItem.TreeModificationEvent, ScrollToEvent, SortEvent, Tree/TableColumn.CellEditEvent
Culprit is a shadowing field source which is returned in the overridden getSource, f.i for ListView.EditEvent:
final ListView<T> source;
public EditEvent(ListView<T> source, ..)
super(source, ..)
this.source = source;
...
}
@Override public ListView<T> getSource() {
return source;
}
fix would be to remove the new field and the override. This will break client code relying on the incorrect source being a ListView always - but such code would be plain wrong anyway.
- relates to
-
JDK-8147822 ClassCastException when pressing F2 or Enter on editable TreeTableView
- Resolved