-// $Id$
/**
* Copyright (C) 2007 EDIT
* European Distributed Institute of Taxonomy
import org.hibernate.LazyInitializationException;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
import eu.etaxonomy.taxeditor.preference.Resources;
import eu.etaxonomy.taxeditor.security.RequiredPermissions;
import eu.etaxonomy.taxeditor.store.CdmStore;
*
* @author p.ciardelli
* @created 04.06.2009
- * @version 1.0
*/
public class TaxonNodeLabelProvider extends ColumnLabelProvider
implements ILabelProvider, IDescriptionProvider, IStyledLabelProvider {
TaxonNode taxonNode = (TaxonNode) HibernateProxyHelper.deproxy(element);
try{
- Taxon taxon = (Taxon) HibernateProxyHelper.deproxy(taxonNode.getTaxon());
+ Taxon taxon = HibernateProxyHelper.deproxy(taxonNode.getTaxon());
if(taxon == null){
- NavigationUtil.error(getClass(), "The taxon node does not have a taxon attached to it. Please check your import. TaxonNode: " + element, null);
+ String text = taxonNode.getClassification().getName().getText();
+ if(text==null){
+ text = taxonNode.getClassification().getTitleCache();
+ }
+ return text;
+ //MessagingUtils.error(getClass(), String.format(Messages.TaxonNodeLabelProvider_NODE_WITH_NO_TAXON, element), null);
// throw new RuntimeException("The data your are trying to view is corrupt. Please check your import.");
}else{
try{
return taxon.getName() != null ? ((IIdentifiableEntity) HibernateProxyHelper.deproxy(taxon.getName())).getTitleCache() : new String();
}catch(Exception e){
- NavigationUtil.error(getClass(), e);
+ MessagingUtils.error(getClass(), e);
}
}
}catch (LazyInitializationException e){
- NavigationUtil.error(getClass(), e);
+ MessagingUtils.error(getClass(), e);
}
}
return new String();
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object)
- */
/** {@inheritDoc} */
@Override
public String getDescription(Object anElement) {
if (anElement instanceof TaxonNode) {
Taxon data = ((TaxonNode) anElement).getTaxon();
- return "Taxon: " + data.getTitleCache(); //$NON-NLS-1$
+ String text = (data != null ? Messages.TaxonNodeLabelProvider_TAXON + data.getTitleCache() : Messages.TaxonNodeLabelProvider_CLASSIFICATION + ((TaxonNode)anElement).getClassification().getTitleCache());
+
+ return text;
}
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
- */
/** {@inheritDoc} */
@Override
public StyledString getStyledText(Object element) {
// determine style base on user grants
Styler styler = null;
- if(!CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(element), RequiredPermissions.TAXONNODE_EDIT)){
+ if(!CdmStore.currentAuthentiationHasPermission((CdmBase) element, RequiredPermissions.TAXONNODE_EDIT)){
styler = getNotGrantedStyler();
}
return new StyledString(getText(element), styler);
-
}
/**