commit 437f2e6ff4477d44c3c0c75043873aebd0055e06
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Tue May 16 18:01:01 2017 +0200

    #6562 restricting AbstractEditorPresenter to events coming from the related view

diff --git a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java
index c68c166b..eeee8a43 100644
--- a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java
@@ -34,6 +34,7 @@ public abstract class AbstractCdmEditorPresenter<DTO extends CdmBase> extends Ab
     @Override
     @EventListener
     public void onEditorPreSaveEvent(EditorPreSaveEvent preSaveEvent){
+        super.onEditorPreSaveEvent(preSaveEvent);
         tx = getRepo().startTransaction(true);
         // merge the bean and update the fieldGroup with the merged bean, so that updating
         // of field values in turn of the commit are can not cause LazyInitializationExeptions
@@ -45,6 +46,9 @@ public abstract class AbstractCdmEditorPresenter<DTO extends CdmBase> extends Ab
     @Override
     @EventListener
     public void onEditorSaveEvent(EditorSaveEvent saveEvent){
+        if(!saveEvent.getView().equals(getView())){
+            return;
+        }
         // the bean is now updated with the changes made by the user
         // merge the bean into the session, ...
         DTO bean = mergedBean(saveEvent.getCommitEvent());
@@ -78,6 +82,7 @@ public abstract class AbstractCdmEditorPresenter<DTO extends CdmBase> extends Ab
             // evict bean before merge to avoid duplicate beans in same session
             session.evict(bean);
         }
+
         @SuppressWarnings("unchecked")
         DTO mergedBean = (DTO) session.merge(bean);
         itemDataSource.setBean(mergedBean);
diff --git a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java
index 6e946126..64d5d443 100644
--- a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java
@@ -29,7 +29,9 @@ public abstract class AbstractEditorPresenter<DTO extends Object> extends Abstra
 
     @EventListener
     public void onEditorPreSaveEvent(EditorPreSaveEvent preSaveEvent){
-
+        if(!preSaveEvent.getView().equals(getView())){
+            return;
+        }
     }
 
     /**
@@ -38,6 +40,9 @@ public abstract class AbstractEditorPresenter<DTO extends Object> extends Abstra
      */
     @EventListener
     public void onEditorSaveEvent(EditorSaveEvent saveEvent){
+        if(!saveEvent.getView().equals(getView())){
+            return;
+        }
         DTO bean = ((BeanFieldGroup<DTO>)saveEvent.getCommitEvent().getFieldBinder()).getItemDataSource().getBean();
         saveBean(bean);
     }
diff --git a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
index d1c84d0e..36a9014e 100644
--- a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
+++ b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
@@ -145,14 +145,14 @@ public abstract class AbstractPopupEditor<DTO extends Object, P extends Abstract
         public void preCommit(CommitEvent commitEvent) throws CommitException {
             logger.debug("preCommit");
             // notify the presenter to start a transaction
-            eventBus.publishEvent(new EditorPreSaveEvent(commitEvent));
+            eventBus.publishEvent(new EditorPreSaveEvent(commitEvent, AbstractPopupEditor.this));
         }
 
         @Override
         public void postCommit(CommitEvent commitEvent) throws CommitException {
             try {
                 // notify the presenter to persist the bean and to commit the transaction
-                eventBus.publishEvent(new EditorSaveEvent(commitEvent));
+                eventBus.publishEvent(new EditorSaveEvent(commitEvent, AbstractPopupEditor.this));
 
                 // notify the NavigationManagerBean to close the window and to dispose the view
                 eventBus.publishEvent(new DoneWithPopupEvent(AbstractPopupEditor.this, Reason.SAVE));
diff --git a/src/main/java/eu/etaxonomy/vaadin/mvp/EditorPreSaveEvent.java b/src/main/java/eu/etaxonomy/vaadin/mvp/EditorPreSaveEvent.java
index 26fc2e7a..c2396bcf 100644
--- a/src/main/java/eu/etaxonomy/vaadin/mvp/EditorPreSaveEvent.java
+++ b/src/main/java/eu/etaxonomy/vaadin/mvp/EditorPreSaveEvent.java
@@ -22,15 +22,26 @@ public class EditorPreSaveEvent {
 
     private CommitEvent commitEvent;
 
+    // FIXME this is only a iterim solution for the problem described in https://dev.e-taxonomy.eu/redmine/issues/6562
+    private AbstractView view;
+
     /**
      * @param commitEvent
      */
-    public EditorPreSaveEvent(CommitEvent commitEvent) {
+    public EditorPreSaveEvent(CommitEvent commitEvent, AbstractView view) {
         this.commitEvent = commitEvent;
+        this.view = view;
     }
 
     public CommitEvent getCommitEvent(){
         return commitEvent;
     }
 
+    /**
+     * @return the view
+     */
+    public AbstractView getView() {
+        return view;
+    }
+
 }
diff --git a/src/main/java/eu/etaxonomy/vaadin/mvp/EditorSaveEvent.java b/src/main/java/eu/etaxonomy/vaadin/mvp/EditorSaveEvent.java
index 0d2b9c1b..b3c359b3 100644
--- a/src/main/java/eu/etaxonomy/vaadin/mvp/EditorSaveEvent.java
+++ b/src/main/java/eu/etaxonomy/vaadin/mvp/EditorSaveEvent.java
@@ -22,15 +22,27 @@ public class EditorSaveEvent {
 
     private CommitEvent commitEvent;
 
+    // FIXME this is only a iterim solution for the problem described in https://dev.e-taxonomy.eu/redmine/issues/6562
+    private AbstractView view;
+
+
     /**
      * @param commitEvent
      */
-    public EditorSaveEvent(CommitEvent commitEvent) {
+    public EditorSaveEvent(CommitEvent commitEvent, AbstractView view) {
         this.commitEvent = commitEvent;
+        this.view = view;
     }
 
     public CommitEvent getCommitEvent(){
         return commitEvent;
     }
 
+    /**
+     * @return the view
+     */
+    public AbstractView getView() {
+        return view;
+    }
+
 }
