Skip to content

Commit 64aa926

Browse files
Maran23Jeanette Winzenburg
authored andcommitted
8188026: TextFieldXXCell: NPE on calling startEdit
8268295: Tree- and TableCell sub implementations should respect the row editability Reviewed-by: fastegal, aghaisas
1 parent f3c72b9 commit 64aa926

28 files changed

+677
-309
lines changed

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ChoiceBoxListCell.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ public ObservableList<T> getItems() {
288288

289289
/** {@inheritDoc} */
290290
@Override public void startEdit() {
291-
if (! isEditable() || ! getListView().isEditable()) {
291+
super.startEdit();
292+
if (!isEditing()) {
292293
return;
293294
}
294295

@@ -298,12 +299,8 @@ public ObservableList<T> getItems() {
298299

299300
choiceBox.getSelectionModel().select(getItem());
300301

301-
super.startEdit();
302-
303-
if (isEditing()) {
304-
setText(null);
305-
setGraphic(choiceBox);
306-
}
302+
setText(null);
303+
setGraphic(choiceBox);
307304
}
308305

309306
/** {@inheritDoc} */

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ChoiceBoxTableCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ public ObservableList<T> getItems() {
303303

304304
/** {@inheritDoc} */
305305
@Override public void startEdit() {
306-
if (! isEditable() || ! getTableView().isEditable() || ! getTableColumn().isEditable()) {
306+
super.startEdit();
307+
if (!isEditing()) {
307308
return;
308309
}
309310

@@ -313,7 +314,6 @@ public ObservableList<T> getItems() {
313314

314315
choiceBox.getSelectionModel().select(getItem());
315316

316-
super.startEdit();
317317
setText(null);
318318
setGraphic(choiceBox);
319319
}

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ChoiceBoxTreeCell.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,13 @@ public ObservableList<T> getItems() {
294294

295295
/** {@inheritDoc} */
296296
@Override public void startEdit() {
297-
if (! isEditable() || ! getTreeView().isEditable()) {
297+
TreeItem<T> treeItem = getTreeItem();
298+
if (treeItem == null) {
298299
return;
299300
}
300301

301-
TreeItem<T> treeItem = getTreeItem();
302-
if (treeItem == null) {
302+
super.startEdit();
303+
if (!isEditing()) {
303304
return;
304305
}
305306

@@ -312,18 +313,14 @@ public ObservableList<T> getItems() {
312313

313314
choiceBox.getSelectionModel().select(treeItem.getValue());
314315

315-
super.startEdit();
316-
317-
if (isEditing()) {
318-
setText(null);
316+
setText(null);
319317

320-
Node graphic = getTreeItemGraphic();
321-
if (graphic != null) {
322-
hbox.getChildren().setAll(graphic, choiceBox);
323-
setGraphic(hbox);
324-
} else {
325-
setGraphic(choiceBox);
326-
}
318+
Node graphic = getTreeItemGraphic();
319+
if (graphic != null) {
320+
hbox.getChildren().setAll(graphic, choiceBox);
321+
setGraphic(hbox);
322+
} else {
323+
setGraphic(choiceBox);
327324
}
328325
}
329326

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ChoiceBoxTreeTableCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ public ObservableList<T> getItems() {
303303

304304
/** {@inheritDoc} */
305305
@Override public void startEdit() {
306-
if (! isEditable() || ! getTreeTableView().isEditable() || ! getTableColumn().isEditable()) {
306+
super.startEdit();
307+
if (!isEditing()) {
307308
return;
308309
}
309310

@@ -313,7 +314,6 @@ public ObservableList<T> getItems() {
313314

314315
choiceBox.getSelectionModel().select(getItem());
315316

316-
super.startEdit();
317317
setText(null);
318318
setGraphic(choiceBox);
319319
}

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ComboBoxListCell.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ public ObservableList<T> getItems() {
319319

320320
/** {@inheritDoc} */
321321
@Override public void startEdit() {
322-
if (! isEditable() || ! getListView().isEditable()) {
322+
super.startEdit();
323+
if (!isEditing()) {
323324
return;
324325
}
325326

@@ -330,12 +331,8 @@ public ObservableList<T> getItems() {
330331

331332
comboBox.getSelectionModel().select(getItem());
332333

333-
super.startEdit();
334-
335-
if (isEditing()) {
336-
setText(null);
337-
setGraphic(comboBox);
338-
}
334+
setText(null);
335+
setGraphic(comboBox);
339336
}
340337

341338
/** {@inheritDoc} */

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ComboBoxTableCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ public ObservableList<T> getItems() {
339339

340340
/** {@inheritDoc} */
341341
@Override public void startEdit() {
342-
if (! isEditable() || ! getTableView().isEditable() || ! getTableColumn().isEditable()) {
342+
super.startEdit();
343+
if (!isEditing()) {
343344
return;
344345
}
345346

@@ -350,7 +351,6 @@ public ObservableList<T> getItems() {
350351

351352
comboBox.getSelectionModel().select(getItem());
352353

353-
super.startEdit();
354354
setText(null);
355355
setGraphic(comboBox);
356356
}

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ComboBoxTreeCell.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,13 @@ public ObservableList<T> getItems() {
325325

326326
/** {@inheritDoc} */
327327
@Override public void startEdit() {
328-
if (! isEditable() || ! getTreeView().isEditable()) {
328+
TreeItem<T> treeItem = getTreeItem();
329+
if (treeItem == null) {
329330
return;
330331
}
331332

332-
TreeItem<T> treeItem = getTreeItem();
333-
if (treeItem == null) {
333+
super.startEdit();
334+
if (!isEditing()) {
334335
return;
335336
}
336337

@@ -344,18 +345,14 @@ public ObservableList<T> getItems() {
344345

345346
comboBox.getSelectionModel().select(treeItem.getValue());
346347

347-
super.startEdit();
348-
349-
if (isEditing()) {
350-
setText(null);
348+
setText(null);
351349

352-
Node graphic = CellUtils.getGraphic(treeItem);
353-
if (graphic != null) {
354-
hbox.getChildren().setAll(graphic, comboBox);
355-
setGraphic(hbox);
356-
} else {
357-
setGraphic(comboBox);
358-
}
350+
Node graphic = CellUtils.getGraphic(treeItem);
351+
if (graphic != null) {
352+
hbox.getChildren().setAll(graphic, comboBox);
353+
setGraphic(hbox);
354+
} else {
355+
setGraphic(comboBox);
359356
}
360357
}
361358

modules/javafx.controls/src/main/java/javafx/scene/control/cell/ComboBoxTreeTableCell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ public ObservableList<T> getItems() {
339339

340340
/** {@inheritDoc} */
341341
@Override public void startEdit() {
342-
if (! isEditable() || ! getTreeTableView().isEditable() || ! getTableColumn().isEditable()) {
342+
super.startEdit();
343+
if (!isEditing()) {
343344
return;
344345
}
345346

@@ -350,7 +351,6 @@ public ObservableList<T> getItems() {
350351

351352
comboBox.getSelectionModel().select(getItem());
352353

353-
super.startEdit();
354354
setText(null);
355355
setGraphic(comboBox);
356356
}

modules/javafx.controls/src/main/java/javafx/scene/control/cell/TextFieldListCell.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,16 @@ public final StringConverter<T> getConverter() {
179179

180180
/** {@inheritDoc} */
181181
@Override public void startEdit() {
182-
if (! isEditable() || ! getListView().isEditable()) {
182+
super.startEdit();
183+
if (!isEditing()) {
183184
return;
184185
}
185-
super.startEdit();
186186

187-
if (isEditing()) {
188-
if (textField == null) {
189-
textField = CellUtils.createTextField(this, getConverter());
190-
}
191-
192-
CellUtils.startEdit(this, getConverter(), null, null, textField);
187+
if (textField == null) {
188+
textField = CellUtils.createTextField(this, getConverter());
193189
}
190+
191+
CellUtils.startEdit(this, getConverter(), null, null, textField);
194192
}
195193

196194
/** {@inheritDoc} */

modules/javafx.controls/src/main/java/javafx/scene/control/cell/TextFieldTableCell.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,16 @@ public final StringConverter<T> getConverter() {
183183

184184
/** {@inheritDoc} */
185185
@Override public void startEdit() {
186-
if (! isEditable()
187-
|| ! getTableView().isEditable()
188-
|| ! getTableColumn().isEditable()) {
186+
super.startEdit();
187+
if (!isEditing()) {
189188
return;
190189
}
191-
super.startEdit();
192190

193-
if (isEditing()) {
194-
if (textField == null) {
195-
textField = CellUtils.createTextField(this, getConverter());
196-
}
197-
198-
CellUtils.startEdit(this, getConverter(), null, null, textField);
191+
if (textField == null) {
192+
textField = CellUtils.createTextField(this, getConverter());
199193
}
194+
195+
CellUtils.startEdit(this, getConverter(), null, null, textField);
200196
}
201197

202198
/** {@inheritDoc} */

0 commit comments

Comments
 (0)