commit 87bbccd430886b5a2b9c744e0dc018e7d6235920
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Fri Jul 6 08:27:47 2018 +0200

    fix #7535 TeamOrPersonField and PersonField without OK button

diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/PersonField.java b/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/PersonField.java
index ccc32abe..7eed19ea 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/PersonField.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/PersonField.java
@@ -54,7 +54,6 @@ public class PersonField extends CompositeCustomField<Person> {
 
     private LazyComboBox<Person> personSelect = new LazyComboBox<Person>(Person.class);
 
-    private Button personSelectConfirmButton = new Button("OK");
     private Button newPersonButton = new Button("New");
 
     private BeanFieldGroup<Person> fieldGroup = new BeanFieldGroup<>(Person.class);
@@ -85,9 +84,6 @@ public class PersonField extends CompositeCustomField<Person> {
     private TextField suffixField = new TextFieldNFix();
     private SwitchButton unlockSwitch = new SwitchButton();
 
-    private boolean onCommit = false;
-
-
 
     /**
      * @param caption
@@ -106,18 +102,15 @@ public class PersonField extends CompositeCustomField<Person> {
         root.setPrimaryStyleName(PRIMARY_STYLE);
 
         // select existing or create new person
-        addStyledComponents(personSelect, personSelectConfirmButton, newPersonButton);
+        addStyledComponents(personSelect, newPersonButton);
         personSelect.addValueChangeListener(e -> {
             if(personSelect.getValue() != null){
-                personSelectConfirmButton.setEnabled(true);
+                setValue(personSelect.getValue());
+                personSelect.clear();
             }
         });
-        personSelectConfirmButton.setEnabled(false);
-        personSelectConfirmButton.addClickListener(e -> {
-            setValue(personSelect.getValue());
-            personSelect.clear();
-        });
-        selectOrNewContainer.addComponents(personSelect, personSelectConfirmButton, newPersonButton);
+
+        selectOrNewContainer.addComponents(personSelect, newPersonButton);
         newPersonButton.addClickListener(e -> createNewPerson());
 
         // edit person
@@ -391,10 +384,6 @@ public class PersonField extends CompositeCustomField<Person> {
         if(bean == null){
             return null;
         }
-       // boolean isUnsaved = bean.getId() == 0;
-//        if(isUnsaved && hasNullContent() && !allowNewEmptyEntity) {
-//            return null;
-//        }
         return bean;
     }
 
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java b/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java
index ea154c55..51761688 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java
@@ -62,7 +62,6 @@ public class TeamOrPersonField extends CompositeCustomField<TeamOrPersonBase<?>>
 
     private ReloadableLazyComboBox<TeamOrPersonBase> teamOrPersonSelect = new ReloadableLazyComboBox<TeamOrPersonBase>(TeamOrPersonBase.class);
 
-    private Button selectConfirmButton = new Button("OK");
     private Button removeButton = new Button(FontAwesome.REMOVE);
     private Button personButton = new Button(FontAwesome.USER);
     private Button teamButton = new Button(FontAwesome.USERS);
@@ -96,7 +95,7 @@ public class TeamOrPersonField extends CompositeCustomField<TeamOrPersonBase<?>>
         addStyledComponent(titleField);
         addStyledComponent(nomenclaturalTitleField);
         addStyledComponent(personsListEditor);
-        addStyledComponents(selectConfirmButton, removeButton, personButton, teamButton);
+        addStyledComponents(removeButton, personButton, teamButton);
 
 
         addSizedComponent(root);
@@ -118,40 +117,29 @@ public class TeamOrPersonField extends CompositeCustomField<TeamOrPersonBase<?>>
     protected Component initContent() {
 
         teamOrPersonSelect.addValueChangeListener(e -> {
-            selectConfirmButton.setEnabled(teamOrPersonSelect.getValue() != null);
-            selectConfirmButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
-        });
-        teamOrPersonSelect.setWidthUndefined();
-
-        selectConfirmButton.setEnabled(teamOrPersonSelect.getValue() != null);
-        selectConfirmButton.addClickListener(e -> {
-            // new entitiy being set, reset the readonly state
-//            resetReadOnlyComponents();
-//            getPropertyDataSource().setReadOnly(false);
             setValue(teamOrPersonSelect.getValue(), false, true);
-            teamOrPersonSelect.clear();
             updateToolBarButtonStates();
         });
+        teamOrPersonSelect.setWidthUndefined();
+
         removeButton.addClickListener(e -> {
-//            resetReadOnlyComponents();
-//            getPropertyDataSource().setReadOnly(false);
             setValue(null, false, true);
             updateToolBarButtonStates();
         });
         removeButton.setDescription("Remove");
 
         personButton.addClickListener(e -> {
-            setValue(Person.NewInstance(), false, true); // FIXME add SelectField or open select dialog, use ToOneSelect field!!
+            setValue(Person.NewInstance(), false, true);
 
         });
         personButton.setDescription("Add person");
         teamButton.addClickListener(e -> {
-            setValue(Team.NewInstance(), false, true); // FIXME add SelectField or open select dialog, use ToOneSelect field!!
+            setValue(Team.NewInstance(), false, true);
         });
         teamButton.setDescription("Add team");
 
         toolBar.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP + " toolbar");
-        toolBar.addComponents(teamOrPersonSelect, selectConfirmButton,  removeButton, personButton, teamButton);
+        toolBar.addComponents(teamOrPersonSelect,  removeButton, personButton, teamButton);
 
         compositeWrapper.setStyleName("margin-wrapper");
         compositeWrapper.addComponent(toolBar);
@@ -174,7 +162,9 @@ public class TeamOrPersonField extends CompositeCustomField<TeamOrPersonBase<?>>
         boolean userCanCreate = UserHelper.fromSession().userHasPermission(Person.class, "CREATE");
 
         teamOrPersonSelect.setVisible(val == null);
-        selectConfirmButton.setVisible(val == null);
+        if(teamOrPersonSelect.getValue() != val){
+            teamOrPersonSelect.clear();
+        }
         removeButton.setVisible(val != null);
         personButton.setEnabled(userCanCreate && val == null);
         teamButton.setEnabled(userCanCreate && val == null);
@@ -256,11 +246,6 @@ public class TeamOrPersonField extends CompositeCustomField<TeamOrPersonBase<?>>
         }
     }
 
-//    private void checkUserPermissions(TeamOrPersonBase<?> newValue) {
-//        boolean userCanEdit = UserHelper.fromSession().userHasPermission(newValue, "DELETE", "UPDATE");
-//        setEnabled(userCanEdit);
-//        personsListEditor.setEnabled(userCanEdit);
-//    }
 
     /**
      * {@inheritDoc}
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
index afcb2a34..0c51f55c 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
@@ -303,10 +303,12 @@ public class ListPresenter extends AbstractPresenter<ListView> {
      */
     private void setSelectValue(AbstractSelect select, Set<?> itemsToChoose) {
 
-        for(Object item : select.getContainerDataSource().getItemIds()){
-            if(item != null){
-                if(itemsToChoose.contains(item)){
-                    select.select(item);
+        if(itemsToChoose != null){
+            for(Object item : select.getContainerDataSource().getItemIds()){
+                if(item != null){
+                    if(itemsToChoose.contains(item)){
+                        select.select(item);
+                    }
                 }
             }
         }
