Package: VdmColoringLabelProvider

VdmColoringLabelProvider

nameinstructionbranchcomplexitylinemethod
VdmColoringLabelProvider(DelegatingStyledCellLabelProvider.IStyledLabelProvider)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
VdmColoringLabelProvider(DelegatingStyledCellLabelProvider.IStyledLabelProvider, ILabelDecorator, IDecorationContext)
M: 6 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: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getText(Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
initialize(ColumnViewer, ViewerColumn)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
prepareStyleRange(StyleRange, boolean)
M: 20 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
update()
M: 33 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.ui
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.ui.internal.viewsupport;
23:
24:
25: import org.eclipse.jface.viewers.ColumnViewer;
26: import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
27: import org.eclipse.jface.viewers.IDecorationContext;
28: import org.eclipse.jface.viewers.ILabelDecorator;
29: import org.eclipse.jface.viewers.ILabelProvider;
30: import org.eclipse.jface.viewers.LabelProviderChangedEvent;
31: import org.eclipse.jface.viewers.StyledString;
32: import org.eclipse.jface.viewers.ViewerColumn;
33: import org.eclipse.jface.viewers.StyledString.Styler;
34: import org.eclipse.swt.SWT;
35: import org.eclipse.swt.custom.StyleRange;
36:
37: public class VdmColoringLabelProvider extends DecoratingStyledCellLabelProvider
38:                 implements ILabelProvider {
39:
40:         
41:
42:         public static final Styler HIGHLIGHT_STYLE= StyledString.createColorRegistryStyler(null, VdmColoredViewersManager.HIGHLIGHT_BG_COLOR_NAME);
43:         public static final Styler HIGHLIGHT_WRITE_STYLE= StyledString.createColorRegistryStyler(null, VdmColoredViewersManager.HIGHLIGHT_WRITE_BG_COLOR_NAME);
44:         
45:         public static final Styler INHERITED_STYLER= StyledString.createColorRegistryStyler(VdmColoredViewersManager.INHERITED_COLOR_NAME, null);
46:
47:         public VdmColoringLabelProvider(IStyledLabelProvider labelProvider) {
48:                 this(labelProvider, null, null);
49:         }
50:
51:         public VdmColoringLabelProvider(IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext) {
52:                 super(labelProvider, decorator, decorationContext);
53:         }
54:
55:         public void initialize(ColumnViewer viewer, ViewerColumn column) {
56:                 VdmColoredViewersManager.install(this);
57:                 setOwnerDrawEnabled(VdmColoredViewersManager.showColoredLabels());
58:
59:                 super.initialize(viewer, column);
60:         }
61:
62:         public void dispose() {
63:                 super.dispose();
64:                 
65:                 VdmColoredViewersManager.uninstall(this);
66:         }
67:
68:         public void update() {
69:                 ColumnViewer viewer= getViewer();
70:
71:•                if (viewer == null) {
72:                         return;
73:                 }
74:                 
75:                 boolean needsUpdate= false;
76:                 
77:                 boolean showColoredLabels= VdmColoredViewersManager.showColoredLabels();
78:•                if (showColoredLabels != isOwnerDrawEnabled()) {
79:                         setOwnerDrawEnabled(showColoredLabels);
80:                         needsUpdate= true;
81:•                } else if (showColoredLabels) {
82:                         needsUpdate= true;
83:                 }
84:•                if (needsUpdate) {
85:                         fireLabelProviderChanged(new LabelProviderChangedEvent(this));
86:                 }
87:         }
88:
89:         protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) {
90:•                if (!applyColors && styleRange.background != null) {
91:                         styleRange= super.prepareStyleRange(styleRange, applyColors);
92:                         styleRange.borderStyle= SWT.BORDER_DOT;
93:                         return styleRange;
94:                 }
95:                 return super.prepareStyleRange(styleRange, applyColors);
96:         }
97:
98:         public String getText(Object element) {
99:                 return getStyledText(element).getString();
100:         }
101:
102: }