本文整理汇总了Java中com.vaadin.ui.Grid.SelectionMode类的典型用法代码示例。如果您正苦于以下问题:Java SelectionMode类的具体用法?Java SelectionMode怎么用?Java SelectionMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SelectionMode类属于com.vaadin.ui.Grid包,在下文中一共展示了SelectionMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMetadataGrid
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的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.SelectionMode; //导入依赖的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: buildGrid
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的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);
}
示例4: discoverSelectionMode
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的package包/类
/**
* Finds the {@link SelectionMode} associated with the given itemType
* through the {@link GridSelectionMode} annotation that may be placed on
* ITEM type.
*
* @param itemType
* @return the {@link SelectionMode} configured to given itemType or
* {@link SelectionMode#NONE} if no mode annotation is specified.
*/
public static <ITEM> SelectionMode discoverSelectionMode(Class<ITEM> itemType) {
if (itemType == null) {
return null;
}
if (itemType.isAnnotationPresent(GridSelectionMode.class)) {
return selectionModeMap.get(itemType.getAnnotation(GridSelectionMode.class).value());
}
return SelectionMode.NONE;
}
示例5: test
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的package包/类
@Test
public void test() {
Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
Person p2 = new Person(2, "George", LocalDate.of(1991, Month.JUNE, 19));
Person p3 = new Person(3, "Tim", LocalDate.of(1995, Month.APRIL, 7));
StyleGenerator<Person> styleGenerator = person -> "test";
FTreeGrid<Person> tree = new FTreeGrid<Person>(Person.class).withCaption("My Tree", true)
.withDescription("description", ContentMode.HTML)
.withCollapseListener(event -> System.out.println("collapsed"))
.withExpandListener(event -> System.out.println("expanded"))
.withItemClickListener(event -> System.out.println("clicked"))
.withItems(p1, p2, p3)
.withItemCollapseAllowedProvider(person -> person.getId() > 1)
.withSelectionMode(SelectionMode.MULTI)
.withSelectionListener(event -> System.out.println("selected"))
.withRowHeight(14)
.withStyleGenerator(styleGenerator)
.withHierarchyColumn("name");
assertEquals("My Tree", tree.getCaption());
assertEquals("description", tree.getDescription());
assertEquals(1, tree.getListeners(CollapseEvent.class).size());
assertEquals(1, tree.getListeners(ExpandEvent.class).size());
assertEquals(1, tree.getListeners(ItemClick.class).size());
assertTrue(tree.getSelectionModel() instanceof MultiSelectionModel);
assertEquals(styleGenerator, tree.getStyleGenerator());
assertTrue(tree.getDataProvider() instanceof HierarchicalDataProvider);
assertEquals("name", tree.getHierarchyColumn().getId());
}
示例6: enter
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的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);
}
示例7: initGrid
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的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();
}
示例8: createGrid
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的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;
}
示例9: initSelectionMode
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的package包/类
/**
* Init selection mode
*/
private void initSelectionMode() {
final CheckBox checkBox = new CheckBox("Multi Select");
addComponent(checkBox);
checkBox.setImmediate(true);
checkBox.setValue(false);
checkBox.addValueChangeListener(new ValueChangeListener() {
/**
*
*/
private static final long serialVersionUID = -1261311232228188664L;
@Override
public void valueChange(ValueChangeEvent event) {
if (checkBox.getValue()) {
grid.setSelectionMode(SelectionMode.MULTI);
grid.recalculateColumnWidths();
// Seems to be some bug in Vaadin Grid when expand ration is
// not given the column shrinks and this is visible when
// selection mode is single
for (Column column : grid.getColumns()) {
column.setExpandRatio(1);
}
} else {
grid.setSelectionMode(SelectionMode.SINGLE);
}
}
});
}
示例10: setDefaultGridProperties
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的package包/类
/**
* Sets the default properties of grid
*/
protected void setDefaultGridProperties() {
grid.setSelectionMode(SelectionMode.SINGLE);
grid.removeColumn("id");
grid.removeColumn("sales2012.totalSales");
grid.removeColumn("sales2013.totalSales");
grid.removeColumn("sales2014.totalSales");
grid.setImmediate(true);
grid.setHeightMode(HeightMode.CSS);
for (Column column : grid.getColumns()) {
column.setExpandRatio(1);
}
}
示例11: initLayout
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的package包/类
private void initLayout(){
setMargin(true);
setSpacing(true);
// vaadin table
grid = new Grid<Customer>(Customer.class);
grid.setDataProvider(mongodbContainer);
// set columns
grid.setColumnOrder(mongodbContainer.PROPERTIES);
grid.setSelectionMode(SelectionMode.SINGLE);
grid.setWidth("100%");
grid.setHeight("300px");
// table select listener
grid.addSelectionListener(event -> {
selectedCustomer = event.getFirstSelectedItem().get();
selectedId = selectedCustomer.getId();
LOG.info("Selected item id {"+ selectedId+"}");
});
// button bar
final AbstractLayout buttonBar = initButtonBar();
buttonBar.setWidth("100%");
// edit Form
editForm.setVisible(false);
addComponent(grid);
addComponent(buttonBar);
addComponent(editForm);
}
示例12: buildGrid
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的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);
}
示例13: buildPanel
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的package包/类
protected void buildPanel(String introText) {
this.setSpacing(true);
this.setSizeFull();
this.addComponent(new Label(introText));
grid.setSizeFull();
grid.setSelectionMode(SelectionMode.MULTI);
BeanItemContainer<ReleasePackage> container = new BeanItemContainer<>(ReleasePackage.class);
container.addAll(configService.findReleasePackages());
grid.setContainerDataSource(container);
grid.setColumns("name", "versionLabel", "releaseDate");
grid.addSelectionListener((e) -> rowSelected());
this.addComponent(grid);
this.setExpandRatio(grid, 1);
}
示例14: buildGrid
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的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);
}
示例15: ReportParameterTable
import com.vaadin.ui.Grid.SelectionMode; //导入依赖的package包/类
public ReportParameterTable(String caption, String parameterName, Class<T> tableClass,
SingularAttribute<T, String> displayField)
{
super(caption, parameterName);
init(caption, tableClass, displayField);
setSelectionMode(SelectionMode.MULTI);
}