merged trunk into branch
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / DescribedSpecimenSection.java
index 3b5005065e355e9f927bfd947e2ecfa0d48a9a34..112927630fc5e6e808c8213d8d084e77407460e3 100644 (file)
 
 package eu.etaxonomy.taxeditor.ui.section.description;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-import eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.DerivedUnitSelectionDialog;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.DerivedUnitSelectionDialog;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
 
 /**
@@ -34,9 +35,9 @@ public class DescribedSpecimenSection extends AbstractEntityCollectionSection<Ta
        /**
         * <p>Constructor for DescribedSpecimenSection.</p>
         *
-        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
+        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
         * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
+        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
         * @param style a int.
         */
        public DescribedSpecimenSection(CdmFormFactory formFactory,
@@ -49,26 +50,32 @@ public class DescribedSpecimenSection extends AbstractEntityCollectionSection<Ta
        @Override
        public Collection<SpecimenOrObservationBase> getCollection(
                        TaxonDescription entity) {
-               return entity.getDescribedSpecimenOrObservations();
+               //FIXME:This class is not really an entity collection section, and should be moved 
+               // to a single entity section, but one with the possibility of launching a wizard
+               List<SpecimenOrObservationBase> collection = new ArrayList<SpecimenOrObservationBase>();
+               if(entity.getDescribedSpecimenOrObservation() != null) {
+                       collection.add(entity.getDescribedSpecimenOrObservation());     
+               }               
+               return collection;
        }
 
        /** {@inheritDoc} */
        @Override
        public SpecimenOrObservationBase createNewElement() {
-               DerivedUnitBase selection = DerivedUnitSelectionDialog.select(getShell(), getConversationHolder(), null);
+               DerivedUnit selection = DerivedUnitSelectionDialog.select(getShell(), getConversationHolder(), null);           
                return selection;
        }
 
        /** {@inheritDoc} */
        @Override
        public void addElement(SpecimenOrObservationBase element) {
-               getEntity().addDescribedSpecimenOrObservation(element);
+               getEntity().setDescribedSpecimenOrObservation(element);
        }
 
        /** {@inheritDoc} */
        @Override
        public void removeElement(SpecimenOrObservationBase element) {
-               getEntity().removeDescribedSpecimenOrObservation(element);
+               getEntity().setDescribedSpecimenOrObservation(null);            
        }
 
        /** {@inheritDoc} */