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
;
14 import org
.eclipse
.swt
.graphics
.Image
;
16 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
17 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionType
;
18 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.MatrixUtility
;
19 import eu
.etaxonomy
.taxeditor
.model
.DescriptionHelper
;
25 public class DescriptiveLabelProvider
extends ColumnLabelProvider
implements IStyledLabelProvider
{
27 private static final String TRUNCATE_SIGN
= "..."; //$NON-NLS-1$
28 private static final int MAX_LENGTH
= 150;
31 public String
getText(Object element
) {
32 String text
= DescriptionHelper
.getLabel(element
);
33 text
= text
.replaceAll("[\\r\\n]", " "); //$NON-NLS-1$ //$NON-NLS-2$
34 if(text
.length()>MAX_LENGTH
){
35 text
= text
.substring(0, MAX_LENGTH
)+TRUNCATE_SIGN
;
41 public StyledString
getStyledText(Object element
) {
42 return new StyledString(getText(element
), StyledString
.QUALIFIER_STYLER
);
46 public Image
getImage(Object element
) {
47 if(element
instanceof DescriptionBase
){
48 DescriptionBase description
= (DescriptionBase
)element
;
49 if(description
.getTypes().contains(DescriptionType
.AGGREGATED_STRUC_DESC
)){
50 return MatrixUtility
.getAggregatedDescriptionIcon();
52 else if(description
.getTypes().contains(DescriptionType
.SECONDARY_DATA
)){
53 return MatrixUtility
.getLiteratureDescriptionIcon();
55 else if(description
.getTypes().contains(DescriptionType
.DEFAULT_VALUES_FOR_AGGREGATION
)){
56 return MatrixUtility
.getDefaultDescriptionIcon();