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
|
|
10
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
11
|
|
12
|
import java.util.Collection;
|
13
|
import java.util.Comparator;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
16
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
17
|
import eu.etaxonomy.cdm.model.description.Feature;
|
18
|
import eu.etaxonomy.cdm.model.media.Media;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
23
|
|
24
|
/**
|
25
|
* <p>DescriptionElementMediaSection class.</p>
|
26
|
*
|
27
|
* @author n.hoffmann
|
28
|
* @created Mar 18, 2010
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class DescriptionElementMediaSection extends
|
32
|
AbstractEntityCollectionSection<DescriptionElementBase, Media> {
|
33
|
|
34
|
public DescriptionElementMediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
|
35
|
ICdmFormElement parentElement, int style) {
|
36
|
super(cdmFormFactory, conversation, parentElement, "Media", style);
|
37
|
}
|
38
|
|
39
|
/** {@inheritDoc} */
|
40
|
@Override
|
41
|
public void setEntity(DescriptionElementBase entity) {
|
42
|
if(entity.getFeature().equals(Feature.IMAGE())){
|
43
|
this.setVisible(false);
|
44
|
}
|
45
|
super.setEntity(entity);
|
46
|
if (entity.getInDescription().isComputed()){
|
47
|
this.setEnabled(false);
|
48
|
}
|
49
|
}
|
50
|
|
51
|
/** {@inheritDoc} */
|
52
|
@Override
|
53
|
public void addElement(Media element) {
|
54
|
getEntity().addMedia(element);
|
55
|
}
|
56
|
|
57
|
/** {@inheritDoc} */
|
58
|
@Override
|
59
|
public Media createNewElement() {
|
60
|
return Media.NewInstance();
|
61
|
}
|
62
|
|
63
|
/** {@inheritDoc} */
|
64
|
@Override
|
65
|
public Collection<Media> getCollection(DescriptionElementBase entity) {
|
66
|
return entity.getMedia();
|
67
|
}
|
68
|
|
69
|
@Override
|
70
|
public Comparator<Media> getComparator() {
|
71
|
return new DefaultCdmBaseComparator<>();
|
72
|
}
|
73
|
|
74
|
/** {@inheritDoc} */
|
75
|
@Override
|
76
|
public String getEmptyString() {
|
77
|
return "No media yet.";
|
78
|
}
|
79
|
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
protected String getTooltipString() {
|
83
|
return "Create new media";
|
84
|
}
|
85
|
|
86
|
/** {@inheritDoc} */
|
87
|
@Override
|
88
|
public void removeElement(Media element) {
|
89
|
getEntity().removeMedia(element);
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* {@inheritDoc}
|
94
|
*/
|
95
|
@Override
|
96
|
public Media addExisting() {
|
97
|
return null;
|
98
|
}
|
99
|
|
100
|
/**
|
101
|
* {@inheritDoc}
|
102
|
*/
|
103
|
@Override
|
104
|
public boolean allowAddExisting() {
|
105
|
return false;
|
106
|
}
|
107
|
|
108
|
|
109
|
}
|