Revision d860133d
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java | ||
---|---|---|
51 | 51 |
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer; |
52 | 52 |
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer; |
53 | 53 |
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer; |
54 |
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer; |
|
55 |
import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer; |
|
54 | 56 |
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; |
55 | 57 |
import org.eclipse.nebula.widgets.nattable.layer.ILayer; |
56 | 58 |
import org.eclipse.nebula.widgets.nattable.layer.ILayerListener; |
57 | 59 |
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator; |
58 | 60 |
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; |
59 | 61 |
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent; |
62 |
import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler; |
|
60 | 63 |
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer; |
61 | 64 |
import org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer; |
62 | 65 |
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; |
... | ... | |
64 | 67 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer; |
65 | 68 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration; |
66 | 69 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode; |
70 |
import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration; |
|
71 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder; |
|
67 | 72 |
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer; |
68 | 73 |
import org.eclipse.swt.SWT; |
69 | 74 |
import org.eclipse.swt.events.SelectionAdapter; |
... | ... | |
189 | 194 |
|
190 | 195 |
RowReorderLayer rowReorderLayer = new RowReorderLayer(eventLayer); |
191 | 196 |
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(rowReorderLayer); |
192 |
SelectionLayer selectionLayer = new SelectionLayer(columnReorderLayer); |
|
197 |
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer); |
|
198 |
RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer); |
|
199 |
SelectionLayer selectionLayer = new SelectionLayer(rowHideShowLayer); |
|
193 | 200 |
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer); |
194 | 201 |
|
195 | 202 |
/** |
... | ... | |
198 | 205 |
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider( |
199 | 206 |
propertyToLabelMap.values().toArray(new String[] {}), propertyToLabelMap); |
200 | 207 |
DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider); |
201 |
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
|
|
208 |
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
|
|
202 | 209 |
|
203 | 210 |
ConfigRegistry configRegistry = new ConfigRegistry(); |
204 | 211 |
|
... | ... | |
206 | 213 |
// as we use GlazedLists, we use the GlazedListsSortModel which |
207 | 214 |
// delegates the sorting to the SortedList |
208 | 215 |
final SortHeaderLayer<SpecimenDescription> sortHeaderLayer = new SortHeaderLayer<>( |
209 |
columnHeaderLayer,
|
|
216 |
columnHeaderLayer, |
|
210 | 217 |
new GlazedListsSortModel<>( |
211 | 218 |
sortedList, |
212 | 219 |
columnPropertyAccessor, |
... | ... | |
248 | 255 |
// to sort on a single click |
249 | 256 |
natTable.addConfiguration(new SingleClickSortConfiguration()); |
250 | 257 |
|
258 |
// add the header menu configuration for adding the column header menu |
|
259 |
// with hide/show actions |
|
260 |
natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) { |
|
261 |
|
|
262 |
@Override |
|
263 |
protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) { |
|
264 |
return super.createColumnHeaderMenu(natTable) |
|
265 |
.withHideColumnMenuItem() |
|
266 |
.withShowAllColumnsMenuItem() |
|
267 |
.withStateManagerMenuItemProvider(); |
|
268 |
} |
|
269 |
|
|
270 |
@Override |
|
271 |
protected PopupMenuBuilder createRowHeaderMenu(NatTable natTable) { |
|
272 |
return super.createRowHeaderMenu(natTable) |
|
273 |
.withHideRowMenuItem() |
|
274 |
.withShowAllRowsMenuItem() |
|
275 |
.withStateManagerMenuItemProvider(); |
|
276 |
} |
|
277 |
|
|
278 |
@Override |
|
279 |
protected PopupMenuBuilder createCornerMenu(NatTable natTable) { |
|
280 |
return super.createCornerMenu(natTable) |
|
281 |
.withShowAllColumnsMenuItem().withShowAllRowsMenuItem() |
|
282 |
.withStateManagerMenuItemProvider(); |
|
283 |
} |
|
284 |
}); |
|
251 | 285 |
|
252 | 286 |
// add custom configuration for data conversion and add column labels |
253 | 287 |
viewportLayer.addConfiguration(new AbstractRegistryConfiguration() { |
... | ... | |
302 | 336 |
|
303 | 337 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable); |
304 | 338 |
|
339 |
//persist table config handler |
|
340 |
gridLayer.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(natTable)); |
|
341 |
|
|
305 | 342 |
//excel export |
306 | 343 |
Button addColumnButton = new Button(parent, SWT.PUSH); |
307 | 344 |
addColumnButton.setText("Export"); |
Also available in: Unified diff
ref #7095 Add context menu to hide/show columns and open config dialog