allow multiple selection for moving taxonnodes
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / descriptive / DescriptiveLabelProvider.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9 package eu.etaxonomy.taxeditor.editor.view.descriptive;
10
11 import org.eclipse.jface.viewers.ColumnLabelProvider;
12 import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
13 import org.eclipse.jface.viewers.StyledString;
14
15 import eu.etaxonomy.taxeditor.model.DescriptionHelper;
16
17 /**
18 * @author p.ciardelli
19 * @version $Id: $
20 */
21 public class DescriptiveLabelProvider extends ColumnLabelProvider implements IStyledLabelProvider {
22
23 private static final String TRUNCATE_SIGN = "..."; //$NON-NLS-1$
24 private static final int MAX_LENGTH = 60;
25
26 @Override
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;
32 }
33 return text;
34 }
35
36 @Override
37 public StyledString getStyledText(Object element) {
38 return new StyledString(getText(element), StyledString.QUALIFIER_STYLER);
39 }
40 }