3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.ui
.forms
;
13 import java
.text
.ParseException
;
15 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
17 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
18 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
19 import eu
.etaxonomy
.taxeditor
.ui
.forms
.CdmFormFactory
.TermComboType
;
20 import eu
.etaxonomy
.taxeditor
.ui
.term
.ReferenceSystemComboElement
;
23 * <p>PointElement class.</p>
26 * @created Oct 15, 2010
29 public class PointElement
extends AbstractCdmFormElement
implements IEntityElement
<Point
>{
33 private ReferenceSystemComboElement combo_referenceSystem
;
34 private TextWithLabelElement text_latitude
;
35 private TextWithLabelElement text_longitude
;
36 private NumberWithLabelElement number_errorRadius
;
39 * <p>Constructor for PointElement.</p>
41 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
42 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
43 * @param point a {@link eu.etaxonomy.cdm.model.location.Point} object.
46 public PointElement(CdmFormFactory formFactory
, ICdmFormElement formElement
, Point point
, final int style
) {
47 super(formFactory
, formElement
);
49 formFactory
.addPropertyChangeListener(this);
51 text_latitude
= formFactory
.createTextWithLabelElement(formElement
, "Latitude (hexagesimal)", null, style
);
52 text_longitude
= formFactory
.createTextWithLabelElement(formElement
, "Longitude (hexagesimal)", null, style
);
53 number_errorRadius
= formFactory
.createIntegerTextWithLabelElement(formElement
, "Error Radius (m)", null, style
);
54 combo_referenceSystem
= (ReferenceSystemComboElement
) formFactory
.createTermComboElement(TermComboType
.REFERENCE_SYSTEM
, formElement
, "Reference System", null, style
);
60 * @see eu.etaxonomy.taxeditor.forms.ISelectable#setSelected(boolean)
64 public void setSelected(boolean selected
) {
69 * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
73 public void propertyChange(PropertyChangeEvent event
) {
78 boolean propagate
= false;
80 Object eventSource
= event
.getSource();
81 if(eventSource
== text_latitude
){
83 getPoint().setLatitudeByParsing(text_latitude
.getText());
84 text_latitude
.setText(point
.getLatitudeSexagesimal().toString(false));
85 text_latitude
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
87 } catch (ParseException e
) {
88 text_latitude
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
91 else if(eventSource
== text_longitude
){
93 getPoint().setLongitudeByParsing(text_longitude
.getText());
94 text_longitude
.setText(point
.getLongitudeSexagesimal().toString(false));
95 text_longitude
.setBackground(getColor(Resources
.COLOR_COMPOSITE_BACKGROUND
));
97 } catch (ParseException e
) {
98 text_latitude
.setBackground(getColor(Resources
.COLOR_PARSE_ERROR
));
101 else if(eventSource
== number_errorRadius
){
102 getPoint().setErrorRadius(number_errorRadius
.getInteger());
105 else if(eventSource
== combo_referenceSystem
){
106 getPoint().setReferenceSystem(combo_referenceSystem
.getSelection());
111 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event
));
116 * @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity()
120 public Point
getEntity() {
127 * @param point a {@link eu.etaxonomy.cdm.model.location.Point} object.
129 public void setEntity(Point point
){
134 * <p>Setter for the field <code>point</code>.</p>
136 * @param point the point to set
138 public void setPoint(Point point
) {
141 text_latitude
.setText(point
.getLatitudeSexagesimal() == null ?
"" : point
.getLatitudeSexagesimal().toString(false));
142 text_longitude
.setText(point
.getLongitudeSexagesimal() == null ?
"" : point
.getLongitudeSexagesimal().toString(false));
143 number_errorRadius
.setInteger(point
.getErrorRadius());
144 combo_referenceSystem
.setSelection(point
.getReferenceSystem());
149 * <p>Getter for the field <code>point</code>.</p>
153 public Point
getPoint() {
155 point
= Point
.NewInstance();