com.vaadin.ui.Grid.addColumn()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(192)

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

Grid.addColumn介绍

[英]Adds a new text column to this Grid with a value provider. The column will use a TextRenderer. The value is converted to a String using Object#toString(). In-memory sorting will use the natural ordering of elements if they are mutually comparable and otherwise fall back to comparing the string representations of the values.
[中]使用值提供程序将新文本列添加到此网格。该列将使用TextRenderer。使用对象#toString()将值转换为字符串。内存中排序将使用元素的自然排序,如果它们相互比较,则返回到比较值的字符串表示形式。

代码示例

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

/**
 * Adds a new text column to this {@link Grid} with a value provider. The
 * column will use a {@link TextRenderer}. The value is converted to a
 * String using {@link Object#toString()}. In-memory sorting will use the
 * natural ordering of elements if they are mutually comparable and
 * otherwise fall back to comparing the string representations of the
 * values.
 *
 * @param valueProvider
 *            the value provider
 *
 * @return the new column
 */
public <V> Column<T, V> addColumn(ValueProvider<T, V> valueProvider) {
  return addColumn(valueProvider, new TextRenderer());
}

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

/**
 * Adds a new column with the given property name. The column will use a
 * {@link TextRenderer}. The value is converted to a String using
 * {@link Object#toString()}. The property name will be used as the
 * {@link Column#getId() column id} and the {@link Column#getCaption()
 * column caption} will be set based on the property definition.
 * <p>
 * This method can only be used for a <code>Grid</code> created using
 * {@link Grid#Grid(Class)} or {@link #withPropertySet(PropertySet)}.
 * <p>
 * You can add columns for nested properties with dot notation, eg.
 * <code>"property.nestedProperty"</code>
 *
 * @param propertyName
 *            the property name of the new column, not <code>null</code>
 * @return the newly added column, not <code>null</code>
 */
public Column<T, ?> addColumn(String propertyName) {
  return addColumn(propertyName, new TextRenderer());
}

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

/**
 * Adds a column that shows components.
 * <p>
 * This is a shorthand for {@link #addColum()} with a
 * {@link ComponentRenderer}.
 *
 * @param componentProvider
 *            a value provider that will return a component for the given
 *            item
 * @return the new column
 * @param <V>
 *            the column value type, extends component
 * @since 8.1
 */
public <V extends Component> Column<T, V> addComponentColumn(
    ValueProvider<T, V> componentProvider) {
  return addColumn(componentProvider, new ComponentRenderer());
}

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

/**
 * Adds a new column to this {@link Grid} with typed renderer and value
 * provider.
 *
 * @param valueProvider
 *            the value provider
 * @param renderer
 *            the column value renderer
 * @param <V>
 *            the column value type
 *
 * @return the new column
 *
 * @see AbstractRenderer
 */
public <V> Column<T, V> addColumn(ValueProvider<T, V> valueProvider,
    AbstractRenderer<? super T, ? super V> renderer) {
  return addColumn(valueProvider, ValueProvider.identity(), renderer);
}

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

/**
 * Adds a new column to this {@link Grid} with value provider and
 * presentation provider.
 * <p>
 * <strong>Note:</strong> The presentation type for this method is set to be
 * String. To use any custom renderer with the presentation provider, use
 * {@link #addColumn(ValueProvider, ValueProvider, AbstractRenderer)}.
 *
 * @param valueProvider
 *            the value provider
 * @param presentationProvider
 *            the value presentation provider
 * @param <V>
 *            the column value type
 *
 * @see #addColumn(ValueProvider, ValueProvider, AbstractRenderer)
 *
 * @return the new column
 * @since 8.1
 */
public <V> Column<T, V> addColumn(ValueProvider<T, V> valueProvider,
    ValueProvider<V, String> presentationProvider) {
  return addColumn(valueProvider, presentationProvider,
      new TextRenderer());
}

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

/**
 * Sets the columns and their order based on their column ids. Columns
 * currently in this grid that are not present in the list of column ids are
 * removed. This includes any column that has no id. Similarly, any new
 * column in columns will be added to this grid. New columns can only be
 * added for a <code>Grid</code> created using {@link Grid#Grid(Class)} or
 * {@link #withPropertySet(PropertySet)}.
 *
 *
 * @param columnIds
 *            the column ids to set
 *
 * @see Column#setId(String)
 */
public void setColumns(String... columnIds) {
  // Must extract to an explicitly typed variable because otherwise javac
  // cannot determine which overload of setColumnOrder to use
  Column<T, ?>[] newColumnOrder = Stream.of(columnIds)
      .map((Function<String, Column<T, ?>>) id -> {
        Column<T, ?> column = getColumn(id);
        if (column == null) {
          column = addColumn(id);
        }
        return column;
      }).toArray(Column[]::new);
  setColumnOrder(newColumnOrder);
  // The columns to remove are now at the end of the column list
  getColumns().stream().skip(columnIds.length)
      .forEach(this::removeColumn);
}

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

Column<T, V> column = createColumn(valueProvider, presentationProvider,
    renderer);
addColumn(generatedIdentifier, column);
return column;

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

Column<T, ?> column = addColumn(definition.getGetter(),
    (AbstractRenderer) renderer).setId(definition.getName())
        .setCaption(definition.getCaption());

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

Column<T, ?> column;
if (property.isPresent()) {
  column = addColumn(id);
} else {
  DeclarativeValueProvider<T> provider = new DeclarativeValueProvider<>();
  column = createColumn(provider, ValueProvider.identity(),
      new HtmlRenderer());
  addColumn(getGeneratedIdentifier(), column);
  if (id != null) {
    column.setId(id);

代码示例来源:origin: jpos/jPOS-EE

@Override
public void setGridGetters() {
  Grid<Role> g = this.getGrid();
  g.addColumn(Role::getId).setId("id");
  g.addColumn(Role::getName).setId("name");
  g.addColumn(Role::getPermissions).setId("permissions");
}

代码示例来源:origin: jpos/jPOS-EE

@Override
public void setGridGetters() {
  Grid<User> g = getGrid();
  g.addColumn(User::getId).setId("id");
  g.addColumn(User::getName).setId("name");
  g.addColumn(User::getNick).setId("nick");
  g.addColumn(User::getEmail).setId("email");
  g.addColumn(User::isActive).setId("active");
  g.addColumn(User::isDeleted).setId("deleted");
  g.addColumn(User::isVerified).setId("verified");
  g.addColumn(User::getStartDate).setId("startDate");
  g.addColumn(User::getEndDate).setId("endDate");
  g.addColumn(User::isForcePasswordChange).setId("forcePasswordChange");
  g.addColumn(User::getLastLogin).setId("lastLogin");
  g.addColumn(User::getPasswordChanged).setId("passwordChanged");
  g.addColumn(User::getLoginAttempts).setId("loginAttempts");
}

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

/**
 * Add a <em>virtual</em> column to the listing, i.e. a column which is not directly bound to a bean property.
 * @param <V> Column value type
 * @param id Column id (not null)
 * @param type Column value type (not null)
 * @param valueProvider Column value provider (not null)
 */
public <V> void addVirtualColumn(String id, Class<V> type, ValueProvider<T, V> valueProvider) {
  getGrid().addColumn(propertySet.addVirtualProperty(type, valueProvider, id));
}

代码示例来源:origin: jpos/jPOS-EE

@Override
public void setGridGetters() {
  Grid<GLTransaction> grid = getGrid();
  grid.addColumn(GLTransaction::getId).setId("id");
  grid.addColumn(GLTransaction::getDetail).setId("detail");
  grid.addColumn(glTransaction -> glTransaction.getJournal().getName()).setId("journal");
  grid.addColumn(glTransaction -> postDateFormat.format(glTransaction.getPostDate())).setId("postDate");
  grid.addColumn(glTransaction -> glTransaction.getTags() != null ? glTransaction.getTags().toString() : "").setId("tags");
  grid.addColumn(GLTransaction::getTimestamp).setId("timestamp");
}

代码示例来源:origin: jpos/jPOS-EE

@Override
public void setGridGetters() {
  Grid<Consumer> g = getGrid();
  g.addColumn(Consumer::getId).setId("id");
  g.addColumn(consumer -> consumer.getRolesAsString()).setId("roles");
  g.addColumn(Consumer::getStartDate).setId("startDate");
  g.addColumn(Consumer::getEndDate).setId("endDate");
  g.addColumn(consumer -> consumer.getUser().getNickAndId()).setId("user");
  g.addColumn(Consumer::isActive).setId("active");
  g.addColumn(Consumer::isDeleted).setId("deleted");
  //select first item on user combobox
  userComboBox.setValue(userComboBox.getDataProvider().fetch(new Query<>()).findFirst().orElse(null));
}

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin

/**
 * Adds a column definition which uses given {@link VirtualProperty} value provider to provide the column contents.
 * @param <T> Property type
 * @param property Column property
 * @return if the property was not already present in listing property set and it was added to the set, return the
 *         column name, <code>null</code> otherwise
 */
public <T> String addColumn(VirtualProperty<T> property) {
  String name = propertySet.addVirtualProperty(property);
  if (name != null) {
    getGrid().addColumn(name);
  }
  return name;
}

代码示例来源:origin: AxonIQ/giftcard-demo

private Grid summaryGrid() {
  cardSummaryDataProvider = new CardSummaryDataProvider(queryGateway);
  Grid<CardSummary> grid = new Grid<>();
  grid.addColumn(CardSummary::getId).setCaption("Card ID");
  grid.addColumn(CardSummary::getInitialValue).setCaption("Initial value");
  grid.addColumn(CardSummary::getRemainingValue).setCaption("Remaining value");
  grid.setSizeFull();
  grid.setDataProvider(cardSummaryDataProvider);
  return grid;
}

代码示例来源:origin: jpos/jPOS-EE

@Override
public void setGridGetters() {
  Grid<SysConfig> g = this.getGrid();
  g.addColumn(sysconfig -> removePrefix(sysconfig.getId())).setId("id");
  g.addColumn(SysConfig::getValue).setId("value");
}

代码示例来源:origin: kingbbode/spring-boot-ehcache-monitor

private Grid<Cache> createCacheInfoGrid() {
  Grid<Cache> grid = new Grid<>();
  grid.addColumn(Cache::getName).setCaption("Name");
  grid.addColumn(cache -> ((Double) (((double) cache.getStatistics().cacheHitCount()) / ((double) (cache.getStatistics().cacheMissCount() + cache.getStatistics().cacheHitCount())) * 100)).intValue() + "%").setCaption("Hit Ratio");
  grid.addColumn(cache -> cache.getCacheConfiguration().getMaxEntriesLocalHeap()).setCaption("Max Size");
  grid.addColumn(Cache::getSize).setCaption("Size");
  grid.addColumn(Cache::getStatus).setCaption("Status");
  grid.addColumn(cache -> cache.getCacheConfiguration().getTimeToIdleSeconds()).setCaption("TTldle(s)");
  grid.addColumn(cache -> cache.getCacheConfiguration().getTimeToLiveSeconds()).setCaption("TTLive(s)");
  grid.addColumn(cache -> cache.getStatistics().cacheHitCount()).setCaption("hit");
  grid.addColumn(cache -> cache.getStatistics().cacheMissExpiredCount()).setCaption("miss : Expire");
  grid.addColumn(cache -> cache.getStatistics().cacheMissNotFoundCount()).setCaption("miss : Not Found");
  grid.setItems(Collections.singletonList(this.ehcache));
  grid.setWidth("100%");
  grid.setSelectionMode(Grid.SelectionMode.NONE);
  grid.setHeightByRows(1);
  return grid;
}

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

@Override
public void setVisible(boolean visible) {
  if (this.visible != visible) {
    this.visible = visible;
    Grid<E> grid = owner.getComponent();
    if (visible) {
      Grid.Column<E, ?> gridColumn =
          grid.addColumn(new EntityValueProvider<>(getPropertyPath()));
      owner.setupGridColumnProperties(gridColumn, this);
      grid.setColumnOrder(owner.getColumnOrder());
    } else {
      grid.removeColumn(getId());
      setGridColumn(null);
    }
  }
}

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

protected void addColumnInternal(ColumnImpl<E> column, int index) {
  Grid.Column<E, ?> gridColumn = component.addColumn(
      new EntityValueProvider<>(column.getPropertyPath()));
  columns.put(column.getId(), column);
  columnsOrder.add(index, column);
  final String caption = StringUtils.capitalize(column.getCaption() != null
      ? column.getCaption()
      : generateColumnCaption(column));
  column.setCaption(caption);
  if (column.getOwner() == null) {
    column.setOwner(this);
  }
  MetaPropertyPath propertyPath = column.getPropertyPath();
  if (propertyPath != null) {
    MetaProperty metaProperty = propertyPath.getMetaProperty();
    MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(propertyPath);
    String storeName = metadataTools.getStoreName(propertyMetaClass);
    if (metadataTools.isLob(metaProperty)
        && !persistenceManagerClient.supportsLobSortingAndFiltering(storeName)) {
      column.setSortable(false);
    }
  }
  setupGridColumnProperties(gridColumn, column);
  component.setColumnOrder(getColumnOrder());
}

相关文章

Grid类方法