Project

General

Profile

Download (3.29 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
        return super.getText(element);
39
        //FIXME E4 show synonym in navigator?
40
        //synonym
41
//        else if (element instanceof Synonym && ((Synonym) element).getName()!=null) {
42
//            return "= " + ((Synonym) element).getName().getTitleCache(); //$NON-NLS-1$
43
//        }
44
    }
45
//    @Override
46
//    public Font getFont(Object element) {
47
//
48
//        return new Font(null, "Arial Unicode MS", 10, SWT.NORMAL);
49
//
50
//    }
51

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

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

    
89

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

    
103

    
104
}
(4-4/6)