X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/1a4fe38f3d3fc0d3e4a43103dffdc4d82c347c89..76d3226c289a49725722da4dfc2035bdde0eef46:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/CharacterDetailElement.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/CharacterDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/CharacterDetailElement.java index b5c8cb29f..c54578e78 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/CharacterDetailElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/CharacterDetailElement.java @@ -8,13 +8,13 @@ */ package eu.etaxonomy.taxeditor.ui.section.feature; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.swt.widgets.Text; import eu.etaxonomy.cdm.model.common.Language; import eu.etaxonomy.cdm.model.description.Character; import eu.etaxonomy.cdm.model.term.DefinedTerm; -import eu.etaxonomy.cdm.model.term.FeatureNode; import eu.etaxonomy.cdm.model.term.Representation; import eu.etaxonomy.cdm.model.term.TermType; import eu.etaxonomy.taxeditor.editor.definedterm.TermBasePropertyTester; @@ -22,11 +22,13 @@ import eu.etaxonomy.taxeditor.model.ColorResources; import eu.etaxonomy.taxeditor.preference.Resources; import eu.etaxonomy.taxeditor.store.CdmStore; import eu.etaxonomy.taxeditor.store.StoreUtil; -import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; +import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; +import eu.etaxonomy.taxeditor.ui.element.LabelElement; import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; +import eu.etaxonomy.taxeditor.ui.element.RemovableTextElement; import eu.etaxonomy.taxeditor.ui.element.RepresentationElement; import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection; @@ -35,16 +37,14 @@ import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSec import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection; /** - * * @author pplitzner * @since Dec 21, 2017 - * */ public class CharacterDetailElement extends AbstractCdmDetailElement { private ICdmFormElement parentFormElement; - protected RepresentationElement element_Representation; + private RepresentationElement element_Representation; private TermComboElement comboStructuralModifier; @@ -52,6 +52,11 @@ public class CharacterDetailElement extends AbstractCdmDetailElement private CheckboxElement supportsCategoricalData; + private CheckboxElement availableForTaxon; + private CheckboxElement availableForTaxonName; + private CheckboxElement availableForSpecimenOrObservation; + + private StateVocabularyCollectionSection sectionStateVocabularies; private MeasurementUnitCollectionSection sectionMeasurementUnits; @@ -59,6 +64,21 @@ public class CharacterDetailElement extends AbstractCdmDetailElement private StatisticalMeasureCollectionSection sectionStatisticalMeasures; private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies; + private Label labelText_structure; + private Text text_structure; + + private Label labelText_property; + private Text text_property; + + private RemovableTextElement ratioTo; +// private Label labelText_ratioTo; +// private Text text_ratioTo; +// private Button button_remove; + + +// private TextWithLabelElement text_structure; +// private TextWithLabelElement text_property; + public CharacterDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) { @@ -68,57 +88,83 @@ public class CharacterDetailElement extends AbstractCdmDetailElement @Override protected void createControls(ICdmFormElement formElement, Character entity, int style) { this.parentFormElement = formElement; - element_Representation = formFactory.createTranslatableRepresentationElement(formElement, getEntity().getPreferredRepresentation(CdmStore.getDefaultLanguage()),getEntity(), 100, style, true); - Label lblStructure = new Label(formElement.getLayoutComposite(), style); - lblStructure.setText("Structure"); - Label lblStructureText = new Label(formElement.getLayoutComposite(), style); - lblStructureText.setText(getPath(entity.getStructure())); - lblStructureText.setForeground(ColorResources.getColor(Resources.BLACK)); - Label lblProperty = new Label(formElement.getLayoutComposite(), style); - lblProperty.setText("Property"); - Label lblPropertyText = new Label(formElement.getLayoutComposite(), style); - lblPropertyText.setForeground(ColorResources.getColor(Resources.BLACK)); - lblPropertyText.setText(getPath(entity.getProperty())); + element_Representation = formFactory.createTranslatableRepresentationElement(formElement, entity.getPreferredRepresentation(CdmStore.getDefaultLanguage()),entity, 100, style, true); + if (labelText_property != null){ + labelText_structure.dispose(); + } + labelText_structure = new Label(formElement.getLayoutComposite(), SWT.NONE); + labelText_structure.setText("Structure"); + if (text_structure != null){ + text_structure.dispose(); + } + text_structure = new Text(formElement.getLayoutComposite(), SWT.WRAP); + text_structure.setText( CharacterNodeDetailElement.getStructureText(entity)); + text_structure.setEditable(false); + text_structure.setLayoutData(LayoutConstants.FILL()); + text_structure.setForeground(ColorResources.getColor(Resources.BLACK)); + if (labelText_property != null){ + labelText_property.dispose(); + } + labelText_property = new Label(formElement.getLayoutComposite(), SWT.NONE); + labelText_property.setText("Property"); + if (text_property != null){ + text_property.dispose(); + } + text_property = new Text(formElement.getLayoutComposite(), SWT.WRAP); + text_property.setEditable(false); + text_property.setText( CharacterNodeDetailElement.getPropertyText(entity)); + text_property.setLayoutData(LayoutConstants.FILL()); + text_property.setForeground(ColorResources.getColor(Resources.BLACK)); comboStructuralModifier = formFactory.createDefinedTermComboElement(TermType.StructureModifier, formElement, "Structural Modifier", entity.getStructureModifier(), style); + ratioTo = formFactory.createRemovableTextField(formElement, "Ratio to", CharacterNodeDetailElement.getRatioToText(entity), style); + supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.isSupportsQuantitativeData(), style); supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style); + LabelElement availableLabel = formFactory.createLabel(formElement, "Available for"); + availableLabel.setBold(); + + availableForTaxon = formFactory.createCheckbox(formElement, "Taxon", entity.isAvailableForTaxon(), style); + availableForTaxonName = formFactory.createCheckbox(formElement, "Taxon Name", entity.isAvailableForTaxonName(), style); + availableForSpecimenOrObservation = formFactory.createCheckbox(formElement, "Occurrence", entity.isAvailableForOccurrence(), style); + if (supportsCategoricalData.getSelection()) { - sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), - parentFormElement, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED); + sectionStateVocabularies = formFactory.createStateVocabulariesSection( + parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, entity.getClass().getCanonicalName(), true)); sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionStateVocabularies.setEntity(getEntity()); + sectionStateVocabularies.setEntity(entity); } if (supportsQuantitativeData.getSelection()) { - sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), - parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection( + parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, entity.getClass().getCanonicalName(), true)); sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionMeasurementUnits.setEntity(getEntity()); + sectionMeasurementUnits.setEntity(entity); - sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), - parentFormElement, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED); + sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection( + parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, entity.getClass().getCanonicalName(), true)); sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionStatisticalMeasures.setEntity(getEntity()); + sectionStatisticalMeasures.setEntity(entity); } if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) { sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection( - getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, entity.getClass().getCanonicalName(), true)); sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionModifierVocabularies.setEntity(getEntity()); + sectionModifierVocabularies.setEntity(entity); } - } - private String getPath(FeatureNode node){ - String path = node.getTerm().getLabel(); - FeatureNode parent = node.getParent(); - while(parent != null && parent.getTerm()!=null){ - path = parent.getTerm().getLabel() + "/" + path; - parent = parent.getParent(); - } - return path; - } + + } +// public void createText(ICdmFormElement formElement, String label, String path) { +// labelText = new Label(formElement.getLayoutComposite(), SWT.NONE); +// labelText.setText(label); +// Text text = new Text(formElement.getLayoutComposite(), SWT.WRAP); +// text.setText(path); +// text.setEditable(false); +// text.setLayoutData(LayoutConstants.FILL()); +// text.setForeground(ColorResources.getColor(Resources.BLACK)); +// } @Override public void setEntity(Character entity) { @@ -131,10 +177,16 @@ public class CharacterDetailElement extends AbstractCdmDetailElement if(eventSource == comboStructuralModifier){ getEntity().setStructureModifier(comboStructuralModifier.getSelection()); } - if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){ - //if any type is selected disable supportsTextData - getEntity().setSupportsTextData(false); - } + if(eventSource == ratioTo){ + if (!ratioTo.isState()){ + getEntity().setRatioToStructure(null); + } + } + +// if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){ +// //if any type is selected disable supportsTextData +// getEntity().setSupportsTextData(false); +// } if(eventSource == supportsQuantitativeData){ getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection()); if(supportsQuantitativeData.getSelection()){ @@ -168,6 +220,19 @@ public class CharacterDetailElement extends AbstractCdmDetailElement } getEntity().setTitleCache(null); } + else if(eventSource == availableForSpecimenOrObservation){ + getEntity().setAvailableForOccurrence(availableForSpecimenOrObservation.getSelection()); + + } + else if(eventSource == availableForTaxon){ + getEntity().setAvailableForTaxon(availableForTaxon.getSelection()); + + } + else if(eventSource == availableForTaxonName){ + getEntity().setAvailableForTaxonName(availableForTaxonName.getSelection()); + + } + } private void activateQuantitativeWidgets(){ @@ -177,20 +242,20 @@ public class CharacterDetailElement extends AbstractCdmDetailElement removeCategoricalWidgets(); //measurement units - sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), - parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(parentFormElement, + StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, getEntity().getClass().getCanonicalName(), true)); sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionMeasurementUnits.setEntity(getEntity()); //statistical measures sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection( - getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName(), true)); sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionStatisticalMeasures.setEntity(getEntity()); //modifiers sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection( - getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true)); sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionModifierVocabularies.setEntity(getEntity()); } @@ -210,14 +275,14 @@ public class CharacterDetailElement extends AbstractCdmDetailElement removeQuantitativeWidgets(); //states - sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), - parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + sectionStateVocabularies = formFactory.createStateVocabulariesSection( + parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, getEntity().getClass().getCanonicalName(), true)); sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionStateVocabularies.setEntity(getEntity()); //modifiers sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection( - getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true)); sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionModifierVocabularies.setEntity(getEntity()); } @@ -229,4 +294,26 @@ public class CharacterDetailElement extends AbstractCdmDetailElement } } + @Override + public void fillFields() { + if (getEntity()!= null) { + element_Representation.setTerm(getEntity(), isEnabled()); + comboStructuralModifier.setSelection(getEntity().getStructureModifier()); + supportsQuantitativeData.setSelection(getEntity().isSupportsQuantitativeData()); + supportsCategoricalData.setSelection(getEntity().isSupportsCategoricalData());; + availableForTaxon.setSelection(getEntity().isAvailableForTaxon()); + availableForTaxonName.setSelection(getEntity().isAvailableForTaxonName()); + availableForSpecimenOrObservation.setSelection(getEntity().isAvailableForOccurrence()); + sectionStateVocabularies.setEntity(getEntity()); + sectionMeasurementUnits.setEntity(getEntity()); + sectionStatisticalMeasures.setEntity(getEntity()); + sectionModifierVocabularies.setEntity(getEntity()); + + text_structure.setText(CharacterNodeDetailElement.getStructureText(getEntity())); + text_property.setText(CharacterNodeDtoDetailElement.getPropertyText(getEntity())); + ratioTo.setText(CharacterNodeDetailElement.getRatioToText(getEntity())); + } + + } + }