Project

General

Profile

Download (2.99 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
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.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.ui.section.description;
12

    
13
import java.util.ArrayList;
14
import java.util.Collection;
15
import java.util.List;
16

    
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

    
26
/**
27
 * <p>DescribedSpecimenSection class.</p>
28
 *
29
 * @author n.hoffmann
30
 * @created Sep 16, 2010
31
 * @version 1.0
32
 */
33
public class DescribedSpecimenSection extends AbstractEntityCollectionSection<TaxonDescription, SpecimenOrObservationBase> {
34

    
35
	/**
36
	 * <p>Constructor for DescribedSpecimenSection.</p>
37
	 *
38
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
39
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
40
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
41
	 * @param style a int.
42
	 */
43
	public DescribedSpecimenSection(CdmFormFactory formFactory,
44
			ConversationHolder conversation, ICdmFormElement parentElement,
45
			int style) {
46
		super(formFactory, conversation, parentElement, "Described Specimen", style);
47
	}
48
	
49
	/** {@inheritDoc} */
50
	@Override
51
	public Collection<SpecimenOrObservationBase> getCollection(
52
			TaxonDescription entity) {
53
		//FIXME:This class is not really an entity collection section, and should be moved 
54
		// to a single entity section, but one with the possibility of launching a wizard
55
		List<SpecimenOrObservationBase> collection = new ArrayList<SpecimenOrObservationBase>();
56
		if(entity.getDescribedSpecimenOrObservation() != null) {
57
			collection.add(entity.getDescribedSpecimenOrObservation());	
58
		}		
59
		return collection;
60
	}
61

    
62
	/** {@inheritDoc} */
63
	@Override
64
	public SpecimenOrObservationBase createNewElement() {
65
		DerivedUnit selection = DerivedUnitSelectionDialog.select(getShell(), getConversationHolder(), null);		
66
		return selection;
67
	}
68

    
69
	/** {@inheritDoc} */
70
	@Override
71
	public void addElement(SpecimenOrObservationBase element) {
72
		getEntity().setDescribedSpecimenOrObservation(element);
73
	}
74

    
75
	/** {@inheritDoc} */
76
	@Override
77
	public void removeElement(SpecimenOrObservationBase element) {
78
		getEntity().setDescribedSpecimenOrObservation(null);		
79
	}
80

    
81
	/** {@inheritDoc} */
82
	@Override
83
	public String getEmptyString() {
84
		return "No described specimen yet.";
85
	}
86

    
87
	/** {@inheritDoc} */
88
	@Override
89
	protected String getTooltipString() {
90
		return "Add a described specimen.";
91
	}
92
}
(2-2/24)