Project

General

Profile

Download (2.82 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

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

    
12
import java.util.Collection;
13

    
14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
16
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
17
import eu.etaxonomy.cdm.model.description.DescriptionBase;
18
import eu.etaxonomy.taxeditor.ui.dialog.selection.OriginalSourceTypeSelectionDialog;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
22

    
23
/**
24
 * <p>DescriptionSourceSection class.</p>
25
 *
26
 * @author n.hoffmann
27
 * @created Mar 18, 2010
28
 * @version 1.0
29
 */
30
public class DescriptionSourceSection extends
31
		AbstractEntityCollectionSection<DescriptionBase, IdentifiableSource>{
32

    
33
	/**
34
	 * <p>Constructor for DescriptionSourceSection.</p>
35
	 *
36
	 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
37
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
38
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
39
	 * @param style a int.
40
	 */
41
	public DescriptionSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
42
			ICdmFormElement parentElement, int style) {
43
		super(cdmFormFactory, conversation, parentElement, "Description Sources", style);
44
	}
45

    
46

    
47

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

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

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

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

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

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

    
89

    
90

    
91
    /**
92
     * {@inheritDoc}
93
     */
94
    @Override
95
    public IdentifiableSource addExisting() {
96
        return null;
97
    }
98

    
99

    
100

    
101
    /**
102
     * {@inheritDoc}
103
     */
104
    @Override
105
    public boolean allowAddExisting() {
106
        return false;
107
    }
108
}
(11-11/25)