use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateHiddenOnInsertAndDelete.
@Test
public void shouldUpdateHiddenOnInsertAndDelete() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(6);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateReorderOnInsert.
@Test
public void shouldUpdateReorderOnInsert() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsertAndDelete.
@Test
public void shouldUpdateOnInsertAndDelete() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(6);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsert.
@Test
public void shouldUpdateOnInsert() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnInsertEvent in project nebula.widgets.nattable by eclipse.
the class DynamicColumnExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// start with 3 columns
this.columns.add("Column_0");
this.columns.add("Column_1");
this.columns.add("Column_2");
this.values.add(createValueRow("Homer"));
this.values.add(createValueRow("Marge"));
this.values.add(createValueRow("Bart"));
this.values.add(createValueRow("Lisa"));
this.values.add(createValueRow("Maggie"));
Composite panel = new Composite(parent, SWT.NONE);
panel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
Composite gridPanel = new Composite(panel, SWT.NONE);
gridPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(gridPanel);
Composite buttonPanel = new Composite(panel, SWT.NONE);
buttonPanel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(buttonPanel);
ConfigRegistry configRegistry = new ConfigRegistry();
final GlazedListsGridLayer<Map<String, String>> glazedListsGridLayer = new GlazedListsGridLayer<>(this.values, new MyColumnPropertyAccessor(), new SimpleColumnHeaderDataProvider(), configRegistry, true);
final NatTable natTable = new NatTable(gridPanel, glazedListsGridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
natTable.addConfiguration(new SingleClickSortConfiguration());
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
Button addColumnButton = new Button(buttonPanel, SWT.PUSH);
addColumnButton.setText("add column");
addColumnButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String newColumn = "Column_" + DynamicColumnExample.this.columns.size();
DynamicColumnExample.this.columns.add(newColumn);
for (Map<String, String> value : DynamicColumnExample.this.values) {
String prefix = value.get("Column_0");
prefix = prefix.substring(0, prefix.indexOf("_"));
value.put(newColumn, prefix + "_" + (DynamicColumnExample.this.columns.size() - 1));
}
glazedListsGridLayer.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(glazedListsGridLayer.getBodyDataLayer(), DynamicColumnExample.this.columns.size() - 1));
natTable.refresh();
}
});
natTable.doCommand(new ColumnHideCommand(glazedListsGridLayer.getBodyLayer(), 1));
return panel;
}
Aggregations