merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / DerivedUnitFacadeDetailElement.java
index dc63ae2e416cf095d3bd20a96cd1194a0a30cd6c..03daf4a9d884ac15cb0ace21d0b01f7fb47c08a8 100644 (file)
@@ -1,25 +1,24 @@
 // $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.
 */
 
 package eu.etaxonomy.taxeditor.ui.section.occurrence;
 
-import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
 import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
@@ -32,10 +31,10 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
  * @version 1.0
  */
 public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<DerivedUnit> {
-       
+
        private DerivedUnitFacade facade;
 
-       private DerivedUnitFacadeConfigurator configurator;
+       private final DerivedUnitFacadeConfigurator configurator;
 
        private GeneralDetailSection section_general;
        private GatheringEventDetailSection section_gatheringEvent;
@@ -55,24 +54,24 @@ public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<Der
                configurator.setMoveDerivedUnitMediaToGallery(true);
                configurator.setMoveFieldObjectMediaToGallery(true);
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void setEntity(DerivedUnit entity) {
                super.setEntity(entity);
                try {
                        facade = DerivedUnitFacade.NewInstance(entity, configurator);
-                       
+
                        section_general.setEntity(facade);
                        section_derivedUnitBase.setEntity(facade);
                        section_gatheringEvent.setEntity(facade);
                        section_fieldObservation.setEntity(facade);
-                       
+
                } catch (DerivedUnitFacadeNotSupportedException e) {
-                       StoreUtil.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e);
+                       AbstractUtility.errorDialog("Error", this, "SpecimenFacadeNotSupportedException while inititating SpecimenFacade", e);
                }
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void removeElements() {
@@ -98,13 +97,13 @@ public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<Der
                        section_fieldObservation = null;
                }
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public DerivedUnit getEntity() {
                throw new IllegalArgumentException("Should not be called");
        }
-       
+
        /**
         * <p>Getter for the field <code>facade</code>.</p>
         *
@@ -113,28 +112,28 @@ public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<Der
        public DerivedUnitFacade getFacade(){
                return facade;
        }
-       
+
        /** {@inheritDoc} */
        @Override
        protected void createControls(ICdmFormElement formElement,
                        DerivedUnit entity, int style) {
-               
-               section_general = (GeneralDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT_GENERAL, getConversationHolder(), formElement, null, Section.TWISTIE | Section.EXPANDED);
+
+               section_general = formFactory.createGeneralDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
                section_general.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
                addControl(section_general);
                addElement(section_general);
-               
-               section_gatheringEvent = (GatheringEventDetailSection) formFactory.createCdmDetailSection(DetailType.GATHERING_EVENT, getConversationHolder(), formElement, null, Section.TWISTIE);
+
+               section_gatheringEvent = formFactory.createGatheringEventDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
                section_gatheringEvent.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
                addControl(section_gatheringEvent);
                addElement(section_gatheringEvent);
-               
-               section_fieldObservation = (FieldObservationDetailSection) formFactory.createCdmDetailSection(DetailType.FIELD_OBSERVATION, getConversationHolder(), formElement, null, Section.TWISTIE);
+
+               section_fieldObservation = formFactory.createFieldObservationDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
                section_fieldObservation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
                addControl(section_fieldObservation);
                addElement(section_fieldObservation);
-               
-               section_derivedUnitBase = (DerivedUnitBaseDetailSection) formFactory.createCdmDetailSection(DetailType.DERIVED_UNIT, getConversationHolder(), formElement, null, Section.TWISTIE);
+
+               section_derivedUnitBase = formFactory.createDerivedUnitBaseDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
                section_derivedUnitBase.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
                addControl(section_derivedUnitBase);
                addElement(section_derivedUnitBase);
@@ -144,8 +143,9 @@ public class DerivedUnitFacadeDetailElement extends AbstractCdmDetailElement<Der
        @Override
        public void handleEvent(Object eventSource) {
                if(eventSource == section_derivedUnitBase || eventSource == section_gatheringEvent || eventSource == section_fieldObservation){
-                       if(getParentElement() instanceof AbstractCdmDetailSection)
-                               ((AbstractCdmDetailSection) getParentElement()).updateTitle();
+                       if(getParentElement() instanceof AbstractCdmDetailSection) {
+                ((AbstractCdmDetailSection) getParentElement()).updateTitle();
+            }
                }
        }
 }