merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / ScopeSection.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.description;
12
13 import java.util.Collection;
14
15 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 import eu.etaxonomy.cdm.model.common.DefinedTerm;
17 import eu.etaxonomy.cdm.model.common.TermType;
18 import eu.etaxonomy.cdm.model.description.TaxonDescription;
19 import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
22
23 /**
24 * <p>ScopeSection class.</p>
25 *
26 * @author n.hoffmann
27 * @created Mar 18, 2010
28 * @version 1.0
29 */
30 public class ScopeSection extends AbstractEntityCollectionSection<TaxonDescription, DefinedTerm> {
31
32 /**
33 * <p>Constructor for ScopeSection.</p>
34 *
35 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
36 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
37 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
38 * @param style a int.
39 */
40 public ScopeSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
41 super(cdmFormFactory, conversation, parentElement, "Scope", style);
42 }
43
44 /** {@inheritDoc} */
45 @Override
46 public void addElement(DefinedTerm element) {
47 getEntity().addScope(element);
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public DefinedTerm createNewElement() {
53 return DefinedTerm.NewInstance(TermType.Scope,"","Untitled","");
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public Collection<DefinedTerm> getCollection(TaxonDescription entity) {
59 return entity.getScopes();
60 }
61
62 /** {@inheritDoc} */
63 @Override
64 public String getEmptyString() {
65 return "No scopes yet.";
66 }
67
68 /** {@inheritDoc} */
69 @Override
70 protected String getTooltipString() {
71 return "Create a new scope";
72 }
73
74 /** {@inheritDoc} */
75 @Override
76 public void removeElement(DefinedTerm element) {
77 getEntity().removeScope(element);
78 }
79 }