Fixed a missing addControl() method call in TimePeriod element. Reverting half done...
authorn.hoffmann <n.hoffmann@localhost>
Mon, 4 Apr 2011 15:30:00 +0000 (15:30 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 4 Apr 2011 15:30:00 +0000 (15:30 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/PointElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/TimePeriodElement.java

index f8df475c59cb1725db4d33ae8491ebbf150f77a0..bb65087ce56fe0ff3784323712b05b0b590f5748 100644 (file)
@@ -1,19 +1,18 @@
 // $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.forms;
 
 import java.text.ParseException;
 
 import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Label;
 
 import eu.etaxonomy.cdm.model.location.Point;
 import eu.etaxonomy.taxeditor.preference.Resources;
@@ -21,142 +20,99 @@ import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType;
 import eu.etaxonomy.taxeditor.ui.term.ReferenceSystemComboElement;
 
 /**
- * <p>
- * PointElement class.
- * </p>
- * 
+ * <p>PointElement class.</p>
+ *
  * @author n.hoffmann
  * @created Oct 15, 2010
  * @version 1.0
  */
-public class PointElement extends AbstractCdmFormElement implements
-               IEntityElement<Point> {
+public class PointElement extends AbstractCdmFormElement implements IEntityElement<Point>{
 
        private Point point;
-
-       private final ReferenceSystemComboElement combo_referenceSystem;
-       private final TextWithLabelElement text_latitude;
-       private final TextWithLabelElement text_longitude;
-       private final NumberWithLabelElement number_errorRadius;
-
-       private final Label label_latitude;
-
-       private final Label label_longitude;
-
+       
+       private ReferenceSystemComboElement combo_referenceSystem;
+       private TextWithLabelElement text_latitude;     
+       private TextWithLabelElement text_longitude;    
+       private NumberWithLabelElement number_errorRadius;
+       
        /**
-        * <p>
-        * Constructor for PointElement.
-        * </p>
-        * 
-        * @param formFactory
-        *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
-        *            object.
-        * @param formElement
-        *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
-        *            object.
-        * @param point
-        *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
-        * @param style
-        *            a int.
+        * <p>Constructor for PointElement.</p>
+        *
+        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
+        * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
+        * @param point a {@link eu.etaxonomy.cdm.model.location.Point} object.
+        * @param style a int.
         */
-       public PointElement(CdmFormFactory formFactory,
-                       ICdmFormElement formElement, Point point, final int style) {
+       public PointElement(CdmFormFactory formFactory, ICdmFormElement formElement, Point point,  final int style) {
                super(formFactory, formElement);
-
+               
                formFactory.addPropertyChangeListener(this);
-
-               getLayoutComposite().setLayoutData(
-                               CdmFormFactory.FILL_HORIZONTALLY(3, 1));
-
-               text_latitude = formFactory.createTextWithLabelElement(formElement,
-                               "Latitude (hexagesimal)", null, style);
-
-               label_latitude = formFactory.createLabel(getLayoutComposite(), null);
-               addControl(label_latitude);
-
-               text_longitude = formFactory.createTextWithLabelElement(formElement,
-                               "Longitude (hexagesimal)", null, style);
-
-               label_longitude = formFactory.createLabel(getLayoutComposite(), null);
-               addControl(label_longitude);
-
-               number_errorRadius = formFactory.createIntegerTextWithLabelElement(
-                               formElement, "Error Radius (m)", null, style);
-               combo_referenceSystem = (ReferenceSystemComboElement) formFactory
-                               .createTermComboElement(TermComboType.REFERENCE_SYSTEM,
-                                               formElement, "Reference System", null, style);
-
+               
+               text_latitude = formFactory.createTextWithLabelElement(formElement, "Latitude (hexagesimal)", null, style);
+               text_longitude = formFactory.createTextWithLabelElement(formElement, "Longitude (hexagesimal)", null, style);
+               number_errorRadius = formFactory.createIntegerTextWithLabelElement(formElement, "Error Radius (m)", null, style);
+               combo_referenceSystem = (ReferenceSystemComboElement) formFactory.createTermComboElement(TermComboType.REFERENCE_SYSTEM, formElement, "Reference System", null, style);
+               
                setPoint(point);
        }
 
-       /*
-        * (non-Javadoc)
-        * 
+       /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.forms.ISelectable#setSelected(boolean)
         */
        /** {@inheritDoc} */
        @Override
        public void setSelected(boolean selected) {
-
+               
        }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org
-        * .eclipse.jface.util.PropertyChangeEvent)
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
         */
        /** {@inheritDoc} */
        @Override
        public void propertyChange(PropertyChangeEvent event) {
-               if (event == null) {
+               if(event == null){
                        return;
                }
-
+               
                boolean propagate = false;
-
+               
                Object eventSource = event.getSource();
-               if (eventSource == text_latitude) {
+               if(eventSource == text_latitude){
                        try {
                                getPoint().setLatitudeByParsing(text_latitude.getText());
-                               text_latitude.setText(point.getLatitudeSexagesimal().toString(
-                                               false));
-                               text_latitude
-                                               .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+                               text_latitude.setText(point.getLatitudeSexagesimal().toString(false));
+                               text_latitude.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
                                propagate = true;
                        } catch (ParseException e) {
-                               text_latitude
-                                               .setBackground(getColor(Resources.COLOR_PARSE_ERROR));
+                               text_latitude.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
                        }
-               } else if (eventSource == text_longitude) {
+               }
+               else if(eventSource == text_longitude){
                        try {
                                getPoint().setLongitudeByParsing(text_longitude.getText());
-                               text_longitude.setText(point.getLongitudeSexagesimal()
-                                               .toString(false));
-                               text_longitude
-                                               .setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
+                               text_longitude.setText(point.getLongitudeSexagesimal().toString(false));
+                               text_longitude.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
                                propagate = true;
                        } catch (ParseException e) {
-                               text_latitude
-                                               .setBackground(getColor(Resources.COLOR_PARSE_ERROR));
+                               text_latitude.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
                        }
-               } else if (eventSource == number_errorRadius) {
+               }
+               else if(eventSource == number_errorRadius){
                        getPoint().setErrorRadius(number_errorRadius.getInteger());
                        propagate = true;
-               } else if (eventSource == combo_referenceSystem) {
+               }
+               else if(eventSource == combo_referenceSystem){
                        getPoint().setReferenceSystem(combo_referenceSystem.getSelection());
                        propagate = true;
-               }
-
-               if (propagate) {
+               }       
+               
+               if(propagate){
                        firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event));
                }
        }
 
-       /*
-        * (non-Javadoc)
-        * 
+       /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity()
         */
        /** {@inheritDoc} */
@@ -166,49 +122,39 @@ public class PointElement extends AbstractCdmFormElement implements
        }
 
        /**
-        * <p>
-        * setEntity
-        * </p>
-        * 
-        * @param point
-        *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
+        * <p>setEntity</p>
+        *
+        * @param point a {@link eu.etaxonomy.cdm.model.location.Point} object.
         */
-       public void setEntity(Point point) {
+       public void setEntity(Point point){
                setPoint(point);
        }
-
+       
        /**
-        * <p>
-        * Setter for the field <code>point</code>.
-        * </p>
-        * 
-        * @param point
-        *            the point to set
+        * <p>Setter for the field <code>point</code>.</p>
+        *
+        * @param point the point to set
         */
        public void setPoint(Point point) {
                this.point = point;
-               if (point != null) {
-                       text_latitude.setText(point.getLatitudeSexagesimal() == null ? ""
-                                       : point.getLatitudeSexagesimal().toString(false));
-                       text_longitude.setText(point.getLongitudeSexagesimal() == null ? ""
-                                       : point.getLongitudeSexagesimal().toString(false));
+               if(point != null){
+                       text_latitude.setText(point.getLatitudeSexagesimal() == null ? "" : point.getLatitudeSexagesimal().toString(false));
+                       text_longitude.setText(point.getLongitudeSexagesimal() == null ? "" : point.getLongitudeSexagesimal().toString(false));
                        number_errorRadius.setInteger(point.getErrorRadius());
                        combo_referenceSystem.setSelection(point.getReferenceSystem());
                }
        }
 
        /**
-        * <p>
-        * Getter for the field <code>point</code>.
-        * </p>
-        * 
+        * <p>Getter for the field <code>point</code>.</p>
+        *
         * @return the point
         */
        public Point getPoint() {
-               if (point == null) {
+               if(point == null){
                        point = Point.NewInstance();
                }
-
+               
                return point;
        }
 
index 2ad606b5858d2d66ebce7f0a4684a53b6b134eec..14efd25b2ea5a95472245089d5fd22e7809de159 100644 (file)
@@ -1,12 +1,12 @@
 // $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.forms;
 
@@ -18,102 +18,125 @@ import org.eclipse.ui.forms.widgets.Section;
 import eu.etaxonomy.cdm.model.common.TimePeriod;
 
 /**
- * <p>TimePeriodElement class.</p>
- *
+ * <p>
+ * TimePeriodElement class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Nov 17, 2009
  * @version 1.0
  */
-public class TimePeriodElement extends AbstractCdmFormElement{
+public class TimePeriodElement extends AbstractCdmFormElement {
 
        private TimePeriod timePeriod;
-       private Label label;
-       private DateDetailSection section_dateDetails;
-       
+       private final Label label;
+       private final DateDetailSection section_dateDetails;
+
        /**
-        * <p>Constructor for TimePeriodElement.</p>
-        *
-        * @param style a int.
-        * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
-        * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
-        * @param labelString a {@link java.lang.String} object.
-        * @param timePeriod a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
+        * <p>
+        * Constructor for TimePeriodElement.
+        * </p>
+        * 
+        * @param style
+        *            a int.
+        * @param formFactory
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+        *            object.
+        * @param parentElement
+        *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
+        *            object.
+        * @param labelString
+        *            a {@link java.lang.String} object.
+        * @param timePeriod
+        *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
         */
-       public TimePeriodElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString, TimePeriod timePeriod, final int style) {
+       public TimePeriodElement(CdmFormFactory formFactory,
+                       ICdmFormElement parentElement, String labelString,
+                       TimePeriod timePeriod, final int style) {
                super(formFactory, parentElement);
 
                label = formFactory.createLabel(getLayoutComposite(), labelString);
-               
-               section_dateDetails = formFactory.createDateDetailSection(this, Section.TWISTIE);
+               addControl(label);
+
+               section_dateDetails = formFactory.createDateDetailSection(this,
+                               Section.TWISTIE);
                addControl(section_dateDetails);
-                               
+
                setTimePeriod(timePeriod);
-               
+
                formFactory.addPropertyChangeListener(this);
        }
 
        /** {@inheritDoc} */
+       @Override
        public void setSelected(boolean selected) {
                setBackground(getColor(selected));
        }
 
        /**
-        * <p>setEntity</p>
-        *
-        * @param timePeriod a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
+        * <p>
+        * setEntity
+        * </p>
+        * 
+        * @param timePeriod
+        *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
         */
        public void setEntity(TimePeriod timePeriod) {
                setTimePeriod(timePeriod);
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void propertyChange(PropertyChangeEvent event) {
-               if(event == null){
+               if (event == null) {
                        return;
                }
                Object eventSource = event.getSource();
-               
-               if(getElements().contains(eventSource)){
+
+               if (getElements().contains(eventSource)) {
                        handleEvent(eventSource);
                }
        }
-       
-       private void handleEvent(Object eventSource){           
-               
-//             if(eventSource == text_freeText){
-//                     String freeText = text_freeText.getText();
-//                     timePeriod = TimePeriod.parseString(freeText);
-//                     section_dateDetails.setEntity(timePeriod);
-//                     
-               if(eventSource == section_dateDetails){
+
+       private void handleEvent(Object eventSource) {
+
+               // if(eventSource == text_freeText){
+               // String freeText = text_freeText.getText();
+               // timePeriod = TimePeriod.parseString(freeText);
+               // section_dateDetails.setEntity(timePeriod);
+               //
+               if (eventSource == section_dateDetails) {
                        firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
                }
-               
-               
+
        }
 
        /**
-        * <p>Setter for the field <code>timePeriod</code>.</p>
-        *
-        * @param timePeriod the timePeriod to set
+        * <p>
+        * Setter for the field <code>timePeriod</code>.
+        * </p>
+        * 
+        * @param timePeriod
+        *            the timePeriod to set
         */
        public void setTimePeriod(TimePeriod timePeriod) {
                this.timePeriod = timePeriod;
-               if(timePeriod != null){
+               if (timePeriod != null) {
                        section_dateDetails.setEntity(timePeriod);
                }
        }
 
        /**
-        * <p>Getter for the field <code>timePeriod</code>.</p>
-        *
+        * <p>
+        * Getter for the field <code>timePeriod</code>.
+        * </p>
+        * 
         * @return the timePeriod
         */
        public TimePeriod getTimePeriod() {
                return timePeriod;
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void setBackground(Color color) {