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