Skip to content

Package: ColumnConfigurationImpl

ColumnConfigurationImpl

nameinstructionbranchcomplexitylinemethod
ColumnConfigurationImpl(Set, boolean, boolean, int, int, int, IObservableValue, IObservableValue, CellLabelProviderFactory, EditingSupportCreator, Image, Map, List)
M: 12 C: 71
86%
M: 4 C: 2
33%
M: 3 C: 1
25%
M: 2 C: 22
92%
M: 0 C: 1
100%
createEditingSupport(AbstractTableViewer)
M: 0 C: 14
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createLabelProvider(AbstractTableViewer)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
dispose()
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getColumnImage()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getColumnText()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getColumnTooltip()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getConfigurationCallbacks()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getData()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getData(String)
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%
getEditingSupportCreator()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEnabledFeatures()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getLabelProviderFactory()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getMinWidth()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getStyleBits()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getWeight()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isMoveable()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isResizeable()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
matchFilter()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setData(Map)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
showFilterControl()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
visible()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH 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: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.swt.table;
15:
16: import java.util.Collections;
17: import java.util.List;
18: import java.util.Map;
19: import java.util.Set;
20:
21: import org.eclipse.core.databinding.observable.value.IObservableValue;
22: import org.eclipse.emfforms.common.Feature;
23: import org.eclipse.emfforms.common.Optional;
24: import org.eclipse.emfforms.common.Property;
25: import org.eclipse.emfforms.internal.common.SimpleProperty;
26: import org.eclipse.jface.viewers.AbstractTableViewer;
27: import org.eclipse.jface.viewers.CellLabelProvider;
28: import org.eclipse.jface.viewers.EditingSupport;
29: import org.eclipse.jface.viewers.ViewerColumn;
30: import org.eclipse.swt.graphics.Image;
31:
32: /**
33: * Implementation of the {@link ColumnConfiguration}.
34: *
35: * @author Johannes Faltermeier
36: * @author Mat Hansen
37: *
38: */
39: public final class ColumnConfigurationImpl implements ColumnConfiguration {
40:
41:         private final Set<Feature> enabledFeatures;
42:
43:         private final boolean resizeable;
44:         private final boolean moveable;
45:         private final int styleBits;
46:         private final int weight;
47:         private final int minWidth;
48:         private final IObservableValue columnText;
49:         private final IObservableValue tooltipText;
50:         private final CellLabelProviderFactory labelProviderFactory;
51:         private final Optional<EditingSupportCreator> editingSupportCreator;
52:         private final Optional<Image> image;
53:         private final Map<String, Object> data;
54:         private final List<ConfigurationCallback<AbstractTableViewer, ViewerColumn>> configurationCallbacks;
55:
56:         private final Property<Boolean> visibleProperty = new SimpleProperty<Boolean>("isVisible", Boolean.TRUE); //$NON-NLS-1$
57:         private final Property<Boolean> showFilterControlProperty = new SimpleProperty<Boolean>("showFilter", //$NON-NLS-1$
58:                 Boolean.FALSE);
59:         private final Property<Object> matchFilterProperty = new SimpleProperty<Object>("filterValue", null); //$NON-NLS-1$
60:
61:         // BEGIN COMPLEX CODE
62:         /**
63:          * Constructs a new {@link ColumnConfiguration}.
64:          *
65:          * @param enabledFeatures list of enabled features
66:          * @param resizeable resizeable
67:          * @param moveable moveable
68:          * @param styleBits styleBits
69:          * @param weight weight
70:          * @param minWidth minWidth
71:          * @param columnText columnText
72:          * @param tooltipText tooltipText
73:          * @param labelProviderFactory labelProvider
74:          * @param editingSupport editingSupport. May be <code>null</code> to indicate that there is no editing support
75:          */
76:         public ColumnConfigurationImpl(
77:                 Set<Feature> enabledFeatures,
78:                 boolean resizeable,
79:                 boolean moveable,
80:                 int styleBits,
81:                 int weight,
82:                 int minWidth,
83:                 IObservableValue columnText,
84:                 IObservableValue tooltipText,
85:                 CellLabelProviderFactory labelProviderFactory,
86:                 EditingSupportCreator editingSupport,
87:                 Image image,
88:                 Map<String, Object> data,
89:                 List<ConfigurationCallback<AbstractTableViewer, ViewerColumn>> configurationCallbacks) {
90:                 // END COMPLEX CODE
91:                 this.enabledFeatures = Collections.unmodifiableSet(enabledFeatures);
92:                 this.resizeable = resizeable;
93:                 this.moveable = moveable;
94:                 this.styleBits = styleBits;
95:                 this.weight = weight;
96:                 this.minWidth = minWidth;
97:                 this.columnText = columnText;
98:                 this.tooltipText = tooltipText;
99:                 this.labelProviderFactory = labelProviderFactory;
100:                 editingSupportCreator = Optional.ofNullable(editingSupport);
101:                 this.image = Optional.ofNullable(image);
102:•                if (data == null) {
103:                         throw new IllegalArgumentException("Data map cannot be null"); //$NON-NLS-1$
104:                 }
105:                 this.data = data;
106:•                if (configurationCallbacks == null || configurationCallbacks.isEmpty()) {
107:                         this.configurationCallbacks = Collections.emptyList();
108:                 } else {
109:                         this.configurationCallbacks = Collections.unmodifiableList(configurationCallbacks);
110:                 }
111:
112:         }
113:
114:         @Override
115:         public Set<Feature> getEnabledFeatures() {
116:                 return enabledFeatures;
117:         }
118:
119:         @Override
120:         public boolean isResizeable() {
121:                 return resizeable;
122:         }
123:
124:         @Override
125:         public boolean isMoveable() {
126:                 return moveable;
127:         }
128:
129:         @Override
130:         public int getStyleBits() {
131:                 return styleBits;
132:         }
133:
134:         @Override
135:         public int getWeight() {
136:                 return weight;
137:         }
138:
139:         @Override
140:         public int getMinWidth() {
141:                 return minWidth;
142:         }
143:
144:         @Override
145:         public IObservableValue getColumnText() {
146:                 return columnText;
147:         }
148:
149:         @Override
150:         public IObservableValue getColumnTooltip() {
151:                 return tooltipText;
152:         }
153:
154:         @Override
155:         public CellLabelProvider createLabelProvider(AbstractTableViewer columnViewer) {
156:                 return labelProviderFactory.createCellLabelProvider(columnViewer);
157:         }
158:
159:         /**
160:          * Returns the cell label provider factory.
161:          *
162:          * @return the cell label provider factory
163:          */
164:         CellLabelProviderFactory getLabelProviderFactory() {
165:                 return labelProviderFactory;
166:         }
167:
168:         @Override
169:         public Optional<EditingSupport> createEditingSupport(AbstractTableViewer columnViewer) {
170:•                if (editingSupportCreator.isPresent()) {
171:                         return Optional.of(editingSupportCreator.get().createEditingSupport(columnViewer));
172:                 }
173:                 return Optional.empty();
174:         }
175:
176:         /**
177:          * Returns the editing support creator.
178:          *
179:          * @return the editing support creator
180:          */
181:         Optional<EditingSupportCreator> getEditingSupportCreator() {
182:                 return editingSupportCreator;
183:         }
184:
185:         @Override
186:         public Optional<Image> getColumnImage() {
187:                 return image;
188:         }
189:
190:         @Override
191:         public void setData(Map<String, Object> data) {
192:                 this.data.putAll(data);
193:         }
194:
195:         @Override
196:         public Object getData(String key) {
197:                 return data.get(key);
198:         }
199:
200:         @Override
201:         public Map<String, Object> getData() {
202:                 return data;
203:         }
204:
205:         @Override
206:         public List<ConfigurationCallback<AbstractTableViewer, ViewerColumn>> getConfigurationCallbacks() {
207:                 return configurationCallbacks;
208:         }
209:
210:         @Override
211:         public Property<Boolean> visible() {
212:                 return visibleProperty;
213:         }
214:
215:         @Override
216:         public Property<Boolean> showFilterControl() {
217:                 return showFilterControlProperty;
218:         }
219:
220:         @Override
221:         public Property<Object> matchFilter() {
222:                 return matchFilterProperty;
223:         }
224:
225:         @Override
226:         public void dispose() {
227:                 visibleProperty.dispose();
228:                 showFilterControlProperty.dispose();
229:                 matchFilterProperty.dispose();
230:                 data.clear();
231:         }
232:
233: }