Project

General

Profile

Download (2.92 KB) Statistics
| Branch: | Tag: | Revision:
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.metadata.PreferencePredicate;
16
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
17
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
18
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21

    
22
/**
23
 * @author k.luther
24
 * @date 16.02.2018
25
 *
26
 */
27
public class MisappliedRelationshipComboElement extends TermComboElement<TaxonRelationshipType> {
28
	
29
	
30

    
31
    /**
32
     * @param formFactory
33
     * @param parentElement
34
     * @param termType
35
     * @param labelString
36
     * @param selection
37
     * @param addEmptyElement
38
     * @param style
39
     * @param useAbbrevLabel
40
     * @param comparator
41
     */
42
    public MisappliedRelationshipComboElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
43
             String labelString, TaxonRelationshipType selection, boolean addEmptyElement, int style, boolean useAbbrevLabel) {
44
        super(formFactory, parentElement, TaxonRelationshipType.class, labelString, selection, addEmptyElement, style);
45
        List<TaxonRelationshipType> relTypes = new ArrayList<>();
46
        if (selection.isAnyMisappliedName()){
47

    
48
            relTypes.add(TaxonRelationshipType.MISAPPLIED_NAME_FOR());
49
            relTypes.add(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR());
50
            if (PreferencesUtil.getBooleanValue(PreferencePredicate.AllowPartialMisapplied.getKey())) {
51
            	relTypes.add(TaxonRelationshipType.PARTIAL_MISAPPLIED_NAME_FOR());
52
            }
53
        }else if (selection.isAnySynonym()){
54
            relTypes.add(TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR());
55
            relTypes.add(TaxonRelationshipType.PARTIAL_SYNONYM_FOR());
56
        }
57
        addTerms(relTypes);
58
        populateTerms();
59
        setSelection(selection);
60
    }
61
    @Override
62
    protected List<TaxonRelationshipType> getPreferredTerms(){
63
    	List<TaxonRelationshipType> relTypes = new ArrayList<>();
64
    	if (selection.isAnyMisappliedName()){
65

    
66
            relTypes.add(TaxonRelationshipType.MISAPPLIED_NAME_FOR());
67
            relTypes.add(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR());
68
            if (PreferencesUtil.getBooleanValue(PreferencePredicate.AllowPartialMisapplied.getKey())) {
69
            	relTypes.add(TaxonRelationshipType.PARTIAL_MISAPPLIED_NAME_FOR());
70
            }
71
        }else if (selection.isAnySynonym()){
72
            relTypes.add(TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR());
73
            relTypes.add(TaxonRelationshipType.PARTIAL_SYNONYM_FOR());
74
        }
75
		return relTypes;
76
    }
77

    
78
}
(5-5/8)