1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.media;
|
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.IdentifiableMediaEntity;
|
11
|
import eu.etaxonomy.cdm.model.media.Media;
|
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
|
* <p>MediaSection class.</p>
|
20
|
*
|
21
|
* @author nho
|
22
|
* @version $Id: $
|
23
|
*/
|
24
|
public class MediaSection extends AbstractEntityCollectionSection<IdentifiableMediaEntity, Media>{
|
25
|
|
26
|
/**
|
27
|
* <p>Constructor for MediaSection.</p>
|
28
|
*
|
29
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
|
30
|
* @param style a int.
|
31
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
32
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
33
|
*/
|
34
|
public MediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
|
35
|
super(cdmFormFactory, conversation, parentElement, "Media", style);
|
36
|
}
|
37
|
|
38
|
/** {@inheritDoc} */
|
39
|
@Override
|
40
|
public Media createNewElement() {
|
41
|
return Media.NewInstance();
|
42
|
}
|
43
|
|
44
|
/** {@inheritDoc} */
|
45
|
@Override
|
46
|
public Collection<Media> getCollection(IdentifiableMediaEntity entity) {
|
47
|
return entity.getMedia();
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
public Comparator<Media> getComparator() {
|
52
|
return new DefaultCdmBaseComparator<>();
|
53
|
}
|
54
|
|
55
|
/** {@inheritDoc} */
|
56
|
@Override
|
57
|
public String getEmptyString() {
|
58
|
return "No media yet.";
|
59
|
}
|
60
|
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
protected String getTooltipString() {
|
64
|
return "Create new media";
|
65
|
}
|
66
|
|
67
|
/** {@inheritDoc} */
|
68
|
@Override
|
69
|
public void addElement(Media element) {
|
70
|
getEntity().addMedia(element);
|
71
|
}
|
72
|
|
73
|
/** {@inheritDoc} */
|
74
|
@Override
|
75
|
public void removeElement(Media element) {
|
76
|
getEntity().removeMedia(element);
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* {@inheritDoc}
|
81
|
*/
|
82
|
@Override
|
83
|
public Media addExisting() {
|
84
|
return MediaSelectionDialog.select(getShell(), //getConversationHolder(),
|
85
|
null);
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* {@inheritDoc}
|
90
|
*/
|
91
|
@Override
|
92
|
public boolean allowAddExisting() {
|
93
|
return true;
|
94
|
}
|
95
|
|
96
|
}
|