Project

General

Profile

Download (2.72 KB) Statistics
| Branch: | Tag: | Revision:
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.preference.PreferencesUtil;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
23
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
24

    
25
/**
26
 * <p>DescriptionElementMediaSection class.</p>
27
 *
28
 * @author n.hoffmann
29
 * @created Mar 18, 2010
30
 * @version 1.0
31
 */
32
public class DescriptionElementMediaSection extends
33
		AbstractEntityCollectionSection<DescriptionElementBase, Media> {
34

    
35
	public DescriptionElementMediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
36
			ICdmFormElement parentElement, int style) {
37
		super(cdmFormFactory, conversation, parentElement, "Media", style);
38
	}
39

    
40
	/** {@inheritDoc} */
41
	@Override
42
	public void setEntity(DescriptionElementBase entity) {
43
		if(entity.getFeature().equals(Feature.IMAGE())){
44
			this.setVisible(false);
45
		}
46
		super.setEntity(entity);
47
		if ((entity.getInDescription().isComputed() || entity.getInDescription().isCloneForSource())&& PreferencesUtil.isComputedDesciptionHandlingDisabled()){
48
		    this.setEnabled(false);
49
		}
50
	}
51

    
52
	/** {@inheritDoc} */
53
	@Override
54
	public void addElement(Media element) {
55
		getEntity().addMedia(element);
56
	}
57

    
58
	/** {@inheritDoc} */
59
	@Override
60
	public Media createNewElement() {
61
		return Media.NewInstance();
62
	}
63

    
64
	/** {@inheritDoc} */
65
	@Override
66
	public Collection<Media> getCollection(DescriptionElementBase entity) {
67
		return entity.getMedia();
68
	}
69

    
70
	@Override
71
	public Comparator<Media> getComparator() {
72
        return new DefaultCdmBaseComparator<>();
73
	}
74

    
75
	/** {@inheritDoc} */
76
	@Override
77
	public String getEmptyString() {
78
		return "No media yet.";
79
	}
80

    
81
	/** {@inheritDoc} */
82
	@Override
83
	protected String getTooltipString() {
84
		return "Create new media";
85
	}
86

    
87
	/** {@inheritDoc} */
88
	@Override
89
	public void removeElement(Media element) {
90
		getEntity().removeMedia(element);
91
	}
92

    
93
    /**
94
     * {@inheritDoc}
95
     */
96
    @Override
97
    public Media addExisting() {
98
        return null;
99
    }
100

    
101
    /**
102
     * {@inheritDoc}
103
     */
104
    @Override
105
    public boolean allowAddExisting() {
106
        return false;
107
    }
108

    
109

    
110
}
(8-8/26)