1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.vocabulary;
|
5
|
|
6
|
import java.util.Collection;
|
7
|
import java.util.Comparator;
|
8
|
|
9
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
10
|
import eu.etaxonomy.cdm.model.media.Media;
|
11
|
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
|
12
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog;
|
13
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
14
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
15
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
16
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
17
|
|
18
|
/**
|
19
|
*
|
20
|
* @author pplitzner
|
21
|
* @since May 17, 2019
|
22
|
*
|
23
|
*/
|
24
|
public class TermMediaSection extends AbstractEntityCollectionSection<DefinedTermBase, Media>{
|
25
|
|
26
|
public TermMediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
|
27
|
super(cdmFormFactory, conversation, parentElement, "Media", style);
|
28
|
}
|
29
|
|
30
|
@Override
|
31
|
public Media createNewElement() {
|
32
|
return Media.NewInstance();
|
33
|
}
|
34
|
|
35
|
@Override
|
36
|
public Collection<Media> getCollection(DefinedTermBase entity) {
|
37
|
return entity.getMedia();
|
38
|
}
|
39
|
|
40
|
@Override
|
41
|
public Comparator<Media> getComparator() {
|
42
|
return new DefaultCdmBaseComparator<>();
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
public String getEmptyString() {
|
47
|
return "No media yet.";
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
protected String getTooltipString() {
|
52
|
return "Create new media";
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public void addElement(Media element) {
|
57
|
getEntity().addMedia(element);
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public void removeElement(Media element) {
|
62
|
getEntity().removeMedia(element);
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
public Media addExisting() {
|
67
|
return MediaSelectionDialog.select(getShell(), null);
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
public boolean allowAddExisting() {
|
72
|
return true;
|
73
|
}
|
74
|
|
75
|
}
|