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
.Feature
;
20 import eu
.etaxonomy
.cdm
.model
.description
.FeatureState
;
21 import eu
.etaxonomy
.cdm
.model
.term
.TermNode
;
22 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermNodeDto
;
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 import eu
.etaxonomy
.taxeditor
.ui
.section
.DefaultCdmBaseComparator
;
33 public class InapplicableIfEntityCollectionSectionForNode
extends AbstractEntityCollectionSection
<TermNode
<?
extends Feature
>, FeatureState
>{
35 public InapplicableIfEntityCollectionSectionForNode(CdmFormFactory formFactory
, ConversationHolder conversation
,
36 ICdmFormElement parentElement
, int style
) {
37 super(formFactory
, conversation
, parentElement
, "Inapplicable If", style
);
44 public Collection
<FeatureState
> getCollection(TermNode
<?
extends Feature
>entity
) {
45 return entity
.getInapplicableIf();
52 public Comparator
<FeatureState
> getComparator() {
53 return new DefaultCdmBaseComparator
<>();
61 public FeatureState
createNewElement() {
62 FeatureStateWizard wizard
= new FeatureStateWizard(new TermNodeDto(getEntity()), formFactory
);
63 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
64 int status
= dialog
.open();
65 if(status
== IStatus
.OK
) {
66 return wizard
.getFeatureState();
75 public void addElement(FeatureState element
) {
76 getEntity().getInapplicableIf().add(element
);
83 public FeatureState
addExisting() {
91 public boolean allowAddExisting() {
99 public void removeElement(FeatureState element
) {
100 getEntity().getInapplicableIf().remove(element
);
105 public String
getEmptyString() {
106 return "No feature state added yet.";
111 protected String
getTooltipString() {
112 return "Add a feature state";