Project

General

Profile

Download (2.59 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.Collection;
14

    
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
17
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
18
import eu.etaxonomy.cdm.model.description.DescriptionBase;
19
import eu.etaxonomy.taxeditor.ui.dialog.selection.OriginalSourceTypeSelectionDialog;
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

    
24
/**
25
 * <p>DescriptionSourceSection class.</p>
26
 *
27
 * @author n.hoffmann
28
 * @created Mar 18, 2010
29
 * @version 1.0
30
 */
31
public class DescriptionSourceSection extends
32
		AbstractEntityCollectionSection<DescriptionBase, IdentifiableSource>{
33
	
34
	/**
35
	 * <p>Constructor for DescriptionSourceSection.</p>
36
	 *
37
	 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
38
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
39
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
40
	 * @param style a int.
41
	 */
42
	public DescriptionSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
43
			ICdmFormElement parentElement, int style) {
44
		super(cdmFormFactory, conversation, parentElement, "Description Sources", style);
45
	}
46

    
47
	
48

    
49
	/** {@inheritDoc} */
50
	@Override
51
	public void addElement(IdentifiableSource element) {
52
		getEntity().addSource(element);
53
	}
54

    
55
	/** {@inheritDoc} */
56
	@Override
57
	public IdentifiableSource createNewElement() {
58
		OriginalSourceType ost = OriginalSourceTypeSelectionDialog.select(getShell(), getConversationHolder());	
59
		if(ost != null) {
60
			return IdentifiableSource.NewInstance(ost);
61
		} else {
62
			return null;
63
		}
64
	}
65

    
66
	/** {@inheritDoc} */
67
	@Override
68
	public Collection<IdentifiableSource> getCollection(DescriptionBase entity) {
69
		return entity.getSources();
70
	}
71

    
72
	/** {@inheritDoc} */
73
	@Override
74
	public String getEmptyString() {
75
		return "No description sources yet.";
76
	}
77

    
78
	/** {@inheritDoc} */
79
	@Override
80
	protected String getTooltipString() {
81
		return "Add a reference as source for this description";
82
	}
83

    
84
	/** {@inheritDoc} */
85
	@Override
86
	public void removeElement(IdentifiableSource element) {
87
		getEntity().removeSource(element);
88
	}
89
}
(11-11/24)