2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.feature
;
11 import java
.util
.Collection
;
12 import java
.util
.Comparator
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
15 import org
.eclipse
.jface
.wizard
.WizardDialog
;
17 import eu
.etaxonomy
.cdm
.model
.description
.FeatureState
;
18 import eu
.etaxonomy
.cdm
.model
.term
.TermNode
;
19 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermNodeDto
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionSection
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.DefaultCdmBaseComparator
;
29 public class OnlyApplicableIfEntityCollectionSectionForNode
extends AbstractEntityCollectionSection
<TermNode
, FeatureState
>{
31 public OnlyApplicableIfEntityCollectionSectionForNode(CdmFormFactory formFactory
,
32 ICdmFormElement parentElement
, int style
) {
33 super(formFactory
, parentElement
, "Only applicable if", style
);
37 public Collection
<FeatureState
> getCollection(TermNode entity
) {
38 return entity
.getOnlyApplicableIf();
42 public Comparator
<FeatureState
> getComparator() {
43 return new DefaultCdmBaseComparator
<>();
47 public FeatureState
createNewElement() {
48 FeatureStateWizard wizard
= new FeatureStateWizard(TermNodeDto
.fromNode(getEntity(), null), formFactory
);
49 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
50 int status
= dialog
.open();
51 if(status
== IStatus
.OK
) {
52 return wizard
.getFeatureState();
58 public void addElement(FeatureState element
) {
59 getEntity().getOnlyApplicableIf().add(element
);
63 public FeatureState
addExisting() {
68 public boolean allowAddExisting() {
73 public void removeElement(FeatureState element
) {
74 getEntity().getOnlyApplicableIf().remove(element
);
78 public String
getEmptyString() {
79 return "No feature state added yet.";
83 protected String
getTooltipString() {
84 return "Add a feature state";