use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class _6045_HierarchicalTreeLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout());
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("manufacturer", "Manufacturer");
propertyToLabelMap.put("model", "Model");
propertyToLabelMap.put("motors.identifier", "Identifier");
propertyToLabelMap.put("motors.capacity", "Capacity");
propertyToLabelMap.put("motors.capacityUnit", "Capacity Unit");
propertyToLabelMap.put("motors.maximumSpeed", "Maximum Speed");
propertyToLabelMap.put("motors.feedbacks.creationTime", "Creation Time");
propertyToLabelMap.put("motors.feedbacks.classification", "Classification");
propertyToLabelMap.put("motors.feedbacks.comment", "Comment");
ConfigRegistry configRegistry = new ConfigRegistry();
BodyLayerStack bodyLayerStack = new BodyLayerStack(CarService.getInput(), CarService.PROPERTY_NAMES);
// create the column header layer stack
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(CarService.PROPERTY_NAMES, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
// add the SortHeaderLayer to the column header layer stack
final SortHeaderLayer<HierarchicalWrapper> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new HierarchicalWrapperSortModel(bodyLayerStack.getSortedList(), bodyLayerStack.getColumnPropertyAccessor(), bodyLayerStack.getTreeLayer().getLevelIndexMapping(), columnHeaderDataLayer, configRegistry), false);
// add the filter row functionality
final FilterRowHeaderComposite<HierarchicalWrapper> filterRowHeaderLayer = new FilterRowHeaderComposite<>(new DefaultGlazedListsFilterStrategy<>(bodyLayerStack.getFilterList(), bodyLayerStack.getColumnPropertyAccessor(), configRegistry), sortHeaderLayer, columnHeaderDataLayer.getDataProvider(), configRegistry);
filterRowHeaderLayer.addConfigLabelAccumulatorForRegion(GridRegion.FILTER_ROW, new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
int columnIndex = filterRowHeaderLayer.getColumnIndexByPosition(columnPosition);
// header column
if (columnIndex < 0) {
configLabels.addLabelOnTop(HierarchicalTreeLayer.LEVEL_HEADER_CELL);
}
}
});
// create the composite layer composed with the prior created layer
// stacks
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, filterRowHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, bodyLayerStack, 0, 1);
compositeLayer.addConfiguration(new DefaultGridLayerConfiguration(compositeLayer) {
@Override
protected void addAlternateRowColoringConfig(CompositeLayer gridLayer) {
// do nothing to avoid the default grid alternate row coloring
// needed because the alternate row coloring in the hierarchical
// tree
// is based on the spanned cells and not per individual row
// position
}
});
NatTable natTable = new NatTable(container, compositeLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
this.vAlign = VerticalAlignmentEnum.TOP;
this.hAlign = HorizontalAlignmentEnum.LEFT;
this.cellPainter = new PaddingDecorator(new TextPainter(), 2);
}
});
// add editing configuration
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// make identifier editable
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2);
// make capacity unit editable
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new ComboBoxCellEditor("KW", "PS"), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new PaddingDecorator(new ComboBoxPainter(), 2), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
// make comment editable
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 8);
}
});
// adds the key bindings that allows pressing space bar to
// expand/collapse tree nodes
natTable.addConfiguration(new TreeLayerExpandCollapseKeyBindings(bodyLayerStack.getTreeLayer(), bodyLayerStack.getSelectionLayer()));
// add sorting configuration
natTable.addConfiguration(new SingleClickSortConfiguration());
// add some additional filter configuration
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
Style style = new Style();
style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.getColor(173, 216, 230));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
}
});
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
Composite buttonPanel = new Composite(container, SWT.NONE);
buttonPanel.setLayout(new RowLayout());
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
Button collapseAllButton = new Button(buttonPanel, SWT.PUSH);
collapseAllButton.setText("Collapse All");
collapseAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeCollapseAllCommand());
}
});
Button expandAllButton = new Button(buttonPanel, SWT.PUSH);
expandAllButton.setText("Expand All");
expandAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeExpandAllCommand());
}
});
Button expandAllFirstLevelButton = new Button(buttonPanel, SWT.PUSH);
expandAllFirstLevelButton.setText("Expand All First Level");
expandAllFirstLevelButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeExpandToLevelCommand(0));
}
});
Button toggleExpandButton = new Button(buttonPanel, SWT.PUSH);
toggleExpandButton.setText("Enable Advanced Expand");
toggleExpandButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
_6045_HierarchicalTreeLayerExample.this.advancedExpandEnabled = !_6045_HierarchicalTreeLayerExample.this.advancedExpandEnabled;
if (_6045_HierarchicalTreeLayerExample.this.advancedExpandEnabled) {
toggleExpandButton.setText("Disable Advanced Expand");
// configure advanced action
natTable.getUiBindingRegistry().registerFirstSingleClickBinding(_6045_HierarchicalTreeLayerExample.this.treeImagePainterMouseEventMatcher, _6045_HierarchicalTreeLayerExample.this.advancedTreeExpandCollapseAction);
} else {
toggleExpandButton.setText("Enable Advanced Expand");
// configure simple action
natTable.getUiBindingRegistry().registerFirstSingleClickBinding(_6045_HierarchicalTreeLayerExample.this.treeImagePainterMouseEventMatcher, _6045_HierarchicalTreeLayerExample.this.simpleTreeExpandCollapseAction);
}
}
});
Button multiReorderButton = new Button(buttonPanel, SWT.PUSH);
multiReorderButton.setText("Reorder Second Level");
multiReorderButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
List<Integer> fromColumnPositions = Arrays.asList(4, 5);
natTable.doCommand(new MultiColumnReorderCommand(natTable, fromColumnPositions, 8));
}
});
Button deleteButton = new Button(buttonPanel, SWT.PUSH);
deleteButton.setText("Delete Row 4");
deleteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// remove the element
HierarchicalWrapper rowObject = bodyLayerStack.getFilterList().remove(3);
// fire the event to refresh
bodyLayerStack.getBodyDataLayer().fireLayerEvent(new RowDeleteEvent(bodyLayerStack.getBodyDataLayer(), 3));
bodyLayerStack.getTreeLayer().cleanupRetainedCollapsedNodes(rowObject);
}
});
return container;
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTest method shouldUpdateOnMultiRowDelete.
@Test
public void shouldUpdateOnMultiRowDelete() {
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 3, "Lovejoy"));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 5, "Lovejoy"));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 7, "Lovejoy"));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 9, "Lovejoy"));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 0));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 2));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 3));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 4));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 5));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 6));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 7));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 8));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 9));
// delete all the Simpsons
this.dataModel.remove(8);
this.dataModel.remove(6);
this.dataModel.remove(4);
this.dataModel.remove(2);
this.dataModel.remove(0);
this.dataLayer.fireLayerEvent(new RowDeleteEvent(this.dataLayer, new Range(0, 1), new Range(2, 3), new Range(4, 5), new Range(6, 7), new Range(8, 9)));
assertEquals(13, this.dataModel.size());
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 0));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 2));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 3));
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 4));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 0));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 2));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 3));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 4));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 0).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 3).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 4).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 5).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 6).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 7).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 8).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 9).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 10).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 11).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 12).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
assertTrue("Row 0 is not dirty", this.dataChangeLayer.isRowDirty(0));
assertTrue("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(1));
assertTrue("Row 2 is not dirty", this.dataChangeLayer.isRowDirty(2));
assertTrue("Row 3 is not dirty", this.dataChangeLayer.isRowDirty(3));
assertTrue("Row 4 is not dirty", this.dataChangeLayer.isRowDirty(4));
assertFalse("Row 5 is dirty", this.dataChangeLayer.isRowDirty(5));
assertFalse("Row 6 is dirty", this.dataChangeLayer.isRowDirty(6));
assertFalse("Row 7 is dirty", this.dataChangeLayer.isRowDirty(7));
assertFalse("Row 8 is dirty", this.dataChangeLayer.isRowDirty(8));
assertFalse("Row 9 is dirty", this.dataChangeLayer.isRowDirty(9));
assertFalse("Row 10 is dirty", this.dataChangeLayer.isRowDirty(10));
assertFalse("Row 11 is dirty", this.dataChangeLayer.isRowDirty(11));
assertFalse("Row 12 is dirty", this.dataChangeLayer.isRowDirty(12));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 0));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 1));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 2));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 3));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 4));
assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 5));
assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(0, 2));
assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(2, 3));
assertFalse("changed columns are empty", this.dataChangeLayer.changedColumns.isEmpty());
assertFalse("changed rows are empty", this.dataChangeLayer.changedRows.isEmpty());
assertFalse("changes are empty", this.dataChangeLayer.dataChanges.isEmpty());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTempStorageTest method shouldSaveAfterDelete.
@Test
public void shouldSaveAfterDelete() {
assertEquals("Simpson", this.dataLayer.getDataValue(1, 9));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 10));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 9, "Lovejoy"));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 9));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 9));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 10));
// delete a row before the change
this.dataModel.remove(2);
this.dataLayer.fireLayerEvent(new RowDeleteEvent(this.dataLayer, 2));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 8));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 8));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 9));
assertEquals("Flanders", this.dataChangeLayer.getDataValueByPosition(1, 9));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 8).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
assertTrue("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(8));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 8));
assertFalse("changed columns are empty", this.dataChangeLayer.changedColumns.isEmpty());
assertFalse("changed rows are empty", this.dataChangeLayer.changedRows.isEmpty());
assertFalse("changes are empty", this.dataChangeLayer.dataChanges.isEmpty());
// now discard and check that previous state is restored correctly
this.dataChangeLayer.doCommand(new SaveDataChangesCommand());
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 8));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 8));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 9));
assertEquals("Flanders", this.dataChangeLayer.getDataValueByPosition(1, 9));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 8).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(8));
assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 8));
assertTrue("changed columns are not empty", this.dataChangeLayer.changedColumns.isEmpty());
assertTrue("changed rows are not empty", this.dataChangeLayer.changedRows.isEmpty());
assertTrue("changes are not empty", this.dataChangeLayer.dataChanges.isEmpty());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayerStructuralChangeEventTest method testHandleLastRowDeleteEvent.
@Test
public void testHandleLastRowDeleteEvent() {
// test start order: 0 1 2 3 4
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(2, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals(4, this.rowHideShowLayer.getRowIndexByPosition(4));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("three", this.rowHideShowLayer.getDataValueByPosition(0, 2));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 3));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 4));
// hide row at position 2: 0 1 3 4
List<Integer> rowsToHide = new ArrayList<Integer>();
rowsToHide.add(2);
this.rowHideShowLayer.hideRowPositions(rowsToHide);
assertEquals(4, this.rowHideShowLayer.getRowCount());
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(4, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals(-1, this.rowHideShowLayer.getRowIndexByPosition(4));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 2));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 3));
// delete last row in list
int lastRowIndex = this.contents.size() - 1;
this.contents.remove(lastRowIndex);
this.underlyingLayer.fireLayerEvent(new RowDeleteEvent(this.underlyingLayer, lastRowIndex));
assertEquals(3, this.rowHideShowLayer.getRowCount());
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(-1, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 2));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayerStructuralChangeEventTest method testHandleHiddenRowDeleteEvent.
@Test
public void testHandleHiddenRowDeleteEvent() {
// test start order: 0 1 2 3 4
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(2, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals(4, this.rowHideShowLayer.getRowIndexByPosition(4));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("three", this.rowHideShowLayer.getDataValueByPosition(0, 2));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 3));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 4));
// hide row at position 2: 0 1 3 4
List<Integer> rowsToHide = new ArrayList<Integer>();
rowsToHide.add(2);
this.rowHideShowLayer.hideRowPositions(rowsToHide);
assertEquals(4, this.rowHideShowLayer.getRowCount());
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(4, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals(-1, this.rowHideShowLayer.getRowIndexByPosition(4));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 2));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 3));
// delete row index 2: value "three"
this.contents.remove(2);
this.underlyingLayer.fireLayerEvent(new RowDeleteEvent(this.underlyingLayer, 2));
assertEquals(4, this.rowHideShowLayer.getRowCount());
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(2, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals(-1, this.rowHideShowLayer.getRowIndexByPosition(4));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 2));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 3));
}
Aggregations