Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
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 |
* |
|
19 |
*/ |
|
20 |
public class LabelImageProvider implements ILabelImageStrategy { |
|
21 |
|
|
22 |
private ILabelImageStrategy strategy; |
|
23 |
|
|
24 |
public static ILabelImageStrategy getLabelStrategy(TaxonNameBase name) { |
|
25 |
if (name == null) { |
|
26 |
if (PreferencesUtil.getPreferredNomenclaturalCode(). |
|
27 |
equals(NomenclaturalCode.ICZN)) { |
|
28 |
return new ZoologicalNameLabelStrategy(); |
|
29 |
} |
|
30 |
} else if (name.getNomenclaturalCode() != null && |
|
31 |
name.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)) { |
|
32 |
return new ZoologicalNameLabelStrategy(); |
|
33 |
} |
|
34 |
return new DefaultLabelStrategy(); |
|
35 |
} |
|
36 |
|
|
37 |
public LabelImageProvider(ILabelImageStrategy strategy) { |
|
38 |
this.strategy = strategy; |
|
39 |
} |
|
40 |
|
|
41 |
/* (non-Javadoc) |
|
42 |
* @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType) |
|
43 |
*/ |
|
44 |
public String getNameRelationTypeLabel(NameRelationshipType type) { |
|
45 |
return strategy.getNameRelationTypeLabel(type); |
|
46 |
} |
|
47 |
|
|
48 |
/* (non-Javadoc) |
|
49 |
* @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationInverseTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType) |
|
50 |
*/ |
|
51 |
public String getNameRelationTypeInverseLabel(NameRelationshipType type) { |
|
52 |
return strategy.getNameRelationTypeInverseLabel(type); |
|
53 |
} |
|
54 |
|
|
55 |
/* (non-Javadoc) |
|
56 |
* @see eu.etaxonomy.taxeditor.editor.labels.ILabelImageStrategy#getNameRelationImage(eu.etaxonomy.cdm.model.name.NameRelationship) |
|
57 |
*/ |
|
58 |
public Image getNameRelationTypeImage(NameRelationshipType type) { |
|
59 |
return strategy.getNameRelationTypeImage(type); |
|
60 |
} |
|
61 |
|
|
62 |
/* (non-Javadoc) |
|
63 |
* @see eu.etaxonomy.taxeditor.labels.ILabelImageStrategy#getNameRelationDescription(eu.etaxonomy.cdm.model.name.NameRelationshipType) |
|
64 |
*/ |
|
65 |
public String getNameRelationTypeDescription(NameRelationshipType type) { |
|
66 |
return strategy.getNameRelationTypeDescription(type); |
|
67 |
} |
|
68 |
} |
|
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 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation