Project

General

Profile

Download (1.44 KB) Statistics
| Branch: | Tag: | Revision:
1 3fb05254 n.hoffmann
/**
2
* Copyright (C) 2007 EDIT
3 41153841 Patrick Plitzner
* European Distributed Institute of Taxonomy
4 3fb05254 n.hoffmann
* http://www.e-taxonomy.eu
5 41153841 Patrick Plitzner
*
6 3fb05254 n.hoffmann
* 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 f59b9a4e Patrick Plitzner
import java.util.ArrayList;
13
14 3fb05254 n.hoffmann
import org.eclipse.jface.viewers.LabelProvider;
15
16 f59b9a4e Patrick Plitzner
import eu.etaxonomy.cdm.model.common.Language;
17
import eu.etaxonomy.cdm.model.common.Representation;
18 3fb05254 n.hoffmann
import eu.etaxonomy.cdm.model.description.Feature;
19
import eu.etaxonomy.cdm.model.description.FeatureNode;
20
import eu.etaxonomy.cdm.model.description.FeatureTree;
21 f59b9a4e Patrick Plitzner
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22 3fb05254 n.hoffmann
23
/**
24 3be6ef3e n.hoffmann
 *
25 3fb05254 n.hoffmann
 * @author n.hoffmann
26
 * @created Aug 5, 2010
27
 * @version 1.0
28
 */
29
public class FeatureTreeLabelProvider extends LabelProvider {
30 41153841 Patrick Plitzner
31 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
32 3fb05254 n.hoffmann
	@Override
33
	public String getText(Object element) {
34
		if(element instanceof FeatureTree){
35
			return ((FeatureTree) element).getTitleCache();
36
		}else if(element instanceof FeatureNode){
37 41153841 Patrick Plitzner
		    Feature feature = ((FeatureNode) element).getFeature();
38 03911510 Patrick Plitzner
		    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 41153841 Patrick Plitzner
46 3fb05254 n.hoffmann
		}
47 cfcb0ce6 n.hoffmann
		return "No label provided";
48 3fb05254 n.hoffmann
	}
49 41153841 Patrick Plitzner
50 3fb05254 n.hoffmann
}