2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
;
11 import java
.util
.Collection
;
12 import java
.util
.Comparator
;
13 import java
.util
.HashSet
;
15 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
16 import eu
.etaxonomy
.cdm
.persistence
.dto
.FeatureDto
;
17 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.dna
.AbstractUnboundEntityCollectionSection
;
26 public class MeasurementUnitDtoCollectionSection
extends AbstractUnboundEntityCollectionSection
<FeatureDto
, TermDto
> {
28 public MeasurementUnitDtoCollectionSection(CdmFormFactory formFactory
,
29 ICdmFormElement parentElement
, int style
) {
30 super(formFactory
, parentElement
, "Recommended measurement units", style
);
34 protected Collection
<TermDto
> getEntityCollection(FeatureDto entity
) {
35 if (entity
.getRecommendedMeasurementUnits() == null){
36 entity
.setRecommendedMeasurementUnits(new HashSet
<TermDto
>());
38 return entity
.getRecommendedMeasurementUnits();
42 public Comparator
<TermDto
> getComparator() {
43 return new Comparator
<TermDto
>() {
45 public int compare(TermDto o1
, TermDto o2
) {
52 int diff
= o1
.getTitleCache().compareTo(o2
.getTitleCache());
54 diff
= o1
.getUuid().compareTo(o2
.getUuid());
62 public TermDto
createNewElement() {
63 return TermDto
.fromTerm(MeasurementUnit
.NewInstance());
67 public void addElement(TermDto element
) {
72 public void removeElement(TermDto element
) {
76 TermDto remove
= null;
77 for (TermDto unit
: getEntity().getRecommendedMeasurementUnits()){
78 if (unit
.getUuid().equals(element
.getUuid())){
83 getEntity().getRecommendedMeasurementUnits().remove(remove
);
87 public String
getEmptyString() {
88 return "No recommended measurement units yet.";
92 protected String
getTooltipString() {
93 return "Add a measurement unit";
97 public TermDto
addExisting() {
98 // TODO Auto-generated method stub
103 public boolean allowAddExisting() {
104 // TODO Auto-generated method stub