2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
;
11 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
12 import org
.eclipse
.jface
.viewers
.DelegatingStyledCellLabelProvider
.IStyledLabelProvider
;
13 import org
.eclipse
.jface
.viewers
.StyledString
;
15 import eu
.etaxonomy
.taxeditor
.model
.DescriptionHelper
;
21 public class DescriptiveLabelProvider
extends ColumnLabelProvider
implements IStyledLabelProvider
{
23 private static final String TRUNCATE_SIGN
= "..."; //$NON-NLS-1$
24 private static final int MAX_LENGTH
= 60;
27 public String
getText(Object element
) {
28 String text
= DescriptionHelper
.getLabel(element
);
29 text
= text
.replaceAll("[\\r\\n]", " "); //$NON-NLS-1$ //$NON-NLS-2$
30 if(text
.length()>MAX_LENGTH
){
31 text
= text
.substring(0, MAX_LENGTH
)+TRUNCATE_SIGN
;
37 public StyledString
getStyledText(Object element
) {
38 return new StyledString(getText(element
), StyledString
.QUALIFIER_STYLER
);