Project

General

Profile

Download (2.19 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.singlesource.editor.view.concept;
12

    
13
import org.apache.log4j.Logger;
14
import org.eclipse.jface.viewers.LabelProvider;
15
import org.eclipse.swt.graphics.Image;
16

    
17
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
18
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
19
import eu.etaxonomy.taxeditor.model.ImageResources;
20
import eu.etaxonomy.taxeditor.singlesource.ImplementationLoader;
21

    
22
/**
23
 * @author n.hoffmann
24
 * @created Jan 24, 2011
25
 * @version 1.0
26
 */
27
public abstract class ConceptLabelProviderFacade extends LabelProvider {
28
	private static final Logger logger = Logger.getLogger(ConceptLabelProviderFacade.class);
29
	
30
	private final static ConceptLabelProviderFacade IMPL;
31
	static {
32
		IMPL = (ConceptLabelProviderFacade)ImplementationLoader.newInstance(ConceptLabelProviderFacade.class) ;
33
	}
34
	
35
	public static ConceptLabelProviderFacade getInstance () {
36
		return (ConceptLabelProviderFacade)IMPL.getInstanceInternal();
37
	}
38
	protected abstract Object getInstanceInternal();
39

    
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
42
	 */
43
	@Override
44
	public Image getImage(Object element) {
45
		if(element instanceof TaxonRelationship){
46
			TaxonRelationshipType type = ((TaxonRelationship) element).getType();
47
			
48
			return getTaxonRelationshipImage(type);
49
		}
50
		return super.getImage(element);
51
	}
52
	
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
55
	 */
56
	@Override
57
	public String getText(Object element) {
58
		if(element instanceof TaxonRelationship){
59
			TaxonRelationship relationship = (TaxonRelationship) element;
60
			
61
			return String.format("%s %s %s", relationship.getFromTaxon(), relationship.getType().getLabel(), relationship.getToTaxon());
62
		}
63
		
64
		return "";
65
	}
66
	
67
	/**
68
	 * @param type
69
	 * @return
70
	 */
71
	public Image getTaxonRelationshipImage(TaxonRelationshipType type) {
72
		
73
		return ImageResources.getImage(ImageResources.CONCEPT_ICON);
74
	}
75
}
    (1-1/1)