public void testSetDataDisplay() { SelectionModel<String> model = new SingleSelectionModel<String>(); DefaultSelectionEventManager<String> manager = DefaultSelectionEventManager.createDefaultManager(); MockDataProvider<String> provider = new MockDataProvider<String>(null); DefaultNodeInfo<String> nodeInfo = new DefaultNodeInfo<String>(provider, new TextCell(), model, manager, null); MockHasData<String> display = new MockHasData<String>(); display.setVisibleRange(0, 10); display.clearLastRowDataAndRange(); assertEquals(0, display.getHandlerCount(CellPreviewEvent.getType())); // setDataDisplay. nodeInfo.setDataDisplay(display); assertEquals(1, display.getHandlerCount(CellPreviewEvent.getType())); provider.assertLastRangeChanged(display); provider.clearLastRangeChanged(); display.setVisibleRange(0, 5); provider.assertLastRangeChanged(display); provider.clearLastRangeChanged(); // unsetDataDisplay. nodeInfo.unsetDataDisplay(); assertEquals(0, display.getHandlerCount(CellPreviewEvent.getType())); display.setVisibleRange(0, 5); provider.assertLastRangeChanged(null); }
private void setupSessionDataGrid() { sessionsDataGrid = new DataGrid<SessionDataDto>(); sessionsDataGrid.setPageSize(15); sessionsDataGrid.setEmptyTableWidget(new Label("No Sessions")); // Add a selection model so we can select cells. final SelectionModel<SessionDataDto> selectionModel = new MultiSelectionModel<SessionDataDto>( new ProvidesKey<SessionDataDto>() { @Override public Object getKey(SessionDataDto item) { return item.getSessionId(); } }); sessionsDataGrid.setSelectionModel( selectionModel, DefaultSelectionEventManager.<SessionDataDto>createCheckboxManager()); // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable mouse selection. Column<SessionDataDto, Boolean> checkColumn = new Column<SessionDataDto, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(SessionDataDto object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; sessionsDataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); sessionsDataGrid.setColumnWidth(checkColumn, 40, Style.Unit.PX); sessionsDataGrid.addColumn( new TextColumn<SessionDataDto>() { @Override public String getValue(SessionDataDto object) { return object.getName(); } }, "Name"); sessionsDataGrid.addColumn( new TextColumn<SessionDataDto>() { @Override public String getValue(SessionDataDto object) { return object.getStartDate(); } }, "Start Date"); sessionsDataGrid.addColumn( new TextColumn<SessionDataDto>() { @Override public String getValue(SessionDataDto object) { return object.getEndDate(); } }, "End Date"); sessionDataProvider.addDataDisplay(sessionsDataGrid); }
private void setupTestDataGrid() { testDataGrid = new CellTable<TaskDataDto>(); testDataGrid.setWidth("500px"); testDataGrid.setEmptyTableWidget(new Label("No Tests")); // Add a selection model so we can select cells. final SelectionModel<TaskDataDto> selectionModel = new MultiSelectionModel<TaskDataDto>( new ProvidesKey<TaskDataDto>() { @Override public Object getKey(TaskDataDto item) { return item.getTaskName(); } }); testDataGrid.setSelectionModel( selectionModel, DefaultSelectionEventManager.<TaskDataDto>createCheckboxManager()); // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable mouse selection. Column<TaskDataDto, Boolean> checkColumn = new Column<TaskDataDto, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(TaskDataDto object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; testDataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); testDataGrid.setColumnWidth(checkColumn, 40, Style.Unit.PX); testDataGrid.addColumn( new TextColumn<TaskDataDto>() { @Override public String getValue(TaskDataDto object) { return object.getTaskName(); } }, "Tests"); testDataGrid.setRowData(Collections.EMPTY_LIST); }