(no commit message)
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / CollectingAreasDetailSection.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.api.facade.DerivedUnitFacade;
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 * <p>CollectingAreasDetailSection class.</p>
25 *
26 * @author n.hoffmann
27 * @created Oct 14, 2010
28 * @version 1.0
29 */
30 public class CollectingAreasDetailSection extends
31 AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> {
32
33 /**
34 * <p>Constructor for CollectingAreasDetailSection.</p>
35 *
36 * @param formFactory 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 CollectingAreasDetailSection(CdmFormFactory formFactory,
42 ConversationHolder conversation, ICdmFormElement parentElement, int style) {
43 super(formFactory, conversation, parentElement, "Collecting Areas", style);
44 }
45
46 /* (non-Javadoc)
47 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
48 */
49 /** {@inheritDoc} */
50 @Override
51 public Collection<NamedArea> getCollection(DerivedUnitFacade entity) {
52 return entity.getCollectingAreas();
53 }
54
55 /* (non-Javadoc)
56 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#createNewElement()
57 */
58 /** {@inheritDoc} */
59 @Override
60 public NamedArea createNewElement() {
61 NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
62
63 return selection;
64 }
65
66 /* (non-Javadoc)
67 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
68 */
69 /** {@inheritDoc} */
70 @Override
71 public void addElement(NamedArea element) {
72 getEntity().addCollectingArea(element);
73 }
74
75 /* (non-Javadoc)
76 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
77 */
78 /** {@inheritDoc} */
79 @Override
80 public void removeElement(NamedArea element) {
81 getEntity().removeCollectingArea(element);
82 }
83
84 /* (non-Javadoc)
85 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
86 */
87 /** {@inheritDoc} */
88 @Override
89 public String getEmptyString() {
90 return "No collecting areas yet.";
91 }
92
93 /* (non-Javadoc)
94 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
95 */
96 /** {@inheritDoc} */
97 @Override
98 protected String getTooltipString() {
99 return "Add a collecting area";
100 }
101
102 }