From a799444d832a82c3ad1467a6a60735aab015c87f Mon Sep 17 00:00:00 2001 From: Tatu Lund Date: Tue, 14 Jan 2020 15:36:15 +0200 Subject: Making setEditable friendlier (#11869) * Making setEditable friendlier The current behavior is not buggy, so this PR is an enhancement Fixes https://github.com/vaadin/framework/issues/8718 * Improved JavaDoc --- server/src/main/java/com/vaadin/ui/Grid.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'server/src') diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 1ac71ff984..bba799690d 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -1948,13 +1948,19 @@ public class Grid extends AbstractListing implements HasComponents, * @param editable * {@code true} if column is editable; {@code false} if not * @return this column + * @throws IllegalStateException + * if editable is true and column has no editor binding or + * component defined * * @see #setEditorComponent(HasValue, Setter) * @see #setEditorBinding(Binding) */ - public Column setEditable(boolean editable) { - Objects.requireNonNull(editorBinding, - "Column has no editor binding or component defined"); + public Column setEditable(boolean editable) + throws IllegalStateException { + if (editable && editorBinding == null) { + throw new IllegalStateException( + "Column has no editor binding or component defined"); + } getState().editable = editable; return this; } -- cgit v1.2.3