import org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
-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.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;
public class GatheringEventDetailElement extends
AbstractCdmDetailElement<DerivedUnitFacade> {
- private NumberWithLabelElement number_absoluteElevationError;
-
- private NumberWithLabelElement number_absoluteElevationMinimum;
-
- private NumberWithLabelElement number_absoluteElevationMaximum;
+ private GatheringEventUnitElement element_elevation;
+ private GatheringEventUnitElement element_distToGround;
+
+ private GatheringEventUnitElement element_distToWater;
+
private TextWithLabelElement text_collectingMethod;
- private NumberWithLabelElement number_distanceToGround;
-
- private NumberWithLabelElement number_distanceToWaterSurface;
-
private TextWithLabelElement text_gatheringEventDescription;
private CollectingAreasDetailSection section_collectingAreas;
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.getAbsoluteElevationMaximum(), style);
+ /** {@inheritDoc} */
+ @Override
+ protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
+
+
+ // collectingArea
+
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);
+ // exactLocation
+ text_gatheringEventDescription = formFactory.createTextWithLabelElement(
+ formElement, "Gathering Event Description", entity.getGatheringEventDescription(), style);
+// element_elevation = formFactory.createGatheringEventUnitElement(
+// formElement, "Elevation : ", entity, MinMaxTextSection.UnitType.ELEVATION, 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);
+
section_collectingAreas = formFactory.createCollectingAreasDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
section_collectingAreas.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- section_collectingAreas.setEntity(entity);
- }
+ 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));
- 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) {
+ 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());