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

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

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

Grid.addSelectionListener介绍

[英]Adds a selection listener to the current selection model.

NOTE: If selection mode is switched with #setSelectionMode(SelectionMode), then this listener is not triggered anymore when selection changes!

This is a shorthand for grid.getSelectionModel().addSelectionListener(). To get more detailed selection events, use #getSelectionModel() and either SingleSelectionModel#addSingleSelectionListener(SingleSelectionListener)or MultiSelectionModel#addMultiSelectionListener(MultiSelectionListener)depending on the used selection mode.
[中]将选择侦听器添加到当前选择模型。
*注意:*如果使用#setSelectionMode(SelectionMode)切换选择模式,则当选择更改时,不再触发此侦听器!
这是网格的简写。getSelectionModel()。addSelectionListener()。要获取更详细的选择事件,请使用#getSelectionModel()和SingleSelectionModel#addSingleSelectionListener(SingleSelectionListener)或MultiSelectionModel#addMultiSelectionListener(MultiSelectionListener),具体取决于使用的选择模式。

代码示例

代码示例来源:origin: vaadin/material-theme-fw8

public void enableSelectionListener() {
  registration = this.grid.addSelectionListener(selectionListener);
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

/**
 * Registers the selection of this grid as master for another grid that
 * displays the details.
 *
 * @param details
 *            the details of another grid the selection of this grid should
 *            be registered for as master.
 */
public void registerDetails(final AbstractGrid<?>.DetailsSupport details) {
  grid.addSelectionListener(event -> {
    final Long masterId = (Long) event.getSelected().stream().findFirst().orElse(null);
    details.populateMasterDataAndRecalculateContainer(masterId);
  });
}

代码示例来源:origin: eclipse/hawkbit

/**
 * Registers the selection of this grid as master for another grid that
 * displays the details.
 *
 * @param details
 *            the details of another grid the selection of this grid should
 *            be registered for as master.
 */
public void registerDetails(final AbstractGrid<?>.DetailsSupport details) {
  grid.addSelectionListener(event -> {
    final Long masterId = (Long) event.getSelected().stream().findFirst().orElse(null);
    details.populateMasterDataAndRecalculateContainer(masterId);
  });
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

/**
 * Override default registration for selection propagation in order to
 * interrupt update cascade in minimized state to prevent updates on
 * invisible action-status-grid and message-grid.
 * <p>
 * The master selection is stored and propagation is performed as soon as
 * the state changes to maximize and hence the dependent grids are updated.
 */
@Override
public void registerDetails(final AbstractGrid<?>.DetailsSupport details) {
  this.details = details;
  getGrid().addSelectionListener(event -> {
    masterForDetails = (Long) event.getSelected().stream().findFirst().orElse(null);
    if (managementUIState.isActionHistoryMaximized()) {
      details.populateMasterDataAndRecalculateContainer(masterForDetails);
    }
  });
}

代码示例来源:origin: eclipse/hawkbit

/**
 * Override default registration for selection propagation in order to
 * interrupt update cascade in minimized state to prevent updates on
 * invisible action-status-grid and message-grid.
 * <p>
 * The master selection is stored and propagation is performed as soon as
 * the state changes to maximize and hence the dependent grids are updated.
 */
@Override
public void registerDetails(final AbstractGrid<?>.DetailsSupport details) {
  this.details = details;
  getGrid().addSelectionListener(event -> {
    masterForDetails = (Long) event.getSelected().stream().findFirst().orElse(null);
    if (managementUIState.isActionHistoryMaximized()) {
      details.populateMasterDataAndRecalculateContainer(masterForDetails);
    }
  });
}

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

@Override
public Registration addSelectionListener(
    final com.holonplatform.vaadin.components.Selectable.SelectionListener<T> selectionListener) {
  ObjectUtils.argumentNotNull(selectionListener, "SelectionListener must be not null");
  return getGrid().addSelectionListener(e -> selectionListener.onSelectionChange(buildSelectionEvent(e)));
}

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

case MULTI:
  grid.setSelectionMode(Grid.SelectionMode.MULTI);
  grid.addSelectionListener(this);
  break;
case SINGLE:
  grid.setSelectionMode(Grid.SelectionMode.SINGLE);
  grid.addSelectionListener(this);
  break;
case NONE:

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

grid.setSizeFull();
grid.setSelectionMode(definition.isMultiSelect() ? Grid.SelectionMode.MULTI : Grid.SelectionMode.SINGLE);
grid.addSelectionListener(event -> valueContext.current().set(SelectedItems.of(event.getAllSelectedItems())));
grid.addItemClickListener(event -> {
  grid.deselectAll();

代码示例来源:origin: jreznot/electron-java-app

tasksGrid.addSelectionListener(event -> {
  boolean enableRemove = !event.getAllSelectedItems().isEmpty();
  removeButton.setEnabled(enableRemove);

代码示例来源:origin: eclipse/hawkbit

protected Grid createMetadataGrid() {
  final Grid metadataGrid = new Grid();
  metadataGrid.addStyleName(SPUIStyleDefinitions.METADATA_GRID);
  metadataGrid.setImmediate(true);
  metadataGrid.setHeight("100%");
  metadataGrid.setWidth("100%");
  metadataGrid.setId(UIComponentIdProvider.METDATA_TABLE_ID);
  metadataGrid.setSelectionMode(SelectionMode.SINGLE);
  metadataGrid.setColumnReorderingAllowed(true);
  metadataGrid.setContainerDataSource(getMetadataContainer());
  metadataGrid.getColumn(KEY).setHeaderCaption(i18n.getMessage("header.key"));
  metadataGrid.getColumn(VALUE).setHeaderCaption(i18n.getMessage("header.value"));
  metadataGrid.getColumn(VALUE).setHidden(true);
  metadataGrid.addSelectionListener(this::onRowClick);
  metadataGrid.getColumn(DELETE_BUTTON).setHeaderCaption("");
  metadataGrid.getColumn(DELETE_BUTTON).setRenderer(new HtmlButtonRenderer(this::onDelete));
  metadataGrid.getColumn(DELETE_BUTTON).setWidth(50);
  metadataGrid.getColumn(KEY).setExpandRatio(1);
  return metadataGrid;
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

protected Grid createMetadataGrid() {
  final Grid metadataGrid = new Grid();
  metadataGrid.addStyleName(SPUIStyleDefinitions.METADATA_GRID);
  metadataGrid.setImmediate(true);
  metadataGrid.setHeight("100%");
  metadataGrid.setWidth("100%");
  metadataGrid.setId(UIComponentIdProvider.METDATA_TABLE_ID);
  metadataGrid.setSelectionMode(SelectionMode.SINGLE);
  metadataGrid.setColumnReorderingAllowed(true);
  metadataGrid.setContainerDataSource(getMetadataContainer());
  metadataGrid.getColumn(KEY).setHeaderCaption(i18n.getMessage("header.key"));
  metadataGrid.getColumn(VALUE).setHeaderCaption(i18n.getMessage("header.value"));
  metadataGrid.getColumn(VALUE).setHidden(true);
  metadataGrid.addSelectionListener(this::onRowClick);
  metadataGrid.getColumn(DELETE_BUTTON).setHeaderCaption("");
  metadataGrid.getColumn(DELETE_BUTTON).setRenderer(new HtmlButtonRenderer(this::onDelete));
  metadataGrid.getColumn(DELETE_BUTTON).setWidth(50);
  metadataGrid.getColumn(KEY).setExpandRatio(1);
  return metadataGrid;
}

相关文章

Grid类方法