Merge branch 'hotfix/5.45.1'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / GeoScopeSection.java
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 package eu.etaxonomy.taxeditor.ui.section.description;
10
11 import java.util.Collection;
12 import java.util.Comparator;
13
14 import eu.etaxonomy.cdm.model.description.TaxonDescription;
15 import eu.etaxonomy.cdm.model.location.NamedArea;
16 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
18 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
19 import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
20
21 /**
22 * @author n.hoffmann
23 * @created Sep 17, 2010
24 */
25 public class GeoScopeSection extends AbstractEntityCollectionSection<TaxonDescription, NamedArea> {
26
27 public GeoScopeSection(CdmFormFactory formFactory,
28 ICdmFormElement parentElement, int style) {
29 super(formFactory, parentElement, "Geo Scope", style);
30 }
31
32 @Override
33 public Collection<NamedArea> getCollection(TaxonDescription entity) {
34 return entity.getGeoScopes();
35 }
36
37 @Override
38 public Comparator<NamedArea> getComparator() {
39 return new DefaultCdmBaseComparator<>();
40 }
41
42 @Override
43 public NamedArea createNewElement() {
44 return NamedArea.NewInstance();
45 }
46
47 @Override
48 public void addElement(NamedArea element) {
49 getEntity().addGeoScope(element);
50 }
51
52 @Override
53 public void removeElement(NamedArea element) {
54 getEntity().removeGeoScope(element);
55 }
56
57 @Override
58 public String getEmptyString() {
59 return "No geo scopes yet.";
60 }
61
62 @Override
63 protected String getTooltipString() {
64 return "Add a new geo scope.";
65 }
66
67 @Override
68 public NamedArea addExisting() {
69 return null;
70 }
71
72 @Override
73 public boolean allowAddExisting() {
74 return false;
75 }
76 }