diff options
author | Tatu Lund <tatu@vaadin.com> | 2020-01-14 15:36:15 +0200 |
---|---|---|
committer | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2020-01-14 15:36:15 +0200 |
commit | a799444d832a82c3ad1467a6a60735aab015c87f (patch) | |
tree | 03c7c71e1b957e32d346844452c1295dca935794 /server/src/main | |
parent | cfb26c45de6fb7ba66ca4be83beeda556b6036fa (diff) | |
download | vaadin-framework-a799444d832a82c3ad1467a6a60735aab015c87f.tar.gz vaadin-framework-a799444d832a82c3ad1467a6a60735aab015c87f.zip |
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
Diffstat (limited to 'server/src/main')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 12 |
1 files changed, 9 insertions, 3 deletions
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<T> extends AbstractListing<T> 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<T, V> setEditable(boolean editable) { - Objects.requireNonNull(editorBinding, - "Column has no editor binding or component defined"); + public Column<T, V> 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; } |