Project

General

Profile

Download (2.26 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.bulkeditor.e4;
11

    
12
import java.net.URISyntaxException;
13
import java.net.URL;
14

    
15
import org.eclipse.core.runtime.FileLocator;
16
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.Path;
18
import org.eclipse.jface.viewers.LabelProvider;
19
import org.eclipse.swt.graphics.Image;
20

    
21
import eu.etaxonomy.cdm.model.common.CdmBase;
22
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
23
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
24
import eu.etaxonomy.taxeditor.model.ImageResources;
25

    
26
/**
27
 * @author pplitzner
28
 * @date 11.09.2017
29
 *
30
 */
31
public class BulkEditorLabelProvider extends LabelProvider {
32

    
33
    private BulkEditorE4 editor;
34

    
35
    public BulkEditorLabelProvider(BulkEditorE4 editor) {
36
        super();
37
        this.editor = editor;
38
    }
39

    
40
    /**
41
     * {@inheritDoc}
42
     */
43
    @Override
44
    public Image getImage(Object element) {
45
        AbstractBulkEditorInput input = editor.getEditorInput();
46

    
47
        try {
48
            if(input.getMergeCandidates().contains(element)){
49
                IPath path = new Path("icons/merge_candidate.gif"); //$NON-NLS-1$
50
                URL url = FileLocator.find(TaxeditorBulkeditorPlugin.getDefault().getBundle(), path, null);
51
                return ImageResources.getImage(url.toURI());
52
            }
53
            else if(input.getMergeTarget()!=null && input.getMergeTarget().equals(element)){
54
                IPath path = new Path("icons/merge_target.gif"); //$NON-NLS-1$
55
                URL url = FileLocator.find(TaxeditorBulkeditorPlugin.getDefault().getBundle(), path, null);
56
                return ImageResources.getImage(url.toURI());
57
            }
58
        } catch (URISyntaxException e) {
59
            return null;
60
        }
61
        return null;
62
    }
63

    
64
    /**
65
     * {@inheritDoc}
66
     */
67
    @Override
68
    public String getText(Object element) {
69
        if(element instanceof CdmBase){
70
            return editor.getEditorInput().getText((CdmBase) element);
71
        }
72
        return super.getText(element);
73
    }
74

    
75
}
(2-2/3)