1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.preference.menu;
|
12
|
|
13
|
import org.eclipse.swt.graphics.Image;
|
14
|
import org.eclipse.swt.widgets.Composite;
|
15
|
import org.eclipse.swt.widgets.Control;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
|
18
|
import eu.etaxonomy.taxeditor.labels.ILabelImageStrategy;
|
19
|
import eu.etaxonomy.taxeditor.labels.LabelImageProvider;
|
20
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
21
|
import eu.etaxonomy.taxeditor.store.TermStore;
|
22
|
|
23
|
/**
|
24
|
* <p>NameRelationshipTypeMenuPreferences class.</p>
|
25
|
*
|
26
|
* @author n.hoffmann
|
27
|
* @created 25.06.2009
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class NameRelationshipTypeMenuPreferences extends
|
31
|
AbstractMenuPreferences<NameRelationshipType> {
|
32
|
|
33
|
|
34
|
/**
|
35
|
* <p>Constructor for NameRelationshipTypeMenuPreferences.</p>
|
36
|
*/
|
37
|
public NameRelationshipTypeMenuPreferences() {
|
38
|
super(TermStore.getNameRelationshipTypes(),
|
39
|
"Name relationship types",
|
40
|
"Configure name relationship types",
|
41
|
false);
|
42
|
}
|
43
|
|
44
|
/* (non-Javadoc)
|
45
|
* @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#createContents(org.eclipse.swt.widgets.Composite)
|
46
|
*/
|
47
|
/** {@inheritDoc} */
|
48
|
@Override
|
49
|
public Control createContents(Composite parent) {
|
50
|
Control container = super.createContents(parent);
|
51
|
getTableViewer().setLabelProvider(new NameRelationLabelProvider());
|
52
|
return container;
|
53
|
}
|
54
|
|
55
|
public class NameRelationLabelProvider extends DefinedTermBaseLabelProvider {
|
56
|
|
57
|
private LabelImageProvider labelProvider;
|
58
|
|
59
|
public NameRelationLabelProvider() {
|
60
|
super();
|
61
|
|
62
|
ILabelImageStrategy strategy = LabelImageProvider.getLabelStrategy(
|
63
|
PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null));
|
64
|
this.labelProvider = new LabelImageProvider(strategy);
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnImage(java.lang.Object, int)
|
69
|
*/
|
70
|
@Override
|
71
|
public Image getColumnImage(Object element, int columnIndex) {
|
72
|
// The preference page looked lame with images
|
73
|
// if (element instanceof NameRelationshipType) {
|
74
|
// return labelProvider.getNameRelationImage((NameRelationshipType) element);
|
75
|
// }
|
76
|
return super.getColumnImage(element, columnIndex);
|
77
|
}
|
78
|
|
79
|
/* (non-Javadoc)
|
80
|
* @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnText(java.lang.Object, int)
|
81
|
*/
|
82
|
@Override
|
83
|
public String getColumnText(Object element, int columnIndex) {
|
84
|
if (element instanceof NameRelationshipType) {
|
85
|
return labelProvider.getNameRelationTypeLabel((NameRelationshipType) element);
|
86
|
}
|
87
|
return super.getColumnText(element, columnIndex);
|
88
|
}
|
89
|
}
|
90
|
|
91
|
/* (non-Javadoc)
|
92
|
* @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
|
93
|
*/
|
94
|
/** {@inheritDoc} */
|
95
|
@Override
|
96
|
protected Class<NameRelationshipType> getTermClass() {
|
97
|
return NameRelationshipType.class;
|
98
|
}
|
99
|
}
|