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.occurrence;
|
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.location.NamedArea;
|
18
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
|
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
|
*
|
26
|
* @author pplitzner
|
27
|
* @date Sep 21, 2015
|
28
|
*
|
29
|
*/
|
30
|
public class GeoScopePolyKeyDetailSection extends AbstractEntityCollectionSection<PolytomousKey, NamedArea> {
|
31
|
|
32
|
public GeoScopePolyKeyDetailSection(CdmFormFactory formFactory,
|
33
|
ConversationHolder conversation, ICdmFormElement parentElement, int style) {
|
34
|
super(formFactory, conversation, parentElement, "Geo Scopes", style);
|
35
|
}
|
36
|
|
37
|
/** {@inheritDoc} */
|
38
|
@Override
|
39
|
public Collection<NamedArea> getCollection(PolytomousKey entity) {
|
40
|
return entity.getGeographicalScope();
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public Comparator<NamedArea> getComparator() {
|
45
|
return new DefaultCdmBaseComparator<>();
|
46
|
}
|
47
|
|
48
|
/** {@inheritDoc} */
|
49
|
@Override
|
50
|
public NamedArea createNewElement() {
|
51
|
NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
|
52
|
null, PolytomousKey.class.getCanonicalName());
|
53
|
|
54
|
return selection;
|
55
|
}
|
56
|
|
57
|
/** {@inheritDoc} */
|
58
|
@Override
|
59
|
public void addElement(NamedArea element) {
|
60
|
getEntity().addGeographicalScope(element);
|
61
|
}
|
62
|
|
63
|
/** {@inheritDoc} */
|
64
|
@Override
|
65
|
public void removeElement(NamedArea element) {
|
66
|
getEntity().removeGeographicalScope(element);
|
67
|
}
|
68
|
|
69
|
/** {@inheritDoc} */
|
70
|
@Override
|
71
|
public String getEmptyString() {
|
72
|
return "No geo scopes yet.";
|
73
|
}
|
74
|
|
75
|
/** {@inheritDoc} */
|
76
|
@Override
|
77
|
protected String getTooltipString() {
|
78
|
return "Add a geo scope";
|
79
|
}
|
80
|
|
81
|
/**
|
82
|
* {@inheritDoc}
|
83
|
*/
|
84
|
@Override
|
85
|
public NamedArea addExisting() {
|
86
|
return null;
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* {@inheritDoc}
|
91
|
*/
|
92
|
@Override
|
93
|
public boolean allowAddExisting() {
|
94
|
return false;
|
95
|
}
|
96
|
|
97
|
}
|