Project

General

Profile

Download (2.68 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.labels;
5

    
6
import org.eclipse.swt.graphics.Image;
7

    
8
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
9
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
10
import eu.etaxonomy.cdm.model.name.TaxonName;
11
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
12

    
13
/**
14
 * Returns labels and images that are dependent on a nomenclatural
15
 * code using a code-specific ILabelImageStrategy.
16
 *
17
 * @author p.ciardelli
18
 */
19
public class LabelImageProvider implements ILabelImageStrategy {
20

    
21
	private ILabelImageStrategy strategy;
22

    
23
	/**
24
	 * <p>getLabelStrategy</p>
25
	 *
26
	 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
27
	 * @return a {@link eu.etaxonomy.taxeditor.labels.ILabelImageStrategy} object.
28
	 */
29
	public static ILabelImageStrategy getLabelStrategy(TaxonName name) {
30
		if (name == null) {
31
			if (PreferencesUtil.getPreferredNomenclaturalCode().
32
					equals(NomenclaturalCode.ICZN)) {
33
				return new ZoologicalNameLabelStrategy();
34
			}
35
		} else if (name.getNameType() != null &&
36
				name.getNameType().equals(NomenclaturalCode.ICZN)) {
37
			return new ZoologicalNameLabelStrategy();
38
		}
39
		return new DefaultLabelStrategy();
40
	}
41

    
42
	/**
43
	 * <p>Constructor for LabelImageProvider.</p>
44
	 *
45
	 * @param strategy a {@link eu.etaxonomy.taxeditor.labels.ILabelImageStrategy} object.
46
	 */
47
	public LabelImageProvider(ILabelImageStrategy strategy) {
48
		this.strategy = strategy;
49
	}
50

    
51
	/* (non-Javadoc)
52
	 * @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType)
53
	 */
54
	/** {@inheritDoc} */
55
	@Override
56
    public String getNameRelationTypeLabel(NameRelationshipType type) {
57
		return strategy.getNameRelationTypeLabel(type);
58
	}
59

    
60
	/* (non-Javadoc)
61
	 * @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationInverseTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType)
62
	 */
63
	/** {@inheritDoc} */
64
	@Override
65
    public String getNameRelationTypeInverseLabel(NameRelationshipType type) {
66
		return strategy.getNameRelationTypeInverseLabel(type);
67
	}
68

    
69
	/* (non-Javadoc)
70
	 * @see eu.etaxonomy.taxeditor.editor.labels.ILabelImageStrategy#getNameRelationImage(eu.etaxonomy.cdm.model.name.NameRelationship)
71
	 */
72
	/** {@inheritDoc} */
73
	@Override
74
    public Image getNameRelationTypeImage(NameRelationshipType type) {
75
		return strategy.getNameRelationTypeImage(type);
76
	}
77

    
78
	/* (non-Javadoc)
79
	 * @see eu.etaxonomy.taxeditor.labels.ILabelImageStrategy#getNameRelationDescription(eu.etaxonomy.cdm.model.name.NameRelationshipType)
80
	 */
81
	/** {@inheritDoc} */
82
	@Override
83
    public String getNameRelationTypeDescription(NameRelationshipType type) {
84
		return strategy.getNameRelationTypeDescription(type);
85
	}
86
}
(3-3/4)