com.vaadin.v7.ui.Table类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(15.0k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中com.vaadin.v7.ui.Table类的一些代码示例,展示了Table类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table类的具体详情如下:
包路径:com.vaadin.v7.ui.Table
类名称:Table

Table介绍

[英]Table is used for representing data or components in a pageable and selectable table.

Scalability of the Table is largely dictated by the container. A table does not have a limit for the number of items and is just as fast with hundreds of thousands of items as with just a few. The current GWT implementation with scrolling however limits the number of rows to around 500000, depending on the browser and the pixel height of rows.

Components in a Table will not have their caption nor icon rendered.
[中]Table用于在可分页的可选表格中表示数据或组件。
表的可伸缩性在很大程度上取决于容器。一张表格没有项目数量的限制,数十万个项目的速度和只有几个项目的速度一样快。不过,当前的GWT滚动实现将行数限制在500000左右,具体取决于浏览器和行的像素高度。
表中的组件不会呈现其标题或图标。

代码示例

代码示例来源:origin: OpenNMS/opennms

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());

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

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;

代码示例来源:origin: OpenNMS/opennms

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();
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

/**
 * 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);
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public void buttonClick(Button.ClickEvent clickEvent) {
    ColumnDef columnDef = (ColumnDef) columnsTable.getValue();
    if (columnDef != null) {
      columnsTable.unselect(columnDef);
      columns.removeItem(columnDef);
    }
    columnsTable.refreshRowCache();
  }
});

代码示例来源:origin: info.magnolia.activation/magnolia-module-activation

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;
}

代码示例来源:origin: OpenNMS/opennms

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");

代码示例来源:origin: OpenNMS/opennms

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());

代码示例来源:origin: OpenNMS/opennms

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());

代码示例来源:origin: OpenNMS/opennms

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");

代码示例来源:origin: OpenNMS/opennms

/**
 * 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);
}

代码示例来源:origin: OpenNMS/opennms

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);

代码示例来源:origin: com.haulmont.cuba/cuba-web

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)) {

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

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());

代码示例来源:origin: OpenNMS/opennms

@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);
      }
    }
  }
});

代码示例来源:origin: OpenNMS/opennms

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)));

代码示例来源:origin: com.haulmont.cuba/cuba-web

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);

代码示例来源:origin: de.mhus.lib/mhu-lib-vaadin

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()));

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@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;
  }
};

代码示例来源:origin: OpenNMS/opennms

@Override
public void refreshRowCache() {
  if (m_disableRowCacheRefresh) {
    return;
  }
  super.refreshRowCache();
}

相关文章

微信公众号

最新文章

更多

Table类方法