本文整理了Java中com.vaadin.ui.Grid.getSelectionModel()
方法的一些代码示例,展示了Grid.getSelectionModel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Grid.getSelectionModel()
方法的具体详情如下:
包路径:com.vaadin.ui.Grid
类名称:Grid
方法名:getSelectionModel
[英]Returns the selection model for this grid.
[中]返回此网格的选择模型。
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Constructs a MultiSelect wrapper for given Grid.
*
* @param grid
* the grid to wrap
*/
public GridMultiSelect(Grid<T> grid) {
GridSelectionModel<T> selectionModel = grid.getSelectionModel();
if (!(selectionModel instanceof MultiSelectionModel)) {
throw new IllegalStateException(
"Grid is not in multiselect mode, it needs to be explicitly set to such with setSelectionModel(MultiSelectionModel) before being able to use multiselection features.");
}
model = (MultiSelectionModel<T>) selectionModel;
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Constructs a SingleSelect wrapper for given Grid.
*
* @param grid
* the grid to wrap
*/
public GridSingleSelect(Grid<T> grid) {
GridSelectionModel<T> selectionModel = grid.getSelectionModel();
if (!(selectionModel instanceof SingleSelectionModel)) {
throw new IllegalStateException(
"Grid is not in single select mode, it needs to be explicitly set to such with setSelectionModel(SingleSelectionModel) before being able to use single selection features.");
}
model = (SingleSelectionModel<T>) selectionModel;
}
代码示例来源:origin: com.vaadin/vaadin-server
private SelectionMode getSelectionMode() {
GridSelectionModel<T> selectionModel = getSelectionModel();
SelectionMode mode = null;
if (selectionModel.getClass().equals(SingleSelectionModelImpl.class)) {
mode = SelectionMode.SINGLE;
} else if (selectionModel.getClass()
.equals(MultiSelectionModelImpl.class)) {
mode = SelectionMode.MULTI;
} else if (selectionModel.getClass().equals(NoSelectionModel.class)) {
mode = SelectionMode.NONE;
}
return mode;
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* This method is a shorthand that delegates to the currently set selection
* model.
*
* @see #getSelectionModel()
* @see GridSelectionModel
*/
public void deselect(T item) {
getSelectionModel().deselect(item);
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* This method is a shorthand that delegates to the currently set selection
* model.
*
* @see #getSelectionModel()
* @see GridSelectionModel
*/
public void deselectAll() {
getSelectionModel().deselectAll();
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* This method is a shorthand that delegates to the currently set selection
* model.
*
* @see #getSelectionModel()
* @see GridSelectionModel
*/
public Set<T> getSelectedItems() {
return getSelectionModel().getSelectedItems();
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* This method is a shorthand that delegates to the currently set selection
* model.
*
* @see #getSelectionModel()
* @see GridSelectionModel
*/
public void select(T item) {
getSelectionModel().select(item);
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Adds a selection listener to the current selection model.
* <p>
* <em>NOTE:</em> If selection mode is switched with
* {@link #setSelectionMode(SelectionMode)}, then this listener is not
* triggered anymore when selection changes!
* <p>
* This is a shorthand for
* {@code grid.getSelectionModel().addSelectionListener()}. To get more
* detailed selection events, use {@link #getSelectionModel()} and either
* {@link SingleSelectionModel#addSingleSelectionListener(SingleSelectionListener)}
* or
* {@link MultiSelectionModel#addMultiSelectionListener(MultiSelectionListener)}
* depending on the used selection mode.
*
* @param listener
* the listener to add
* @return a registration handle to remove the listener
* @throws UnsupportedOperationException
* if selection has been disabled with
* {@link SelectionMode#NONE}
*/
public Registration addSelectionListener(SelectionListener<T> listener)
throws UnsupportedOperationException {
return getSelectionModel().addSelectionListener(listener);
}
代码示例来源: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
getSelectionModel().deselectAll();
List<T> items = new ArrayList<>();
List<T> selectedItems = new ArrayList<>();
selectedItems.forEach(getSelectionModel()::select);
代码示例来源:origin: com.haulmont.cuba/cuba-web
@Nullable
@Override
public E getSingleSelected() {
return component.getSelectionModel()
.getFirstSelectedItem()
.orElse(null);
}
代码示例来源:origin: com.haulmont.cuba/cuba-web
@SuppressWarnings("unchecked")
protected void setSelectedItems(Collection<E> items) {
switch (selectionMode) {
case SINGLE:
if (items.size() > 0) {
E item = items.iterator().next();
component.getSelectionModel().select(item);
} else {
component.deselectAll();
}
break;
case MULTI:
case MULTI_CHECK:
component.deselectAll();
((SelectionModel.Multi) component.getSelectionModel()).selectItems(items.toArray());
break;
default:
throw new UnsupportedOperationException("Unsupported selection mode");
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-web
@Override
public void selectAll() {
if (isMultiSelect()) {
((SelectionModel.Multi) component.getSelectionModel()).selectAll();
}
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
public void selectAll() {
if (selectionMode == SelectionMode.MULTI) {
((Multi<?>) getGrid().getSelectionModel()).selectAll();
}
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
public Optional<T> getFirstSelectedItem() {
if (getSelectionMode() == SelectionMode.NONE) {
return Optional.empty();
}
return getGrid().getSelectionModel().getFirstSelectedItem();
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
public boolean isDeselectAllowed() {
if (getSelectionMode() == SelectionMode.SINGLE) {
((Single<?>) getGrid().getSelectionModel()).isDeselectAllowed();
}
return true;
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-admincentral
public MultiSelectionModel getMultiSelectionModel() {
if (getGrid().getSelectionModel() instanceof MultiSelectionModel) {
return ((MultiSelectionModel) getGrid().getSelectionModel());
}
throw new IllegalStateException("Not a MultiSelectionModel. Was selecting all items enabled?");
}
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
public void setDeselectAllowed(boolean deselectAllowed) {
if (getSelectionMode() == SelectionMode.SINGLE) {
((Single<?>) getGrid().getSelectionModel()).setDeselectAllowed(deselectAllowed);
}
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
/**
* Set the {@link SelectAllCheckBoxVisibility} mode when listing is in multiple selection mode.
* @param selectAllCheckBoxVisibility the mode to set
*/
public void setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility selectAllCheckBoxVisibility) {
ObjectUtils.argumentNotNull(selectAllCheckBoxVisibility, "SelectAllCheckBoxVisibility must be not null");
this.selectAllCheckBoxVisibility = selectAllCheckBoxVisibility;
if (SelectionMode.MULTI == getSelectionMode()) {
((MultiSelectionModel<T>) getGrid().getSelectionModel())
.setSelectAllCheckBoxVisibility(selectAllCheckBoxVisibility);
}
}
代码示例来源:origin: eclipse/hawkbit
private void setUpDetails(final Long swId, final String metaDatakey) {
resetDetails();
metadataWindow.clearOriginalValues();
if (swId != null) {
metaDataGrid.getContainerDataSource().removeAllItems();
populateGrid();
metaDataGrid.getSelectionModel().reset();
if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) {
if (metaDatakey == null) {
metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
} else {
metaDataGrid.select(metaDatakey);
}
} else if (hasCreatePermission()) {
enableEditing();
addIcon.setEnabled(false);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!