2c5cdc6b92acc1241bd1bac5ce5ce84a3c7263a7
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / GeoScopePolyKeyDetailSection.java
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.occurrence;
12
13 import java.util.Collection;
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
23 /**
24 *
25 * @author pplitzner
26 * @date Sep 21, 2015
27 *
28 */
29 public class GeoScopePolyKeyDetailSection extends AbstractEntityCollectionSection<PolytomousKey, NamedArea> {
30
31 public GeoScopePolyKeyDetailSection(CdmFormFactory formFactory,
32 ConversationHolder conversation, ICdmFormElement parentElement, int style) {
33 super(formFactory, conversation, parentElement, "Geo Scopes", style);
34 }
35
36 /** {@inheritDoc} */
37 @Override
38 public Collection<NamedArea> getCollection(PolytomousKey entity) {
39 return entity.getGeographicalScope();
40 }
41
42 /** {@inheritDoc} */
43 @Override
44 public NamedArea createNewElement() {
45 NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
46
47 return selection;
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public void addElement(NamedArea element) {
53 getEntity().addGeographicalScope(element);
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public void removeElement(NamedArea element) {
59 getEntity().removeGeographicalScope(element);
60 }
61
62 /** {@inheritDoc} */
63 @Override
64 public String getEmptyString() {
65 return "No geo scopes yet.";
66 }
67
68 /** {@inheritDoc} */
69 @Override
70 protected String getTooltipString() {
71 return "Add a geo scope";
72 }
73
74 }