Project

General

Profile

Download (2.16 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
package eu.etaxonomy.taxeditor.ui.section.occurrence;
10

    
11
import java.util.Collection;
12
import java.util.Comparator;
13

    
14
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
15
import eu.etaxonomy.cdm.model.location.NamedArea;
16
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
17
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
21
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
22

    
23
/**
24
 * @author n.hoffmann
25
 * @created Oct 14, 2010
26
 */
27
public class CollectingAreasDetailSection extends AbstractEntityCollectionSection<DerivedUnitFacade, NamedArea> {
28

    
29
	public CollectingAreasDetailSection(CdmFormFactory formFactory,
30
			ICdmFormElement parentElement, int style) {
31
		super(formFactory, parentElement, "Collecting Areas", style);
32
	}
33

    
34
	@Override
35
	public Collection<NamedArea> getCollection(DerivedUnitFacade entity) {
36
		return entity.getCollectingAreas();
37
	}
38

    
39
	@Override
40
	public Comparator<NamedArea> getComparator() {
41
        return new DefaultCdmBaseComparator<>();
42
	}
43

    
44
	@Override
45
	public NamedArea createNewElement() {
46
		NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(),
47
		        null, FieldUnit.class.getCanonicalName());
48

    
49
		return selection;
50
	}
51

    
52
	@Override
53
	public void addElement(NamedArea element) {
54
		getEntity().addCollectingArea(element);
55
	}
56

    
57
	@Override
58
	public void removeElement(NamedArea element) {
59
		getEntity().removeCollectingArea(element);
60
	}
61

    
62
	@Override
63
	public String getEmptyString() {
64
		return "No collecting areas yet.";
65
	}
66

    
67
	@Override
68
	protected String getTooltipString() {
69
		return "Add a collecting area";
70
	}
71

    
72
    @Override
73
    public NamedArea addExisting() {
74
        return null;
75
    }
76

    
77
    @Override
78
    public boolean allowAddExisting() {
79
        return false;
80
    }
81
}
(5-5/38)