commit 333b3e6296bc2a04b663a3d9ce803cd0562253b6
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Thu Jan 18 17:20:03 2018 +0100

    fix #7205 using ToManyRelatedEntitiesListSelect create edit button in TaxonNamePopupEditor
     - includes commit relared to ref #7204

diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/CachingPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/CachingPresenter.java
index a5a46a84..a41dcdb5 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/CachingPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/CachingPresenter.java
@@ -19,4 +19,6 @@ public interface CachingPresenter {
 
     public EntityCache getCache();
 
+    public boolean isCacheInitialized();
+
 }
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
index 8f9f25f9..2e73037f 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
@@ -288,13 +288,24 @@ public class SpecimenTypeDesignationWorkingsetEditorPresenter
      */
     @Override
     public EntityCache getCache() {
-        if(((AbstractPopupEditor)getView()).isBeanLoaded()){
-            return cache;
-        } else {
-            return null;
-        }
+        return cache;
+//        if(((AbstractPopupEditor)getView()).isBeanLoaded()){
+//        } else {
+//            return null;
+//        }
     }
 
+    /**
+     * Returns true only after the view method {@link AbstractPopupEditor#loadInEditor()}
+     * has completed.
+     *
+     */
+    @Override
+    public boolean isCacheInitialized() {
+        return ((AbstractPopupEditor)getView()).isBeanLoaded();
+    }
+
+
     public void doCollectionEditorAdd() {
 
         collectionPopupEditor = getNavigationManager().showInPopup(CollectionPopupEditor.class);
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
index 3e0f2abb..b2fc9a88 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
@@ -10,6 +10,7 @@ package eu.etaxonomy.cdm.vaadin.view.name;
 
 import java.util.Arrays;
 import java.util.EnumSet;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -17,11 +18,16 @@ import org.apache.log4j.Logger;
 import org.hibernate.criterion.Restrictions;
 import org.springframework.context.event.EventListener;
 
+import com.vaadin.ui.AbstractField;
+
 import eu.etaxonomy.cdm.api.service.INameService;
+import eu.etaxonomy.cdm.cache.CdmEntityCache;
+import eu.etaxonomy.cdm.debug.PersistentContextAnalyzer;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.name.NameRelationship;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
@@ -32,6 +38,7 @@ import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
 import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
 import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
+import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
 import eu.etaxonomy.cdm.vaadin.security.UserHelper;
 import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
@@ -48,11 +55,18 @@ import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason;
  */
 public class TaxonNameEditorPresenter extends AbstractCdmEditorPresenter<TaxonName, TaxonNamePopupEditorView> {
 
+    /**
+     *
+     */
+    private static final List<String> BASIONYM_INIT_STRATEGY = Arrays.asList("$", "relationsFromThisName", "homotypicalGroup.typifiedNames");
+
     private static final long serialVersionUID = -3538980627079389221L;
 
     private static final Logger logger = Logger.getLogger(TaxonNameEditorPresenter.class);
 
-    ReferencePopupEditor newReferencePopup = null;
+    private ReferencePopupEditor referenceEditorPopup = null;
+
+    private TaxonNamePopupEditor basionymNamePopup = null;
 
     private CdmFilterablePagingProvider<Reference, Reference> referencePagingProvider;
 
@@ -60,6 +74,10 @@ public class TaxonNameEditorPresenter extends AbstractCdmEditorPresenter<TaxonNa
 
     private BeanInstantiator<Reference> newReferenceInstantiator;
 
+    private BeanInstantiator<TaxonName> newBasionymNameInstantiator;
+
+    private AbstractField<TaxonName> basionymSourceField;
+
     /**
      * {@inheritDoc}
      */
@@ -92,10 +110,11 @@ public class TaxonNameEditorPresenter extends AbstractCdmEditorPresenter<TaxonNa
         getView().getNomReferenceCombobox().loadFrom(referencePagingProvider, referencePagingProvider, referencePagingProvider.getPageSize());
         getView().getNomReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getNomReferenceCombobox()));
 
-        getView().getBasionymCombobox().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
-        CdmFilterablePagingProvider<TaxonName, TaxonName> namePagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(getRepo().getNameService());
+        getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
 
-        getView().getBasionymCombobox().setPagingProviders(namePagingProvider, namePagingProvider, namePagingProvider.getPageSize());
+        CdmFilterablePagingProvider<TaxonName, TaxonName> basionymPagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(getRepo().getNameService());
+        basionymPagingProvider.setInitStrategy(BASIONYM_INIT_STRATEGY);
+        getView().getBasionymComboboxSelect().setPagingProviders(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize(), this);
     }
 
     /**
@@ -200,29 +219,65 @@ public class TaxonNameEditorPresenter extends AbstractCdmEditorPresenter<TaxonNa
     protected TaxonName handleTransientProperties(TaxonName bean) {
 
         logger.trace(this._toString() + ".onEditorSaveEvent - handling transient properties");
-        List<TaxonName> newBasionymNames = getView().getBasionymCombobox().getValueFromNestedFields();
+
+
+        List<TaxonName> newBasionymNames = getView().getBasionymComboboxSelect().getValueFromNestedFields();
         Set<TaxonName> oldBasionyms = bean.getBasionyms();
-        boolean updateBasionyms = false;
+        Set<TaxonName> updateBasionyms = new HashSet<>();
+        Set<TaxonName> removeBasionyms = new HashSet<>();
 
         for(TaxonName newB : newBasionymNames){
-            updateBasionyms = updateBasionyms || !oldBasionyms.contains(newB);
+            if(!oldBasionyms.contains(newB)){
+                updateBasionyms.add(newB);
+            }
         }
 
         for(TaxonName oldB : oldBasionyms){
-            updateBasionyms = updateBasionyms || !newBasionymNames.contains(oldB);
+            if(!newBasionymNames.contains(oldB)){
+                removeBasionyms.add(oldB);
+            }
         }
-
-        if(updateBasionyms){
-            bean.removeBasionyms();
-            for(TaxonName basionymName :newBasionymNames){
-                if(basionymName != null){
-                    if(basionymName .getUuid() != null){
-                        // reload
-                        basionymName = getRepo().getNameService().load(basionymName.getUuid(), Arrays.asList("$", "relationsFromThisName", "homotypicalGroup.typifiedNames"));
-                    }
-                    bean.addBasionym(basionymName);
+        for(TaxonName removeBasionym :removeBasionyms){
+            Set<NameRelationship> removeRelations = new HashSet<NameRelationship>();
+            for (NameRelationship nameRelation : bean.getRelationsToThisName()){
+                if (nameRelation.getType().isBasionymRelation() && nameRelation.getFromName().equals(removeBasionym)){
+                    removeRelations.add(nameRelation);
                 }
             }
+            for (NameRelationship relation : removeRelations){
+                bean.removeNameRelationship(relation);
+            }
+        }
+        // updateBasionyms.clear(); // DEBUGGING #########################
+        getRepo().getSession().clear();
+        for(TaxonName addBasionymName :updateBasionyms){
+            // if(addBasionymName != null){
+                // if(addBasionymName.getUuid() != null){
+                    // reload
+
+                    System.err.println("====== Cache ======");
+                    addBasionymName = getRepo().getNameService().load(addBasionymName.getUuid(), BASIONYM_INIT_STRATEGY);
+                    PersistentContextAnalyzer pca = new PersistentContextAnalyzer((CdmEntityCache)getCache(), getRepo().getSession());
+                    pca.setShowHashCodes(true);
+                    pca.printEntityGraph(System.err);
+                    pca.printCopyEntities(System.err);
+
+                    System.err.println("====== Basionym ======");
+                    PersistentContextAnalyzer basiopca = new PersistentContextAnalyzer(addBasionymName, getRepo().getSession());
+                    basiopca.setShowHashCodes(true);
+                    basiopca.printEntityGraph(System.err);
+
+                    TaxonName cachedName = getCache().find(addBasionymName);
+                    if(cachedName != null){
+                        System.err.println("====== Cached Basionym ======");
+                        PersistentContextAnalyzer cahedbasiopca = new PersistentContextAnalyzer(addBasionymName, getRepo().getSession());
+                        cahedbasiopca.setShowHashCodes(true);
+                        cahedbasiopca.printEntityGraph(System.err);
+                        addBasionymName = cachedName;
+                    }
+                // }
+                bean.addBasionym(addBasionymName);
+            //}
         }
         return bean;
     }
@@ -235,63 +290,112 @@ public class TaxonNameEditorPresenter extends AbstractCdmEditorPresenter<TaxonNa
         return getRepo().getNameService();
     }
 
-    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
+    @EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
     public void onReferenceEditorActionAdd(ReferenceEditorAction event) {
 
         if(getView() == null || event.getSourceView() != getView() ){
             return;
         }
-        newReferencePopup = getNavigationManager().showInPopup(ReferencePopupEditor.class);
+        referenceEditorPopup = getNavigationManager().showInPopup(ReferencePopupEditor.class);
 
-        newReferencePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
-        newReferencePopup.withDeleteButton(true);
-        newReferencePopup.setBeanInstantiator(newReferenceInstantiator);
-        newReferencePopup.loadInEditor(null);
+        referenceEditorPopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
+        referenceEditorPopup.withDeleteButton(true);
+        referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
+        referenceEditorPopup.loadInEditor(null);
         if(newReferenceInstantiator != null){
             // this is a bit clumsy, we actually need to inject something like a view configurer
             // which can enable, disable fields
-            newReferencePopup.getInReferenceCombobox().setEnabled(false);
-            newReferencePopup.getTypeSelect().setEnabled(false);
+            referenceEditorPopup.getInReferenceCombobox().setEnabled(false);
+            referenceEditorPopup.getTypeSelect().setEnabled(false);
         }
     }
 
-    @EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT")
+    @EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
     public void onReferenceEditorActionEdit(ReferenceEditorAction event) {
 
         if(getView() == null || event.getSourceView() != getView() ){
             return;
         }
-        newReferencePopup = getNavigationManager().showInPopup(ReferencePopupEditor.class);
+        referenceEditorPopup = getNavigationManager().showInPopup(ReferencePopupEditor.class);
 
-        newReferencePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
-        newReferencePopup.withDeleteButton(true);
-        newReferencePopup.setBeanInstantiator(newReferenceInstantiator);
-        newReferencePopup.loadInEditor(event.getEntityId());
+        referenceEditorPopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
+        referenceEditorPopup.withDeleteButton(true);
+        referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
+        referenceEditorPopup.loadInEditor(event.getEntityId());
         if(newReferenceInstantiator != null){
             // this is a bit clumsy, we actually need to inject something like a view configurer
             // which can enable, disable fields
-            newReferencePopup.getInReferenceCombobox().setEnabled(false);
-            newReferencePopup.getTypeSelect().setEnabled(false);
+            referenceEditorPopup.getInReferenceCombobox().setEnabled(false);
+            referenceEditorPopup.getTypeSelect().setEnabled(false);
         }
     }
 
     @EventListener
     public void onDoneWithPopupEvent(DoneWithPopupEvent event){
-        if(event.getPopup() == newReferencePopup){
+
+        if(event.getPopup() == referenceEditorPopup){
             if(event.getReason() == Reason.SAVE){
 
-                Reference newReference = newReferencePopup.getBean();
+                Reference modifiedReference = referenceEditorPopup.getBean();
+
+                // TODO the bean contained in the popup editor is not yet updated at this point.
+                //      so re reload it using the uuid since new beans will not have an Id at this point.
+                modifiedReference = getRepo().getReferenceService().load(modifiedReference.getUuid(), Arrays.asList("inReference"));
+                getView().getNomReferenceCombobox().setValue(modifiedReference);
+            }
+
+            referenceEditorPopup = null;
+        }
+        if(event.getPopup() == basionymNamePopup){
+            if(event.getReason() == Reason.SAVE){
+                TaxonName modifiedTaxonName = basionymNamePopup.getBean();
 
                 // TODO the bean contained in the popup editor is not yet updated at this point.
                 //      so re reload it using the uuid since new beans will not have an Id at this point.
-                newReference = getRepo().getReferenceService().load(newReference.getUuid(), Arrays.asList("inReference"));
-                getView().getNomReferenceCombobox().setValue(newReference);
+                modifiedTaxonName = getRepo().getNameService().load(modifiedTaxonName.getUuid()); //, BASIONYM_INIT_STRATEGY);
+                basionymSourceField.setValue(modifiedTaxonName);
+
+                // TODO create blocking registration
             }
+            if(event.getReason() == Reason.DELETE){
+                basionymSourceField.setValue(null);
+            }
+
+            basionymNamePopup = null;
+            basionymSourceField = null;
+        }
+    }
+
+    @EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
+    public void onTaxonNameEditorActionEdit(TaxonNameEditorAction event) {
 
-            newReferencePopup = null;
+        if(getView() == null || event.getSourceView() != getView() ){
+            return;
         }
+        basionymSourceField = (AbstractField<TaxonName>)event.getSourceComponent();
+
+        basionymNamePopup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class);
+        basionymNamePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
+        basionymNamePopup.withDeleteButton(true);
+        basionymNamePopup.loadInEditor(event.getEntityId());
+        basionymNamePopup.getBasionymToggle().setVisible(false);
+
     }
 
+    @EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
+    public void onReferenceEditorActionAdd(TaxonNameEditorAction event) {
+
+        if(getView() == null || event.getSourceView() != getView() ){
+            return;
+        }
+        basionymSourceField = (AbstractField<TaxonName>)event.getSourceComponent();
+
+        basionymNamePopup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class);
+        basionymNamePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
+        basionymNamePopup.withDeleteButton(true);
+        basionymNamePopup.loadInEditor(null);
+        basionymNamePopup.getBasionymToggle().setVisible(false);
+    }
 
 
 }
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
index 911f131c..7e30de09 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
@@ -25,14 +25,15 @@ import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
-import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
+import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
 import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView;
 import eu.etaxonomy.cdm.vaadin.security.UserHelper;
 import eu.etaxonomy.cdm.vaadin.util.converter.SetToListConverter;
 import eu.etaxonomy.vaadin.component.SwitchableTextField;
 import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect;
 import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
+import eu.etaxonomy.vaadin.event.EditorActionType;
 import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor;
 import eu.etaxonomy.vaadin.permission.EditPermissionTester;
 
@@ -71,7 +72,7 @@ public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonName, Taxo
 
     private TeamOrPersonField basionymAuthorshipField;
 
-    private ToManyRelatedEntitiesComboboxSelect<TaxonName> basionymCombobox;
+    private ToManyRelatedEntitiesComboboxSelect<TaxonName> basionymsComboboxSelect;
 
     private CheckBox basionymToggle;
 
@@ -240,13 +241,13 @@ public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonName, Taxo
         row++;
         nomReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("Nomenclatural reference", Reference.class);
         nomReferenceCombobox.addClickListenerAddEntity(e -> getEventBus().publishEvent(
-                new ReferenceEditorAction(AbstractEditorAction.Action.ADD, null, nomReferenceCombobox, this)
+                new ReferenceEditorAction(EditorActionType.ADD, null, nomReferenceCombobox, this)
                 ));
         nomReferenceCombobox.addClickListenerEditEntity(e -> {
             if(nomReferenceCombobox.getValue() != null){
                 getEventBus().publishEvent(
                     new ReferenceEditorAction(
-                            AbstractEditorAction.Action.EDIT,
+                            EditorActionType.EDIT,
                             nomReferenceCombobox.getValue().getId(),
                             nomReferenceCombobox,
                             this)
@@ -261,35 +262,29 @@ public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonName, Taxo
 
         // Basionym
         row++;
-        basionymCombobox = new ToManyRelatedEntitiesComboboxSelect<TaxonName>(TaxonName.class, "Basionym");
-        /**
-        basionymCombobox.newAdd(e -> getEventBus().publishEvent(
-                new TaxonNameEditorAction(AbstractEditorAction.Action.ADD, null, basionymCombobox, this)
-                ));
-        basionymCombobox.addClickListenerEditEntity(e -> {
-            if(basionymCombobox.getValue() != null){
-                getEventBus().publishEvent(
-                    new TaxonNameEditorAction(
-                            AbstractEditorAction.Action.EDIT,
-                            basionymCombobox.getValue().getId(),
-                            basionymCombobox,
-                            this)
-                );
-            }
-            });
-         **/
-        basionymCombobox.setConverter(new SetToListConverter<TaxonName>());
-        addField(basionymCombobox, "basionyms", 0, row, 3, row);
-        basionymCombobox.setWidth(100, Unit.PERCENTAGE);
-        basionymCombobox.withEditButton(true);
-        basionymCombobox.setEditPermissionTester(new EditPermissionTester() {
+        basionymsComboboxSelect = new ToManyRelatedEntitiesComboboxSelect<TaxonName>(TaxonName.class, "Basionym");
+        basionymsComboboxSelect.setConverter(new SetToListConverter<TaxonName>());
+        addField(basionymsComboboxSelect, "basionyms", 0, row, 3, row);
+        basionymsComboboxSelect.setWidth(100, Unit.PERCENTAGE);
+        basionymsComboboxSelect.withEditButton(true);
+        basionymsComboboxSelect.setEditPermissionTester(new EditPermissionTester() {
 
             @Override
             public boolean userHasEditPermission(Object bean) {
                 return  UserHelper.fromSession().userHasPermission((CdmBase)bean, CRUD.UPDATE, CRUD.DELETE);
             }
         });
-        grid.setComponentAlignment(basionymCombobox, Alignment.TOP_RIGHT);
+        basionymsComboboxSelect.setEditActionListener(e -> {
+
+            Object fieldValue = e.getSource().getValue();
+            Integer beanId = null;
+            if(fieldValue != null){
+                beanId = ((CdmBase)fieldValue).getId();
+
+            }
+            eventBus.publishEvent(new TaxonNameEditorAction(e.getAction(), beanId, e.getSource(), this));
+        });
+        grid.setComponentAlignment(basionymsComboboxSelect, Alignment.TOP_RIGHT);
         row++;
         basionymAuthorshipField = new TeamOrPersonField("Basionym author(s)");
         basionymAuthorshipField.setWidth(100,  Unit.PERCENTAGE);
@@ -319,7 +314,7 @@ public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonName, Taxo
     private void enableBasionymFields(boolean enable) {
         basionymAuthorshipField.setVisible(enable);
         exBasionymAuthorshipField.setVisible(enable);
-        basionymCombobox.setVisible(enable);
+        basionymsComboboxSelect.setVisible(enable);
         if(modesActive.contains(TaxonNamePopupEditorMode.suppressReplacementAuthorshipData)){
             TaxonName taxonName = getBean();
             basionymAuthorshipField.setVisible(taxonName.getBasionymAuthorship() != null);
@@ -381,8 +376,8 @@ public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonName, Taxo
      * {@inheritDoc}
      */
     @Override
-    public ToManyRelatedEntitiesComboboxSelect<TaxonName> getBasionymCombobox() {
-        return basionymCombobox;
+    public ToManyRelatedEntitiesComboboxSelect<TaxonName> getBasionymComboboxSelect() {
+        return basionymsComboboxSelect;
     }
 
     /**
@@ -440,5 +435,10 @@ public class TaxonNamePopupEditor extends AbstractCdmPopupEditor<TaxonName, Taxo
         modesActive.remove(mode);
     }
 
+    @Override
+    public CheckBox getBasionymToggle() {
+        return basionymToggle;
+    }
+
 
 }
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditorView.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditorView.java
index 5ef1300b..63dec7ea 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditorView.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditorView.java
@@ -8,6 +8,7 @@
 */
 package eu.etaxonomy.cdm.vaadin.view.name;
 
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.ListSelect;
 
 import eu.etaxonomy.cdm.model.name.TaxonName;
@@ -32,7 +33,7 @@ public interface TaxonNamePopupEditorView extends ApplicationView<TaxonNameEdito
     /**
      * @return
      */
-    public ToManyRelatedEntitiesComboboxSelect<TaxonName> getBasionymCombobox();
+    public ToManyRelatedEntitiesComboboxSelect<TaxonName> getBasionymComboboxSelect();
 
     public ListSelect getRankSelect();
 
@@ -71,4 +72,9 @@ public interface TaxonNamePopupEditorView extends ApplicationView<TaxonNameEdito
      */
     boolean isModeEnabled(TaxonNamePopupEditorMode mode);
 
+    /**
+     * @return
+     */
+    CheckBox getBasionymToggle();
+
 }
diff --git a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
index 075d02d8..1364b65d 100644
--- a/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
+++ b/src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
@@ -542,6 +542,11 @@ public abstract class AbstractPopupEditor<DTO extends Object, P extends Abstract
         isBeanLoaded = true;
     }
 
+    /**
+     * Passes the beanInstantiator to the presenter method {@link AbstractEditorPresenter#setBeanInstantiator(BeanInstantiator)}
+     *
+     * @param beanInstantiator
+     */
     public final void setBeanInstantiator(BeanInstantiator<DTO> beanInstantiator) {
         getPresenter().setBeanInstantiator(beanInstantiator);
     }
