Project

General

Profile

Download (8.99 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.feature;
10

    
11
import org.eclipse.jface.util.PropertyChangeEvent;
12

    
13
import eu.etaxonomy.cdm.model.description.Character;
14
import eu.etaxonomy.cdm.persistence.dto.CharacterDto;
15
import eu.etaxonomy.cdm.persistence.dto.TermNodeDto;
16
import eu.etaxonomy.taxeditor.editor.definedterm.TermBasePropertyTester;
17
import eu.etaxonomy.taxeditor.event.EventUtility;
18
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
19
import eu.etaxonomy.taxeditor.store.StoreUtil;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
24

    
25
/**
26
 *
27
 * @author pplitzner
28
 * @since Aug 19, 2019
29
 *
30
 */
31
public class CharacterNodeDtoDetailElement extends AbstractCdmDetailElement<TermNodeDto> {
32
    private CharacterDtoDetailSection characterDetails;
33

    
34
    private ICdmFormElement parentFormElement;
35

    
36
    private InapplicableIfEntityCollectionSection sectionInapplicableIf;
37
    private OnlyApplicableIfEntityCollectionSection sectionOnlyApplicableIf;
38

    
39
	public CharacterNodeDtoDetailElement(CdmFormFactory formFactory,
40
			ICdmFormElement formElement) {
41
		super(formFactory, formElement);
42
	}
43

    
44
	@Override
45
	protected void createControls(ICdmFormElement formElement, TermNodeDto entity, int style) {
46
	    this.parentFormElement = formElement;
47
//	    characterDetails = formFactory.createCharacterDetailElement(formElement, style);
48
	    characterDetails = formFactory.createCharacterDtoDetailSection(formElement, null, StoreUtil.getSectionStyle(CharacterDetailSection.class, entity.getClass().getCanonicalName(), true));
49
	    characterDetails.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
50
	    addElement(characterDetails);
51
	    addControl(characterDetails);
52
	    characterDetails.setEntity((CharacterDto)entity.getTerm());
53

    
54
        // applicability
55
        sectionInapplicableIf = formFactory.createInapplicableIfEntityCollectionSection(
56
                formElement, StoreUtil.getSectionStyle(InapplicableIfEntityCollectionSection.class, entity.getTerm().getClass().getCanonicalName()));
57
        sectionInapplicableIf.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
58
        sectionInapplicableIf.setEntity(getEntity());
59
        sectionOnlyApplicableIf = formFactory.createOnlyApplicableIfEntityCollectionSection(
60
                formElement, StoreUtil.getSectionStyle(OnlyApplicableIfEntityCollectionSection.class, entity.getTerm().getClass().getCanonicalName()));
61
        sectionOnlyApplicableIf.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
62
        sectionOnlyApplicableIf.setEntity(entity);
63
    }
64

    
65

    
66

    
67
    public static String getPropertyText(Character entity) {
68
        return entity.getProperty()!=null?StoreUtil.getPath(entity.getProperty()):"[no property]";
69
    }
70

    
71
    public static String getStructureText(Character entity) {
72
        return entity.getStructure()!=null?StoreUtil.getPath(entity.getStructure()):"[no structure]";
73
    }
74

    
75
    @Override
76
    public void setEntity(TermNodeDto entity) {
77
        super.setEntity(entity);
78
        characterDetails.setEntity((CharacterDto)entity.getTerm());
79
        setEnabled(TermBasePropertyTester.isModifiable(entity));
80
    }
81

    
82
    @Override
83
    public void propertyChange(PropertyChangeEvent event) {
84
        EventUtility.postEvent(WorkbenchEventConstants.ADD_SAVE_CHARACTER, getEntity());
85
        super.propertyChange(event);
86

    
87
    }
88

    
89
	@Override
90
	public void handleEvent(Object eventSource) {
91

    
92
//	    if(eventSource == characterDetails){
93
//	        getEntity().getTerm().setStructureModifier(comboStructuralModifier.getSelection());
94
//	    }
95
//	    if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){
96
//	        //if any type is selected disable supportsTextData
97
//	        getEntity().getTerm().setSupportsTextData(false);
98
//	    }
99
//	    if(eventSource == supportsQuantitativeData){
100
//	        getEntity().getTerm().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());
101
//	        if(supportsQuantitativeData.getSelection()){
102
//	            activateQuantitativeWidgets();
103
//	        }
104
//	        else{
105
//	            removeQuantitativeWidgets();
106
//	        }
107
//            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
108
//	    }
109
//	    else if(eventSource == supportsCategoricalData){
110
//	        getEntity().getTerm().setSupportsCategoricalData(supportsCategoricalData.getSelection());
111
//            if (supportsCategoricalData.getSelection()) {
112
//                activateCategoricalWidgets();
113
//            }
114
//	        else{
115
//	            removeCategoricalWidgets();
116
//	        }
117
//            StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
118
//	    }
119
//	    else if (eventSource == element_Representation) {
120
//            Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
121
//            if(selectedRepresentation!=null){
122
//                Language representationLanguage = selectedRepresentation.getLanguage();
123
//                if(representationLanguage==null){
124
//                    representationLanguage = Language.getDefaultLanguage();
125
//                }
126
//                getEntity().getTerm().setLabel(selectedRepresentation.getLabel(),  representationLanguage);
127
//                getEntity().getTerm().getRepresentation(representationLanguage).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
128
//                getEntity().getTerm().getRepresentation(representationLanguage).setText(selectedRepresentation.getDescription());
129
//            }
130
//            getEntity().getTerm().setTitleCache(null);
131
//        }
132
	}
133

    
134
//	private void activateQuantitativeWidgets(){
135
//	    //disable categorical widgets
136
//	    supportsCategoricalData.setSelection(false);
137
//	    getEntity().getTerm().setSupportsCategoricalData(false);
138
//	    removeCategoricalWidgets();
139
//
140
//	    //measurement units
141
//	    sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(
142
//	            parentFormElement, StoreUtil.getSectionStyle(MeasurementUnitCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
143
//	    sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
144
//	    sectionMeasurementUnits.setEntity(getEntity().getTerm());
145
//
146
//	    //statistical measures
147
//	    sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(
148
//	            parentFormElement, StoreUtil.getSectionStyle(StatisticalMeasureCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
149
//	    sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
150
//	    sectionStatisticalMeasures.setEntity(getEntity().getTerm());
151
//
152
//	    //modifiers
153
//	    sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
154
//	            parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
155
//	    sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
156
//	    sectionModifierVocabularies.setEntity(getEntity().getTerm());
157
//	}
158
//
159
//	private void removeQuantitativeWidgets(){
160
//	    if(sectionMeasurementUnits!=null){
161
//	        removeElementsAndControls(sectionMeasurementUnits);
162
//	        removeElementsAndControls(sectionStatisticalMeasures);
163
//	        removeElementsAndControls(sectionModifierVocabularies);
164
//	    }
165
//	}
166
//
167
//	private void activateCategoricalWidgets(){
168
//	    //disable quantitative widgeets
169
//	    supportsQuantitativeData.setSelection(false);
170
//	    getEntity().getTerm().setSupportsQuantitativeData(false);
171
//	    removeQuantitativeWidgets();
172
//
173
//	    //states
174
//	    sectionStateVocabularies = formFactory.createStateVocabulariesSection(
175
//                parentFormElement, StoreUtil.getSectionStyle(StateVocabularyCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
176
//        sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
177
//        sectionStateVocabularies.setEntity(getEntity().getTerm());
178
//
179
//        //modifiers
180
//        sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(
181
//                parentFormElement, StoreUtil.getSectionStyle(RecommendedModifierVocabulariesCollectionSection.class, getEntity().getClass().getCanonicalName(), true));
182
//        sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
183
//        sectionModifierVocabularies.setEntity(getEntity().getTerm());
184
//	}
185
//
186
//	private void removeCategoricalWidgets(){
187
//	    if(sectionStateVocabularies!=null){
188
//	        removeElementsAndControls(sectionStateVocabularies);
189
//	        removeElementsAndControls(sectionModifierVocabularies);
190
//	    }
191
//	}
192

    
193
}
(9-9/28)