Project

General

Profile

Download (3.08 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.l10n.Messages;
19
import eu.etaxonomy.taxeditor.labels.ILabelImageStrategy;
20
import eu.etaxonomy.taxeditor.labels.LabelImageProvider;
21
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
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("Name relationship types", //$NON-NLS-1$
39
				Messages.NameRelationshipTypeMenuPreferences_relationshipTypes,
40
				false);
41
	}
42

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

    
54
	public class NameRelationLabelProvider extends DefinedTermBaseLabelProvider {
55

    
56
		private LabelImageProvider labelProvider;
57

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

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

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

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

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