Project

General

Profile

Download (3.7 KB) Statistics
| Branch: | Tag: | Revision:
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

    
10
package eu.etaxonomy.taxeditor.ui.section.occurrence;
11

    
12
import java.util.Collection;
13
import java.util.Comparator;
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.cdm.model.occurrence.FieldUnit;
19
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
23
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
24

    
25
/**
26
 * <p>
27
 * CollectingAreasDetailSection class.
28
 * </p>
29
 *
30
 * @author n.hoffmann
31
 * @created Oct 14, 2010
32
 * @version 1.0
33
 */
34
public class CollectingAreasDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> {
35

    
36
	/**
37
	 * <p>Constructor for CollectingAreasDetailSection.</p>
38
	 *
39
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
40
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
41
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
42
	 * @param style a int.
43
	 */
44
	public CollectingAreasDetailSection(CdmFormFactory formFactory,
45
			ConversationHolder conversation, ICdmFormElement parentElement, int style) {
46
		super(formFactory, conversation, parentElement, "Collecting Areas", style);
47
	}
48

    
49
	/* (non-Javadoc)
50
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
51
	 */
52
	/** {@inheritDoc} */
53
	@Override
54
	public Collection<NamedArea> getCollection(DerivedUnitFacade entity) {
55
		return entity.getCollectingAreas();
56
	}
57

    
58
	@Override
59
	public Comparator<NamedArea> getComparator() {
60
        return new DefaultCdmBaseComparator<>();
61
	}
62

    
63
	/* (non-Javadoc)
64
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#createNewElement()
65
	 */
66
	/** {@inheritDoc} */
67
	@Override
68
	public NamedArea createNewElement() {
69
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
70
		        null, FieldUnit.class.getCanonicalName());
71

    
72
		return selection;
73
	}
74

    
75
	/* (non-Javadoc)
76
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
77
	 */
78
	/** {@inheritDoc} */
79
	@Override
80
	public void addElement(NamedArea element) {
81
		getEntity().addCollectingArea(element);
82
	}
83

    
84
	/* (non-Javadoc)
85
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
86
	 */
87
	/** {@inheritDoc} */
88
	@Override
89
	public void removeElement(NamedArea element) {
90
		getEntity().removeCollectingArea(element);
91
	}
92

    
93
	/* (non-Javadoc)
94
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
95
	 */
96
	/** {@inheritDoc} */
97
	@Override
98
	public String getEmptyString() {
99
		return "No collecting areas yet.";
100
	}
101

    
102
	/* (non-Javadoc)
103
	 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
104
	 */
105
	/** {@inheritDoc} */
106
	@Override
107
	protected String getTooltipString() {
108
		return "Add a collecting area";
109
	}
110

    
111
    /**
112
     * {@inheritDoc}
113
     */
114
    @Override
115
    public NamedArea addExisting() {
116
        return null;
117
    }
118

    
119
    /**
120
     * {@inheritDoc}
121
     */
122
    @Override
123
    public boolean allowAddExisting() {
124
        return false;
125
    }
126

    
127
}
(5-5/37)