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
.editor
.view
.concept
;
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
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
20 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
24 * @created Jan 24, 2011
27 public class ConceptLabelProvider
extends LabelProvider
implements IStyledLabelProvider
{
30 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
33 public Image
getImage(Object element
) {
34 if(element
instanceof TaxonRelationship
){
35 TaxonRelationshipType type
= ((TaxonRelationship
) element
).getType();
37 return getTaxonRelationshipImage(type
);
39 return super.getImage(element
);
43 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
46 public String
getText(Object element
) {
47 if(element
instanceof TaxonRelationship
){
48 TaxonRelationship relationship
= (TaxonRelationship
) element
;
50 return String
.format("%s %s %s", relationship
.getFromTaxon(), relationship
.getType().getLabel(), relationship
.getToTaxon());
57 * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
60 public StyledString
getStyledText(Object element
) {
61 return new StyledString(getText(element
), StyledString
.QUALIFIER_STYLER
);
68 public Image
getTaxonRelationshipImage(TaxonRelationshipType type
) {
70 return ImageResources
.getImage(ImageResources
.CONCEPT_ICON
);