use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class HideSelectedColumnsTest method setUp.
@Before
public void setUp() {
this.columnHideShowLayer = new ColumnHideShowLayer(new DataLayerFixture());
this.selectionLayer = new SelectionLayer(this.columnHideShowLayer);
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class SearchGridCommandHandlerTest method doTest.
private void doTest() throws PatternSyntaxException {
// Register call back
final ILayerListener listener = new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof SearchEvent) {
// Check event, coordinate should be in composite layer
// coordinates
SearchEvent searchEvent = (SearchEvent) event;
if (SearchGridCommandHandlerTest.this.expected != null) {
assertEquals(SearchGridCommandHandlerTest.this.expected.columnPosition, searchEvent.getCellCoordinate().getColumnPosition());
assertEquals(SearchGridCommandHandlerTest.this.expected.rowPosition, searchEvent.getCellCoordinate().getRowPosition());
} else {
assertNull(searchEvent.getCellCoordinate());
}
}
}
};
this.gridLayer.addLayerListener(listener);
try {
SelectionLayer selectionLayer = this.gridLayer.getBodyLayer().getSelectionLayer();
final GridSearchStrategy gridSearchStrategy = new GridSearchStrategy(this.configRegistry, this.isWrapSearch, this.isColumnFirst);
final SearchCommand searchCommand = new SearchCommand(this.searchText, selectionLayer, gridSearchStrategy, this.isForward ? ISearchDirection.SEARCH_FORWARD : ISearchDirection.SEARCH_BACKWARDS, this.isWrapSearch, this.isCaseSensitive, this.isWholeWord, this.isIncremental, this.isRegex, this.isIncludeCollapsed, new CellValueAsStringComparator<>());
this.commandHandler.doCommand(selectionLayer, searchCommand);
final PositionCoordinate searchResultCellCoordinate = this.commandHandler.getSearchResultCellCoordinate();
if (this.expected != null) {
assertEquals(this.expected.columnPosition, searchResultCellCoordinate.columnPosition);
assertEquals(this.expected.rowPosition, searchResultCellCoordinate.rowPosition);
assertEquals(1, selectionLayer.getSelectedCellPositions().length);
assertEquals(this.expected.columnPosition, selectionLayer.getSelectedCellPositions()[0].columnPosition);
assertEquals(this.expected.rowPosition, selectionLayer.getSelectedCellPositions()[0].rowPosition);
} else {
assertNull(searchResultCellCoordinate);
}
} finally {
this.gridLayer.removeLayerListener(listener);
}
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class SummaryRowIntegrationTest method initLayerStackWithSummaryRow.
@Before
public void initLayerStackWithSummaryRow() {
this.dataList = RowDataListFixture.getList().subList(0, 4);
// Rows 0, 1, 2, 3; Summary row would be position 4
assertEquals(4, this.dataList.size());
this.dataProvider = new ListDataProvider<RowDataFixture>(this.dataList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
IConfigRegistry configRegistry = new ConfigRegistry();
this.dataLayer = new DataLayer(this.dataProvider);
this.summaryRowLayer = new SummaryRowLayer(this.dataLayer, configRegistry);
IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(this.summaryRowLayer);
IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
IUniqueIndexLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
this.layerStackWithSummary = new ViewportLayer(selectionLayer);
// NatTableFixture initializes the client area
this.natTable = new NatTableFixture(this.layerStackWithSummary, false);
this.natTable.setConfigRegistry(configRegistry);
this.natTable.addConfiguration(new TestSummaryRowConfiguration());
this.natTable.configure();
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method openEditorForSpannedCellsShouldOpenInline.
@Test
public void openEditorForSpannedCellsShouldOpenInline() throws Exception {
CompositeLayer layer = new CompositeLayer(1, 1);
SelectionLayer selectionLayer = new SelectionLayer(new SpanningDataLayer(new DummySpanningBodyDataProvider(100, 100)));
layer.setChildLayer(GridRegion.BODY, new ViewportLayer(selectionLayer), 0, 0);
this.natTable = new NatTableFixture(layer, 1200, 300, false);
layer.addConfiguration(new DefaultEditBindings());
layer.addConfiguration(new DefaultEditConfiguration());
this.natTable.enableEditingOnAllCells();
final boolean[] inlineFired = new boolean[1];
inlineFired[0] = false;
selectionLayer.addLayerListener(new ILayerListener() {
@Override
public void handleLayerEvent(ILayerEvent event) {
if (event instanceof InlineCellEditEvent) {
inlineFired[0] = true;
}
}
});
this.natTable.configure();
this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.F2));
// Verify edit mode
assertNotNull(this.natTable.getActiveCellEditor());
assertEquals("Col: 1, Row: 1", this.natTable.getActiveCellEditor().getCanonicalValue());
assertNotNull(ActiveCellEditorRegistry.getActiveCellEditor());
assertEquals("Col: 1, Row: 1", ActiveCellEditorRegistry.getActiveCellEditor().getCanonicalValue());
// verify that inline editing is used and not dialog
assertTrue("No InlineCellEditEvent fired", inlineFired[0]);
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class TickUpdateCommandHandlerTest method setup.
@Before
public void setup() {
DataLayerFixture bodyDataLayer = new DataLayerFixture();
this.selectionLayer = new SelectionLayer(bodyDataLayer);
this.selectionLayer.setSelectedCell(1, 1);
this.testConfigRegistry = new ConfigRegistry();
this.testConfigRegistry.registerConfigAttribute(TickUpdateConfigAttributes.UPDATE_HANDLER, new TickUpdateHandlerFixture());
this.testConfigRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
registerCellStyleAccumulators(bodyDataLayer);
this.commandHandler = new TickUpdateCommandHandler(this.selectionLayer);
}
Aggregations