Project

General

Profile

Download (2.89 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.section.feature;
11

    
12
import java.util.Collection;
13
import java.util.Comparator;
14

    
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.jface.wizard.WizardDialog;
17

    
18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19

    
20
import eu.etaxonomy.cdm.persistence.dto.FeatureStateDto;
21
import eu.etaxonomy.cdm.persistence.dto.TermNodeDto;
22
import eu.etaxonomy.cdm.persistence.dto.FeatureStateDtoComparator;
23
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
24
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
25
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
26

    
27

    
28
/**
29
 * @author pplitzner
30
 * @date 06.03.2018
31
 *
32
 */
33
public class OnlyApplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNodeDto, FeatureStateDto>{
34

    
35
    public OnlyApplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
36
            ICdmFormElement parentElement, int style) {
37
        super(formFactory, conversation, parentElement, "Only applicable if", style);
38
    }
39

    
40
    /**
41
     * {@inheritDoc}
42
     */
43
    @Override
44
    public Collection<FeatureStateDto> getCollection(TermNodeDto entity) {
45
        return entity.getOnlyApplicableIf();
46
    }
47

    
48
    /**
49
     * {@inheritDoc}
50
     */
51
    @Override
52
    public Comparator<FeatureStateDto> getComparator() {
53
    	 return new FeatureStateDtoComparator();
54
             
55
    }
56

    
57
    /**
58
     * {@inheritDoc}
59
     */
60
    @Override
61
    public FeatureStateDto createNewElement() {
62
        FeatureStateWizard wizard = new FeatureStateWizard(getEntity(), formFactory);
63
        WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
64
        int status = dialog.open();
65
        if(status == IStatus.OK) {
66
            return wizard.getFeatureStateDto();
67
        }
68
        return null;
69
    }
70

    
71
    /**
72
     * {@inheritDoc}
73
     */
74
    @Override
75
    public void addElement(FeatureStateDto element) {
76
        getEntity().getOnlyApplicableIf().add(element);
77
    }
78

    
79
    /**
80
     * {@inheritDoc}
81
     */
82
    @Override
83
    public FeatureStateDto addExisting() {
84
        return null;
85
    }
86

    
87
    /**
88
     * {@inheritDoc}
89
     */
90
    @Override
91
    public boolean allowAddExisting() {
92
        return false;
93
    }
94

    
95
    /**
96
     * {@inheritDoc}
97
     */
98
    @Override
99
    public void removeElement(FeatureStateDto element) {
100
        getEntity().getOnlyApplicableIf().remove(element);
101
    }
102

    
103
    /** {@inheritDoc} */
104
    @Override
105
    public String getEmptyString() {
106
        return "No feature state added yet.";
107
    }
108

    
109
    /** {@inheritDoc} */
110
    @Override
111
    protected String getTooltipString() {
112
        return "Add a feature state";
113
    }
114

    
115
}
(21-21/28)