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;
/**
- * <p>DescriptiveLabelProvider class.</p>
- *
* @author p.ciardelli
* @version $Id: $
*/
public class DescriptiveLabelProvider extends ColumnLabelProvider implements IStyledLabelProvider {
- /** {@inheritDoc} */
+ private static final String TRUNCATE_SIGN = "..."; //$NON-NLS-1$
+ private static final int MAX_LENGTH = 150;
+
@Override
public String getText(Object element) {
- return DescriptionHelper.getLabel(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;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
- */
- /** {@inheritDoc} */
@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;
+ }
}