Merge branch 'develop' into remoting-4.0
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / FieldUnitGeneralDetailElement.java
index 622e8b7f954eb16a433dcc6d3a72d3fc9d3edd5f..b26451ff9268ef6d64e29a66bd3fdf02a9cc1dd6 100644 (file)
@@ -9,6 +9,8 @@
  */
 package eu.etaxonomy.taxeditor.ui.section.occurrence;
 
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.common.LanguageString;
@@ -18,9 +20,11 @@ import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
 import eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
 import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.element.PointElement;
@@ -40,6 +44,7 @@ public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<Deri
     private ToggleableTextElement toggleableText_titleCache;
     private EnumComboElement<SpecimenOrObservationType> combo_specorobstype;
     private EntitySelectionElement<NamedArea> selection_country;
+    private CollectingAreasDetailSection section_collectingAreas;
     private LanguageStringWithLabelElement languageText_locality;
     private PointElement element_point;
     private NumberWithLabelElement number_elevation;
@@ -47,6 +52,7 @@ public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<Deri
     private EntitySelectionElement<AgentBase> selection_collector;
     private TextWithLabelElement text_collectingNumber;
     private GatheringEventUnitElement element_elevation;
+    private CheckboxElement checkIsPublish;
 
     /**
      * @param formFactory
@@ -68,12 +74,16 @@ public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<Deri
         toggleableText_titleCache = formFactory.createToggleableTextField(formElement, "Title Cache",
                 entity.getTitleCache(), entity.isProtectedTitleCache(), style);
 
-        if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS)){
-            combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
-            combo_specorobstype.setSelection(entity.getType());
-        }
+        combo_specorobstype = formFactory.createEnumComboElement(SpecimenOrObservationType.class, formElement, style);
+        combo_specorobstype.setSelection(entity.getType());
         selection_country = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(), formElement,
                 "Country", entity.getCountry(), EntitySelectionElement.NOTHING, style);
+        if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION)){
+            section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
+            section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+            section_collectingAreas.setEntity(entity);
+        }
+
         languageText_locality = formFactory.createLanguageStringWithLabelElement(formElement, "Locality",
                 entity.getLocality(), style);
         element_point = formFactory.createPointElement(formElement, entity.getExactLocation(), style);
@@ -85,6 +95,7 @@ public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<Deri
                 "Collector", entity.getCollector(), EntitySelectionElement.ALL, style);
         text_collectingNumber = formFactory.createTextWithLabelElement(formElement, "Collecting number",
                 entity.getFieldNumber(), style);
+        checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.isPublish(), style);
     }
 
     /*
@@ -101,7 +112,7 @@ public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<Deri
         } else if (eventSource == selection_country) {
             getEntity().setCountry(selection_country.getSelection());
         } else if (eventSource == languageText_locality) {
-            LanguageString locality = languageText_locality.getLanguageString();
+            LanguageString locality = languageText_locality.updateLanguageString(getEntity().getLocality());
             getEntity().setLocality(locality);
         } else if (eventSource == element_point) {
             getEntity().setExactLocation(element_point.getPoint());
@@ -115,6 +126,8 @@ public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<Deri
             getEntity().setFieldNumber(text_collectingNumber.getText());
         } else if (eventSource == combo_specorobstype) {
             getEntity().setType(combo_specorobstype.getSelection());
+        } else if (eventSource == checkIsPublish) {
+            getEntity().innerFieldUnit().setPublish(checkIsPublish.getSelection());
         }
 
         if (eventSource != toggleableText_titleCache) {