1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.bulkeditor.referencingobjects;
|
11
|
|
12
|
import org.apache.commons.lang.StringUtils;
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
15
|
import org.eclipse.jface.viewers.LabelProvider;
|
16
|
import org.eclipse.swt.graphics.Image;
|
17
|
|
18
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
19
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
20
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
21
|
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
|
22
|
|
23
|
/**
|
24
|
* Requires an <code>IReferencingObjectsService</code> to translate the label
|
25
|
* elements into displayable text.
|
26
|
*
|
27
|
* @author p.ciardelli
|
28
|
* @created 09.07.2009
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class ReferencingObjectsLabelProvider extends LabelProvider implements ITableLabelProvider {
|
32
|
private static final Logger logger = Logger
|
33
|
.getLogger(ReferencingObjectsLabelProvider.class);
|
34
|
|
35
|
/**
|
36
|
* <p>Constructor for ReferencingObjectsLabelProvider.</p>
|
37
|
*/
|
38
|
public ReferencingObjectsLabelProvider() {
|
39
|
}
|
40
|
|
41
|
|
42
|
/** {@inheritDoc} */
|
43
|
@Override
|
44
|
public Image getColumnImage(Object element, int columnIndex) {
|
45
|
return null;
|
46
|
}
|
47
|
|
48
|
/** {@inheritDoc} */
|
49
|
@Override
|
50
|
public String getColumnText(Object element, int columnIndex) {
|
51
|
String text = null;
|
52
|
|
53
|
Object deproxiedElement = HibernateProxyHelper.deproxy(element);
|
54
|
|
55
|
if (columnIndex == 0) {
|
56
|
text = DescriptionHelper.getObjectClassname(deproxiedElement);
|
57
|
}else if (columnIndex == 1) {
|
58
|
text = DescriptionHelper.getObjectDescription(deproxiedElement);
|
59
|
}else if (columnIndex == 2) {
|
60
|
if(element instanceof CdmBase){
|
61
|
text = ((CdmBase) element).getUuid().toString();
|
62
|
}
|
63
|
}else if (columnIndex == 3) {
|
64
|
if(element instanceof CdmBase){
|
65
|
text = ((CdmBase) element).getId() + ""; //$NON-NLS-1$
|
66
|
}
|
67
|
}
|
68
|
|
69
|
return (StringUtils.isBlank(text)) ? Messages.ReferencingObjectsLabelProvider_No_description_available : text;
|
70
|
|
71
|
}
|
72
|
}
|