Skip to content

Package: ProvidersLabelProvider

ProvidersLabelProvider

nameinstructionbranchcomplexitylinemethod
ProvidersLabelProvider()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
descriptorChanged(InternalDescriptor, boolean)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getBackground(Object)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getForeground(Object)
M: 13 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getImage(Object)
M: 20 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getText(Object)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /********************************************************************************
2: * Copyright (c) 2011 Eike Stepper (Berlin, Germany) and others.
3: *
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: * Eike Stepper - initial API and implementation
13: ********************************************************************************/
14: package org.eclipse.emf.ecp.internal.ui.model;
15:
16: import org.eclipse.emf.ecp.core.ECPProvider;
17: import org.eclipse.emf.ecp.core.util.ECPUtil;
18: import org.eclipse.emf.ecp.internal.core.ECPProviderRegistryImpl;
19: import org.eclipse.emf.ecp.internal.core.util.ElementDescriptor;
20: import org.eclipse.emf.ecp.internal.ui.Activator;
21: import org.eclipse.emf.ecp.spi.core.InternalProvider;
22: import org.eclipse.emf.ecp.spi.core.util.InternalDescriptor;
23: import org.eclipse.emf.ecp.spi.core.util.InternalElementRegistry.ResolveListener;
24: import org.eclipse.jface.viewers.IColorProvider;
25: import org.eclipse.jface.viewers.LabelProviderChangedEvent;
26: import org.eclipse.swt.SWT;
27: import org.eclipse.swt.graphics.Color;
28: import org.eclipse.swt.graphics.Image;
29: import org.eclipse.swt.widgets.Display;
30:
31: /**
32: * @author Eike Stepper
33: */
34: public class ProvidersLabelProvider extends ECPLabelProvider implements IColorProvider,
35:         ResolveListener<InternalProvider> {
36:         private static final Image PROVIDER = Activator.getImage("icons/provider.gif"); //$NON-NLS-1$
37:
38:         private static final Image PROVIDER_DISABLED = Activator.getImage("icons/provider_disabled.gif"); //$NON-NLS-1$
39:
40:         private static final Color GRAY = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
41:
42:         public ProvidersLabelProvider() {
43:                 super(null);
44:                 ((ECPProviderRegistryImpl) ECPUtil.getECPProviderRegistry()).addResolveListener(this);
45:         }
46:
47:         @Override
48:         public void dispose() {
49:                 ((ECPProviderRegistryImpl) ECPUtil.getECPProviderRegistry()).removeResolveListener(this);
50:                 super.dispose();
51:         }
52:
53:         /** {@inheritDoc} */
54:         @Override
55:         public void descriptorChanged(InternalDescriptor<InternalProvider> descriptor, boolean resolved) throws Exception {
56:                 fireEvent(new LabelProviderChangedEvent(this, descriptor));
57:         }
58:
59:         @Override
60:         public String getText(Object element) {
61:•                if (element instanceof ECPProvider) {
62:                         final ECPProvider provider = (ECPProvider) element;
63:                         return provider.getLabel();
64:                 }
65:
66:                 return super.getText(element);
67:         }
68:
69:         @Override
70:         public Image getImage(Object element) {
71:•                if (element instanceof ECPProvider) {
72:•                        if (element instanceof ElementDescriptor) {
73:                                 final ElementDescriptor<?> descriptor = (ElementDescriptor<?>) element;
74:•                                if (!descriptor.isResolved()) {
75:                                         return PROVIDER_DISABLED;
76:                                 }
77:                         }
78:
79:                         return PROVIDER;
80:                 }
81:
82:                 return super.getImage(element);
83:         }
84:
85:         /** {@inheritDoc} */
86:         @Override
87:         public Color getForeground(Object element) {
88:•                if (element instanceof ElementDescriptor) {
89:                         final ElementDescriptor<?> descriptor = (ElementDescriptor<?>) element;
90:•                        if (!descriptor.isResolved()) {
91:                                 return GRAY;
92:                         }
93:                 }
94:
95:                 return null;
96:         }
97:
98:         /** {@inheritDoc} */
99:         @Override
100:         public Color getBackground(Object element) {
101:                 return null;
102:         }
103: }