本文整理匯總了Java中com.vaadin.ui.Grid.setSelectionMode方法的典型用法代碼示例。如果您正苦於以下問題:Java Grid.setSelectionMode方法的具體用法?Java Grid.setSelectionMode怎麽用?Java Grid.setSelectionMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.ui.Grid
的用法示例。
在下文中一共展示了Grid.setSelectionMode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMetadataGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
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;
}
示例2: ReleasesView
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
public ReleasesView() {
setSizeFull();
setMargin(false);
ButtonBar buttonBar = new ButtonBar();
addButton = buttonBar.addButton("Add", FontAwesome.PLUS, e -> add());
editButton = buttonBar.addButton("Edit", FontAwesome.EDIT, e -> edit());
exportButton = buttonBar.addButton("Export", FontAwesome.DOWNLOAD, e -> export());
archiveButton = buttonBar.addButton("Archive", FontAwesome.ARCHIVE, e -> archive());
// TODO add support for the archive button
archiveButton.setVisible(false);
finalizeButton = buttonBar.addButton("Finalize", FontAwesome.CUBE, e -> finalize());
addComponent(buttonBar);
enableDisableButtonsForSelectionSize(0);
grid = new Grid();
grid.setSizeFull();
grid.setSelectionMode(SelectionMode.MULTI);
grid.addItemClickListener(e->rowClicked(e));
grid.addSelectionListener((e) -> rowSelected(e));
container = new BeanItemContainer<>(ReleasePackage.class);
grid.setContainerDataSource(container);
grid.setColumns("name", "versionLabel", "releaseDate", "released");
grid.sort("releaseDate", SortDirection.DESCENDING);
addComponent(grid);
setExpandRatio(grid, 1);
progressBar = new ProgressBar(0.0f);
}
示例3: createGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Grid createGrid() {
Grid<Dessert> grid = new Grid<>();
grid.setItems(desserts);
grid.setSelectionMode(Grid.SelectionMode.MULTI);
grid.setWidth(100, Unit.PERCENTAGE);
grid.addColumn(Dessert::getName).setCaption("Dessert (100g serving");
grid.addColumn(Dessert::getCalories).setCaption("Calories");
grid.addColumn(Dessert::getFat).setCaption("Fat (g)");
grid.addColumn(Dessert::getCarbs).setCaption("Carbs (g)");
grid.addColumn(Dessert::getProtein).setCaption("Protein (g)");
grid.addColumn(Dessert::getSodium).setCaption("Sodium (mg)");
grid.addColumn(Dessert::getCalcium).setCaption("Calcium (%)");
grid.addColumn(Dessert::getIron).setCaption("Iron (%)");
grid.setHeight(Metrics.Table.COLUMN_HEADER_HEIGHT + desserts.size() * Metrics.Table.ROW_HEIGHT, Unit.PIXELS);
return grid;
}
示例4: buildGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
protected void buildGrid() {
grid = new Grid();
grid.setSelectionMode(SelectionMode.NONE);
grid.setSizeFull();
grid.setEditorEnabled(!readOnly);
container = new BeanItemContainer<Record>(Record.class);
grid.setContainerDataSource(container);
grid.setColumnOrder("entityName", "attributeName", "excelMapping");
HeaderRow filterRow = grid.appendHeaderRow();
addColumn("entityName", filterRow);
addColumn("attributeName", filterRow);
TextField tfExcelMapping = new TextField();
tfExcelMapping.addBlurListener(e->saveExcelMappingSettings());
tfExcelMapping.setWidth(100, Unit.PERCENTAGE);
tfExcelMapping.setImmediate(true);
grid.getColumn("excelMapping").setEditorField(tfExcelMapping).setExpandRatio(1);
addShowPopulatedFilter("excelMapping", filterRow);
grid.setEditorBuffered(false);
addComponent(grid);
setExpandRatio(grid, 1);
}
示例5: initGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
/**
* Grid initialization
* @param grid Grid to initialize
*/
protected void initGrid(Grid grid) {
// reset selection model
grid.setSelectionMode(com.vaadin.ui.Grid.SelectionMode.NONE);
grid.setRowStyleGenerator(this);
grid.setCellStyleGenerator(this);
// editor FieldGroup
grid.setEditorFieldGroup(new PropertyGridFieldGroup());
}
示例6: initGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
/**
* Init internal Grid.
* @param grid Grid
*/
protected void initGrid(Grid<T> grid) {
this.grid = grid;
grid.setWidth(100, Unit.PERCENTAGE);
// reset selection model
grid.setSelectionMode(com.vaadin.ui.Grid.SelectionMode.NONE);
// row style generator
grid.setStyleGenerator(i -> generateRowStyle(i));
Editor<T> editor = grid.getEditor();
if (editor != null) {
editor.addSaveListener(e -> {
if (isBuffered()) {
requireDataSource().update(e.getBean());
if (isCommitOnSave()) {
requireDataSource().commit();
}
} else {
requireDataSource().getConfiguration().getCommitHandler().ifPresent(ch -> {
ch.commit(Collections.emptySet(), Collections.singleton(e.getBean()), Collections.emptySet());
});
}
});
}
super.setWidth(100, Unit.PERCENTAGE);
addStyleName("h-itemlisting", false);
setCompositionRoot(grid);
}
示例7: enter
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
@Override
public void enter(ViewChangeEvent event) {
leftLayout = new VerticalLayout();
rightLayout = new VerticalLayout();
infoLayout = new VerticalLayout();
infoLayout.setSpacing(false);
infoLayout.setMargin(false);
attackButton = new Button("Attaquer", VaadinIcons.SWORD);
attackButton.addStyleName(ValoTheme.BUTTON_LARGE);
attackButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
attackButton.setVisible(false);
Grid<Monster> monsterGrid = new Grid<>();
monsterGrid.setSelectionMode(SelectionMode.SINGLE);
monsterGrid.addColumn(Monster::getChallengeRating).setCaption("DD").setId("challengeRating");
monsterGrid.addColumn(Monster::getName).setCaption("Nom").setId("name");
monsterGrid.setItems(Services.getMonsterService().findAll());
monsterGrid.addSelectionListener(selection -> {
showMonsterInfo(selection.getFirstSelectedItem());
});
leftLayout.addComponent(monsterGrid);
rightLayout.addComponents(infoLayout, attackButton);
addComponents(leftLayout, rightLayout);
setWidth(100, Unit.PERCENTAGE);
setExpandRatio(leftLayout, 1);
setExpandRatio(rightLayout, 1);
}
示例8: initGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private void initGrid(final Grid grid) {
// Add some columns
DeleteButtonRenderer deleteButton = new DeleteButtonRenderer(new DeleteRendererClickListener() {
@Override
public void click(DeleteRendererClickEvent event) {
grid.getContainerDataSource().removeItem(event.getItem());
}
},FontAwesome.TRASH.getHtml()+" Delete",FontAwesome.CHECK.getHtml()+" Confirm");
deleteButton.setHtmlContentAllowed(true);
grid.addColumn("action", Boolean.class);
grid.getColumn("action").setEditable(false);
grid.getColumn("action").setRenderer(deleteButton);
grid.addColumn("col1", String.class);
grid.addColumn("col2", String.class);
for (int i = 0; i < 5; ++i) {
grid.addColumn("col" + (i + 3), Integer.class);
}
grid.addColumn("col8", Date.class);
grid.addColumn("col10", Boolean.class);
grid.addColumn("col11", String.class);
ComboBox comboBox = new ComboBox();
comboBox.addItems("Soft","Medium","Hard");
grid.getColumn("col11").setEditorField(comboBox);
// Make column 2 read only to test statically read only columns
grid.getColumn("col2").setEditable(false);
Random rand = new Random();
for (int i = 0; i < 100; ++i) {
grid.addRow(true,"string 1 " + i, "string 2 " + i, rand.nextInt(i + 10),
rand.nextInt(i + 10), rand.nextInt(i + 10),
rand.nextInt(i + 10), rand.nextInt(i + 10), new Date(), false, "Medium");
}
grid.setSelectionMode(SelectionMode.SINGLE);
grid.setSizeFull();
}
示例9: createGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Grid createGrid() {
final Grid statusGrid = new Grid(uploads);
statusGrid.addStyleName(SPUIStyleDefinitions.UPLOAD_STATUS_GRID);
statusGrid.setSelectionMode(SelectionMode.NONE);
statusGrid.setHeaderVisible(true);
statusGrid.setImmediate(true);
statusGrid.setSizeFull();
return statusGrid;
}
示例10: buildGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
protected void buildGrid() {
grid = new Grid();
grid.setEditorEnabled(true);
grid.setSizeFull();
grid.setSelectionMode(SelectionMode.SINGLE);
grid.setColumns("projectName","newDeployName","newDeployVersion",
"newDeployType","existingDeployName","existingDeployVersion",
"existingDeployType","upgrade");
container = new BeanItemContainer<>(DeploymentLine.class);
buildContainer();
grid.setContainerDataSource(container);
grid.sort("projectName", SortDirection.DESCENDING);
}
示例11: buildGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
protected void buildGrid() {
grid = new Grid();
grid.setSelectionMode(SelectionMode.NONE);
grid.setSizeFull();
grid.setEditorEnabled(!readOnly);
container = new BeanItemContainer<Record>(Record.class);
grid.setContainerDataSource(container);
grid.setColumns("entityName", "attributeName", "xpath");
HeaderRow filterRow = grid.appendHeaderRow();
addColumn("entityName", filterRow);
addColumn("attributeName", filterRow);
ComboBox combo = new ComboBox();
combo.addValueChangeListener(e->saveXPathSettings());
combo.setWidth(100, Unit.PERCENTAGE);
combo.setImmediate(true);
combo.setNewItemsAllowed(true);
combo.setInvalidAllowed(true);
combo.setTextInputAllowed(true);
combo.setScrollToSelectedItem(true);
combo.setFilteringMode(FilteringMode.CONTAINS);
grid.getColumn("xpath").setEditorField(combo).setExpandRatio(1);
addShowPopulatedFilter("xpath", filterRow);
grid.setEditorBuffered(false);
addComponent(grid);
setExpandRatio(grid, 1);
}
示例12: setSelectionMode
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
@Override
public void setSelectionMode(SelectionMode selectionMode) {
ObjectUtils.argumentNotNull(selectionMode, "SelectionMode must be not null");
if (this.selectionMode != selectionMode) {
this.selectionMode = selectionMode;
switch (getRenderingMode()) {
case GRID: {
final Grid grid = getGrid();
grid.removeSelectionListener(this);
switch (selectionMode) {
case MULTI:
grid.setSelectionMode(Grid.SelectionMode.MULTI);
grid.addSelectionListener(this);
break;
case SINGLE:
grid.setSelectionMode(Grid.SelectionMode.SINGLE);
grid.addSelectionListener(this);
break;
case NONE:
default:
grid.setSelectionMode(Grid.SelectionMode.NONE);
break;
}
}
break;
case TABLE: {
final Table table = getTable();
table.removeValueChangeListener(tableSelectionChangeListener);
table.setValue(null);
if (selectionMode != null && selectionMode != SelectionMode.NONE) {
table.setSelectable(true);
table.setMultiSelect(selectionMode == SelectionMode.MULTI);
table.addValueChangeListener(tableSelectionChangeListener);
} else {
table.setSelectable(false);
}
}
break;
default:
break;
}
}
}
示例13: init
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
@Override
protected void init(VaadinRequest request) {
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.setMargin(true);
layout.setSizeFull();
Grid<DemoPerson> grid = new Grid("<b>Demo Grid</b>", new ListDataProvider(DemoPerson.getPersonList()));
grid.setCaptionAsHtml(true);
grid.setSizeFull();
grid.setSelectionMode(Grid.SelectionMode.NONE);
Grid.Column<DemoPerson, String> idColumn = grid.addColumn(DemoPerson::getId).setCaption("Id");
Grid.Column<DemoPerson, String> firstNameColumn = grid.addColumn(DemoPerson::getFirstName).setCaption("Firstname");
Grid.Column<DemoPerson, String> surNameColumn = grid.addColumn(DemoPerson::getSurName).setCaption("Surname");
Grid.Column<DemoPerson, String> companyColumn = grid.addColumn(DemoPerson::getCompany,
new ClickableTextRenderer(getCompanyClickListener())).setCaption("Company");
Grid.Column<DemoPerson, String> companyTypeColumn = grid.addColumn(DemoPerson::getCompanyType).setCaption("Company Type");
Grid.Column<DemoPerson, String> cityColumn = grid.addColumn(DemoPerson::getCity).setCaption("City");
// Use the advanced form of the Clickable Text Renderer on
// column "city". This will require a value provider where the PRESENTATION
// class is of type ClickableText. Because the city is of type String
// the value provider must convert from String to ClickableText.
cityColumn.setRenderer((String source) -> {
ClickableText ct = new ClickableText();
ct.description = "Will take you to " + source; // Sets the HTML title attribute, aka tooltip
// I want a space between the underlined text and the icon. To avoid the
// space being underlined (because of the link styling) I use a
// a different style for the space itself.
ct.value = source + "<span class=\"v-icon\"> </span>" + VaadinIcons.EXTERNAL_LINK.getHtml();
ct.isHTML = true;
return ct;
}, new ClickableTextRendererAdv<>(getCityClickListener()));
layout.addComponent(grid);
setContent(layout);
}
示例14: ReqRespTabSheet
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
public ReqRespTabSheet(String caption, boolean editable) {
setCaption(caption);
setHeight(15, Unit.EM);
setWidth(550, Unit.PIXELS);
addStyleName(ValoTheme.TABSHEET_COMPACT_TABBAR);
payloadLayout = new VerticalLayout();
payloadLayout.setSizeFull();
payload = new TextArea();
payload.setNullRepresentation("");
payload.setSizeFull();
payloadLayout.addComponent(payload);
addTab(payloadLayout, "Payload");
VerticalLayout requestHeadersLayout = new VerticalLayout();
requestHeadersLayout.setSizeFull();
if (editable) {
HorizontalLayout requestHeadersButtonLayout = new HorizontalLayout();
Button addButton = new Button("+", (e) -> add());
addButton.addStyleName(ValoTheme.BUTTON_SMALL);
Button deleteButton = new Button("-", (e) -> delete());
deleteButton.addStyleName(ValoTheme.BUTTON_SMALL);
requestHeadersButtonLayout.addComponent(addButton);
requestHeadersButtonLayout.addComponent(deleteButton);
requestHeadersLayout.addComponent(requestHeadersButtonLayout);
}
headersGrid = new Grid();
headersGrid.setEditorEnabled(editable);
headersGrid.setEditorSaveCaption("Save");
headersGrid.setEditorCancelCaption("Cancel");
headersGrid.setSelectionMode(SelectionMode.SINGLE);
headersGrid.setSizeFull();
headersGrid.addColumn("headerName").setHeaderCaption("Header").setEditable(true)
.setExpandRatio(1);
headersGrid.addColumn("headerValue").setHeaderCaption("Value").setEditable(true)
.setExpandRatio(1);
requestHeadersLayout.addComponent(headersGrid);
requestHeadersLayout.setExpandRatio(headersGrid, 1);
addTab(requestHeadersLayout, "Headers");
}
示例15: createBasicBeanItemNestedPropertiesGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
@Override
public <T extends Serializable> void createBasicBeanItemNestedPropertiesGrid(final AbstractOrderedLayout panelContent,final Class<T> dataType, final List<T> datasource, final String caption, final String[] nestedProperties,
final String[] columnOrder, final String[] hideColumns, final AbstractPageItemRendererClickListener<?> listener,
final String actionId, final ListPropertyConverter[] collectionPropertyConverters) {
final Grid<T> grid = new Grid<T>(caption).withPropertySet(BeanPropertySet.get(dataType));
grid.setItems(datasource.stream().filter(Objects::nonNull)
.collect(Collectors.toList()));
grid.setSelectionMode(SelectionMode.SINGLE);
createNestedProperties(grid, nestedProperties);
configureColumnOrdersAndHiddenFields(columnOrder, hideColumns, grid);
configureListeners(listener, grid);
setColumnConverters(collectionPropertyConverters, grid);
grid.setSizeFull();
grid.setStyleName("Level2Header");
createGridCellFilter(columnOrder, grid,dataType);
grid.setResponsive(true);
panelContent.addComponent(grid);
panelContent.setExpandRatio(grid, ContentRatio.GRID);
}