Project

General

Profile

Download (3.04 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2017 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
package eu.etaxonomy.taxeditor.navigation.navigator.e4;
11

    
12
import org.eclipse.jface.viewers.StyledString;
13
import org.eclipse.jface.viewers.StyledString.Styler;
14
import org.eclipse.swt.graphics.TextStyle;
15
import org.eclipse.ui.navigator.IDescriptionProvider;
16

    
17
import eu.etaxonomy.cdm.model.taxon.Classification;
18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
21
import eu.etaxonomy.taxeditor.preference.Resources;
22
import eu.etaxonomy.taxeditor.store.StoreUtil;
23
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
24

    
25
/**
26
 * @author pplitzner
27
 * @date 05.09.2017
28
 *
29
 */
30
public class TaxonNavigatorLabelProviderE4 extends TaxonTreeNodeLabelProvider
31
implements IDescriptionProvider {
32

    
33
    /**
34
     * {@inheritDoc}
35
     */
36
    @Override
37
    public String getText(Object element) {
38

    
39
            return super.getText(element);
40
    }
41
//    @Override
42
//    public Font getFont(Object element) {
43
//
44
//        return new Font(null, "Arial Unicode MS", 10, SWT.NORMAL);
45
//
46
//    }
47

    
48
    /**
49
     * {@inheritDoc}
50
     */
51
    @Override
52
    public String getDescription(Object anElement) {
53
        //classification
54
        if (anElement instanceof Classification) {
55
            return "Taxonomic Tree: " +  ((Classification) anElement).getTitleCache(); //$NON-NLS-1$
56
        }
57
        //FIXME E4 show synonym in navigator?
58
        //synonym
59
//        else if (anElement instanceof Synonym) {
60
//            Synonym data = (Synonym) anElement;
61
//            return "Synonym: " + data.getTitleCache(); //$NON-NLS-1$
62
//        }
63
        //taxon node
64
        else if (anElement instanceof TaxonNode) {
65
            Taxon data = ((TaxonNode) anElement).getTaxon();
66
            String text =  (data != null ? Messages.TaxonNodeLabelProvider_TAXON + data.getTitleCache() : Messages.TaxonNodeLabelProvider_CLASSIFICATION + ((TaxonNode)anElement).getClassification().getTitleCache());
67
            return text;
68
        }
69
        return null;
70
    }
71

    
72
    /**
73
     * {@inheritDoc}
74
     */
75
    @Override
76
    public StyledString getStyledText(Object element) {
77
        return super.getStyledText(element);
78
        //FIXME E4 show synonym in navigator?
79
        //synonym
80
//        else if(element instanceof Synonym){
81
//            return new StyledString(getText(element), StyledString.QUALIFIER_STYLER);
82
//        }
83
    }
84

    
85

    
86
    private Styler getNotGrantedStyler() {
87
        if (notGrantedStyler  == null) {
88
            notGrantedStyler = new Styler() {
89
                @Override
90
                public void applyStyles(TextStyle textStyle) {
91
                    textStyle.underline = false;
92
                    textStyle.foreground = StoreUtil.getColor(Resources.COLOR_TEXT_DISABLED);
93
                }
94
            };
95
        }
96
        return notGrantedStyler;
97
    }
98

    
99

    
100
}
(4-4/6)