- adding of empty persons to teams via DetailsView is not possible anymore (#4913)
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 26 May 2015 06:41:36 +0000 (06:41 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 26 May 2015 06:41:36 +0000 (06:41 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamMemberElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamMemberSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/dna/AbstractUnboundEntityCollectionSection.java

index 103870d0e2bd364a6f444b2ded17adb72c6b8550..ac7bb0494f5d18a91339a5e193e30b65aa6040db 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * European Distributed Institute of Taxonomy
  * http://www.e-taxonomy.eu
- * 
+ *
  * The contents of this file are subject to the Mozilla Public License Version 1.1
  * See LICENSE.TXT at the top of this package for the full license terms.
  */
@@ -13,7 +13,6 @@ package eu.etaxonomy.taxeditor.ui.section.agent;
 import org.eclipse.swt.events.SelectionListener;
 
 import eu.etaxonomy.cdm.model.agent.Person;
-import eu.etaxonomy.cdm.model.agent.Team;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
@@ -25,7 +24,7 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
  * <p>
  * TeamMemberElement class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Apr 30, 2010
  * @version 1.0
@@ -38,7 +37,7 @@ public class TeamMemberElement extends AbstractEntityCollectionElement<Person> {
         * <p>
         * Constructor for TeamMemberElement.
         * </p>
-        * 
+        *
         * @param cdmFormFactory
         *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
         *            object.
@@ -60,7 +59,7 @@ public class TeamMemberElement extends AbstractEntityCollectionElement<Person> {
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#createControls
         * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
@@ -71,13 +70,13 @@ public class TeamMemberElement extends AbstractEntityCollectionElement<Person> {
                selection_person = formFactory
                                .createSelectionElement(Person.class,
                                                getConversationHolder(), this, "Person", null,
-                                               EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, 
+                                               EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE,
                                                style);
        }
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#setEntity
         * (eu.etaxonomy.cdm.model.common.VersionableEntity)
@@ -90,22 +89,15 @@ public class TeamMemberElement extends AbstractEntityCollectionElement<Person> {
        }
 
        /** {@inheritDoc} */
-       @Override
-       public void handleEvent(Object eventSource) {
-               if (eventSource == selection_person) {
-                       if (getParentElement() instanceof TeamMemberSection) {
-                               TeamMemberSection teamMemberSection = (TeamMemberSection) getParentElement();
-                               Team team = teamMemberSection.getEntity();
-
-                               int index = team.getTeamMembers().indexOf(getEntity());
-
-                               team.removeTeamMember(getEntity());
-                               team.addTeamMember(selection_person.getEntity(), index);
-                               firePropertyChangeEvent(new CdmPropertyChangeEvent(
-                                               teamMemberSection, eventSource));
-                       }
-                       entity = selection_person.getEntity();
-
-               }
-       }
+    @Override
+    public void handleEvent(Object eventSource) {
+        if (eventSource == selection_person) {
+            if (getParentElement() instanceof TeamMemberSection) {
+                TeamMemberSection teamMemberSection = (TeamMemberSection) getParentElement();
+                teamMemberSection.getEntity().addTeamMember(selection_person.getEntity());
+                firePropertyChangeEvent(new CdmPropertyChangeEvent(teamMemberSection, eventSource));
+            }
+            entity = selection_person.getEntity();
+        }
+    }
 }
index 30c64bdaa2bfc9657628f4d51cee3c43d0d264d8..b1acd195bbbc6bede58d77e4912b557a624491e3 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -17,7 +17,7 @@ import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.agent.Team;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection;
 
 /**
  * <p>TeamMemberSection class.</p>
@@ -26,7 +26,7 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
  * @created Apr 30, 2010
  * @version 1.0
  */
-public class TeamMemberSection extends AbstractEntityCollectionSection<Team, Person> {
+public class TeamMemberSection extends AbstractUnboundEntityCollectionSection<Team, Person> {
 
        /**
         * <p>Constructor for TeamMemberSection.</p>
@@ -39,7 +39,7 @@ public class TeamMemberSection extends AbstractEntityCollectionSection<Team, Per
        public TeamMemberSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
                super(cdmFormFactory, conversation, parentElement, null, style);
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public String getTitleString() {
@@ -58,12 +58,6 @@ public class TeamMemberSection extends AbstractEntityCollectionSection<Team, Per
                return Person.NewTitledInstance("");
        }
 
-       /** {@inheritDoc} */
-       @Override
-       public Collection<Person> getCollection(Team entity) {
-               return getEntity().getTeamMembers();
-       }
-
        /** {@inheritDoc} */
        @Override
        public String getEmptyString() {
@@ -81,6 +75,11 @@ public class TeamMemberSection extends AbstractEntityCollectionSection<Team, Per
        public void removeElement(Person element) {
                getEntity().removeTeamMember(element);
        }
-       
-       
+
+    @Override
+    protected Collection<Person> getEntityCollection(Team entity) {
+        return getEntity().getTeamMembers();
+    }
+
+
 }
index 7d12d654d17a57606a6be7af634668263e52a60b..99e0951c3d3fe292dac00e8d7baae5c7bfb26328 100644 (file)
@@ -28,12 +28,17 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
 
 /**
- * This class extends the functionality of {@link AbstractEntityCollectionSection}
- * by creating an {@link AbstractEntityCollectionElement} for an 
- * ELEMENT which is not directly added the the model ENTITY.<br>
+ * This class extends the functionality of
+ * {@link AbstractEntityCollectionSection} by creating an
+ * {@link AbstractEntityCollectionElement} for an ELEMENT which is not directly
+ * added the the model ENTITY.<br>
  * <br>
- * This is useful if the ELEMENT is created after the creation of the AbstractEntityCollectionElement itself 
- * and not in this class.
+ * This is useful if the ELEMENT is created after the creation of the
+ * AbstractEntityCollectionElement itself and not in this class and also if you
+ * do not want to create empty elements. <br>
+ * <br>
+ * <b>Note:</b> In sub classes: do <b>not</b> override {@link #getCollection(Object)}. Use
+ * {@link #getEntityCollection(Object)} instead
  *
  * @author pplitzner
  * @date 21.01.2014