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.ITableLabelProvider;
|
19
|
import org.eclipse.jface.viewers.LabelProvider;
|
20
|
import org.eclipse.swt.graphics.Image;
|
21
|
|
22
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
23
|
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
|
24
|
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
|
25
|
import eu.etaxonomy.taxeditor.model.ImageResources;
|
26
|
|
27
|
/**
|
28
|
* @author pplitzner
|
29
|
* @date 11.09.2017
|
30
|
*
|
31
|
*/
|
32
|
public class BulkEditorLabelProvider extends LabelProvider implements ITableLabelProvider{
|
33
|
|
34
|
private BulkEditorE4 editor;
|
35
|
|
36
|
public BulkEditorLabelProvider(BulkEditorE4 editor) {
|
37
|
super();
|
38
|
this.editor = editor;
|
39
|
}
|
40
|
|
41
|
/** {@inheritDoc} */
|
42
|
@Override
|
43
|
public Image getColumnImage(Object element, int columnIndex) {
|
44
|
if (columnIndex == 0) {
|
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
|
}
|
62
|
return null;
|
63
|
}
|
64
|
|
65
|
/** {@inheritDoc} */
|
66
|
@Override
|
67
|
public String getColumnText(Object element, int columnIndex) {
|
68
|
String text = null;
|
69
|
|
70
|
if (columnIndex == 0) {
|
71
|
if(element instanceof CdmBase){
|
72
|
text = editor.getEditorInput().getText((CdmBase) element);
|
73
|
}
|
74
|
}else if (columnIndex == 1) {
|
75
|
if(editor.getEditorInput().getTypeText(element)!=null){
|
76
|
text = editor.getEditorInput().getTypeText(element);
|
77
|
}
|
78
|
}
|
79
|
return text;
|
80
|
}
|
81
|
|
82
|
|
83
|
}
|