ApplicationUtil : Added 'Remoting' to title
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / labels / LabelImageProvider.java
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.TaxonNameBase;
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 * @version $Id: $
19 */
20 public class LabelImageProvider implements ILabelImageStrategy {
21
22 private ILabelImageStrategy strategy;
23
24 /**
25 * <p>getLabelStrategy</p>
26 *
27 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
28 * @return a {@link eu.etaxonomy.taxeditor.labels.ILabelImageStrategy} object.
29 */
30 public static ILabelImageStrategy getLabelStrategy(TaxonNameBase name) {
31 if (name == null) {
32 if (PreferencesUtil.getPreferredNomenclaturalCode().
33 equals(NomenclaturalCode.ICZN)) {
34 return new ZoologicalNameLabelStrategy();
35 }
36 } else if (name.getNomenclaturalCode() != null &&
37 name.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)) {
38 return new ZoologicalNameLabelStrategy();
39 }
40 return new DefaultLabelStrategy();
41 }
42
43 /**
44 * <p>Constructor for LabelImageProvider.</p>
45 *
46 * @param strategy a {@link eu.etaxonomy.taxeditor.labels.ILabelImageStrategy} object.
47 */
48 public LabelImageProvider(ILabelImageStrategy strategy) {
49 this.strategy = strategy;
50 }
51
52 /* (non-Javadoc)
53 * @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType)
54 */
55 /** {@inheritDoc} */
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 public String getNameRelationTypeInverseLabel(NameRelationshipType type) {
65 return strategy.getNameRelationTypeInverseLabel(type);
66 }
67
68 /* (non-Javadoc)
69 * @see eu.etaxonomy.taxeditor.editor.labels.ILabelImageStrategy#getNameRelationImage(eu.etaxonomy.cdm.model.name.NameRelationship)
70 */
71 /** {@inheritDoc} */
72 public Image getNameRelationTypeImage(NameRelationshipType type) {
73 return strategy.getNameRelationTypeImage(type);
74 }
75
76 /* (non-Javadoc)
77 * @see eu.etaxonomy.taxeditor.labels.ILabelImageStrategy#getNameRelationDescription(eu.etaxonomy.cdm.model.name.NameRelationshipType)
78 */
79 /** {@inheritDoc} */
80 public String getNameRelationTypeDescription(NameRelationshipType type) {
81 return strategy.getNameRelationTypeDescription(type);
82 }
83 }