- converted NamedArea element
[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 org.eclipse.swt.events.SelectionListener;
16 import org.eclipse.swt.graphics.Color;
17
18 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
20 import eu.etaxonomy.cdm.model.location.NamedArea;
21 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
22 import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
23 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
24 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
25
26 /**
27 * <p>
28 * CollectingAreasDetailSection class.
29 * </p>
30 *
31 * @author n.hoffmann
32 * @created Oct 14, 2010
33 * @version 1.0
34 */
35 public class CollectingAreasDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> {
36
37 /**
38 * <p>Constructor for CollectingAreasDetailSection.</p>
39 *
40 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
41 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
42 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
43 * @param style a int.
44 */
45 public CollectingAreasDetailSection(CdmFormFactory formFactory,
46 ConversationHolder conversation, ICdmFormElement parentElement, int style) {
47 super(formFactory, conversation, parentElement, "Collecting Areas", style);
48 }
49
50 /* (non-Javadoc)
51 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
52 */
53 /** {@inheritDoc} */
54 @Override
55 public Collection<NamedArea> getCollection(DerivedUnitFacade entity) {
56 return entity.getCollectingAreas();
57 }
58
59 /* (non-Javadoc)
60 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#createNewElement()
61 */
62 /** {@inheritDoc} */
63 @Override
64 public NamedArea createNewElement() {
65 NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
66
67 return selection;
68 }
69
70 /* (non-Javadoc)
71 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
72 */
73 /** {@inheritDoc} */
74 @Override
75 public void addElement(NamedArea element) {
76 getEntity().addCollectingArea(element);
77 }
78
79 /* (non-Javadoc)
80 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
81 */
82 /** {@inheritDoc} */
83 @Override
84 public void removeElement(NamedArea element) {
85 getEntity().removeCollectingArea(element);
86 }
87
88 /* (non-Javadoc)
89 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
90 */
91 /** {@inheritDoc} */
92 @Override
93 public String getEmptyString() {
94 return "No collecting areas yet.";
95 }
96
97 /* (non-Javadoc)
98 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
99 */
100 /** {@inheritDoc} */
101 @Override
102 protected String getTooltipString() {
103 return "Add a collecting area";
104 }
105
106 /* (non-Javadoc)
107 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createElementComposite(java.lang.Object, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.graphics.Color)
108 */
109 @Override
110 protected void createElementComposite(NamedArea element, SelectionListener removeListener, Color backgroundColor) {
111 formFactory.createNamedAreaFieldController(this, element, removeListener);
112 }
113
114 }