Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / menu / NameRelationshipTypeMenuPreferences.java
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.preference.menu;
11
12 import org.eclipse.swt.graphics.Image;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Control;
15
16 import eu.etaxonomy.cdm.model.name.NameRelationshipType;
17 import eu.etaxonomy.taxeditor.labels.ILabelImageStrategy;
18 import eu.etaxonomy.taxeditor.labels.LabelImageProvider;
19 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20
21 /**
22 * <p>NameRelationshipTypeMenuPreferences class.</p>
23 *
24 * @author n.hoffmann
25 * @created 25.06.2009
26 * @version 1.0
27 */
28 public class NameRelationshipTypeMenuPreferences extends
29 AbstractMenuPreferences<NameRelationshipType> {
30
31
32 /**
33 * <p>Constructor for NameRelationshipTypeMenuPreferences.</p>
34 */
35 public NameRelationshipTypeMenuPreferences() {
36 super("Name relationship types",
37 "Configure name relationship types",
38 false);
39 }
40
41 /* (non-Javadoc)
42 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#createContents(org.eclipse.swt.widgets.Composite)
43 */
44 /** {@inheritDoc} */
45 @Override
46 public Control createContents(Composite parent) {
47 Control container = super.createContents(parent);
48 getTableViewer().setLabelProvider(new NameRelationLabelProvider());
49 return container;
50 }
51
52 public class NameRelationLabelProvider extends DefinedTermBaseLabelProvider {
53
54 private LabelImageProvider labelProvider;
55
56 public NameRelationLabelProvider() {
57 super();
58
59 ILabelImageStrategy strategy = LabelImageProvider.getLabelStrategy(
60 PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null));
61 this.labelProvider = new LabelImageProvider(strategy);
62 }
63
64 /* (non-Javadoc)
65 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnImage(java.lang.Object, int)
66 */
67 @Override
68 public Image getColumnImage(Object element, int columnIndex) {
69 // The preference page looked lame with images
70 // if (element instanceof NameRelationshipType) {
71 // return labelProvider.getNameRelationImage((NameRelationshipType) element);
72 // }
73 return super.getColumnImage(element, columnIndex);
74 }
75
76 /* (non-Javadoc)
77 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnText(java.lang.Object, int)
78 */
79 @Override
80 public String getColumnText(Object element, int columnIndex) {
81 if (element instanceof NameRelationshipType) {
82 return labelProvider.getNameRelationTypeLabel((NameRelationshipType) element);
83 }
84 return super.getColumnText(element, columnIndex);
85 }
86 }
87
88 /* (non-Javadoc)
89 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
90 */
91 /** {@inheritDoc} */
92 @Override
93 protected Class<NameRelationshipType> getTermClass() {
94 return NameRelationshipType.class;
95 }
96 }