// $Id$
/**
-* Copyright (C) 2007 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.
-*/
+ * Copyright (C) 2007 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 org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.forms.NumberWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.preference.Resources;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
+import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
+import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.campanula.compatibility.ICdmFormElement;
/**
- * <p>GatheringEventDetailElement class.</p>
+ * <p>
+ * GatheringEventDetailElement class.
+ * </p>
*
* @author n.hoffmann
* @created Jun 24, 2010
* @version 1.0
*/
-public class GatheringEventDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade>{
-
+public class GatheringEventDetailElement extends
+ AbstractCdmDetailElement<DerivedUnitFacade> {
+
private NumberWithLabelElement number_absoluteElevationError;
private NumberWithLabelElement number_absoluteElevationMinimum;
private NumberWithLabelElement number_distanceToWaterSurface;
private TextWithLabelElement text_gatheringEventDescription;
-
+
private CollectingAreasDetailSection section_collectingAreas;
/**
- * <p>Constructor for GatheringEventDetailElement.</p>
+ * <p>
+ * Constructor for GatheringEventDetailElement.
+ * </p>
*
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
- * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
+ * object.
+ * @param formElement
+ * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
+ * object.
*/
public GatheringEventDetailElement(CdmFormFactory formFactory,
ICdmFormElement formElement) {
super(formFactory, formElement);
}
- /** {@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.getAbsoluteElevationMinimum(), 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(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
- section_collectingAreas.setEntity(entity);
- }
+ /** {@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 = 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){
- getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum.getInteger(), number_absoluteElevationMaximum.getInteger());
- }
- else if(eventSource == number_absoluteElevationMaximum){
- getEntity().setAbsoluteElevationRange(number_absoluteElevationMinimum.getInteger(), number_absoluteElevationMaximum.getInteger());
- }
- else if(eventSource == text_collectingMethod){
+ 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));
+ AbstractUtility.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));
+ AbstractUtility.warn(getClass(), e.getLocalizedMessage());
+ }
+ } else 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());
+ } 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());
}
}
}