1
|
/**
|
2
|
* Copyright (C) 2020 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.conversation.ConversationHolder;
|
15
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
16
|
import eu.etaxonomy.cdm.model.media.Media;
|
17
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog;
|
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 k.luther
|
25
|
* @since Aug 4, 2020
|
26
|
*/
|
27
|
public class DerivedUnitMediaSection extends AbstractEntityCollectionSection<DerivedUnitFacade, Media> {
|
28
|
|
29
|
public DerivedUnitMediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
|
30
|
super(cdmFormFactory, conversation, parentElement, "Media", style);
|
31
|
}
|
32
|
|
33
|
@Override
|
34
|
public Media createNewElement() {
|
35
|
return Media.NewInstance();
|
36
|
}
|
37
|
|
38
|
@Override
|
39
|
public Collection<Media> getCollection(DerivedUnitFacade entity) {
|
40
|
return entity.getDerivedUnitMedia();
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public Comparator<Media> getComparator() {
|
45
|
return new DefaultCdmBaseComparator<>();
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public String getEmptyString() {
|
50
|
return "No media yet.";
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
protected String getTooltipString() {
|
55
|
return "Create new media";
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public void addElement(Media element) {
|
60
|
getEntity().addDerivedUnitMedia(element);
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public void removeElement(Media element) {
|
65
|
getEntity().removeDerivedUnitMedia(element);
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public Media addExisting() {
|
70
|
return MediaSelectionDialog.select(getShell(), null);
|
71
|
}
|
72
|
|
73
|
@Override
|
74
|
public boolean allowAddExisting() {
|
75
|
return true;
|
76
|
}
|
77
|
|
78
|
}
|