3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.preference
.menu
;
13 import java
.util
.List
;
15 import org
.eclipse
.swt
.graphics
.Image
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.swt
.widgets
.Control
;
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
;
26 * <p>NameRelationshipTypeMenuPreferences class.</p>
32 public class NameRelationshipTypeMenuPreferences
extends
33 AbstractMenuPreferences
<NameRelationshipType
> {
37 * <p>Constructor for NameRelationshipTypeMenuPreferences.</p>
39 public NameRelationshipTypeMenuPreferences() {
40 super("Name relationship types",
41 "Configure name relationship types",
46 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#createContents(org.eclipse.swt.widgets.Composite)
50 public Control
createContents(Composite parent
) {
51 Control container
= super.createContents(parent
);
52 getTableViewer().setLabelProvider(new NameRelationLabelProvider());
56 public class NameRelationLabelProvider
extends DefinedTermBaseLabelProvider
{
58 private LabelImageProvider labelProvider
;
60 public NameRelationLabelProvider() {
63 ILabelImageStrategy strategy
= LabelImageProvider
.getLabelStrategy(
64 PreferencesUtil
.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null));
65 this.labelProvider
= new LabelImageProvider(strategy
);
69 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnImage(java.lang.Object, int)
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);
77 return super.getColumnImage(element
, columnIndex
);
81 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences.MenuPreferenceLabelProvider#getColumnText(java.lang.Object, int)
84 public String
getColumnText(Object element
, int columnIndex
) {
85 if (element
instanceof NameRelationshipType
) {
86 return labelProvider
.getNameRelationTypeLabel((NameRelationshipType
) element
);
88 return super.getColumnText(element
, columnIndex
);
93 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
97 protected Class
<NameRelationshipType
> getTermClass() {
98 return NameRelationshipType
.class;
102 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTerms()
105 protected List
<NameRelationshipType
> getTerms() {
106 return TermStore
.getNameRelationshipTypes();