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

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

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

Grid.getColumns介绍

[英]Gets an unmodifiable collection of all columns currently in this Grid.
[中]获取此网格中当前所有列的不可修改的集合。

代码示例

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

@Override
  protected void internalSetDataProvider(DataProvider<T, ?> dataProvider) {
    super.internalSetDataProvider(dataProvider);
    for (Column<T, ?> column : getColumns()) {
      column.updateSortable();
    }
  }
}

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

/**
 * Removes all columns from this Grid.
 *
 * @since 8.0.2
 */
public void removeAllColumns() {
  for (Column<T, ?> column : getColumns()) {
    removeColumn(column);
  }
}

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

/**
 * Adds a cell to this section for given column.
 *
 * @param column
 *            the column for which to add a cell
 */
protected void addCell(Column<?, ?> column) {
  if (!section.getGrid().getColumns().contains(column)) {
    throw new IllegalArgumentException(
        "Given column does not exist in this Grid");
  }
  internalAddCell(section.getInternalIdForColumn(column));
}

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

/**
 * Adds a new row at the given index.
 *
 * @param index
 *            the index of the new row
 * @return the added row
 * @throws IndexOutOfBoundsException
 *             if {@code index < 0 || index > getRowCount()}
 */
public ROW addRowAt(int index) {
  ROW row = createRow();
  rows.add(index, row);
  getState(true).rows.add(index, row.getRowState());
  getGrid().getColumns().stream().forEach(row::addCell);
  return row;
}

代码示例来源: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

private void writeRow(Element container, T item, DesignContext context) {
  Element tableRow = container.appendElement("tr");
  tableRow.attr("item", serializeDeclarativeRepresentation(item));
  if (getSelectionModel().isSelected(item)) {
    tableRow.attr("selected", true);
  }
  for (Column<T, ?> column : getColumns()) {
    Object value = column.valueProvider.apply(item);
    tableRow.appendElement("td")
        .append(Optional.ofNullable(value).map(Object::toString)
            .map(DesignFormatter::encodeForTextNode)
            .orElse(""));
  }
}

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

private void addColumn(String identifier, Column<T, ?> column) {
  if (getColumns().contains(column)) {
    return;
  }
  column.extend(this);
  columnSet.add(column);
  columnKeys.put(identifier, column);
  column.setInternalId(identifier);
  addDataGenerator(column.getDataGenerator());
  getState().columnOrder.add(identifier);
  getHeader().addColumn(identifier);
  getFooter().addColumn(identifier);
  if (getDefaultHeaderRow() != null) {
    getDefaultHeaderRow().getCell(column).setText(column.getCaption());
  }
  column.updateSortable();
}

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

getParent().getColumns().stream().filter(Column::isEditable)
    .forEach(c -> {
      Binding<T, ?> binding = c.getEditorBinding();

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

private void writeStructure(Element design, DesignContext designContext) {
  if (getColumns().isEmpty()) {
    return;
  }
  Element tableElement = design.appendElement("table");
  Element colGroup = tableElement.appendElement("colgroup");
  getColumns().forEach(column -> column
      .writeDesign(colGroup.appendElement("col"), designContext));
  // Always write thead. Reads correctly when there no header rows
  getHeader().writeDesign(tableElement.appendElement("thead"),
      designContext);
  if (designContext.shouldWriteData(this)) {
    Element bodyElement = tableElement.appendElement("tbody");
    writeData(bodyElement, designContext);
  }
  if (getFooter().getRowCount() > 0) {
    getFooter().writeDesign(tableElement.appendElement("tfoot"),
        designContext);
  }
}

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

for (Column<T, ?> c : getColumns()) {
  HeaderCell headerCell = getDefaultHeaderRow().getCell(c);
  if (headerCell.getCellType() == GridStaticCellType.TEXT) {

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

protected List<Column<E>> getColumnsOrderInternal() {
  List<Grid.Column<E, ?>> columnsOrder = component.getColumns();
  return columnsOrder.stream()
      .map(this::getColumnByGridColumn)
      .collect(Collectors.toList());
}

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

@Override
public List<P> getPropertyColumns() {
  List<Column<T, ?>> columns = getGrid().getColumns();
  if (columns != null && !columns.isEmpty()) {
    List<P> properties = new ArrayList<>(columns.size());
    for (Column<T, ?> column : columns) {
      properties.add(getColumnProperty(column.getId()));
    }
    return properties;
  }
  return Collections.emptyList();
}

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

setId("column" + getGrid().getColumns().indexOf(this));

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

@Override
@SuppressWarnings("unchecked")
protected void doEdit(T bean) {
  if (!itemInteractionAvailability.test(bean)) {
    cancel();
    return;
  }
  // resolve all the columns that are editable in context of current item
  final List<String> activeColumns = grid.getColumns().stream()
      .filter(Column::isEditable)
      .filter(column -> cellEditingAvailability.test(column, bean))
      .map(Column::getId)
      .collect(toList());
  // collect all the related bindings
  final List<Binder.Binding> binding = activeColumns.stream()
      .map(grid::getColumn)
      .map(Column::getId)
      .map(id -> grid.getColumn(id).getEditorBinding())
      .collect(toList());
  // set the bindings to the binder
  getBinder().setBindings((List) binding);
  super.doEdit(bean);
  // remove all the currently non-editable cell components from the editor state
  retainOnlyActiveCellComponents(activeColumns);
}

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

switch (getRenderingMode()) {
case GRID: {
  List<Column> columns = getGrid().getColumns();
  if (columns != null && !columns.isEmpty()) {
    List<P> properties = new ArrayList<>(columns.size());

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

@Override
protected void doEdit(T bean) {
  Objects.requireNonNull(bean, "Editor can't edit null");
  if (!isEnabled()) {
    throw new IllegalStateException(
        "Editing is not allowed when Editor is disabled.");
  }
  edited = bean;
  getParent().getColumns().stream().filter(Grid.Column::isEditable)
      .forEach(c -> {
        CubaEditorField<?> editorField = getEnhancedGrid().getColumnEditorField(bean, c);
        configureField(editorField);
        addComponentToGrid(editorField);
        columnFields.put(c, editorField);
        getState().columnFields.put(getInternalIdForColumn(c), editorField.getConnectorId());
      });
  eventRouter.fireEvent(new CubaEditorOpenEvent<>(this, edited, Collections.unmodifiableMap(columnFields)));
}

代码示例来源:origin: KrailOrg/krail

/**
 * Sets the I18N values for the Grid itself, and also iterates the columns for column ids which are I18NKeys, and translates those as well
 *
 * @param grid             the Grid to process
 * @param annotationValues the annotation values to apply
 * @param annotationInfo   used primarily to identify the Field, and therefore its name
 */
protected void processGrid(Grid grid, AnnotationValues annotationValues, AnnotationInfo annotationInfo) {
  // do the grid itself
  applyAnnotationValues(grid, annotationValues, annotationInfo);
  // now do the column headers
  Locale locale = annotationValues.locale.isPresent() ? annotationValues.locale.get() : currentLocale.getLocale();
  final List<Grid.Column> columns = grid.getColumns();
  I18NKeyConverter converter = new I18NKeyConverter();
  for (Grid.Column column : columns) {
    try {
      I18NKey columnKey = converter.convertToModel(column.getId());
      String header = translate.from(columnKey, locale);
      column.setCaption(header);
    } catch (Exception e) {
      log.debug("Column id {} is not an I18NKey", column.getId());
    }
  }
}

代码示例来源:origin: uk.q3c.krail/krail

/**
 * Sets the I18N values for the Grid itself, and also iterates the columns for column ids which are I18NKeys, and translates those as well
 *
 * @param grid
 *         the Grid to process
 * @param annotationValues
 *         the annotation values to apply
 * @param annotationInfo
 *         used primarily to identify the Field, and therefore its name
 */
protected void processGrid(Grid grid, AnnotationValues annotationValues, AnnotationInfo annotationInfo) {
  // do the grid itself
  applyAnnotationValues(grid, annotationValues, annotationInfo);
  // now do the column headers
  Locale locale = annotationValues.locale.isPresent() ? annotationValues.locale.get() : currentLocale.getLocale();
  final List<Grid.Column> columns = grid.getColumns();
  for (Grid.Column column : columns) {
    if (column.getPropertyId() instanceof I18NKey) {
      I18NKey columnKey = (I18NKey) column.getPropertyId();
      String header = translate.from(columnKey, locale);
      column.setHeaderCaption(header);
    } else {
      column.setHeaderCaption(column.getPropertyId()
                     .toString());
    }
  }
}

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

grid.getColumns().stream()
    .map(Grid.Column::getEditorBinding).filter(Objects::nonNull).findFirst()
    .ifPresent(any -> {

相关文章

Grid类方法