2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.description
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Collection
;
14 import java
.util
.Comparator
;
15 import java
.util
.List
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
18 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
19 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
20 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
21 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.DerivedUnitSelectionDialog
;
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
;
28 * <p>DescribedSpecimenSection class.</p>
31 * @created Sep 16, 2010
34 public class DescribedSpecimenSection
extends AbstractEntityCollectionSection
<TaxonDescription
, SpecimenOrObservationBase
> {
37 * <p>Constructor for DescribedSpecimenSection.</p>
39 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
40 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
41 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
44 public DescribedSpecimenSection(CdmFormFactory formFactory
,
45 ConversationHolder conversation
, ICdmFormElement parentElement
,
47 super(formFactory
, conversation
, parentElement
, "Described Specimen", style
);
52 public Collection
<SpecimenOrObservationBase
> getCollection(
53 TaxonDescription entity
) {
54 //FIXME:This class is not really an entity collection section, and should be moved
55 // to a single entity section, but one with the possibility of launching a wizard
56 List
<SpecimenOrObservationBase
> collection
= new ArrayList
<SpecimenOrObservationBase
>();
57 if(entity
.getDescribedSpecimenOrObservation() != null) {
58 collection
.add(entity
.getDescribedSpecimenOrObservation());
64 public Comparator
<SpecimenOrObservationBase
> getComparator() {
65 return new DefaultCdmBaseComparator
<>();
70 public SpecimenOrObservationBase
createNewElement() {
71 DerivedUnit selection
= DerivedUnitSelectionDialog
.select(getShell(), //getConversationHolder(),
78 public void addElement(SpecimenOrObservationBase element
) {
79 getEntity().setDescribedSpecimenOrObservation(element
);
84 public void removeElement(SpecimenOrObservationBase element
) {
85 getEntity().setDescribedSpecimenOrObservation(null);
90 public String
getEmptyString() {
91 return "No described specimen yet.";
96 protected String
getTooltipString() {
97 return "Add a described specimen.";
104 public SpecimenOrObservationBase
addExisting() {
112 public boolean allowAddExisting() {