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
.persistence
.dto
.TermNodeDto
;
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
;
31 public class OnlyApplicableIfEntityCollectionSection
extends AbstractEntityCollectionSection
<TermNodeDto
, FeatureState
>{
33 public OnlyApplicableIfEntityCollectionSection(CdmFormFactory formFactory
, ConversationHolder conversation
,
34 ICdmFormElement parentElement
, int style
) {
35 super(formFactory
, conversation
, parentElement
, "Only applicable if", style
);
42 public Collection
<FeatureState
> getCollection(TermNodeDto entity
) {
43 return entity
.getOnlyApplicableIf();
50 public Comparator
<FeatureState
> getComparator() {
51 return new DefaultCdmBaseComparator
<>();
58 public FeatureState
createNewElement() {
59 FeatureStateWizard wizard
= new FeatureStateWizard(getEntity(), formFactory
);
60 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
61 int status
= dialog
.open();
62 if(status
== IStatus
.OK
) {
63 return wizard
.getFeatureState();
72 public void addElement(FeatureState element
) {
73 getEntity().getOnlyApplicableIf().add(element
);
80 public FeatureState
addExisting() {
88 public boolean allowAddExisting() {
96 public void removeElement(FeatureState element
) {
97 getEntity().getOnlyApplicableIf().remove(element
);
102 public String
getEmptyString() {
103 return "No feature state added yet.";
108 protected String
getTooltipString() {
109 return "Add a feature state";