X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/f67430cd1c0c25f61e0a5d306d0dad297bfda01b..0eccefeabc5ce06cb06bf94e7bc3f7c42450a7ff:/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveLabelProvider.java diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveLabelProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveLabelProvider.java index a8ea15156..d80b4c72b 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveLabelProvider.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveLabelProvider.java @@ -1,8 +1,8 @@ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu -* +* * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ @@ -11,27 +11,51 @@ package eu.etaxonomy.taxeditor.editor.view.descriptive; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; import org.eclipse.jface.viewers.StyledString; +import org.eclipse.swt.graphics.Image; +import eu.etaxonomy.cdm.model.description.DescriptionBase; +import eu.etaxonomy.cdm.model.description.DescriptionType; +import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.MatrixUtility; import eu.etaxonomy.taxeditor.model.DescriptionHelper; /** - *
DescriptiveLabelProvider class.
- * * @author p.ciardelli * @version $Id: $ */ public class DescriptiveLabelProvider extends ColumnLabelProvider implements IStyledLabelProvider { - - /** {@inheritDoc} */ - public String getText(Object element) { - return DescriptionHelper.getLabel(element); - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object) - */ - /** {@inheritDoc} */ - public StyledString getStyledText(Object element) { + private static final String TRUNCATE_SIGN = "..."; //$NON-NLS-1$ + private static final int MAX_LENGTH = 150; + + @Override + public String getText(Object element) { + String text = DescriptionHelper.getLabel(element); + text = text.replaceAll("[\\r\\n]", " "); //$NON-NLS-1$ //$NON-NLS-2$ + if(text.length()>MAX_LENGTH){ + text = text.substring(0, MAX_LENGTH)+TRUNCATE_SIGN; + } + return text; + } + + @Override + public StyledString getStyledText(Object element) { return new StyledString(getText(element), StyledString.QUALIFIER_STYLER); } + + @Override + public Image getImage(Object element) { + if(element instanceof DescriptionBase){ + DescriptionBase description = (DescriptionBase)element; + if(description.getTypes().contains(DescriptionType.AGGREGATED_STRUC_DESC)){ + return MatrixUtility.getAggregatedDescriptionIcon(); + } + else if(description.getTypes().contains(DescriptionType.SECONDARY_DATA)){ + return MatrixUtility.getLiteratureDescriptionIcon(); + } + else if(description.getTypes().contains(DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION)){ + return MatrixUtility.getDefaultDescriptionIcon(); + } + } + return null; + } }