Project

General

Profile

Download (1.44 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.featuretree;
11

    
12
import java.util.ArrayList;
13

    
14
import org.eclipse.jface.viewers.LabelProvider;
15

    
16
import eu.etaxonomy.cdm.model.common.Language;
17
import eu.etaxonomy.cdm.model.common.Representation;
18
import eu.etaxonomy.cdm.model.description.Feature;
19
import eu.etaxonomy.cdm.model.description.FeatureNode;
20
import eu.etaxonomy.cdm.model.description.FeatureTree;
21
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22

    
23
/**
24
 *
25
 * @author n.hoffmann
26
 * @created Aug 5, 2010
27
 * @version 1.0
28
 */
29
public class FeatureTreeLabelProvider extends LabelProvider {
30

    
31
	/** {@inheritDoc} */
32
	@Override
33
	public String getText(Object element) {
34
		if(element instanceof FeatureTree){
35
			return ((FeatureTree) element).getTitleCache();
36
		}else if(element instanceof FeatureNode){
37
		    Feature feature = ((FeatureNode) element).getFeature();
38
		    if(feature!=null){
39
		        Representation rep = feature.getRepresentation(PreferencesUtil.getGlobalLanguage());
40
		        if (rep == null){
41
		            rep = feature.getPreferredRepresentation(new ArrayList<Language>());
42
		        }
43
		        return rep != null? rep.getLabel() : feature.getTitleCache();
44
		    }
45

    
46
		}
47
		return "No label provided";
48
	}
49

    
50
}
(5-5/5)