Skip to content

Package: ShortLabelProvider

ShortLabelProvider

nameinstructionbranchcomplexitylinemethod
ShortLabelProvider(AdapterFactory)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getText(Object)
M: 23 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008-2011 Chair for Applied Software Engineering,
3: * Technische Universitaet Muenchen.
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: ******************************************************************************/
13: package org.eclipse.emf.ecp.editor.internal.e3;
14:
15: import org.eclipse.emf.common.notify.AdapterFactory;
16: import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
17:
18: // TODO: Review this class
19: /**
20: * Label provider to shorten the getText Method.
21: *
22: * @author helming
23: */
24: public class ShortLabelProvider extends AdapterFactoryLabelProvider {
25:
26:         /**
27:          * Default constructor.
28:          *
29:          * @param adapterFactory the {@link AdapterFactory} to be used.
30:          */
31:         public ShortLabelProvider(AdapterFactory adapterFactory) {
32:
33:                 super(adapterFactory);
34:
35:         }
36:
37:         /**
38:          * {@inheritDoc}
39:          *
40:          * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getText(java.lang.Object)
41:          * @override
42:          */
43:         @Override
44:         public String getText(Object object) {
45:                 final int limit = 30;
46:                 String name = super.getText(object);
47:•                if (name == null) {
48:                         name = ""; //$NON-NLS-1$
49:                 }
50:•                if (name.length() > limit + 5) {
51:                         name = name.substring(0, limit).concat("[...]"); //$NON-NLS-1$
52:                 }
53:                 return name;
54:         }
55: }