-// $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.
*/
import java.text.ParseException;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.util.PropertyChangeEvent;
+import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.location.Point;
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
import eu.etaxonomy.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
/**
* <p>
* PointElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Oct 15, 2010
- * @version 1.0
*/
public class PointElement extends AbstractCdmFormElement implements
IEntityElement<Point>, ISelectable {
* <p>
* Constructor for PointElement.
* </p>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
formFactory.addPropertyChangeListener(this);
text_latitude = formFactory.createTextWithLabelElement(formElement,
- "Latitude (hexagesimal)", null, style);
+ "Latitude", null, style);
text_latitudeParsed = formFactory.createTextWithLabelElement(
formElement, "", null, style);
text_latitudeParsed.setEnabled(false);
text_longitude = formFactory.createTextWithLabelElement(formElement,
- "Longitude (hexagesimal)", null, style);
+ "Longitude", null, style);
text_longitudeParsed = formFactory.createTextWithLabelElement(
formElement, "", null, style);
text_longitudeParsed.setEnabled(false);
number_errorRadius = formFactory.createNumberTextWithLabelElement(
formElement, "Error Radius (m)", null, style);
- combo_referenceSystem = formFactory
- .createTermComboElement(ReferenceSystem.class,
+ combo_referenceSystem = formFactory.createDefinedTermComboElement(TermType.ReferenceSystem,
formElement, "Reference System", null, style);
setPoint(point);
/*
* (non-Javadoc)
- *
+ *
* @see
* eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org
* .eclipse.jface.util.PropertyChangeEvent)
Object eventSource = event.getSource();
if (eventSource == text_latitude) {
try {
- getPoint().setLatitudeByParsing(text_latitude.getText());
- text_latitudeParsed.setText(point.getLatitudeSexagesimal()
- .toString(false));
- text_latitude
- .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ if (StringUtils.isBlank(text_latitude.getText())){
+ getPoint().setLatitudeByParsing(null);
+ text_latitudeParsed.setText(null);
+ text_latitude
+ .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ }else{
+ getPoint().setLatitudeByParsing(text_latitude.getText());
+ text_latitudeParsed.setText(point.getLatitudeSexagesimal()
+ .toString(false));
+ text_latitude
+ .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ }
propagate = true;
} catch (ParseException e) {
text_latitude
}
} else if (eventSource == text_longitude) {
try {
- getPoint().setLongitudeByParsing(text_longitude.getText());
- text_longitudeParsed.setText(point.getLongitudeSexagesimal()
- .toString(false));
- text_longitude
- .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ if (StringUtils.isBlank(text_longitude.getText())){
+ getPoint().setLongitudeByParsing(null);
+ text_longitudeParsed.setText(null);
+ text_longitude
+ .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ }else{
+ getPoint().setLongitudeByParsing(text_longitude.getText());
+ text_longitudeParsed.setText(point.getLongitudeSexagesimal()
+ .toString(false));
+ text_longitude
+ .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+ }
propagate = true;
} catch (ParseException e) {
text_longitude
}
}
- /*
- * (non-Javadoc)
- *
- * @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity()
- */
/** {@inheritDoc} */
@Override
public Point getEntity() {
* <p>
* setEntity
* </p>
- *
+ *
* @param point
* a {@link eu.etaxonomy.cdm.model.location.Point} object.
*/
* <p>
* Setter for the field <code>point</code>.
* </p>
- *
+ *
* @param point
* the point to set
*/
* <p>
* Getter for the field <code>point</code>.
* </p>
- *
+ *
* @return the point
*/
public Point getPoint() {
return point;
}
- public void setSelected(boolean selected) {
+ @Override
+ public void setSelected(boolean selected) {
setBackground(selected ? SELECTED : getPersistentBackground());
}
-
+
}