import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
import eu.etaxonomy.cdm.model.description.QuantitativeData;
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
+import eu.etaxonomy.cdm.model.description.TemporalData;
import eu.etaxonomy.cdm.model.description.TextData;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
else if(feature.isSupportsQuantitativeData()){
element = QuantitativeData.NewInstance();
}
+ else if(feature.isSupportsTemporalData()){
+ element = TemporalData.NewInstance(null);
+ }
else {
element = TextData.NewInstance();
}
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
+import eu.etaxonomy.cdm.model.description.TemporalData;
import eu.etaxonomy.cdm.model.description.TextData;
import eu.etaxonomy.cdm.model.location.NamedArea;
import eu.etaxonomy.cdm.model.media.Media;
else if (element instanceof TextData) {
return getElementText((TextData) element);
}
+ else if (element instanceof TemporalData) {
+ return getTemporalDataText((TemporalData) element);
+ }
else{
return element.toString();
}
}
- private static boolean isNotBlank(String str){
+ /**
+ * @param element
+ * @return
+ */
+ private static String getTemporalDataText(TemporalData element) {
+
+ return element.getPeriod().toString();
+ }
+
+ private static boolean isNotBlank(String str){
return StringUtils.isNotBlank(str);
}
return element;
}
+ public PartialElement createPartialElement(ICdmFormElement parentElement, String labelString, Partial partial, boolean showYear,
+ int style) {
+ PartialElement element = new PartialElement(this, parentElement, labelString, style, showYear);
+ adapt(element);
+ parentElement.addElement(element);
+ return element;
+ }
+
/**
* <p>
* addSelectionListener
*/
package eu.etaxonomy.taxeditor.ui.element;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.joda.time.Partial;
+
+import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
/**
* @author k.luther
* @since Jun 12, 2020
*/
-public class ExtendedTimeDetailSection extends DateDetailSection<ExtendedTimePeriod> {
+public class ExtendedTimeDetailSection extends AbstractFormSection<ExtendedTimePeriod> {
private PartialElement partialElement_extremeStart;
+ private PartialElement partialElement_start;
+ private PartialElement partialElement_end;
private PartialElement partialElement_extremeEnd;
+// private TextWithLabelElement text_freeText;
/**
* @param formFactory
* @param parentElement
*/
protected ExtendedTimeDetailSection(CdmFormFactory formFactory, ICdmFormElement parentElement,
int style) {
- super(formFactory, parentElement, false, style);
+ super(formFactory, parentElement, style);
// this.includeVerbatim = includeVerbatim;
- partialElement_extremeStart = formFactory.createPartialElement(this, "Extreme Start", null, style);
- partialElement_start = formFactory.createPartialElement(this,
- "Start ", null, style);
+ partialElement_extremeStart = formFactory.createPartialElement(this, "Extreme Start ", null, false, style);
+
+ partialElement_start = formFactory.createPartialElement(this, "Start ", null, false, style);
+
- period_continue = formFactory.createCheckbox(this, "Continue", false, style);
- period_continue.getMainControl().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(6,1));
- partialElement_end = formFactory.createPartialElement(this, "End ",
- null, style);
+ partialElement_end = formFactory.createPartialElement(this, "End ", null, false, style);
partialElement_extremeEnd = formFactory.createPartialElement(this, "Extreme End ",
- null, style);
+ null, false, style);
- text_freeText = formFactory.createTextWithLabelElement(this,
- "Freetext", null, style);
- text_freeText.getMainControl().setLayoutData(
- LayoutConstants.FILL_HORIZONTALLY(6, 1));
+// text_freeText = formFactory.createTextWithLabelElement(this,
+// "Freetext", null, style);
+// text_freeText.getMainControl().setLayoutData(
+// LayoutConstants.FILL_HORIZONTALLY(5, 1));
formFactory.addPropertyChangeListener(this);
}
@Override
- @SuppressWarnings("unchecked")
- protected ExtendedTimePeriod newInstance(){
- return ExtendedTimePeriod.NewExtendedInstance();
+ public void setEntity(ExtendedTimePeriod timePeriod) {
+ Partial extremeStart = timePeriod.getExtremeStart();
+ partialElement_extremeStart.setPartial(extremeStart);
+ Partial start = timePeriod.getStart();
+ partialElement_start.setPartial(start);
+ Partial end = timePeriod.getEnd();
+ partialElement_end.setPartial(end);
+
+ Partial extremeEnd = timePeriod.getExtremeEnd();
+ partialElement_extremeEnd.setPartial(extremeEnd);
+
+// text_freeText.setText(timePeriod.getFreeText());
+
+ super.setEntity(timePeriod);
}
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event == null) {
+ return;
+ }
+ Object eventSource = event.getSource();
+
+ if (getElements().contains(eventSource)) {
+ if (event instanceof CdmPropertyChangeEvent) {
+ if (((CdmPropertyChangeEvent) event).hasException()) {
+ handleException((CdmPropertyChangeEvent) event);
+ return;
+ }
+ }
+ handleEvent(eventSource);
+ }
+ }
+
+ /**
+ * @param event
+ */
+ private void handleException(CdmPropertyChangeEvent event) {
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this,
+ event.getException()));
+ }
+
+ 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 == partialElement_extremeEnd) {
+ Partial extremeEnd = partialElement_extremeEnd.getPartial();
+ getEntity().setExtremeEnd(extremeEnd);
+ } else if (eventSource == partialElement_extremeStart) {
+ Partial extremeStart = partialElement_extremeStart.getPartial();
+ getEntity().setExtremeStart(extremeStart);
+// } else if (eventSource == text_freeText) {
+// getEntity().setFreeText(text_freeText.getText());
+ }
+// updateTitle();
+
+
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
+ }
+
+ protected void updateTitle(){
+ String title = CdmUtils.Nz(getEntity().toString());
+ this.setText(title);
+ layout();
+ }
+
+
}
*/
package eu.etaxonomy.taxeditor.ui.element;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.forms.widgets.Section;
import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
protected ExtendedTimeDetailSection createDateDetailSection() {
return formFactory.createExtendedTimeDetailSection(this,
- Section.TWISTIE);
+ SWT.NULL);
}
@Override
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.joda.time.IllegalFieldValueException;
import org.joda.time.Partial;
private Label label;
private FloatWithLabelElement number_day;
private FloatWithLabelElement number_month;
- private FloatWithLabelElement number_year;
+ private FloatWithLabelElement number_year = null;
private Partial partial;
+ public PartialElement(CdmFormFactory formFactory,
+ ICdmFormElement formElement, String labelString, int style){
+ this(formFactory, formElement, labelString, style, true);
+ }
+
/**
* <p>Constructor for PartialElement.</p>
*
* @param style a int.
*/
public PartialElement(CdmFormFactory formFactory,
- ICdmFormElement formElement, String labelString, int style) {
+ ICdmFormElement formElement, String labelString, int style, boolean showYear) {
super(formFactory, formElement);
- TableWrapLayout layout = LayoutConstants.LAYOUT(7, false);
+ int rows = 5;
+ if (showYear){
+ rows = 7;
+ }
+ TableWrapLayout layout = LayoutConstants.LAYOUT(rows, false);
+// layout.verticalSpacing = 7;
+ layout.horizontalSpacing = 7;
+
formElement.getLayoutComposite().setLayout(layout);
+ TableWrapData layoutLable = new TableWrapData();
+ layoutLable.valign = TableWrapData.MIDDLE;
+
label = formFactory.createLabel(getLayoutComposite(), labelString);
+ label.setLayoutData(layoutLable);
addControl(label);
- number_year = formFactory.createFloatTextWithLabelElement(this, "Year", null, style);
- number_year.setLimits(4, 0, 9999);
+ if (showYear){
+ number_year = formFactory.createFloatTextWithLabelElement(this, "Year", null, style);
+ number_year.setLimits(4, 0, 9999);
+ }
+
number_month = formFactory.createFloatTextWithLabelElement(this, "Month", null, style);
number_month.setLimits(2, 1, 12);
if(partial != null){
number_day.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.DAY_TYPE));
number_month.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.MONTH_TYPE));
- number_year.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.YEAR_TYPE));
+ if (number_year != null) {
+ number_year.setNumber(TimePeriod.getPartialValue(partial, TimePeriod.YEAR_TYPE));
+ }
}
else{
number_day.setNumber(null);
number_month.setNumber(null);
- number_year.setNumber(null);
+ if (number_year != null) {
+ number_year.setNumber(null);
+ }
}
}
public void setEnabled(boolean enabled){
this.number_day.setEnabled(enabled);
this.number_month.setEnabled(enabled);
- this.number_year.setEnabled(enabled);
+ if (number_year != null){
+ this.number_year.setEnabled(enabled);
+ }
if (!enabled){
- this.number_year.getMainControl().setBackground(AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND));
+ if (number_year != null){
+ this.number_year.getMainControl().setBackground(AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND));
+ }
this.number_month.getMainControl().setBackground(AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND));
this.number_day.getMainControl().setBackground(AbstractUtility.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND));
}else{
- this.number_year.getMainControl().setBackground(getPersistentBackground());
+ if (number_year != null){
+ this.number_year.getMainControl().setBackground(getPersistentBackground());
+ }
this.number_month.getMainControl().setBackground(getPersistentBackground());
this.number_day.getMainControl().setBackground(getPersistentBackground());
}
public void setAllNull() {
this.number_day.setNumber(null);
this.number_month.setNumber(null);
- this.number_year.setNumber(null);
+ if (number_year != null){
+ this.number_year.setNumber(null);
+ }
}
}
*/
package eu.etaxonomy.taxeditor.ui.section.description.detail;
+import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
import eu.etaxonomy.cdm.model.description.TemporalData;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ExtendedTimePeriodElement;
@Override
protected void createControls(ICdmFormElement formElement, TemporalData entity, int style) {
- timePeriod = formFactory.createExtendedTimePeriodElement(formElement, "Flowering Season", entity.getPeriod(), style);
+ ExtendedTimePeriod period = entity.getPeriod();
+ if (period == null){
+ period = ExtendedTimePeriod.NewExtendedInstance();
+ entity.setPeriod(period);
+ }
+ timePeriod = formFactory.createExtendedTimePeriodElement(formElement, "", entity.getPeriod(), style);
}