further implementation for verbatimdate
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / element / DateDetailSection.java
index 35e10d082e3c369200d2a3b015a25d052de48138..2b897c936253c2f17adc48b97a13a674e94bb0e8 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
  * Copyright (C) 2007 EDIT
  * European Distributed Institute of Taxonomy
@@ -29,13 +28,21 @@ import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
  */
 public class DateDetailSection extends AbstractFormSection<TimePeriod> {
 
-       private final TextWithLabelElement text_freeText;
-       private final PartialElement partialElement_start;
-       private final PartialElement partialElement_end;
-       private final TextWithLabelElement text_parseText;
+       protected TextWithLabelElement text_freeText;
+       private PartialElement partialElement_start;
+       private PartialElement partialElement_end;
+       private TextWithLabelElement text_parseText;
        private int cursorPosition;
 
-       /**
+       public int getCursorPosition() {
+        return cursorPosition;
+    }
+
+    public void setCursorPosition(int cursorPosition) {
+        this.cursorPosition = cursorPosition;
+    }
+
+    /**
         * <p>
         * Constructor for DateDetailSection.
         * </p>
@@ -58,9 +65,9 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                partialElement_end = formFactory.createPartialElement(this, "End ",
                                null, style);
 
-               text_parseText = formFactory.createTextWithLabelElement(this, "Parse",
-                               null, style);
-               text_parseText.getMainControl().setLayoutData(
+               setText_parseText(formFactory.createTextWithLabelElement(this, "Parse",
+                               null, style));
+               getText_parseText().getMainControl().setLayoutData(
                                LayoutConstants.FILL_HORIZONTALLY(6, 1));
 
                text_freeText = formFactory.createTextWithLabelElement(this,
@@ -68,6 +75,7 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                text_freeText.getMainControl().setLayoutData(
                                LayoutConstants.FILL_HORIZONTALLY(6, 1));
 
+
                formFactory.addPropertyChangeListener(this);
        }
 
@@ -91,20 +99,20 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
        public void setEntity(TimePeriod timePeriod) {
                setEntityInternally(timePeriod);
                updateTitle();
-               text_parseText.setText(timePeriod.toString());
+               getText_parseText().setText(timePeriod.toString());
        }
 
        /**
         * When setting the entity through parsing we do not want to alter the parse field
         * @param timePeriod
         */
-       private void setEntityInternally(TimePeriod timePeriod){
+       protected void setEntityInternally(TimePeriod timePeriod){
                Partial start = timePeriod.getStart();
                partialElement_start.setPartial(start);
                Partial end = timePeriod.getEnd();
                partialElement_end.setPartial(end);
 
-               ((Text) text_parseText.getMainControl()).setSelection(cursorPosition);
+               ((Text) getText_parseText().getMainControl()).setSelection(cursorPosition);
                text_freeText.setText(timePeriod.getFreeText());
 
                super.setEntity(timePeriod);
@@ -137,17 +145,17 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                                event.getException()));
        }
 
-       private void handleEvent(Object eventSource) {
+       protected void handleEvent(Object eventSource) {
                if (eventSource == partialElement_start) {
                        Partial start = partialElement_start.getPartial();
                        getEntity().setStart(start);
                } else if (eventSource == partialElement_end) {
                        Partial end = partialElement_end.getPartial();
                        getEntity().setEnd(end);
-               } else if (eventSource == text_parseText) {
-                       cursorPosition = ((Text) text_parseText.getMainControl())
+               } else if (eventSource == getText_parseText()) {
+                       cursorPosition = ((Text) getText_parseText().getMainControl())
                                        .getCaretPosition();
-                       setEntityInternally(TimePeriodParser.parseString(text_parseText.getText()));
+                       setEntityInternally(TimePeriodParser.parseString(getText_parseText().getText()));
                } else if (eventSource == text_freeText) {
                        getEntity().setFreeText(text_freeText.getText());
                }
@@ -155,7 +163,7 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
 
-       private void updateTitle(){
+       protected void updateTitle(){
                String title = CdmUtils.Nz(getEntity().toString());
                this.setText(title);
                layout();
@@ -173,4 +181,12 @@ public class DateDetailSection extends AbstractFormSection<TimePeriod> {
                super.dispose();
        }
 
+    public TextWithLabelElement getText_parseText() {
+        return text_parseText;
+    }
+
+    public void setText_parseText(TextWithLabelElement text_parseText) {
+        this.text_parseText = text_parseText;
+    }
+
 }