table.addStyleName("light"); table.setVisibleColumns(new Object[]{"parmid", "decodes"}); table.setColumnHeader("parmid", "Parameter ID"); table.setColumnHeader("decodes", "Decode Values"); table.setColumnExpandRatio("decodes", 1); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setHeight("125px"); table.setWidth("100%"); table.setTableFieldFactory(new DefaultFieldFactory() { @Override public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) { toolbar.addComponent(add); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable());
Object defaultValue, String columnHeader, Resource columnIcon, Align columnAlignment) throws UnsupportedOperationException { if (!this.addContainerProperty(propertyId, type, defaultValue)) { return false; setColumnAlignment(propertyId, columnAlignment); setColumnHeader(propertyId, columnHeader); setColumnIcon(propertyId, columnIcon); return true;
void refreshTable() { if (m_table != null) { m_beanItemContainer = WallboardProvider.getInstance().getBeanContainer(); m_table.setContainerDataSource(m_beanItemContainer); m_table.setVisibleColumns(new Object[]{"title", "Edit", "Remove", "Preview", "Default"}); m_table.setColumnHeader("title", "Title"); m_table.sort(); m_table.refreshRowCache(); } } }
/** * Creates a new table with caption and connect it to a Container. * * @param caption * @param dataSource */ public Table(String caption, Container dataSource) { this(); setCaption(caption); setContainerDataSource(dataSource); }
@Override public void buttonClick(Button.ClickEvent clickEvent) { ColumnDef columnDef = (ColumnDef) columnsTable.getValue(); if (columnDef != null) { columnsTable.unselect(columnDef); columns.removeItem(columnDef); } columnsTable.refreshRowCache(); } });
private Layout createPublicInstancesSection() { VerticalLayout layout = new VerticalLayout(); StaticField fieldsetTitle = createStaticField(null, i18n.translate("activationMonitor.publicInstances.fieldset.label")); fieldsetTitle.addStyleName("fieldset-title"); layout.addComponent(fieldsetTitle); if (activationStorage.getSubscriberResponseTimes().size() > 0) { Table table = new Table(); table.setSelectable(false); table.setMultiSelect(false); table.setImmediate(false); table.setWidth("100%"); table.setPageLength(5); table.addContainerProperty(i18n.translate("activationMonitor.publicInstances.subscriber.label"), String.class, null); table.addContainerProperty(i18n.translate("activationMonitor.publicInstances.max.label"), Long.class, null); table.addContainerProperty(i18n.translate("activationMonitor.publicInstances.min.label"), Long.class, null); table.addContainerProperty(i18n.translate("activationMonitor.publicInstances.avg.label"), Long.class, null); int i = 0; for (Map.Entry<String, ResponseTimeEntry> entry : activationStorage.getSubscriberResponseTimes().entrySet()) { String subscriber = entry.getKey(); long max = entry.getValue().getMax(); long min = entry.getValue().getMin(); long avg = entry.getValue().getAvg(); table.addItem(new Object[]{subscriber, max, min, avg}, i++); } layout.addComponent(table); } else { layout.addComponent(createStaticField(null, i18n.translate("activationMonitor.publicInstances.noActivations.label"))); } return layout; }
final Table columnsTable = new Table(); columnsTable.setSortEnabled(false); columnsTable.setWidth(25, Unit.PERCENTAGE); columnsTable.setContainerDataSource(columns); columnsTable.setVisibleColumns("label"); columnsTable.setColumnHeader("label", "Columns"); columnsTable.setColumnExpandRatio("label", 1.0f); columnsTable.setSelectable(true); columnsTable.setMultiSelect(false); columnsTable.setSizeFull(); columnsTable.setImmediate(true); columnsTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { final Table rowsTable = new Table(); rowsTable.setSortEnabled(false); rowsTable.setWidth(25, Unit.PERCENTAGE); rowsTable.setContainerDataSource(rows); rowsTable.setVisibleColumns("label");
final Table categoriesTable = new Table(); categoriesTable.setSizeFull(); categoriesTable.setHeight(250.0f, Unit.PIXELS); categoriesTable.setCaption("Categories"); categoriesTable.setSortEnabled(true); categoriesTable.addContainerProperty("name", String.class, ""); categoriesTable.setColumnHeader("name", "Category"); categoriesTable.setColumnExpandRatio("Category", 1.0f); categoriesTable.setSelectable(true); categoriesTable.setMultiSelect(true); categoriesTable.addItem(new Object[]{onmsCategory.getName()}, onmsCategory.getId()); categoriesMap.put(onmsCategory.getId(), onmsCategory); if (def.containsCategory(onmsCategory.getName())) { categoriesTable.select(onmsCategory.getId());
setCaption("Include Collections"); table.addStyleName("light"); table.setVisibleColumns(new Object[]{"type", "value"}); table.setColumnHeaders(new String[]{"Type", "Value"}); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setImmediate(true); table.setSizeFull(); final Button add = new Button("Add", new Button.ClickListener() { @Override toolbar.addComponent(edit); toolbar.addComponent(delete); toolbar.setVisible(table.isEditable());
m_table = new Table(); m_table.setContainerDataSource(m_beanItemContainer); m_table.setSizeFull(); m_table.sort(new Object[]{"name"}, new boolean[]{true}); m_table.addGeneratedColumn("Edit", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Edit"); m_table.addGeneratedColumn("Remove", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Remove"); m_table.addGeneratedColumn("Preview", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { Button button = new Button("Preview"); m_table.addGeneratedColumn("Default", new Table.ColumnGenerator() { public Object generateCell(Table source, final Object itemId, Object columnId) { CheckBox checkBox = new CheckBox(); m_table.setVisibleColumns(new Object[]{"name", "Edit", "Remove", "Preview", "Default"}); m_table.setColumnHeader("name", "Name");
/** * Instantiates a new MIB object field. * * @param resourceTypes the available resource types * @param mibGroupEditable true, if the MIB group can be modified */ public MibObjField(final List<String> resourceTypes, boolean mibGroupEditable) { table.addStyleName("light"); table.setVisibleColumns(new Object[] { "oid", "instance", "alias", "type" }); table.setColumnHeaders(new String[] { "OID", "Instance", "Alias", "Type" }); table.setEditable(!isReadOnly()); table.setSelectable(true); table.setHeight("250px"); table.setWidth("100%"); table.setTableFieldFactory(new MibObjFieldFactory(resourceTypes)); if (mibGroupEditable) { toolbar.addComponent(add); toolbar.addComponent(delete); } toolbar.setVisible(table.isEditable()); setValidationVisible(true); }
final Table table = new Table(); table.setTableFieldFactory(new DefaultFieldFactory() { @Override public Field<?> createField(Container container, Object itemId, Object propertyId, Component uiContext) { table.setEditable(true); table.setSizeFull(); table.setImmediate(true); table.addContainerProperty("Key", String.class, ""); table.addContainerProperty("Value", String.class, ""); table.addItem(new Object[]{entry.getKey(), dashletSpec.getParameters().containsKey(entry.getKey()) ? dashletSpec.getParameters().get(entry.getKey()) : ""}, entry.getKey()); table.setColumnWidth("Key", 100); table.setColumnWidth("Value", -1); table.setSizeFull(); verticalLayout.addComponent(table);
protected void initComponent(T component) { component.setMultiSelect(false); component.setValidationVisible(false); component.setShowBufferedSourceException(false); component.addValueChangeListener(this::tableSelectionChanged); component.setSpecificVariablesHandler(this::handleSpecificVariables); component.setIconProvider(this::getItemIcon); component.setColumnWidth(ROW_HEADER_PROPERTY_ID, defaultRowHeaderWidth); component.addShortcutListener( new ShortcutListenerDelegate("tableEnter", KeyCode.ENTER, null) .withHandler((sender, target) -> { T tableImpl = WebAbstractTable.this.component; CubaUI ui = (CubaUI) tableImpl.getUI(); if (!ui.isAccessibleForUser(tableImpl)) { LoggerFactory.getLogger(WebAbstractTable.class) component.addShortcutListener( new ShortcutListenerDelegate("tableSelectAll", KeyCode.A, new int[] { com.vaadin.event.ShortcutAction.ModifierKey.CTRL }) component.addItemClickListener(event -> { if (event.isDoubleClick() && event.getItem() != null) { T tableImpl = WebAbstractTable.this.component; CubaUI ui = (CubaUI) tableImpl.getUI(); if (!ui.isAccessibleForUser(tableImpl)) {
pIds.add(id); addContainerProperty(id, String.class, null); setColumnWidth(id, DesignAttributeHandler.readAttribute( "width", col.attributes(), Integer.class)); setColumnAlignment(id, Align.CENTER); } else if (col.hasAttr("right")) { setColumnAlignment(id, Align.RIGHT); setColumnExpandRatio(id, 1); } else { setColumnExpandRatio(id, DesignAttributeHandler.readAttribute("expand", col.attributes(), float.class)); setColumnCollapsible(id, DesignAttributeHandler.readAttribute("collapsible", col.attributes(), boolean.class)); setColumnCollapsed(id, DesignAttributeHandler.readAttribute( "collapsed", col.attributes(), boolean.class)); setVisibleColumns(pIds.toArray());
@Override public void buttonClick(Button.ClickEvent clickEvent) { ColumnDef columnDef = (ColumnDef) columnsTable.getValue(); if (columnDef != null) { int columnDefIndex = columnOrder.get(columnDef); ColumnDef columnDefToSwap = null; for (Map.Entry<ColumnDef, Integer> entry : columnOrder.entrySet()) { if (entry.getValue().intValue() == columnDefIndex - 1) { columnDefToSwap = entry.getKey(); break; } } if (columnDefToSwap != null) { columnsTable.unselect(columnDef); columnOrder.remove(columnDef); columnOrder.remove(columnDefToSwap); columnOrder.put(columnDef, columnDefIndex - 1); columnOrder.put(columnDefToSwap, columnDefIndex); columns.sort(new Object[]{"label"}, new boolean[]{true}); columnsTable.refreshRowCache(); columnsTable.select(columnDef); } } } });
final Table table = new Table(); table.setCellStyleGenerator((Table.CellStyleGenerator) (source, itemId, propertyId) -> { if (propertyId != null && propertyId.equals(explanation.getStatus())) { return "selected"; table.addContainerProperty(EDGE_COLUMN, String.class, null); table.addContainerProperty(STATUS_COLUMN, Label.class, null); table.addContainerProperty(WEIGHT_COLUMN, Integer.class, Edge.DEFAULT_WEIGHT); table.addContainerProperty(WEIGHT_FACTOR, String.class, null); table.addContainerProperty(Status.CRITICAL, String.class, null); table.addContainerProperty(Status.MAJOR, String.class, null); table.addContainerProperty(Status.MINOR, String.class, null); table.addContainerProperty(Status.WARNING, String.class, null); table.addContainerProperty(Status.NORMAL, String.class, null); table.addItem(new Object[] { getLabel(eachEdge, explanation), createStatusLabel(null, eachEdge.getStatus()), table.setFooterVisible(true); table.setColumnFooter(EDGE_COLUMN, "Total"); table.setColumnFooter(STATUS_COLUMN, explanation.getStatus().getLabel()); table.setColumnFooter(WEIGHT_COLUMN, String.valueOf(explanation.getWeightSum())); table.setColumnFooter(WEIGHT_FACTOR, toString(explanation.getWeightSumFactor())); table.setColumnFooter(Status.CRITICAL, toString(explanation.getStatusResult(Status.CRITICAL))); table.setColumnFooter(Status.MAJOR, toString(explanation.getStatusResult(Status.MAJOR))); table.setColumnFooter(Status.MINOR, toString(explanation.getStatusResult(Status.MINOR))); table.setColumnFooter(Status.WARNING, toString(explanation.getStatusResult(Status.WARNING)));
protected void applyColumnSettings(Element element) { Element columnsElem = element.element("columns"); Object[] oldColumns = component.getVisibleColumns(); List<Object> newColumns = new ArrayList<>(); component.setColumnWidth(column, Integer.parseInt(width)); } else { component.setColumnWidth(column, -1); if (component.isColumnCollapsingAllowed()) { // throws exception if not component.setColumnCollapsed(column, !Boolean.parseBoolean(visible)); if (component.isColumnCollapsingAllowed()) { // throws exception if not component.setColumnCollapsed(newColumns.get(0), false); component.setVisibleColumns(newColumns.toArray()); boolean sortAscending = Boolean.parseBoolean(columnsElem.attributeValue("sortAscending")); component.setSortContainerPropertyId(null); component.setSortAscending(sortAscending); component.setSortContainerPropertyId(sortProperty); component.setSortContainerPropertyId(null);
table.setVisibleColumns(columns.values().toArray()); title = columnDef.title(); if (title != null) table.setColumnHeader(colId, title); table.setColumnAlignment(colId, mapToVaadin(columnDef.align())); table.setColumnCollapsed(colId, !columnDef.elapsed()); table.setColumnCollapsible(colId, columnDef.collapsible()); table.setConverter(colId,model.generateConverter(descriptor.getPropertyType()));
@Override protected Table createTable(Container container) { Table table = new Table(null, container); table.setSelectable(true); table.setMultiSelect(true); // use B as default selected value here table.setValue(Lists.newArrayList(B)); return table; } };
@Override public void refreshRowCache() { if (m_disableRowCacheRefresh) { return; } super.refreshRowCache(); }