RFR: 8188026: TextFieldXXCell: NPE on calling startEdit [v4]

Jeanette Winzenburg fastegal at openjdk.java.net
Sun Sep 26 12:07:58 UTC 2021


On Sun, 19 Sep 2021 11:24:43 GMT, Marius Hanl <mhanl at openjdk.org> wrote:

>> modules/javafx.controls/src/main/java/javafx/scene/control/cell/ChoiceBoxTreeCell.java line 301:
>> 
>>> 299:             return;
>>> 300:         }
>>> 301: 
>> 
>> (darn, can't add the important lines - which is backing out if treeItem is null)
>> 
>> The re-ordering leads to change of behavior, here's a test that's passing/failing before/after:
>> 
>>     /**
>>      * change of behavior: cell must not be editing if treeItem == null.
>>      * fails with fix, passes without
>>      */
>>     @Test
>>     public void testChoiceBoxTreeCellEditing() {
>>         TreeView<String> treeView = new TreeView<>();
>>         treeView.setEditable(true);
>>         ChoiceBoxTreeCell<String> cell = new ChoiceBoxTreeCell<>();
>>         cell.updateTreeView(treeView);
>>         cell.updateItem("TEST", false);
>>         
>>         cell.startEdit();
>>         assertFalse(cell.isEditing());
>>         assertNull(cell.getGraphic());
>>     }
>>     
>> same for ComboBoxTreeCell
>
> Hm.. weird that the super class is firing an edit event even with `treeItem = null`. Maybe this should be investigated in a follow-up. Good catch though. :)

yeah, there are whacky aspects:

- we can switch a cell that's not attached to its surroundings (like table, column, treeItem, off-range) into editing state - the only constraint being that it's not empty
- the other way round: a cell that didn't switch into editing will nevertheless fire a editStart on its target

Definitely leeway for improvements ;)

-------------

PR: https://git.openjdk.java.net/jfx/pull/569


More information about the openjfx-dev mailing list