Project

General

Profile

Download (3.27 KB) Statistics
| Branch: | Tag: | Revision:
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 java.util.List;
14

    
15
import org.eclipse.swt.graphics.Image;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Control;
18

    
19
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
20
import eu.etaxonomy.taxeditor.labels.ILabelImageStrategy;
21
import eu.etaxonomy.taxeditor.labels.LabelImageProvider;
22
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
23
import eu.etaxonomy.taxeditor.store.TermStore;
24

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

    
35
	
36
	/**
37
	 * <p>Constructor for NameRelationshipTypeMenuPreferences.</p>
38
	 */
39
	public NameRelationshipTypeMenuPreferences() {
40
		super("Name relationship types", 
41
				"Configure name relationship types",
42
				false);
43
	}
44
	
45
	/* (non-Javadoc)
46
	 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#createContents(org.eclipse.swt.widgets.Composite)
47
	 */
48
	/** {@inheritDoc} */
49
	@Override
50
	public Control createContents(Composite parent) {
51
		Control container = super.createContents(parent);
52
		getTableViewer().setLabelProvider(new NameRelationLabelProvider());
53
		return container;
54
	}
55
	
56
	public class NameRelationLabelProvider extends DefinedTermBaseLabelProvider {
57

    
58
		private LabelImageProvider labelProvider;
59

    
60
		public NameRelationLabelProvider() {
61
			super();
62
			
63
			ILabelImageStrategy strategy = LabelImageProvider.getLabelStrategy(
64
							PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null));
65
			this.labelProvider = new LabelImageProvider(strategy);
66
		}
67
		
68
		/* (non-Javadoc)
69
		 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnImage(java.lang.Object, int)
70
		 */
71
		@Override
72
		public Image getColumnImage(Object element, int columnIndex) {
73
			// The preference page looked lame with images 
74
//			if (element instanceof NameRelationshipType) {
75
//				return labelProvider.getNameRelationImage((NameRelationshipType) element);
76
//			}
77
			return super.getColumnImage(element, columnIndex);
78
		}
79
		
80
		/* (non-Javadoc)
81
		 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnText(java.lang.Object, int)
82
		 */
83
		@Override
84
		public String getColumnText(Object element, int columnIndex) {
85
			if (element instanceof NameRelationshipType) {
86
				return labelProvider.getNameRelationTypeLabel((NameRelationshipType) element);
87
			}
88
			return super.getColumnText(element, columnIndex);
89
		}
90
	}
91

    
92
	/* (non-Javadoc)
93
	 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
94
	 */
95
	/** {@inheritDoc} */
96
	@Override
97
	protected Class<NameRelationshipType> getTermClass() {
98
		return NameRelationshipType.class;
99
	}
100

    
101
	/* (non-Javadoc)
102
	 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTerms()
103
	 */
104
	@Override
105
	protected List<NameRelationshipType> getTerms() {
106
		return TermStore.getNameRelationshipTypes();
107
	}
108
}
(9-9/18)