Project

General

Profile

Download (3.24 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.key;
11

    
12
import java.util.Collection;
13
import java.util.Comparator;
14

    
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.description.PolytomousKey;
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonSelectionDialog;
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
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
23

    
24
/**
25
 * @author n.hoffmann
26
 * @created Mar 29, 2011
27
 * @version 1.0
28
 */
29
public class TaxonomicScopeSection extends
30
		AbstractEntityCollectionSection<PolytomousKey, Taxon> {
31

    
32
	/**
33
	 * @param formFactory
34
	 * @param conversation
35
	 * @param parentElement
36
	 * @param title
37
	 * @param style
38
	 */
39
	public TaxonomicScopeSection(CdmFormFactory formFactory,
40
			ConversationHolder conversation, ICdmFormElement parentElement,
41
			int style) {
42
		super(formFactory, conversation, parentElement, "Taxonomic Scope",
43
				style);
44
	}
45

    
46
	/*
47
	 * (non-Javadoc)
48
	 *
49
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
50
	 * getCollection(java.lang.Object)
51
	 */
52
	@Override
53
	public Collection<Taxon> getCollection(PolytomousKey entity) {
54
		return entity.getTaxonomicScope();
55
	}
56

    
57
	@Override
58
	public Comparator<Taxon> getComparator() {
59
        return new DefaultCdmBaseComparator<>();
60
	}
61

    
62
	/*
63
	 * (non-Javadoc)
64
	 *
65
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
66
	 * createNewElement()
67
	 */
68
	@Override
69
	public Taxon createNewElement() {
70
		Taxon selection = TaxonSelectionDialog.selectTaxon(getShell(),//getConversationHolder(),
71
		        null);
72

    
73
		return selection;
74
	}
75

    
76
	/*
77
	 * (non-Javadoc)
78
	 *
79
	 * @see
80
	 * eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement
81
	 * (java.lang.Object)
82
	 */
83
	@Override
84
	public void addElement(Taxon element) {
85
		getEntity().addTaxonomicScope(element);
86
	}
87

    
88
	/*
89
	 * (non-Javadoc)
90
	 *
91
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
92
	 * removeElement(java.lang.Object)
93
	 */
94
	@Override
95
	public void removeElement(Taxon element) {
96
		getEntity().removeTaxonomicScope(element);
97
	}
98

    
99
	/*
100
	 * (non-Javadoc)
101
	 *
102
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
103
	 * getEmptyString()
104
	 */
105
	@Override
106
	public String getEmptyString() {
107
		return "No taxonomic scope yet.";
108
	}
109

    
110
	/*
111
	 * (non-Javadoc)
112
	 *
113
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
114
	 * getTooltipString()
115
	 */
116
	@Override
117
	protected String getTooltipString() {
118
		return "Add a taxon to the scope of this key";
119
	}
120

    
121
    /**
122
     * {@inheritDoc}
123
     */
124
    @Override
125
    public Taxon addExisting() {
126
        // TODO Auto-generated method stub
127
        return null;
128
    }
129

    
130
    /**
131
     * {@inheritDoc}
132
     */
133
    @Override
134
    public boolean allowAddExisting() {
135
        // TODO Auto-generated method stub
136
        return false;
137
    }
138

    
139
}
(6-6/6)