Project

General

Profile

Download (2.1 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.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
22
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
23
import eu.etaxonomy.taxeditor.model.ImageResources;
24

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

    
32
    private BulkEditorE4 editor;
33

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

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

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

    
63
    /**
64
     * {@inheritDoc}
65
     */
66
    @Override
67
    public String getText(Object element) {
68
        return super.getText(element);
69
    }
70

    
71
}
(2-2/3)