Changed calls to retrieve term vocabularies to preferred term mechanism where applicable.
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / labels / DefaultLabelStrategy.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.editor.labels;
5
6 import java.util.SortedSet;
7
8 import org.eclipse.swt.graphics.Image;
9
10 import eu.etaxonomy.cdm.model.name.NameRelationship;
11 import eu.etaxonomy.cdm.model.name.NameRelationshipType;
12 import eu.etaxonomy.taxeditor.model.ImageResources;
13 import eu.etaxonomy.taxeditor.store.VocabularyStore;
14
15 /**
16 * @author p.ciardelli
17 *
18 */
19 public class DefaultLabelStrategy implements ILabelImageStrategy {
20
21 /* (non-Javadoc)
22 * @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType)
23 */
24 public String getNameRelationTypeLabel(NameRelationshipType type) {
25 SortedSet<NameRelationshipType> vocab =
26 VocabularyStore.getNameRelationshipTypes();
27
28 for (NameRelationshipType type1 : vocab) {
29 if (type1.equals(type)) {
30 return type1.getLabel();
31 }
32 }
33 return "";
34 }
35
36 /* (non-Javadoc)
37 * @see eu.etaxonomy.taxeditor.editor.labels.IEditorLabelStrategy#getNameRelationInverseTypeLabel(eu.etaxonomy.cdm.model.name.NameRelationshipType)
38 */
39 public String getNameRelationTypeInverseLabel(NameRelationshipType type) {
40
41 SortedSet<NameRelationshipType> vocab =
42 VocabularyStore.getNameRelationshipTypes();
43
44 for (NameRelationshipType type1 : vocab) {
45 if (type1.equals(type)) {
46 return type1.getInverseLabel();
47 }
48 }
49 return "";
50 }
51
52 /* (non-Javadoc)
53 * @see eu.etaxonomy.taxeditor.editor.labels.ILabelImageStrategy#getNameRelationImage(eu.etaxonomy.cdm.model.name.NameRelationship)
54 */
55 public Image getNameRelationImage(NameRelationship relation) {
56 if (relation.getType().equals(NameRelationshipType.BASIONYM())) {
57 return ImageResources.getImage(
58 ImageResources.BASIONYM_ICON);
59 }
60 if (relation.getType().equals(
61 NameRelationshipType.ORTHOGRAPHIC_VARIANT())) {
62 return ImageResources.getImage(
63 ImageResources.ORTHOGRAPHIC_VARIANT_ICON);
64 }
65 return null;
66 }
67 }