diff options
author | Giovanni Lovato <heruan@aldu.net> | 2017-03-10 11:55:55 +0100 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2017-03-10 12:55:55 +0200 |
commit | a7eb9f7f704e8dfc098efe1e5115ccddb8367c45 (patch) | |
tree | b42ac08d553a9f1779c35b88b61506576f8a790f /server | |
parent | f4e437bbb439ef6e51ccda2fc1dbeb9268f43b8a (diff) | |
download | vaadin-framework-a7eb9f7f704e8dfc098efe1e5115ccddb8367c45.tar.gz vaadin-framework-a7eb9f7f704e8dfc098efe1e5115ccddb8367c45.zip |
Add the bean to grid editor events
Fixes #8658
Diffstat (limited to 'server')
3 files changed, 32 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelEvent.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelEvent.java index b2af155977..a698687900 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelEvent.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelEvent.java @@ -33,14 +33,19 @@ import com.vaadin.ui.Grid; */ public class EditorCancelEvent<T> extends EventObject { + private T bean; + /** * Constructor for a editor cancel event. * * @param editor * the source of the event + * @param bean + * the bean being edited */ - public EditorCancelEvent(Editor<T> editor) { + public EditorCancelEvent(Editor<T> editor, T bean) { super(editor); + this.bean = bean; } @SuppressWarnings("unchecked") @@ -57,4 +62,13 @@ public class EditorCancelEvent<T> extends EventObject { public Grid<T> getGrid() { return getSource().getGrid(); } + + /** + * Gets the bean being edited. + * + * @return the bean being edited + */ + public T getBean() { + return bean; + } } diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java index b771696aa2..dad45f0fbb 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java @@ -246,7 +246,7 @@ public class EditorImpl<T> extends AbstractGridExtension<T> binder.validate(); if (binder.writeBeanIfValid(edited)) { refresh(edited); - eventRouter.fireEvent(new EditorSaveEvent<>(this)); + eventRouter.fireEvent(new EditorSaveEvent<>(this, edited)); return true; } } @@ -267,7 +267,7 @@ public class EditorImpl<T> extends AbstractGridExtension<T> private void doCancel(boolean afterBeingSaved) { doClose(); if (!afterBeingSaved) { - eventRouter.fireEvent(new EditorCancelEvent<>(this)); + eventRouter.fireEvent(new EditorCancelEvent<>(this, edited)); } } diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveEvent.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveEvent.java index e3d29f38a2..44a58a900f 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveEvent.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveEvent.java @@ -33,14 +33,19 @@ import com.vaadin.ui.Grid; */ public class EditorSaveEvent<T> extends EventObject { + private T bean; + /** * Constructor for a editor save event. * * @param editor * the source of the event + * @param bean + * the bean being edited */ - public EditorSaveEvent(Editor<T> editor) { + public EditorSaveEvent(Editor<T> editor, T bean) { super(editor); + this.bean = bean; } @SuppressWarnings("unchecked") @@ -57,4 +62,13 @@ public class EditorSaveEvent<T> extends EventObject { public Grid<T> getGrid() { return getSource().getGrid(); } + + /** + * Gets the bean being edited. + * + * @return the bean being edited + */ + public T getBean() { + return bean; + } } |