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.editor.view.concept;
|
12
|
|
13
|
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
|
14
|
import org.eclipse.jface.viewers.LabelProvider;
|
15
|
import org.eclipse.jface.viewers.StyledString;
|
16
|
import org.eclipse.swt.graphics.Image;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
|
19
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
20
|
import eu.etaxonomy.taxeditor.model.ImageResources;
|
21
|
|
22
|
/**
|
23
|
* @author n.hoffmann
|
24
|
* @created Jan 24, 2011
|
25
|
* @version 1.0
|
26
|
*/
|
27
|
public class ConceptLabelProvider extends LabelProvider implements IStyledLabelProvider {
|
28
|
|
29
|
/* (non-Javadoc)
|
30
|
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
|
31
|
*/
|
32
|
@Override
|
33
|
public Image getImage(Object element) {
|
34
|
if(element instanceof TaxonRelationship){
|
35
|
TaxonRelationshipType type = ((TaxonRelationship) element).getType();
|
36
|
|
37
|
return getTaxonRelationshipImage(type);
|
38
|
}
|
39
|
return super.getImage(element);
|
40
|
}
|
41
|
|
42
|
/* (non-Javadoc)
|
43
|
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
|
44
|
*/
|
45
|
@Override
|
46
|
public String getText(Object element) {
|
47
|
if(element instanceof TaxonRelationship){
|
48
|
TaxonRelationship relationship = (TaxonRelationship) element;
|
49
|
|
50
|
return String.format("%s %s %s", relationship.getFromTaxon(), relationship.getType().getLabel(), relationship.getToTaxon());
|
51
|
}
|
52
|
|
53
|
return "";
|
54
|
}
|
55
|
|
56
|
/* (non-Javadoc)
|
57
|
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
|
58
|
*/
|
59
|
@Override
|
60
|
public StyledString getStyledText(Object element) {
|
61
|
return new StyledString(getText(element), StyledString.QUALIFIER_STYLER);
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* @param type
|
66
|
* @return
|
67
|
*/
|
68
|
public Image getTaxonRelationshipImage(TaxonRelationshipType type) {
|
69
|
|
70
|
return ImageResources.getImage(ImageResources.CONCEPT_ICON);
|
71
|
}
|
72
|
}
|