Project

General

Profile

Download (2.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.ui.section.description;
10

    
11
import java.util.ArrayList;
12
import java.util.Collection;
13
import java.util.Comparator;
14
import java.util.List;
15

    
16
import eu.etaxonomy.cdm.model.description.TaxonDescription;
17
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
18
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
19
import eu.etaxonomy.taxeditor.ui.dialog.selection.DerivedUnitSelectionDialog;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
23
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
24

    
25
/**
26
 * @author n.hoffmann
27
 * @created Sep 16, 2010
28
 */
29
public class DescribedSpecimenSection extends AbstractEntityCollectionSection<TaxonDescription, SpecimenOrObservationBase> {
30

    
31
	public DescribedSpecimenSection(CdmFormFactory formFactory,
32
			ICdmFormElement parentElement,
33
			int style) {
34
		super(formFactory, parentElement, "Described Specimen", style);
35
	}
36

    
37
	@Override
38
	public Collection<SpecimenOrObservationBase> getCollection(
39
			TaxonDescription entity) {
40
		//FIXME:This class is not really an entity collection section, and should be moved
41
		// to a single entity section, but one with the possibility of launching a wizard
42
		List<SpecimenOrObservationBase> collection = new ArrayList<SpecimenOrObservationBase>();
43
		if(entity.getDescribedSpecimenOrObservation() != null) {
44
			collection.add(entity.getDescribedSpecimenOrObservation());
45
		}
46
		return collection;
47
	}
48

    
49
    @Override
50
    public Comparator<SpecimenOrObservationBase> getComparator() {
51
        return new DefaultCdmBaseComparator<>();
52
    }
53

    
54
	@Override
55
	public SpecimenOrObservationBase createNewElement() {
56
		DerivedUnit selection = DerivedUnitSelectionDialog.select(getShell(),
57
		        null);
58
		return selection;
59
	}
60

    
61
	@Override
62
	public void addElement(SpecimenOrObservationBase element) {
63
		getEntity().setDescribedSpecimenOrObservation(element);
64
	}
65

    
66
	@Override
67
	public void removeElement(SpecimenOrObservationBase element) {
68
		getEntity().setDescribedSpecimenOrObservation(null);
69
	}
70

    
71
	@Override
72
	public String getEmptyString() {
73
		return "No described specimen yet.";
74
	}
75

    
76
	@Override
77
	protected String getTooltipString() {
78
		return "Add a described specimen.";
79
	}
80

    
81
    @Override
82
    public SpecimenOrObservationBase addExisting() {
83
        return null;
84
    }
85

    
86
    @Override
87
    public boolean allowAddExisting() {
88
        return false;
89
    }
90
}
(3-3/26)