Project

General

Profile

Download (2.26 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.navigation.navigator;
11

    
12
import org.apache.log4j.Logger;
13
import org.eclipse.jface.viewers.ColumnLabelProvider;
14
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
15
import org.eclipse.jface.viewers.ILabelProvider;
16
import org.eclipse.jface.viewers.StyledString;
17
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.ui.navigator.IDescriptionProvider;
19

    
20
import eu.etaxonomy.cdm.model.taxon.Classification;
21

    
22
/**
23
 * <p>ClassificationLabelProvider class.</p>
24
 *
25
 * @author n.hoffmann
26
 * @created 17.06.2009
27
 * @version 1.0
28
 */
29
public class ClassificationLabelProvider extends ColumnLabelProvider 
30
implements ILabelProvider, IDescriptionProvider, IStyledLabelProvider {
31
	private static final Logger logger = Logger
32
			.getLogger(ClassificationLabelProvider.class);
33
	
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
36
	 */
37
	/** {@inheritDoc} */
38
	@Override
39
	public Image getImage(Object element) {
40
		return null;
41
	}
42

    
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
45
	 */
46
	/** {@inheritDoc} */
47
	@Override
48
	public String getText(Object element) {
49
		if(element instanceof Classification){
50
			String text = ((Classification) element).getName().getText();
51
			return text != null ? text : "Unnamed Taxonomic Tree";
52
		}
53
		return new String();
54
	}
55
	
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object)
58
	 */
59
	/** {@inheritDoc} */
60
	public String getDescription(Object anElement) {
61
		if (anElement instanceof Classification) {
62
			return "Taxonomic Tree: " +  ((Classification) anElement).getTitleCache(); //$NON-NLS-1$
63
		}
64
		return null;
65
	}
66

    
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
69
	 */
70
	/** {@inheritDoc} */
71
	public StyledString getStyledText(Object element) {
72
		return new StyledString(getText(element), StyledString.DECORATIONS_STYLER);
73
	}
74
}
(2-2/21)