- added creation of FieldUnits via wizard to bulk editor
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 27 Aug 2013 17:07:27 +0000 (17:07 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 27 Aug 2013 17:07:27 +0000 (17:07 +0000)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/DynamicNewObjectMenu.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/campanula/detailViews/specimen/SpecimenGeneralElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java

index cf09eda13ffeb7456c33c8083f8a648d47317747..bc9116b1effd63741e4a27e19f5af75ab9e0632d 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.
 */
@@ -26,7 +26,6 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.CompoundContributionItem;
 import org.eclipse.ui.handlers.IHandlerService;
 
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
@@ -42,7 +41,7 @@ import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
 public class DynamicNewObjectMenu extends CompoundContributionItem {
        private static final Logger logger = Logger
                        .getLogger(DynamicNewObjectMenu.class);
-       
+
        private IHandlerService handlerService = (IHandlerService) BulkEditorUtil.getService(IHandlerService.class);
        private Map<Object, String> classLabelPairs;
        /* (non-Javadoc)
@@ -51,15 +50,16 @@ public class DynamicNewObjectMenu extends CompoundContributionItem {
        /** {@inheritDoc} */
        @Override
        protected IContributionItem[] getContributionItems() {
-               
+
                classLabelPairs = getClassLabelPairs();
-               
+
                return new IContributionItem[] {
                                new ContributionItem() {
-                                       public void fill(Menu menu, int index){
+                                       @Override
+                    public void fill(Menu menu, int index){
                                                for(final Object key : classLabelPairs.keySet()){
                                                        createMenuItem(menu, key);
-                                               }                       
+                                               }
                                        }
                                }
                };
@@ -70,9 +70,11 @@ public class DynamicNewObjectMenu extends CompoundContributionItem {
                menuItem.setText(classLabelPairs.get(key));
                menuItem.addSelectionListener(new SelectionListener(){
 
-                       public void widgetDefaultSelected(SelectionEvent e) {}
+                       @Override
+            public void widgetDefaultSelected(SelectionEvent e) {}
 
-                       public void widgetSelected(SelectionEvent ev) {
+                       @Override
+            public void widgetSelected(SelectionEvent ev) {
                                Event event = new Event();
                                event.data = key;
                                event.text = classLabelPairs.get(key);
@@ -82,15 +84,10 @@ public class DynamicNewObjectMenu extends CompoundContributionItem {
                                        logger.error("Error executing command", e);
                                        throw new RuntimeException("Error executing command", e);
                                }
-                       }                               
+                       }
                });
-               
-               //FIXME:3.3MC Need corresponding Details Viewer section for FieldUnit
-               if(key == SpecimenOrObservationType.FieldUnit){
-                       menuItem.setEnabled(false);
-               }
        }
-       
+
        /**
         * Get class label pairs from Annotated Line Editor's entity creator.
         * @return
@@ -99,13 +96,13 @@ public class DynamicNewObjectMenu extends CompoundContributionItem {
                IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
                if (editor != null){
                        IEditorInput input = editor.getEditorInput();
-                       
+
                        if(input instanceof AbstractBulkEditorInput){
                                IEntityCreator<?> entityCreator = ((AbstractBulkEditorInput) input).getEntityCreator();
                                return entityCreator.getKeyLabelPairs();
                        }
                }
-               
+
                return null;
-       }       
+       }
 }
index 1dfb04352f9db4f0620678649fee8b049bf35998..59ba07120c4b2e8e0ab5a7217207a90700e006a2 100644 (file)
@@ -14,7 +14,9 @@ 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;
@@ -30,7 +32,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() {
@@ -47,16 +49,21 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUni
         DerivedUnitFacade derivedUnitFacade = null;
         try {
             if (getEntity() != null) {
-                derivedUnitFacade = DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
+                if(getEntity() instanceof FieldUnit){
+                    derivedUnitFacade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit)getEntity());
+                    addPage(new GeneralWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+                    addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+                    addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+                }
+                else if(getEntity() instanceof DerivedUnit){
+                    derivedUnitFacade = DerivedUnitFacade.NewInstance((DerivedUnit)getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
+                    addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+                }
             }
         } catch (DerivedUnitFacadeNotSupportedException e) {
             // we should never get here
             throw new IllegalStateException();
         }
-        addPage(new GeneralWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
-        addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
-        addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
-        addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
 
     }
 
@@ -65,7 +72,7 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUni
         */
        /** {@inheritDoc} */
        @Override
-       protected DerivedUnit createNewEntity() {
+       protected SpecimenOrObservationBase<?> createNewEntity() {
                if(specOrObsType == null) {
                        return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
                } else {
@@ -73,6 +80,8 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUni
                                        ((specOrObsType.getKindOf() != null) &&
                                        specOrObsType.getKindOf().equals(SpecimenOrObservationType.Media))) {
                                return MediaSpecimen.NewInstance(SpecimenOrObservationType.Media);
+                       } else if(specOrObsType == SpecimenOrObservationType.FieldUnit){
+                           return FieldUnit.NewInstance();
                        } else {
                                return DerivedUnit.NewInstance(specOrObsType);
                        }
index eec44ca76be8c0b3c6c76a5b4f7d2a78d82cda85..09a2fdb6922604cd5730344313425385174f3f61 100644 (file)
@@ -60,7 +60,6 @@ public class SpecimenGeneralElement extends Composite{
      */
     public SpecimenGeneralElement(Composite parent, int style) {
         super(parent, style);
-        setEnabled(false);
         setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
         {
             TableWrapLayout tableWrapLayout = new TableWrapLayout();
@@ -159,10 +158,6 @@ public class SpecimenGeneralElement extends Composite{
 
         collectorSelectionField = new EntitySelectionField(this, SWT.NONE);
         collectorSelectionField.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
-        collectorSelectionField.getButton_selection().setEnabled(false);
-        collectorSelectionField.getButton_edit().setEnabled(false);
-        collectorSelectionField.getButton_remove().setEnabled(false);
-        collectorSelectionField.getText().setEnabled(false);
         formToolkit.adapt(collectorSelectionField);
         formToolkit.paintBordersFor(collectorSelectionField);
 
@@ -176,16 +171,27 @@ public class SpecimenGeneralElement extends Composite{
         textCollectingNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
 
         lblCollection = formToolkit.createLabel(this, "Collection", SWT.NONE);
+        lblCollection.setEnabled(true);
 
         collectionSelectionField = new EntitySelectionField(this, SWT.NONE);
+        collectionSelectionField.getButton_remove().setEnabled(true);
+        collectionSelectionField.getButton_edit().setEnabled(true);
+        collectionSelectionField.getButton_selection().setEnabled(true);
+        collectionSelectionField.getText().setEnabled(true);
+        collectionSelectionField.setEnabled(true);
         formToolkit.adapt(collectionSelectionField);
         formToolkit.paintBordersFor(collectionSelectionField);
 
         lblAccessionNumber = formToolkit.createLabel(this, "Accession Number", SWT.NONE);
+        lblAccessionNumber.setEnabled(true);
 
         textAccessionNumber = formToolkit.createText(this, "New Text", SWT.NONE);
+        textAccessionNumber.setEnabled(true);
         textAccessionNumber.setText("");
         textAccessionNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
+        Label label = new Label(this, SWT.NONE);
+        label.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));
+        new Label(this, SWT.NONE);
 
     }
 
index 01d0d78e5f1d8669ec3ebf74f956e0170bbafc7a..7ae4a971478add9941a7c47de09fe156a55ce08c 100644 (file)
@@ -39,6 +39,7 @@ import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
@@ -142,6 +143,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                 AbstractUtility.error(getClass(), e);
             }
         }
+               else if(input instanceof FieldUnit){
+                   input = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit) input,PreferencesUtil.getDerivedUnitConfigurator());
+               }
         super.setInput(input);
     }
 
@@ -227,11 +231,13 @@ public class DetailsViewer extends AbstractCdmDataViewer {
             createMediaElementSection(rootElement);
 
         } else if (input instanceof DerivedUnitFacade) {
-            createSpecimenDetailsView(rootElement);
-
-        } else if (input instanceof FieldUnit) {
-            createDerivedUnitBaseElementSection(rootElement);
+            DerivedUnitFacade derivedUnitFacade = (DerivedUnitFacade)input;
 
+            if(derivedUnitFacade.getType()==SpecimenOrObservationType.FieldUnit){
+                createDerivedUnitBaseElementSection(rootElement);
+            } else if(derivedUnitFacade.getType()==SpecimenOrObservationType.DerivedUnit){
+                createSpecimenDetailsView(rootElement);
+            }
         } else if (input instanceof FeatureNodeContainer) {
             createFeatureDistributionSection(rootElement);