Revision 58e6cb8f
Added by Andreas Müller about 3 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsLabelProvider.java | ||
---|---|---|
15 | 15 |
import org.eclipse.jface.viewers.LabelProvider; |
16 | 16 |
import org.eclipse.swt.graphics.Image; |
17 | 17 |
|
18 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
|
18 |
import eu.etaxonomy.cdm.common.CdmUtils;
|
|
19 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
20 |
import eu.etaxonomy.cdm.persistence.dto.ReferencingObjectDto; |
|
20 | 21 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
21 |
import eu.etaxonomy.taxeditor.model.DescriptionHelper; |
|
22 | 22 |
|
23 | 23 |
/** |
24 | 24 |
* Requires an <code>IReferencingObjectsService</code> to translate the label |
... | ... | |
45 | 45 |
|
46 | 46 |
@Override |
47 | 47 |
public String getColumnText(Object element, int columnIndex) { |
48 |
String text = null; |
|
48 |
if (element == null){ |
|
49 |
return ""; |
|
50 |
}else if (element instanceof String){ |
|
51 |
return columnIndex == 0 ? element.toString() :""; |
|
52 |
}else if (element instanceof ReferencingObjectDto){ |
|
53 |
ReferencingObjectDto dto = (ReferencingObjectDto)element; |
|
54 |
if (columnIndex == 0) { |
|
55 |
Class<?> type = dto.getType() != null ? dto.getType() : dto.getReferencedEntity() != null? dto.getReferencedEntity().getClass() : null; |
|
56 |
return type == null? null : CdmUtils.userFriendlyClassName(type); |
|
57 |
}else if (columnIndex == 1) { |
|
58 |
return dto.getTitleCache(); |
|
59 |
}else if (columnIndex == 2) { |
|
60 |
return dto.getUuid() == null ? null : dto.getUuid().toString(); |
|
61 |
}else if (columnIndex == 3) { |
|
62 |
return String.valueOf(dto.getId() == null? null :dto.getId()); |
|
63 |
}else{ |
|
64 |
return "-"; |
|
65 |
} |
|
66 |
} |
|
67 |
else{ |
|
68 |
//this should not happen, but just in case |
|
69 |
String text = null; |
|
70 |
Object deproxiedElement = CdmBase.deproxy(element); |
|
71 |
if (columnIndex == 0) { |
|
72 |
text = CdmUtils.userFriendlyClassName(deproxiedElement.getClass()); |
|
73 |
}else if (columnIndex == 1) { |
|
74 |
text = element.toString(); |
|
75 |
}else if (columnIndex == 2) { |
|
76 |
if(element instanceof CdmBase){ |
|
77 |
text = ((CdmBase) element).getUuid().toString(); |
|
78 |
} |
|
79 |
}else if (columnIndex == 3) { |
|
80 |
if(element instanceof CdmBase){ |
|
81 |
text = String.valueOf(((CdmBase) element).getId()); |
|
82 |
} |
|
83 |
} |
|
84 |
return (StringUtils.isBlank(text)) ? Messages.ReferencingObjectsLabelProvider_No_description_available : text; |
|
85 |
} |
|
49 | 86 |
|
50 |
Object deproxiedElement = HibernateProxyHelper.deproxy(element); |
|
51 |
|
|
52 |
if (columnIndex == 0) { |
|
53 |
text = DescriptionHelper.getObjectClassname(deproxiedElement); |
|
54 |
}else if (columnIndex == 1) { |
|
55 |
text = DescriptionHelper.getObjectDescription(deproxiedElement); |
|
56 |
}else if (columnIndex == 2) { |
|
57 |
if(element instanceof CdmBase){ |
|
58 |
text = ((CdmBase) element).getUuid().toString(); |
|
59 |
} |
|
60 |
}else if (columnIndex == 3) { |
|
61 |
if(element instanceof CdmBase){ |
|
62 |
text = ((CdmBase) element).getId() + ""; //$NON-NLS-1$ |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
return (StringUtils.isBlank(text)) ? Messages.ReferencingObjectsLabelProvider_No_description_available : text; |
|
67 | 87 |
} |
68 | 88 |
} |
Also available in: Unified diff
ref #9541 new referencing objects implementation in TaxEditor