Fixes a problem with DateDetail elements where the parse text was always overwritten...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / forms / DateDetailSection.java
index b3ef32b96b611ef0a5cb14c0316c28739d7eca8a..0b95563705ee7b7d5405b9050cdc3317739e6f54 100644 (file)
@@ -80,18 +80,25 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
         */
        @Override
        public void setEntity(TimePeriod timePeriod) {
+               setEntityInternally(timePeriod);
+               text_parseText.setText(timePeriod.toString());
+               super.setEntity(timePeriod);
+       }
+       
+       /**
+        * When setting the entity through parsing we do not want to alter the parse field
+        * @param timePeriod
+        */
+       private void setEntityInternally(TimePeriod timePeriod){
                Partial start = timePeriod.getStart();
                partialElement_start.setPartial(start);
                Partial end = timePeriod.getEnd();
                partialElement_end.setPartial(end);
 
-               text_parseText.setText(timePeriod.toString());
                ((Text) text_parseText.getMainControl()).setSelection(cursorPosition);
                text_freeText.setText(timePeriod.getFreeText());
 
                this.setText(CdmUtils.Nz(timePeriod.toString()));
-
-               super.setEntity(timePeriod);
        }
 
        /** {@inheritDoc} */
@@ -131,7 +138,7 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                } else if (eventSource == text_parseText) {
                        cursorPosition = ((Text) text_parseText.getMainControl())
                                        .getCaretPosition();
-                       setEntity(TimePeriod.parseString(text_parseText.getText()));
+                       setEntityInternally(TimePeriod.parseString(text_parseText.getText()));
                } else if (eventSource == text_freeText) {
                        getEntity().setFreeText(text_freeText.getText());
                }