Project

General

Profile

Download (2.66 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
 * @author n.hoffmann
27
 * @created Oct 14, 2010
28
 */
29
public class CollectingAreasDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> {
30

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

    
44
	@Override
45
	public Collection<NamedArea> getCollection(DerivedUnitFacade entity) {
46
		return entity.getCollectingAreas();
47
	}
48

    
49
	@Override
50
	public Comparator<NamedArea> getComparator() {
51
        return new DefaultCdmBaseComparator<>();
52
	}
53

    
54
	@Override
55
	public NamedArea createNewElement() {
56
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
57
		        null, FieldUnit.class.getCanonicalName());
58

    
59
		return selection;
60
	}
61

    
62
	@Override
63
	public void addElement(NamedArea element) {
64
		getEntity().addCollectingArea(element);
65
	}
66

    
67
	@Override
68
	public void removeElement(NamedArea element) {
69
		getEntity().removeCollectingArea(element);
70
	}
71

    
72
	@Override
73
	public String getEmptyString() {
74
		return "No collecting areas yet.";
75
	}
76

    
77
	@Override
78
	protected String getTooltipString() {
79
		return "Add a collecting area";
80
	}
81

    
82
    @Override
83
    public NamedArea addExisting() {
84
        return null;
85
    }
86

    
87
    @Override
88
    public boolean allowAddExisting() {
89
        return false;
90
    }
91
}
(5-5/38)