@SuppressWarnings("unchecked") private void addActionColumn() { ((GeneratedPropertyListContainer<E>) grid.getContainerDataSource()) .addGeneratedProperty(ACTION_MENU_PROPERTY_ID, getActionMenuColumnGenerator()); final Column actionMenuColumn = grid.addColumn(ACTION_MENU_PROPERTY_ID); grid.setFrozenColumnCount(1); actionMenuColumn.setHeaderCaption(""); actionMenuColumn.setRenderer(new ComponentRenderer()); actionMenuColumn.setWidth(40); actionMenuColumn.setResizable(false); grid.setCellStyleGenerator(new CellStyleGenerator() { /** * */ private static final long serialVersionUID = 1L; @Override public String getStyle(CellReference event) { String style = ""; if (event.getPropertyId().equals(ACTION_MENU_PROPERTY_ID)) { style = "grid-actionmenu"; } return style; } }); }
@SuppressWarnings("unchecked") @Override public void enter(final ViewChangeEvent event) { eventbus.register(this); setSizeFull(); // caption caption.addStyleName("h2"); // toolbar createToolbar(); beanContainer = new BeanContainer<>(AbstractSimulatedDevice.class); beanContainer.setBeanIdProperty(ID_COL); grid.setSizeFull(); grid.setCellStyleGenerator(new CellStyleGenerator() { private static final long serialVersionUID = 1L; @Override public String getStyle(final CellReference cellReference) { return cellReference.getPropertyId().equals(STATUS_COL) ? "centeralign" : null; } }); grid.setSelectionMode(SelectionMode.NONE); grid.setContainerDataSource(beanContainer); grid.appendHeaderRow().getCell(RESPONSE_STATUS_COL).setComponent(responseComboBox); grid.setColumnOrder(ID_COL, STATUS_COL, SWVERSION_COL, PROGRESS_COL, TENANT_COL, PROTOCOL_COL, RESPONSE_STATUS_COL, NEXT_POLL_COUNTER_SEC_COL); // header widths grid.getColumn(STATUS_COL).setMaximumWidth(80); grid.getColumn(PROTOCOL_COL).setMaximumWidth(180); grid.getColumn(RESPONSE_STATUS_COL).setMaximumWidth(240); grid.getColumn(NEXT_POLL_COUNTER_SEC_COL).setMaximumWidth(210); grid.getColumn(NEXT_POLL_COUNTER_SEC_COL).setHeaderCaption("Next Poll in (sec)"); grid.getColumn(SWVERSION_COL).setHeaderCaption("SW Version"); grid.getColumn(RESPONSE_STATUS_COL).setHeaderCaption("Response Update Status"); grid.getColumn(PROGRESS_COL).setRenderer(new ProgressBarRenderer()); grid.getColumn(PROTOCOL_COL).setConverter(createProtocolConverter()); grid.getColumn(STATUS_COL).setRenderer(new HtmlRenderer(), createStatusConverter()); grid.removeColumn(TENANT_COL); // grid combobox responseComboBox.setItemIcon(ResponseStatus.SUCCESSFUL, FontAwesome.CHECK_CIRCLE); responseComboBox.setItemIcon(ResponseStatus.ERROR, FontAwesome.EXCLAMATION_CIRCLE); responseComboBox.setNullSelectionAllowed(false); responseComboBox.setValue(ResponseStatus.SUCCESSFUL); responseComboBox.addValueChangeListener( valueChangeEvent -> beanContainer.getItemIds().forEach(itemId -> beanContainer.getItem(itemId) .getItemProperty(RESPONSE_STATUS_COL).setValue(valueChangeEvent.getProperty().getValue()))); // add all components addComponent(caption); addComponent(toolbar); addComponent(grid); setExpandRatio(grid, 1.0F); // load beans repository.getAll().forEach(beanContainer::addBean); }
public void setCellStyleGenerator(CellStyleGenerator generator) { grid.setCellStyleGenerator(generator); }