Skip to content

Package: ColumnConfiguration

ColumnConfiguration

nameinstructionbranchcomplexitylinemethod
static {...}
M: 0 C: 33
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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: * Mat Hansen - initial API and implementation
13: * Christian W. Damus - bug 534829
14: ******************************************************************************/
15: package org.eclipse.emfforms.spi.swt.table;
16:
17: import java.util.Arrays;
18: import java.util.Collections;
19: import java.util.LinkedHashSet;
20: import java.util.List;
21: import java.util.Map;
22: import java.util.Set;
23:
24: import org.eclipse.core.databinding.observable.value.IObservableValue;
25: import org.eclipse.emfforms.common.Feature;
26: import org.eclipse.emfforms.common.Optional;
27: import org.eclipse.emfforms.common.Property;
28: import org.eclipse.jface.viewers.AbstractTableViewer;
29: import org.eclipse.jface.viewers.CellLabelProvider;
30: import org.eclipse.jface.viewers.EditingSupport;
31: import org.eclipse.jface.viewers.ViewerColumn;
32: import org.eclipse.swt.graphics.Image;
33:
34: /**
35: * A ColumnConfiguration is used to configure how a viewer column shall be created
36: * and how it behaves during runtime.
37: *
38: * @author Johannes Faltermeier
39: * @author Mat Hansen
40: *
41: * @noextend This class is not intended to be subclassed by clients.
42: * @noimplement This interface is not intended to be implemented by clients.
43: *
44: */
45: // TODO: migrate all configuration options to Property<T>
46: public interface ColumnConfiguration {
47:
48:         /**
49:          * Feature toggle for column hide/show support. Can be enabled on a per-column basis.
50:          */
51:         Feature FEATURE_COLUMN_HIDE_SHOW = TableConfiguration.FEATURE_COLUMN_HIDE_SHOW;
52:
53:         /**
54:          * Feature toggle for column filter support.
55:          */
56:         Feature FEATURE_COLUMN_FILTER = TableConfiguration.FEATURE_COLUMN_FILTER;
57:
58:         /**
59:          * Feature toggle for column filter support.
60:          */
61:         Feature FEATURE_COLUMN_REGEX_FILTER = TableConfiguration.FEATURE_COLUMN_REGEX_FILTER;
62:
63:         /**
64:          * All configurable features.
65:          *
66:          * @since 1.21
67:          */
68:         Set<Feature> ALL_FEATURES = Collections.unmodifiableSet(new LinkedHashSet<>(
69:                 Arrays.asList(FEATURE_COLUMN_HIDE_SHOW,
70:                         FEATURE_COLUMN_FILTER,
71:                         FEATURE_COLUMN_REGEX_FILTER)));
72:
73:         /**
74:          * All configurable features.
75:          *
76:          * @deprecated Since 1.21, use the immutable {@link #ALL_FEATURES} set instead of this,
77:          * which can be modified in place.
78:          */
79:         @Deprecated
80:         Feature[] FEATURES = ALL_FEATURES.toArray(new Feature[0]);
81:
82:         /**
83:          * Column data configuration key.
84:          */
85:         String ID = "emfforms.column.configuration"; //$NON-NLS-1$
86:
87:         /** Data key for resizable columns. */
88:         String RESIZABLE = "resizable"; //$NON-NLS-1$
89:
90:         /** Data key for column weight. */
91:         String WEIGHT = "weight"; //$NON-NLS-1$
92:
93:         /** Constant indicating that {@link #getWeight()} has no value. */
94:         int NO_WEIGHT = -1;
95:
96:         /** Data key for the minimum width of the column. */
97:         String MIN_WIDTH = "min_width"; //$NON-NLS-1$
98:
99:         /** Data key for column id. */
100:         String COLUMN_ID = "column_id"; //$NON-NLS-1$
101:
102:         /** Data key for a domain model reference. */
103:         String DMR = "domain_model_reference"; //$NON-NLS-1$
104:
105:         /**
106:          * Returns a static array of enabled features.
107:          *
108:          * @return array of enabled features.
109:          */
110:         Set<Feature> getEnabledFeatures();
111:
112:         /**
113:          * <code>true</code> if resizeable, <code>false</code> otherwise.
114:          *
115:          * @return whether the column is resizeable
116:          */
117:         boolean isResizeable();
118:
119:         /**
120:          * <code>true</code> if moveable, <code>false</code> otherwise.
121:          *
122:          * @return whether the column is moveable
123:          */
124:         boolean isMoveable();
125:
126:         /**
127:          * The SWT style bits which will be used to create the column.
128:          *
129:          * @return the SWT style bits for the column
130:          */
131:         int getStyleBits();
132:
133:         /**
134:          * The weight of the column.
135:          *
136:          * @return the weight of the column
137:          */
138:         int getWeight();
139:
140:         /**
141:          * The minimal width of the column.
142:          *
143:          * @return the min width of the column in pixels
144:          */
145:         int getMinWidth();
146:
147:         /**
148:          * The header text for the column.
149:          *
150:          * @return the column header text
151:          */
152:         @SuppressWarnings("rawtypes")
153:         IObservableValue getColumnText();
154:
155:         /**
156:          * The column header tooltip text.
157:          *
158:          * @return the column header tooltip
159:          */
160:         @SuppressWarnings("rawtypes")
161:         IObservableValue getColumnTooltip();
162:
163:         /**
164:          * The cell label provider which will be set on the column.
165:          *
166:          * @param columnViewer the column viewer
167:          * @return the label provider
168:          */
169:         CellLabelProvider createLabelProvider(AbstractTableViewer columnViewer);
170:
171:         /**
172:          * Called to setup the {@link EditingSupport} for the viewer.
173:          *
174:          * @param columnViewer the {@link AbstractTableViewer}
175:          * @return the editing support for the column, if present
176:          */
177:         Optional<EditingSupport> createEditingSupport(AbstractTableViewer columnViewer);
178:
179:         /**
180:          * The image of the column.
181:          *
182:          * @return the column image, if present
183:          */
184:         Optional<Image> getColumnImage();
185:
186:         /**
187:          * Get an arbitrary element from the data map.
188:          *
189:          * @param key (see constants)
190:          * @return object
191:          */
192:         Object getData(String key);
193:
194:         /**
195:          * Add the contents of the given map to the data map.
196:          *
197:          * @param data object
198:          */
199:         void setData(Map<String, Object> data);
200:
201:         /**
202:          * Get the underlying data map.
203:          *
204:          * @return data map object
205:          */
206:         Map<String, Object> getData();
207:
208:         /**
209:          * Get the list of additional ConfigurationCallbacks.
210:          *
211:          * @return list of ConfigurationCallbacks.
212:          */
213:         List<ConfigurationCallback<AbstractTableViewer, ViewerColumn>> getConfigurationCallbacks();
214:
215:         /**
216:          * Toggle the visible state of the column.
217:          *
218:          * @return visible property
219:          */
220:         Property<Boolean> visible();
221:
222:         /**
223:          * Toggle the visible state of the filter control.
224:          *
225:          * @return visible property
226:          */
227:         Property<Boolean> showFilterControl();
228:
229:         /**
230:          * Set a filter on the current column.
231:          *
232:          * @return visible property
233:          */
234:         Property<Object> matchFilter();
235:
236:         /**
237:          * Dispose this configuration and all its properties.
238:          */
239:         void dispose();
240: }