--- /dev/null
+/**
+* Copyright (C) 2020 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.editor.definedterm;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.persistence.dto.FeatureDto;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @since Jun 11, 2020
+ */
+public class FeatureDtoContentProvider extends TermDtoContentProvider {
+
+ boolean isAvailableForTaxon = true;
+ boolean isAvailableForTaxonName = true;
+ boolean isAvailableForOccurrence = true;
+
+ public FeatureDtoContentProvider(boolean isAvailableForTaxon, boolean isAvailableForTaxonName, boolean isAvailableForOccurrence){
+ super();
+ this.isAvailableForOccurrence = isAvailableForOccurrence;
+ this.isAvailableForTaxon = isAvailableForTaxon;
+ this.isAvailableForTaxonName = isAvailableForTaxonName;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ Collection<TermDto> children = new HashSet<>();
+ if(parentElement instanceof TermVocabularyDto){
+ children.addAll(getChildTerms((TermVocabularyDto)parentElement));
+ } else if(parentElement instanceof FeatureDto){
+ if(((FeatureDto) parentElement).getIncludes()!=null){
+ for (TermDto child: ((FeatureDto) parentElement).getIncludes()){
+ if (child instanceof FeatureDto){
+ FeatureDto featureChild= (FeatureDto)child;
+ if (featureChild.isAvailableForOccurrence() && isAvailableForOccurrence) {
+ children.add(featureChild);
+ }
+ else if (featureChild.isAvailableForTaxon() && isAvailableForTaxon) {
+ children.add(featureChild);
+ }else if (featureChild.isAvailableForTaxonName() && isAvailableForTaxonName) {
+ children.add(featureChild);
+ }
+ }
+ }
+
+ }
+ if(((FeatureDto) parentElement).getGeneralizationOf()!=null){
+ for (TermDto child: ((FeatureDto) parentElement).getGeneralizationOf()){
+ if (child instanceof FeatureDto){
+ FeatureDto featureChild= (FeatureDto)child;
+ if (featureChild.isAvailableForOccurrence() && isAvailableForOccurrence) {
+ children.add(featureChild);
+ }
+ else if (featureChild.isAvailableForTaxon() && isAvailableForTaxon) {
+ children.add(featureChild);
+ }else if (featureChild.isAvailableForTaxonName() && isAvailableForTaxonName) {
+ children.add(featureChild);
+ }
+ }
+ }
+
+ }
+ }
+ return children.toArray();
+ }
+
+
+
+ @Override
+ public Collection<TermDto> getChildTerms(TermVocabularyDto voc) {
+ Collection<TermDto> children = getVocabularyToChildTermMap().get(voc);
+ Collection<TermDto> filteredChildren = new HashSet<>();
+ if(children==null || children.isEmpty()){
+ children = new ArrayList<>(CdmStore.getService(IVocabularyService.class).getCompleteTermHierarchy(voc));
+ for (TermDto child: children){
+ if (child instanceof FeatureDto){
+ FeatureDto featureChild= (FeatureDto)child;
+ if (featureChild.isAvailableForOccurrence() && isAvailableForOccurrence) {
+ filteredChildren.add(featureChild);
+ }
+ else if (featureChild.isAvailableForTaxon() && isAvailableForTaxon) {
+ filteredChildren.add(featureChild);
+ }else if (featureChild.isAvailableForTaxonName() && isAvailableForTaxonName) {
+ filteredChildren.add(featureChild);
+ }
+ }
+ }
+
+ getVocabularyToChildTermMap().put(voc, filteredChildren);
+ }else{
+ filteredChildren = children;
+ }
+ return filteredChildren;
+ }
+
+
+}
import eu.etaxonomy.cdm.model.common.Annotation;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.Credit;
+import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
import eu.etaxonomy.cdm.model.common.Extension;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
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.location.NamedArea;
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
import eu.etaxonomy.taxeditor.ui.section.description.detail.IndividualsAssociationDetailElement;
import eu.etaxonomy.taxeditor.ui.section.description.detail.QuantitativeDataDetailElement;
import eu.etaxonomy.taxeditor.ui.section.description.detail.TaxonInteractionDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.description.detail.TemporalDataDetailElement;
import eu.etaxonomy.taxeditor.ui.section.description.detail.TextDataDetailElement;
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailElement;
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterDetailSection;
public RightsSection createRightsSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
RightsSection section = new RightsSection(this, conversation, parentElement, style);
+
addAndAdaptSection(parentElement, section);
return section;
}
} else if (entity instanceof TaxonInteraction) {
detailedDescriptionElement = new TaxonInteractionDetailElement(this, parentElement,
(TaxonInteraction) entity, style);
+ } else if (entity instanceof TemporalData) {
+ detailedDescriptionElement = new TemporalDataDetailElement(this, parentElement, (TemporalData) entity, style);
} else if (entity instanceof TextData) {
detailedDescriptionElement = new TextDataDetailElement(this, parentElement, (TextData) entity, style);
- } else {
+ }
+ else {
throw new IllegalStateException("There is no interface for the given description element");
}
adapt(detailedDescriptionElement);
return element;
}
+ /**
+ * @param extendedTimePeriodElement
+ * @param twistie
+ * @return
+ */
+ public ExtendedTimeDetailSection createExtendedTimeDetailSection(
+ ExtendedTimePeriodElement parentElement, int style) {
+ ExtendedTimeDetailSection section = new ExtendedTimeDetailSection(this, parentElement, style);
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+ public ExtendedTimePeriodElement createExtendedTimePeriodElement(
+ ICdmFormElement parentElement, String labelString, ExtendedTimePeriod timePeriod, int style) {
+ ExtendedTimePeriodElement section = new ExtendedTimePeriodElement(this, parentElement, labelString, timePeriod, style);
+ parentElement.addElement(section);
+ adapt(section);
+ return section;
+ }
+
// public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
// RichTextWithLabelElement element = new RichTextWithLabelElement(this, parentElement, labelString,
public class DateDetailSection<T extends TimePeriod>\r
extends AbstractFormSection<T> {\r
protected TextWithLabelElement text_freeText;\r
- private PartialElement partialElement_start;\r
- private PartialElement partialElement_end;\r
- private CheckboxElement period_continue;\r
- private TextWithLabelElement text_parseText;\r
- private TextWithLabelElement text_VerbatimDate = null;\r
- private int cursorPosition;\r
- private boolean includeVerbatim;\r
+ protected PartialElement partialElement_start;\r
+ protected PartialElement partialElement_end;\r
+ protected CheckboxElement period_continue;\r
+ protected TextWithLabelElement text_parseText;\r
+ protected TextWithLabelElement text_VerbatimDate = null;\r
+ protected int cursorPosition;\r
+ protected boolean includeVerbatim;\r
\r
public int getCursorPosition() {\r
return cursorPosition;\r
--- /dev/null
+/**
+* Copyright (C) 2020 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.element;
+
+import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
+
+/**
+ * @author k.luther
+ * @since Jun 12, 2020
+ */
+public class ExtendedTimeDetailSection extends DateDetailSection<ExtendedTimePeriod> {
+
+ private PartialElement partialElement_extremeStart;
+ private PartialElement partialElement_extremeEnd;
+ /**
+ * @param formFactory
+ * @param parentElement
+ * @param includeVerbatim
+ * @param style
+ */
+ protected ExtendedTimeDetailSection(CdmFormFactory formFactory, ICdmFormElement parentElement,
+ int style) {
+ super(formFactory, parentElement, false, style);
+
+// this.includeVerbatim = includeVerbatim;
+
+
+ partialElement_extremeStart = formFactory.createPartialElement(this, "Extreme Start", null, style);
+ partialElement_start = formFactory.createPartialElement(this,
+ "Start ", null, 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_extremeEnd = formFactory.createPartialElement(this, "Extreme End ",
+ null, style);
+
+ text_freeText = formFactory.createTextWithLabelElement(this,
+ "Freetext", null, style);
+ text_freeText.getMainControl().setLayoutData(
+ LayoutConstants.FILL_HORIZONTALLY(6, 1));
+
+
+ formFactory.addPropertyChangeListener(this);
+
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected ExtendedTimePeriod newInstance(){
+ return ExtendedTimePeriod.NewExtendedInstance();
+
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2020 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.element;
+
+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;
+
+/**
+ * @author k.luther
+ * @since Jun 12, 2020
+ */
+public class ExtendedTimePeriodElement extends AbstractCdmFormElement implements ISelectable {
+
+ protected ExtendedTimePeriod timePeriod;
+ protected Label label;
+ protected ExtendedTimeDetailSection section_dateDetails;
+
+ /**
+ * @param formFactory
+ * @param parentElement
+ * @param labelString
+ * @param timePeriod
+ * @param style
+ */
+ public ExtendedTimePeriodElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
+ ExtendedTimePeriod timePeriod, int style) {
+ super(formFactory, parentElement);
+ label = formFactory.createLabel(getLayoutComposite(), labelString);
+
+ addControl(label);
+
+ section_dateDetails = createDateDetailSection();
+ addControl(section_dateDetails);
+
+ setTimePeriod(timePeriod);
+
+ formFactory.addPropertyChangeListener(this);
+ }
+
+ protected ExtendedTimeDetailSection createDateDetailSection() {
+ return formFactory.createExtendedTimeDetailSection(this,
+ Section.TWISTIE);
+ }
+
+ @Override
+ public void setBackground(Color color) {
+ label.setBackground(color);
+ section_dateDetails.setBackground(color);
+ }
+
+ @Override
+ public void setSelected(boolean selected) {
+ setBackground(selected ? SELECTED : getPersistentBackground());
+ }
+
+ public void setLabel(String string) {
+ label.setText(string);
+ }
+
+ public void setTimePeriod(ExtendedTimePeriod timePeriod) {
+ this.timePeriod = timePeriod;
+ if (timePeriod != null) {
+ section_dateDetails.setEntity(timePeriod);
+ }
+ }
+
+}
super(formFactory, formElement);
TableWrapLayout layout = LayoutConstants.LAYOUT(7, false);
- layout.horizontalSpacing = 5;
- formElement.getLayoutComposite().setLayout(layout);
+ formElement.getLayoutComposite().setLayout(layout);
label = formFactory.createLabel(getLayoutComposite(), labelString);
addControl(label);
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Label;
-
import eu.etaxonomy.cdm.model.common.TimePeriod;
-public abstract class TimePeriodElementBase<T extends TimePeriod>
- extends AbstractCdmFormElement
+public abstract class TimePeriodElementBase<T extends TimePeriod>
+ extends AbstractCdmFormElement
implements ISelectable {
-
+
+
+
+ protected T timePeriod;
+ protected Label label;
+ protected DateDetailSection<T> section_dateDetails;
+
/**
* <p>
* Constructor for TimePeriodElement.
formFactory.addPropertyChangeListener(this);
}
- protected abstract DateDetailSection<T> createDateDetailSection();
-
- protected T timePeriod;
- protected Label label;
- protected DateDetailSection<T> section_dateDetails;
+ protected abstract DateDetailSection<T> createDateDetailSection();
/**
* <p>
if(feature.isSupportsQuantitativeData()){count++;}
if(feature.isSupportsTaxonInteraction()){count++;}
if(feature.isSupportsTextData()){count++;}
+ if(feature.isSupportsTemporalData()){count++;}
return count > 1;
}
--- /dev/null
+/**
+* Copyright (C) 2020 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.section.description.detail;
+
+import eu.etaxonomy.cdm.model.description.TemporalData;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ExtendedTimePeriodElement;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+
+/**
+ * @author k.luther
+ * @since Jun 12, 2020
+ */
+public class TemporalDataDetailElement extends AbstractDetailedDescriptionDetailElement<TemporalData> {
+
+ ExtendedTimePeriodElement timePeriod;
+
+ /**
+ * @param formFactory
+ * @param formElement
+ * @param entity
+ * @param style
+ */
+ public TemporalDataDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement, TemporalData entity,
+ int style) {
+ super(formFactory, formElement, entity, style);
+
+ }
+
+ @Override
+ protected void createControls(ICdmFormElement formElement, TemporalData entity, int style) {
+ timePeriod = formFactory.createExtendedTimePeriodElement(formElement, "Flowering Season", entity.getPeriod(), style);
+
+
+ }
+
+}
\r
private CheckboxElement supportsCommonTaxonName;\r
\r
+ private CheckboxElement supportsTemporalData;\r
+\r
private StateVocabularyCollectionSection sectionStateVocabularies;\r
\r
private MeasurementUnitCollectionSection sectionMeasurementUnits;\r
supportsTaxonInteraction = formFactory.createCheckbox(formElement, "Supports Taxon Interaction", entity.isSupportsTaxonInteraction(), style);\r
supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style);\r
supportsCommonTaxonName = formFactory.createCheckbox(formElement, "Supports Common Taxon Name", entity.isSupportsCommonTaxonName(), style);\r
+ supportsTemporalData = formFactory.createCheckbox(formElement, "Supports Temporal Data", entity.isSupportsTemporalData(), style);\r
\r
if (supportsCategoricalData.getSelection()) {\r
sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),\r
else if(eventSource == supportsCommonTaxonName){\r
getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());\r
}\r
+ else if(eventSource == supportsTemporalData){\r
+ getEntity().setSupportsTemporalData(supportsTemporalData.getSelection());\r
+ }\r
else if(eventSource == availableForSpecimenOrObservation){\r
getEntity().setAvailableForOccurrence(availableForSpecimenOrObservation.getSelection());\r
}\r