-// $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 eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.model.common.TimePeriod;
+import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
/**
* <p>
* DateDetailSection class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Mar 31, 2010
* @version 1.0
*/
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>
- *
+ *
* @param formFactory
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
* object.
super(formFactory, parentElement, style);
partialElement_start = formFactory.createPartialElement(this,
- "Start: ", null, style);
- partialElement_end = formFactory.createPartialElement(this, "End: ",
+ "Start ", null, style);
+ 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,
text_freeText.getMainControl().setLayoutData(
LayoutConstants.FILL_HORIZONTALLY(6, 1));
+
formFactory.addPropertyChangeListener(this);
}
}
return super.getEntity();
}
-
+
/**
* <p>
* Setter for the field <code>timePeriod</code>.
* </p>
- *
+ *
* @param timePeriod
* a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
*/
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);
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(TimePeriod.parseString(text_parseText.getText()));
+ setEntityInternally(TimePeriodParser.parseString(getText_parseText().getText()));
} else if (eventSource == text_freeText) {
getEntity().setFreeText(text_freeText.getText());
}
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
- private void updateTitle(){
+ protected void updateTitle(){
String title = CdmUtils.Nz(getEntity().toString());
this.setText(title);
layout();
}
-
+
/*
* (non-Javadoc)
- *
+ *
* @see eu.etaxonomy.taxeditor.forms.AbstractFormSection#dispose()
*/
/** {@inheritDoc} */
super.dispose();
}
+ public TextWithLabelElement getText_parseText() {
+ return text_parseText;
+ }
+
+ public void setText_parseText(TextWithLabelElement text_parseText) {
+ this.text_parseText = text_parseText;
+ }
+
}