- Fixed the creation of a single FieldUnit via context-menu in the bulk editor which...
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 27 Nov 2013 16:36:58 +0000 (16:36 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 27 Nov 2013 16:36:58 +0000 (16:36 +0000)
 - added wizard for FieldUnit creation

.gitattributes
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitGeneralWizardPage.java [new file with mode: 0644]

index 1a425bf33362a93c3e8fdfc29e6274a4f3c97229..e2b9f9652c1370f290ee75ed5b6cd20d3aed25a1 100644 (file)
@@ -1435,6 +1435,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occ
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitDetailSection.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitGeneralDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitGeneralDetailSection.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitGeneralWizardPage.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitWizardPage.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GatheringEventDetailElement.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GatheringEventDetailSection.java -text
index 0b4c9bf950612fc6756a278146d3c76198dcbf47..260beaf7b4b8f95707fa6d1d735561672e8d2340 100644 (file)
@@ -14,11 +14,14 @@ import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseWizardPage;
+import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitGeneralWizardPage;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldUnitWizardPage;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventWizardPage;
 import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage;
@@ -30,7 +33,7 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage;
  * @created Jun 16, 2010
  * @version 1.0
  */
-public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUnit> {
+public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<SpecimenOrObservationBase> {
        private SpecimenOrObservationType specOrObsType = null;
 
        public NewDerivedUnitBaseWizard() {
@@ -44,54 +47,47 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUni
        /** {@inheritDoc} */
        @Override
        public void addPages() {
-           DerivedUnitFacade facade = getFacade();
-           try {
-               if(getEntity() != null) {
-                   facade = DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
-               }
-           } catch (DerivedUnitFacadeNotSupportedException e) {
-               // w should never get here
-               throw new IllegalStateException();
-           }
-        addPage(new GeneralWizardPage(formFactory, getConversationHolder(), facade));
-               addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), facade));
-               addPage(new FieldUnitWizardPage(formFactory, getConversationHolder(), facade));
-               addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), facade));
-
+           DerivedUnitFacade facade = null;
+        try {
+            if(getEntity() instanceof DerivedUnit) {
+                facade = DerivedUnitFacade.NewInstance((DerivedUnit)getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
+                addPage(new GeneralWizardPage(formFactory, getConversationHolder(), facade));
+                addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), facade));
+                addPage(new FieldUnitWizardPage(formFactory, getConversationHolder(), facade));
+                addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), facade));
+            }
+            else if(getEntity() instanceof FieldUnit){
+                facade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit)getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
+                addPage(new FieldUnitGeneralWizardPage(formFactory, getConversationHolder(), facade));
+                addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), facade));
+                addPage(new FieldUnitWizardPage(formFactory, getConversationHolder(), facade));
+            }
+        } catch (DerivedUnitFacadeNotSupportedException e) {
+            // we should never get here
+            throw new IllegalStateException();
+        }
        }
 
-       /**
-        * @return
-        */
-       private DerivedUnitFacade getFacade() {
-               try {
-                       if(getEntity() != null) {
-                               return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
-                       }
-               } catch (DerivedUnitFacadeNotSupportedException e) {
-                       // w should never get here
-                       throw new IllegalStateException();
-               }
-               return null;
-       }
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
         */
        /** {@inheritDoc} */
        @Override
-       protected DerivedUnit createNewEntity() {
-               if(specOrObsType == null) {
-                       return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
-               } else {
-                       if(SpecimenOrObservationType.Media.equals(specOrObsType) ||
-                                       ((specOrObsType.getKindOf() != null) &&
-                                       specOrObsType.getKindOf().equals(SpecimenOrObservationType.Media))) {
-                               return MediaSpecimen.NewInstance(SpecimenOrObservationType.Media);
-                       } else {
-                               return DerivedUnit.NewInstance(specOrObsType);
-                       }
-               }
+       protected SpecimenOrObservationBase createNewEntity() {
+           if(specOrObsType == null) {
+               return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+           } else {
+               if(SpecimenOrObservationType.Media.equals(specOrObsType) ||
+                       ((specOrObsType.getKindOf() != null) &&
+                               specOrObsType.getKindOf().equals(SpecimenOrObservationType.Media))) {
+                   return MediaSpecimen.NewInstance(SpecimenOrObservationType.Media);
+               } else if (specOrObsType.equals(SpecimenOrObservationType.FieldUnit)) {
+                   return FieldUnit.NewInstance();
+               } else {
+                   return DerivedUnit.NewInstance(specOrObsType);
+               }
+           }
        }
 
        /* (non-Javadoc)
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitGeneralWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitGeneralWizardPage.java
new file mode 100644 (file)
index 0000000..780f94b
--- /dev/null
@@ -0,0 +1,54 @@
+// $Id$
+/**
+* Copyright (C) 2013 EDIT
+* 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.
+*/
+package eu.etaxonomy.taxeditor.ui.section.occurrence;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
+import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
+
+/**
+ *
+ */
+public class FieldUnitGeneralWizardPage extends AbstractCdmEntityWizardPage<DerivedUnitFacade> {
+
+    /**
+     * @param formFactory
+     * @param conversation
+     * @param entity
+     */
+    public FieldUnitGeneralWizardPage(CdmFormFactory formFactory,
+            ConversationHolder conversation, DerivedUnitFacade entity) {
+        super(formFactory, conversation, entity);
+        setTitle("General FieldUnit Data");
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.ui.forms.AbstractCdmEntityWizardPage#checkComplete()
+     */
+    @Override
+    protected void checkComplete() {
+        setPageComplete(true);
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.forms.AbstractCdmEntityWizardPage#createElement(eu.etaxonomy.taxeditor.forms.ICdmFormElement)
+     */
+    @Override
+    public AbstractCdmDetailElement<DerivedUnitFacade> createElement(ICdmFormElement rootElement) {
+        FieldUnitGeneralDetailElement detailElement = formFactory.createFieldUnitGeneralDetailElement(rootElement);
+        detailElement.setEntity(getEntity());
+        checkComplete();
+        return detailElement;
+    }
+
+}