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
|
import eu.etaxonomy.cdm.model.description.FeatureState;
|
20
|
import eu.etaxonomy.cdm.model.term.TermNode;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
25
|
|
26
|
/**
|
27
|
* @author pplitzner
|
28
|
* @date 06.03.2018
|
29
|
*
|
30
|
*/
|
31
|
public class InapplicableIfEntityCollectionSection extends AbstractEntityCollectionSection<TermNode, FeatureState>{
|
32
|
|
33
|
public InapplicableIfEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation,
|
34
|
ICdmFormElement parentElement, int style) {
|
35
|
super(formFactory, conversation, parentElement, "Inapplicable If", style);
|
36
|
}
|
37
|
|
38
|
/**
|
39
|
* {@inheritDoc}
|
40
|
*/
|
41
|
@Override
|
42
|
public Collection<FeatureState> getCollection(TermNode entity) {
|
43
|
return entity.getInapplicableIf();
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* {@inheritDoc}
|
48
|
*/
|
49
|
@Override
|
50
|
public Comparator<FeatureState> getComparator() {
|
51
|
return new DefaultCdmBaseComparator<>();
|
52
|
}
|
53
|
|
54
|
|
55
|
/**
|
56
|
* {@inheritDoc}
|
57
|
*/
|
58
|
@Override
|
59
|
public FeatureState createNewElement() {
|
60
|
FeatureStateWizard wizard = new FeatureStateWizard(formFactory, "Inapplicable If");
|
61
|
WizardDialog dialog = new WizardDialog(getLayoutComposite().getShell(), wizard);
|
62
|
int status = dialog.open();
|
63
|
if(status == IStatus.OK) {
|
64
|
return wizard.getFeatureState();
|
65
|
}
|
66
|
return null;
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* {@inheritDoc}
|
71
|
*/
|
72
|
@Override
|
73
|
public void addElement(FeatureState element) {
|
74
|
getEntity().addInapplicableState(element);
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* {@inheritDoc}
|
79
|
*/
|
80
|
@Override
|
81
|
public FeatureState addExisting() {
|
82
|
return null;
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* {@inheritDoc}
|
87
|
*/
|
88
|
@Override
|
89
|
public boolean allowAddExisting() {
|
90
|
return false;
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* {@inheritDoc}
|
95
|
*/
|
96
|
@Override
|
97
|
public void removeElement(FeatureState element) {
|
98
|
getEntity().removeInapplicableState(element);
|
99
|
}
|
100
|
|
101
|
/** {@inheritDoc} */
|
102
|
@Override
|
103
|
public String getEmptyString() {
|
104
|
return "No feature state added yet.";
|
105
|
}
|
106
|
|
107
|
/** {@inheritDoc} */
|
108
|
@Override
|
109
|
protected String getTooltipString() {
|
110
|
return "Add a feature state";
|
111
|
}
|
112
|
|
113
|
}
|