// $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.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
+import eu.etaxonomy.taxeditor.ui.element.GatheringEventUnitElement;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
-import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.element.MinMaxTextSection;
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
* <p>
* GatheringEventDetailElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Jun 24, 2010
* @version 1.0
public class GatheringEventDetailElement extends
AbstractCdmDetailElement<DerivedUnitFacade> {
- private NumberWithLabelElement number_absoluteElevationError;
+ private GatheringEventUnitElement element_elevation;
- private NumberWithLabelElement number_absoluteElevationMinimum;
+ private GatheringEventUnitElement element_distToGround;
- private NumberWithLabelElement number_absoluteElevationMaximum;
+ private GatheringEventUnitElement element_distToWater;
private TextWithLabelElement text_collectingMethod;
- private NumberWithLabelElement number_distanceToGround;
-
- private NumberWithLabelElement number_distanceToWaterSurface;
-
private TextWithLabelElement text_gatheringEventDescription;
private CollectingAreasDetailSection section_collectingAreas;
* <p>
* Constructor for GatheringEventDetailElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
/** {@inheritDoc} */
@Override
- protected void createControls(ICdmFormElement formElement,
- DerivedUnitFacade entity, int style) {
- // collectingArea
- number_absoluteElevationError = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Elevation Error", entity.getAbsoluteElevationError(),
- style);
- number_absoluteElevationMinimum = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Elevation Minimum (m)",
- entity.getAbsoluteElevationMinimum(), style);
- number_absoluteElevationMaximum = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Elevation Maximum (m)",
- entity.getAbsoluteElevationMaximum(), style);
-
- text_collectingMethod = formFactory.createTextWithLabelElement(
- formElement, "Collecting Method", entity.getCollectingMethod(),
- style);
-
- number_distanceToGround = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Distance To Ground (m)", entity.getDistanceToGround(),
- style);
- number_distanceToWaterSurface = formFactory
- .createIntegerTextWithLabelElement(formElement,
- "Distance To Water Surface (m)",
- entity.getDistanceToWaterSurface(), style);
- // exactLocation
- text_gatheringEventDescription = formFactory
- .createTextWithLabelElement(formElement,
- "Gathering Event Description",
- entity.getGatheringEventDescription(), style);
-
- section_collectingAreas = (CollectingAreasDetailSection) formFactory
- .createEntityDetailSection(EntityDetailType.COLLECTING_AREA,
- getConversationHolder(), formElement, Section.TWISTIE);
- section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(
- 2, 1));
- section_collectingAreas.setEntity(entity);
+ protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
+
+ text_collectingMethod = formFactory.createTextWithLabelElement(formElement, "Collecting Method", entity.getCollectingMethod(), style);
+
+ text_gatheringEventDescription = formFactory.createTextWithLabelElement(
+ formElement, "Gathering Event Description", entity.getGatheringEventDescription(), style);
+
+ element_distToGround = formFactory.createGatheringEventUnitElement(
+ formElement, "Dist. To Ground : ", entity, MinMaxTextSection.UnitType.DIST_TO_GROUND, style);
+
+ element_distToWater = formFactory.createGatheringEventUnitElement(
+ formElement, "Dist. To Watersurface : ", entity, MinMaxTextSection.UnitType.DIST_TO_WATER, 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);
+ }
+
}
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
- if (eventSource == number_absoluteElevationError) {
- getEntity().setAbsoluteElevationError(
- number_absoluteElevationError.getInteger());
- } else if (eventSource == number_absoluteElevationMinimum) {
- try {
- getEntity().setAbsoluteElevationRange(
- number_absoluteElevationMinimum.getInteger(),
- number_absoluteElevationMaximum.getInteger());
- number_absoluteElevationMinimum
- .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
- } catch (IllegalArgumentException e) {
- number_absoluteElevationMinimum
- .setBackground(getColor(Resources.COLOR_PARSE_ERROR));
- StoreUtil.warn(getClass(), e.getLocalizedMessage());
- }
- } else if (eventSource == number_absoluteElevationMaximum) {
- try {
- getEntity().setAbsoluteElevationRange(
- number_absoluteElevationMinimum.getInteger(),
- number_absoluteElevationMaximum.getInteger());
- number_absoluteElevationMaximum
- .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
- } catch (IllegalArgumentException e) {
- number_absoluteElevationMaximum
- .setBackground(getColor(Resources.COLOR_PARSE_ERROR));
- StoreUtil.warn(getClass(), e.getLocalizedMessage());
- }
- } else if (eventSource == text_collectingMethod) {
+ if (eventSource == text_collectingMethod) {
getEntity().setCollectingMethod(text_collectingMethod.getText());
- } else if (eventSource == number_distanceToGround) {
- getEntity().setDistanceToGround(
- number_distanceToGround.getInteger());
- } else if (eventSource == number_distanceToWaterSurface) {
- getEntity().setDistanceToWaterSurface(
- number_distanceToWaterSurface.getInteger());
} else if (eventSource == text_gatheringEventDescription) {
getEntity().setGatheringEventDescription(
text_gatheringEventDescription.getText());