Project

General

Profile

Revision 3a9975f6

ID3a9975f6a6d489a36210e991ec44b29d75656b0b
Parent 1ce096c2
Child 3d6f9d14

Added by Katja Luther almost 3 years ago

ref #7215: add combobox for selecting misapplied name type

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/MisappliedRelationshipComboElement.java
1
// $Id$
2
/**
3
* Copyright (C) 2018 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.combo;
11

  
12
import java.util.ArrayList;
13
import java.util.List;
14

  
15
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
16
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
18

  
19
/**
20
 * @author k.luther
21
 * @date 16.02.2018
22
 *
23
 */
24
public class MisappliedRelationshipComboElement extends TermComboElement<TaxonRelationshipType> {
25

  
26
    /**
27
     * @param formFactory
28
     * @param parentElement
29
     * @param termType
30
     * @param labelString
31
     * @param selection
32
     * @param addEmptyElement
33
     * @param style
34
     * @param useAbbrevLabel
35
     * @param comparator
36
     */
37
    public MisappliedRelationshipComboElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
38
             String labelString, TaxonRelationshipType selection, boolean addEmptyElement, int style, boolean useAbbrevLabel) {
39
        super(formFactory, parentElement, TaxonRelationshipType.class, labelString, selection, addEmptyElement, style);
40
        List<TaxonRelationshipType> relTypes = new ArrayList<>();
41
        relTypes.add(TaxonRelationshipType.MISAPPLIED_NAME_FOR());
42
        relTypes.add(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR());
43
        populateTerms(relTypes);
44
    }
45

  
46
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
111 111
import eu.etaxonomy.cdm.model.taxon.Taxon;
112 112
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
113 113
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
114
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
114 115
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
115
import eu.etaxonomy.taxeditor.editor.IDistributionEditor;
116 116
import eu.etaxonomy.taxeditor.model.MessagingUtils;
117 117
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
118
import eu.etaxonomy.taxeditor.ui.combo.MisappliedRelationshipComboElement;
118 119
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
119 120
import eu.etaxonomy.taxeditor.ui.combo.VocabularyComboElement;
120 121
import eu.etaxonomy.taxeditor.ui.dialog.CloneClassificationDetailElement;
......
216 217
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
217 218
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
218 219
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
220
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
219 221
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
220 222
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
221 223
import eu.etaxonomy.taxeditor.ui.section.occurrence.CurrentDeterminationDetailSection;
......
236 238
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailSection;
237 239
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopeDetailSection;
238 240
import eu.etaxonomy.taxeditor.ui.section.occurrence.GeoScopePolyKeyDetailSection;
239
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreaDetailElement;
240 241
import eu.etaxonomy.taxeditor.ui.section.occurrence.OriginalLabelDataSection;
241 242
import eu.etaxonomy.taxeditor.ui.section.occurrence.SourceCollectionDetailSection;
242 243
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenCollectionDetailElement;
......
996 997
	        return null;
997 998
	    }
998 999
	}
1000
	public MisappliedRelationshipComboElement createMisappliedRelationshipComboElement(
1001
	        ICdmFormElement parentElement,
1002
            String labelString,
1003
            TaxonRelationshipType selection,
1004
            int style) {
1005
	    MisappliedRelationshipComboElement combo = new MisappliedRelationshipComboElement(this, parentElement, labelString, selection, false, style, false);
1006
        return combo;
1007
    }
999 1008

  
1000 1009
	public <T extends IEnumTerm<T>> EnumComboElement<T> createEnumComboElement(
1001 1010
	        Class<T> enumComboType, ICdmFormElement parentElement,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java
17 17
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
18 18
import eu.etaxonomy.taxeditor.event.EventUtility;
19 19
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
20
import eu.etaxonomy.taxeditor.ui.combo.MisappliedRelationshipComboElement;
20 21
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
21 22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22 23
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
......
36 37
public class TaxonRelationshipDetailElement extends AbstractCdmDetailElement<TaxonRelationship> {
37 38

  
38 39
	private TermComboElement<TaxonRelationshipTypeInverseContainer> combo_taxonRelationshipType;
40
	private MisappliedRelationshipComboElement combo_misappliedRelationshipType;
39 41

  
40 42
	private EntitySelectionElement<Taxon> selection_relatedTaxon;
41 43
	private CheckboxElement checkBoxDoubtful;
......
61 63
	@Override
62 64
	protected void createControls(ICdmFormElement formElement,
63 65
			TaxonRelationship entity, int style) {
64
		if (!entity.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
65
			combo_taxonRelationshipType = formFactory.createTermComboElement(
66
					TaxonRelationshipTypeInverseContainer.class,
67
					formElement, "Relationship Type",
68
					getTaxonRelationshipTypeInverseContainer(), style);
66
		if (!(entity.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) || entity.getType().equals(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR())) ){
67
		    combo_taxonRelationshipType = formFactory.createTermComboElement(
68
                    TaxonRelationshipTypeInverseContainer.class,
69
                    formElement, "Relationship Type",
70
                    getTaxonRelationshipTypeInverseContainer(), style);
71

  
69 72
			combo_taxonRelationshipType.setEnabled(false);
70 73
			selection_relatedTaxon = formFactory.createSelectionElement(
71 74
					Taxon.class, //getConversationHolder(),
......
74 77
			checkBoxDoubtful = formFactory.createCheckbox(formElement, "Relation is doubtful", entity.isDoubtful(), style);
75 78
		}else{
76 79
			taxon = entity.getFromTaxon();
77
//			toggleable_cache = formFactory.createToggleableTextField(formElement,
78
//					"Title Cache", taxon.getTitleCache(),
79
//					taxon.isProtectedTitleCache(), style);
80
//
81
//			text_appendedPhrase = formFactory.createTextWithLabelElement(
82
//					formElement, "Appended Phrase", taxon.getAppendedPhrase(),
83
//					SWT.WRAP);
84

  
85 80

  
86 81
			taxonElement = formFactory.createTaxonDetailSection(getConversationHolder(), formElement, null, style);
87 82
			taxonElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
88 83
			addControl(taxonElement);
89 84
			addElement(taxonElement);
85
			combo_misappliedRelationshipType = formFactory.createMisappliedRelationshipComboElement(formElement, "Relationship Type",
86
                    entity.getType(), style);
87

  
88
			combo_misappliedRelationshipType.setEnabled(true);
90 89

  
91 90
			sensuReference = formFactory.createSelectionElement(Reference.class,//getConversationHolder(),
92 91
				 formElement, "Sensu",
......
131 130
				getEntity().setCitationMicroReference(text_secundum_microreference.getText());
132 131
			}  else if (eventSource == text_sensu_microreference) {
133 132
		        taxon.setSecMicroReference(text_sensu_microreference.getText());
134
			}else if (eventSource == sensuReference) {
133
			} else if (eventSource == sensuReference) {
135 134
				taxon.setSec(sensuReference.getSelection());
136
			}
135
			} else if (eventSource == combo_taxonRelationshipType) {
136
			    getEntity().setType(combo_taxonRelationshipType.getSelection().getType());
137
        }
137 138
		}else{
138 139
			if (eventSource == selection_relatedTaxon){
139 140
				boolean inverse = getTaxonRelationshipTypeInverseContainer().isInverse();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailSection.java
25 25
import eu.etaxonomy.taxeditor.model.ImageResources;
26 26
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonBaseSelectionDialog;
27 27
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
28
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
28 29
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
29 30
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
30 31
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
......
95 96
                            TaxonRelationship rel = getEntity();
96 97
                            rel.setFromTaxon(taxon);
97 98
                            setEntity(rel);
99
                            detailElement.firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
98 100
                            setTaxonBase(taxon);
99 101

  
100
                            firePropertyChangeEvent(TaxonRelationshipDetailSection.this);
102

  
103
                            firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
101 104
	                    }
102 105
	                }
103 106
	            };

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)