3 * Copyright (C) 2018 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.feature
;
12 import java
.util
.Collection
;
13 import java
.util
.Comparator
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.jface
.wizard
.WizardDialog
;
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
.cdm
.persistence
.dto
.TermNodeDto
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionSection
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.DefaultCdmBaseComparator
;
32 public class OnlyApplicableIfEntityCollectionSectionForNode
extends AbstractEntityCollectionSection
<TermNode
, FeatureState
>{
34 public OnlyApplicableIfEntityCollectionSectionForNode(CdmFormFactory formFactory
, ConversationHolder conversation
,
35 ICdmFormElement parentElement
, int style
) {
36 super(formFactory
, conversation
, parentElement
, "Only applicable if", style
);
43 public Collection
<FeatureState
> getCollection(TermNode entity
) {
44 return entity
.getOnlyApplicableIf();
51 public Comparator
<FeatureState
> getComparator() {
52 return new DefaultCdmBaseComparator
<>();
59 public FeatureState
createNewElement() {
60 FeatureStateWizard wizard
= new FeatureStateWizard(TermNodeDto
.fromNode(getEntity(), null), formFactory
);
61 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
62 int status
= dialog
.open();
63 if(status
== IStatus
.OK
) {
64 return wizard
.getFeatureState();
73 public void addElement(FeatureState element
) {
74 getEntity().getOnlyApplicableIf().add(element
);
81 public FeatureState
addExisting() {
89 public boolean allowAddExisting() {
97 public void removeElement(FeatureState element
) {
98 getEntity().getOnlyApplicableIf().remove(element
);
103 public String
getEmptyString() {
104 return "No feature state added yet.";
109 protected String
getTooltipString() {
110 return "Add a feature state";