Project

General

Profile

« Previous | Next » 

Revision ec00e362

Added by Katja Luther over 4 years ago

ref #8410: add nomencl. code edition

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/EnumComboElement.java
20 20

  
21 21
import org.eclipse.swt.events.SelectionEvent;
22 22

  
23
import eu.etaxonomy.cdm.model.term.IEnumTerm;
24
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
25 23
import eu.etaxonomy.cdm.model.media.ExternalLinkType;
26 24
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
25
import eu.etaxonomy.cdm.model.name.NomenclaturalCodeEdition;
27 26
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
27
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
28 28
import eu.etaxonomy.cdm.model.reference.ReferenceType;
29
import eu.etaxonomy.cdm.model.term.IEnumTerm;
29 30
import eu.etaxonomy.taxeditor.model.AbstractUtility;
30 31
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
31 32
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
......
137 138
				return OriginalSourceType.class;
138 139
			}
139 140

  
140
		}
141
		},
142
        new CdmEnumDataHolder<NomenclaturalCodeEdition>(){
143

  
144
            @Override
145
            public String getName() {
146
                return "Nomenclatural Code Edition";
147
            }
148

  
149
            @Override
150
            public Collection<NomenclaturalCodeEdition> getElements() {
151
                return Arrays.asList(NomenclaturalCodeEdition.values());
152
            }
153

  
154
            @Override
155
            public Class<NomenclaturalCodeEdition> getClazz() {
156
                return NomenclaturalCodeEdition.class;
157
            }
158

  
159
        }
141 160

  
142 161
	};
143 162

  
......
167 186
			return "Orig. Source Type";
168 187
		} else if(enumType.equals(SpecimenOrObservationType.class)) {
169 188
			return "Spec./Obs. Type";
170
		}
171
		else if(enumType.equals(ExternalLinkType.class)) {
189
		} else if(enumType.equals(ExternalLinkType.class)) {
172 190
            return "Type";
191
        } else if(enumType.equals(NomenclaturalCodeEdition.class)) {
192
            return "Nomencl. Code Edition";
173 193
        }
174 194
		return "No Label";
175 195
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
240 240
import eu.etaxonomy.taxeditor.ui.section.name.NonViralNameDetailSection;
241 241
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
242 242
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
243
import eu.etaxonomy.taxeditor.ui.section.name.RuleConsideredElement;
243 244
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
244 245
import eu.etaxonomy.taxeditor.ui.section.name.TextTypeDesignationElement;
245 246
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
......
3232 3233
	        return section;
3233 3234
	}
3234 3235

  
3236
	  /**
3237
     * <p>
3238
     * createTextWithLabelElement
3239
     * </p>
3240
     *
3241
     * @param parentElement
3242
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3243
     *            object.
3244
     * @param labelString
3245
     *            a {@link java.lang.String} object.
3246
     * @param initialText
3247
     *            a {@link java.lang.String} object.
3248
     * @param textLimit maximal number of characters allowed
3249
     * @param style
3250
     *            a int.
3251
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3252
     *         object.
3253
     */
3254
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString,
3255
            NameRelationship relation, int style) {
3256

  
3235 3257

  
3258
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, relation, style);
3259
        adapt(element);
3260
        parentElement.addElement(element);
3261
        return element;
3262
    }
3236 3263

  
3264
    /**
3265
     * <p>
3266
     * createTextWithLabelElement
3267
     * </p>
3268
     *
3269
     * @param parentElement
3270
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3271
     *            object.
3272
     * @param labelString
3273
     *            a {@link java.lang.String} object.
3274
     * @param initialText
3275
     *            a {@link java.lang.String} object.
3276
     * @param textLimit maximal number of characters allowed
3277
     * @param style
3278
     *            a int.
3279
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3280
     *         object.
3281
     */
3282
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString,
3283
            NomenclaturalStatus status, int style) {
3284

  
3285

  
3286
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, status, style);
3287
        adapt(element);
3288
        parentElement.addElement(element);
3289
        return element;
3290
    }
3291
    /**
3292
     * <p>
3293
     * createTextWithLabelElement
3294
     * </p>
3295
     *
3296
     * @param parentElement
3297
     *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
3298
     *            object.
3299
     * @param labelString
3300
     *            a {@link java.lang.String} object.
3301
     * @param initialText
3302
     *            a {@link java.lang.String} object.
3303
     * @param textLimit maximal number of characters allowed
3304
     * @param style
3305
     *            a int.
3306
     * @return a {@link eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement}
3307
     *         object.
3308
     */
3309
    public RuleConsideredElement createRuleConsideredElement(ICdmFormElement parentElement, String labelString,
3310
            int style) {
3311

  
3312

  
3313
        RuleConsideredElement element = new RuleConsideredElement(this, parentElement, labelString, style);
3314
        adapt(element);
3315
        parentElement.addElement(element);
3316
        return element;
3317
    }
3237 3318

  
3238 3319

  
3239 3320
//	public RichTextWithLabelElement createRichTextLabelElement(ICdmFormElement parentElement, String labelString, String initialText, int textHeight, int style) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipDetailElement.java
21 21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22 22
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23 23
import eu.etaxonomy.taxeditor.ui.element.LabelElement;
24
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
25 24
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
26 25
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
27 26

  
......
34 33
 */
35 34
public class NameRelationshipDetailElement extends AbstractReferencedEntityElement<NameRelationship>{
36 35

  
37
	private TextWithLabelElement text_ruleConsidered;
36
	private RuleConsideredElement ruleConsidered;
38 37
	private EntitySelectionElement selection_toName;
39 38
	private TermComboElement<NameRelationshipType> combo_relationshipType;
40 39
	private LabelElement label;
......
62 61
	public void createControls(ICdmFormElement element, int style) {
63 62
		label = formFactory.createLabel(element, null);
64 63

  
65
		text_ruleConsidered = formFactory.createTextWithLabelElement(element, "Rule Considered", null, SWT.NULL);
64
		ruleConsidered = formFactory.createRuleConsideredElement(element, "Rule Considered", SWT.NULL);
66 65

  
67 66
		super.createControls(element, style);
68 67
	}
......
73 72
		String text = entity.getFromName().getTitleCache() + " is " + entity.getType().getLabel() + " " + entity.getToName().getTitleCache();
74 73

  
75 74
		label.setText(text);
76
		text_ruleConsidered.setText(entity.getRuleConsidered());
75
		ruleConsidered.setNameRelation(entity);
77 76

  
78 77
		super.setEntity(entity);
79 78
	}
......
81 80
	/** {@inheritDoc} */
82 81
	@Override
83 82
	public void handleEvent(Object eventSource) {
84
		if(eventSource == combo_relationshipType){
83
	if(eventSource == combo_relationshipType){
85 84
			getEntity().setType(combo_relationshipType.getSelection());
86 85
		}
87 86
		else if(eventSource == selection_toName){
88 87
			MessagingUtils.error(getClass(), "No API call available.", null);
89 88
		}
90
		else if(eventSource == text_ruleConsidered){
91
			getEntity().setRuleConsidered(text_ruleConsidered.getText());
89
		else if(eventSource == ruleConsidered.textRuleConsidered){
90
			getEntity().setRuleConsidered(ruleConsidered.textRuleConsidered.getText());
92 91
		}
93 92
		else if(eventSource == selection_reference){
94 93
			getEntity().setCitation(selection_reference.getSelection());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NomenclaturalStatusElement.java
36 36

  
37 37
	private TextWithLabelElement ruleConsideredText;
38 38

  
39

  
40

  
39 41
	private final SelectionArbitrator selectionArbitrator;
40 42

  
41 43
	public NomenclaturalStatusElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/RuleConsideredElement.java
1
/**
2
* Copyright (C) 2019 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.name;
10

  
11
import java.util.HashMap;
12
import java.util.Map;
13

  
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.events.SelectionListener;
16

  
17
import eu.etaxonomy.cdm.model.name.NameRelationship;
18
import eu.etaxonomy.cdm.model.name.NomenclaturalCodeEdition;
19
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
20
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
21
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
23
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
25

  
26

  
27
/**
28
 * @author k.luther
29
 * @since 17.09.2019
30
 */
31
public class RuleConsideredElement extends AbstractCdmFormElement implements SelectionListener {
32

  
33
    protected TextWithLabelElement textRuleConsidered;
34

  
35
    protected EnumComboElement<NomenclaturalCodeEdition> nomenclaturalCodeEdition;
36

  
37
    Map<String, Integer> nomenclaturalCodeEditionStringMap;
38

  
39
    private NomenclaturalStatus status = null;
40

  
41

  
42
    private NameRelationship nameRelation = null;
43

  
44
    /**
45
     * @param cdmFormFactory
46
     * @param parentElement
47
     * @param labelString
48
     * @param initialRule
49
     * @param style
50
     */
51
    public RuleConsideredElement( CdmFormFactory formFactory, ICdmFormElement formElement, String labelString, int style) {
52
        super(formFactory, formElement);
53
        this.textRuleConsidered = formFactory.createTextWithLabelElement(formElement, "Rule considered", null, style);
54
        this.nomenclaturalCodeEdition = formFactory.createEnumComboElement(NomenclaturalCodeEdition.class, formElement, null, style);
55
        nomenclaturalCodeEditionStringMap = new HashMap<>();
56
        nomenclaturalCodeEdition.addSelectionListener(this);
57

  
58
    }
59

  
60

  
61
    /**
62
     * @param cdmFormFactory
63
     * @param parentElement
64
     * @param labelString
65
     * @param initialRule
66
     * @param style
67
     */
68
    public RuleConsideredElement( CdmFormFactory formFactory, ICdmFormElement formElement, String labelString, NomenclaturalStatus status, int style) {
69
        super(formFactory, formElement);
70
        this.textRuleConsidered = formFactory.createTextWithLabelElement(formElement, "Rule considered", null, style);
71
        this.nomenclaturalCodeEdition =  formFactory.createEnumComboElement(NomenclaturalCodeEdition.class, formElement, null, style);
72

  
73
        nomenclaturalCodeEditionStringMap = new HashMap<>();
74

  
75

  
76
        this.status = status;
77
        textRuleConsidered.setText(status.getRuleConsidered());
78

  
79
        nomenclaturalCodeEdition.addSelectionListener(this);
80

  
81
    }
82

  
83
    /**
84
     * @param cdmFormFactory
85
     * @param parentElement
86
     * @param labelString
87
     * @param initialRule
88
     * @param style
89
     */
90
    public RuleConsideredElement( CdmFormFactory formFactory, ICdmFormElement formElement, String labelString, NameRelationship relation, int style) {
91
        super(formFactory, formElement);
92
        this.textRuleConsidered = formFactory.createTextWithLabelElement(formElement, "Rule considered", null, style);
93

  
94
        this.nomenclaturalCodeEdition =  formFactory.createEnumComboElement(NomenclaturalCodeEdition.class, formElement, null, style);
95

  
96
        nomenclaturalCodeEditionStringMap = new HashMap<>();
97

  
98
        this.nameRelation = relation;
99
        textRuleConsidered.setText(nameRelation.getRuleConsidered());
100

  
101
        nomenclaturalCodeEdition.addSelectionListener(this);
102

  
103
    }
104

  
105

  
106
    public NomenclaturalStatus getStatus() {
107
        return status;
108
    }
109

  
110

  
111
    public void setStatus(NomenclaturalStatus status) {
112
        this.status = status;
113
    }
114

  
115

  
116
    public NameRelationship getNameRelation() {
117
        return nameRelation;
118
    }
119

  
120

  
121
    public void setNameRelation(NameRelationship nameRelation) {
122
        this.nameRelation = nameRelation;
123
        this.textRuleConsidered.setText(getText());
124
        this.nomenclaturalCodeEdition.setSelection(getCodeEdition());
125
    }
126

  
127
    public String getText(){
128
        return this.nameRelation.getRuleConsidered();
129
    }
130

  
131
    public NomenclaturalCodeEdition getCodeEdition(){
132
        return this.nameRelation.getCodeEdition();
133
    }
134
    @Override
135
    public void widgetSelected(SelectionEvent e) {
136
       //if (e.getSource().equals(nomenclaturalCodeEdition)){
137
            NomenclaturalCodeEdition edition =  nomenclaturalCodeEdition.getSelection();
138
            if (status != null){
139
                this.status.setCodeEdition(edition);
140
            }else if (nameRelation != null){
141
                this.nameRelation.setCodeEdition(edition);
142
            }
143
     //   }
144

  
145
    }
146

  
147
    @Override
148
    public void widgetDefaultSelected(SelectionEvent e) {
149
        // TODO Auto-generated method stub
150

  
151
    }
152

  
153

  
154
    public void handleEvent(Object eventSource) {
155
        if(eventSource == textRuleConsidered){
156
            if (status != null){
157
                status.setRuleConsidered(textRuleConsidered.getText());
158
            }else if (nameRelation != null){
159
                nameRelation.setRuleConsidered(textRuleConsidered.getText());
160
            }
161
        }
162

  
163
    }
164

  
165

  
166
}

Also available in: Unified diff