*/
package eu.etaxonomy.taxeditor.ui.section.feature;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Label;
+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.Representation;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermBasePropertyTester;
+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.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.section.vocabulary.DefinedTermDetailElement;
+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;
import eu.etaxonomy.taxeditor.ui.section.vocabulary.RecommendedModifierVocabulariesCollectionSection;
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StateVocabularyCollectionSection;
import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollectionSection;
/**
- *
* @author pplitzner
* @since Dec 21, 2017
- *
*/
-public class CharacterDetailElement extends DefinedTermDetailElement<Character> {
+public class CharacterDetailElement extends AbstractCdmDetailElement<Character> {
private ICdmFormElement parentFormElement;
+ private RepresentationElement element_Representation;
+
+ // private TermComboElement<DefinedTerm> comboStructuralModifier;
+
private CheckboxElement supportsQuantitativeData;
private CheckboxElement supportsCategoricalData;
+ private CheckboxElement availableForTaxon;
+ private CheckboxElement availableForTaxonName;
+ private CheckboxElement availableForSpecimenOrObservation;
+
+
private StateVocabularyCollectionSection sectionStateVocabularies;
private MeasurementUnitCollectionSection sectionMeasurementUnits;
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) {
@Override
protected void createControls(ICdmFormElement formElement, Character entity, int style) {
- super.createControls(formElement, entity, style);
this.parentFormElement = formElement;
+ 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);
+ 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);
+ 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);
+ 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
- );
+ parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, entity.getClass().getCanonicalName(), true));
sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- sectionModifierVocabularies.setEntity(getEntity());
-
- //if any type is selected disable supportsTextData
- entity.setSupportsTextData(false);
+ sectionModifierVocabularies.setEntity(entity);
}
+
+
+ }
+// 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) {
+ super.setEntity(entity);
+ setEnabled(TermBasePropertyTester.isModifiable(entity));
}
@Override
public void handleEvent(Object eventSource) {
- super.handleEvent(eventSource);
+// if(eventSource == comboStructuralModifier){
+// getEntity().setStructureModifier(comboStructuralModifier.getSelection());
+// }
+ 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()){
- sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),
- parentFormElement, ExpandableComposite.TWISTIE);
- sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- sectionMeasurementUnits.setEntity(getEntity());
-
- sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
- getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
- sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- sectionStatisticalMeasures.setEntity(getEntity());
-
- if (!supportsCategoricalData.getSelection()) {
- sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
- getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
- sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- sectionModifierVocabularies.setEntity(getEntity());
- }
+ activateQuantitativeWidgets();
}
else{
- if(sectionMeasurementUnits!=null){
- removeElementsAndControls(sectionMeasurementUnits);
- removeElementsAndControls(sectionStatisticalMeasures);
- if(!supportsCategoricalData.getSelection()){
- removeElementsAndControls(sectionModifierVocabularies);
- }
- }
+ removeQuantitativeWidgets();
}
+ StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
}
else if(eventSource == supportsCategoricalData){
getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());
if (supportsCategoricalData.getSelection()) {
- sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),
- parentFormElement, ExpandableComposite.TWISTIE);
- sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- sectionStateVocabularies.setEntity(getEntity());
-
- if (!supportsQuantitativeData.getSelection()) {
- sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
- getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);
- sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- sectionModifierVocabularies.setEntity(getEntity());
- }
+ activateCategoricalWidgets();
}
else{
- if(sectionStateVocabularies!=null){
- removeElementsAndControls(sectionStateVocabularies);
- if(!supportsQuantitativeData.getSelection()){
- removeElementsAndControls(sectionModifierVocabularies);
- }
- }
+ removeCategoricalWidgets();
}
+ StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
}
+ else if (eventSource == element_Representation) {
+ Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
+ if(selectedRepresentation!=null){
+ Language representationLanguage = selectedRepresentation.getLanguage();
+ if(representationLanguage==null){
+ representationLanguage = Language.getDefaultLanguage();
+ }
+ getEntity().setLabel(selectedRepresentation.getLabel(), representationLanguage);
+ getEntity().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
+ getEntity().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
+ }
+ 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(){
+ //disable categorical widgets
+ supportsCategoricalData.setSelection(false);
+ getEntity().setSupportsCategoricalData(false);
+ removeCategoricalWidgets();
+
+ //measurement units
+ 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(
+ parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
+ sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ sectionStatisticalMeasures.setEntity(getEntity());
+
+ //modifiers
+ sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
+ parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
+ sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ sectionModifierVocabularies.setEntity(getEntity());
+ }
+
+ private void removeQuantitativeWidgets(){
+ if(sectionMeasurementUnits!=null){
+ removeElementsAndControls(sectionMeasurementUnits);
+ removeElementsAndControls(sectionStatisticalMeasures);
+ removeElementsAndControls(sectionModifierVocabularies);
+ }
+ }
+
+ private void activateCategoricalWidgets(){
+ //disable quantitative widgeets
+ supportsQuantitativeData.setSelection(false);
+ getEntity().setSupportsQuantitativeData(false);
+ removeQuantitativeWidgets();
+
+ //states
+ 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(
+ parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
+ sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ sectionModifierVocabularies.setEntity(getEntity());
+ }
+
+ private void removeCategoricalWidgets(){
+ if(sectionStateVocabularies!=null){
+ removeElementsAndControls(sectionStateVocabularies);
+ removeElementsAndControls(sectionModifierVocabularies);
+ }
+ }
+
+ @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()));
+ }
+
}
}