2 * Copyright (C) 2015 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
.occurrence
.association
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Collection
;
13 import java
.util
.List
;
16 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
17 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
18 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
19 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionSection
;
29 public class DerivedUnitTypeDesignationSection
extends AbstractEntityCollectionSection
<DerivedUnitFacade
, SpecimenTypeDesignation
> {
31 private Collection
<SpecimenTypeDesignation
> typeDesignations
;
33 public DerivedUnitTypeDesignationSection(CdmFormFactory formFactory
,
34 ConversationHolder conversation
, ICdmFormElement parentElement
, int style
) {
35 super(formFactory
, conversation
, parentElement
, "Type Designations", style
);
40 public Collection
<SpecimenTypeDesignation
> getCollection(DerivedUnitFacade entity
) {
41 typeDesignations
= entity
.innerDerivedUnit().getSpecimenTypeDesignations();
42 return typeDesignations
;
47 public SpecimenTypeDesignation
createNewElement() {
48 return SpecimenTypeDesignation
.NewInstance();
53 public void addElement(SpecimenTypeDesignation element
) {
54 element
.setTypeSpecimen(getEntity().innerDerivedUnit());
55 typeDesignations
.add(element
);
60 public void removeElement(SpecimenTypeDesignation element
) {
61 List
<SpecimenTypeDesignation
> toRemove
= new ArrayList
<SpecimenTypeDesignation
>();
62 for (SpecimenTypeDesignation specimenTypeDesignation
: typeDesignations
) {
63 if(element
.equals(specimenTypeDesignation
)){
64 toRemove
.add(specimenTypeDesignation
);
67 for (SpecimenTypeDesignation specimenTypeDesignation
: toRemove
) {
68 specimenTypeDesignation
.removeType();
69 Set
<TaxonNameBase
> names
= specimenTypeDesignation
.getTypifiedNames();
70 for (TaxonNameBase taxonNameBase
: names
) {
71 taxonNameBase
.removeTypeDesignation(specimenTypeDesignation
);
74 typeDesignations
.removeAll(toRemove
);
79 public String
getEmptyString() {
80 return "No type designation yet.";
85 protected String
getTooltipString() {
86 return "Add a type designation";