Project

General

Profile

Download (3 KB) Statistics
| Branch: | Tag: | Revision:
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.common.TermType;
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

    
22
/**
23
 * <p>NameRelationshipTypeMenuPreferences class.</p>
24
 *
25
 * @author n.hoffmann
26
 * @created 25.06.2009
27
 * @version 1.0
28
 */
29
public class NameRelationshipTypeMenuPreferences extends
30
		AbstractMenuPreferences<NameRelationshipType> {
31

    
32

    
33
	/**
34
	 * <p>Constructor for NameRelationshipTypeMenuPreferences.</p>
35
	 */
36
	public NameRelationshipTypeMenuPreferences() {
37
		super("Name relationship types",
38
				"Configure name relationship types",
39
				false);
40
	}
41

    
42
	/* (non-Javadoc)
43
	 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#createContents(org.eclipse.swt.widgets.Composite)
44
	 */
45
	/** {@inheritDoc} */
46
	@Override
47
	public Control createContents(Composite parent) {
48
		Control container = super.createContents(parent);
49
		getTableViewer().setLabelProvider(new NameRelationLabelProvider());
50
		return container;
51
	}
52

    
53
	public class NameRelationLabelProvider extends DefinedTermBaseLabelProvider {
54

    
55
		private LabelImageProvider labelProvider;
56

    
57
		public NameRelationLabelProvider() {
58
			super();
59

    
60
			ILabelImageStrategy strategy = LabelImageProvider.getLabelStrategy(
61
							PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null));
62
			this.labelProvider = new LabelImageProvider(strategy);
63
		}
64

    
65
		/* (non-Javadoc)
66
		 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnImage(java.lang.Object, int)
67
		 */
68
		@Override
69
		public Image getColumnImage(Object element, int columnIndex) {
70
			// The preference page looked lame with images
71
//			if (element instanceof NameRelationshipType) {
72
//				return labelProvider.getNameRelationImage((NameRelationshipType) element);
73
//			}
74
			return super.getColumnImage(element, columnIndex);
75
		}
76

    
77
		/* (non-Javadoc)
78
		 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnText(java.lang.Object, int)
79
		 */
80
		@Override
81
		public String getColumnText(Object element, int columnIndex) {
82
			if (element instanceof NameRelationshipType) {
83
				return labelProvider.getNameRelationTypeLabel((NameRelationshipType) element);
84
			}
85
			return super.getColumnText(element, columnIndex);
86
		}
87
	}
88

    
89
	/* (non-Javadoc)
90
	 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
91
	 */
92
	/** {@inheritDoc} */
93
	@Override
94
	protected TermType getTermType() {
95
		return TermType.NameRelationshipType;
96
	}
97
}
(10-10/20)