本文整理匯總了Java中com.vaadin.ui.Grid.setItems方法的典型用法代碼示例。如果您正苦於以下問題:Java Grid.setItems方法的具體用法?Java Grid.setItems怎麽用?Java Grid.setItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.ui.Grid
的用法示例。
在下文中一共展示了Grid.setItems方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: formatHeaders
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Grid<HeaderGridRow> formatHeaders(String title, Map<String, List<String>> headers) {
Grid<HeaderGridRow> grid = new Grid<>(HeaderGridRow.class);
grid.removeAllColumns();
Column<HeaderGridRow, String> headerColumn = grid.addColumn(HeaderGridRow::getHeader)
.setCaption("Header")
.setExpandRatio(1);
Column<HeaderGridRow, String> valuesColumn = grid.addColumn(HeaderGridRow::getValues)
.setCaption("Values")
.setDescriptionGenerator(HeaderGridRow::getValues)
.setExpandRatio(1);
grid.setItems(headers.entrySet().stream().map(HeaderGridRow::new));
grid.sort(headerColumn);
HeaderRow titleRow = grid.prependHeaderRow();
titleRow.join(headerColumn, valuesColumn).setHtml(title);
return grid;
}
示例2: printConvocationResponses
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private void printConvocationResponses(List<Attendance> attendances) {
List<MemberInfo> attends = attendances.stream()
.filter(Attendance::isAttend)
.map(MemberInfo::from)
.collect(Collectors.toList());
Grid<MemberInfo> attendsGrid = new Grid<>("參加者一覧 (" + attends.size() + ")");
attendsGrid.setItems(attends);
attendsGrid.addColumn(MemberInfo::getName).setCaption("名前");
attendsGrid.addColumn(MemberInfo::getComment).setCaption("コメント");
attendsGrid.setWidth(100, Unit.PERCENTAGE);
attendsGrid.setHeightByRows(attends.size());
addComponent(attendsGrid);
List<MemberInfo> cancels = attendances.stream()
.filter(a -> !a.isAttend())
.map(MemberInfo::from)
.collect(Collectors.toList());
Grid<MemberInfo> cancelsGrid = new Grid<>("キャンセル一覧 (" + cancels.size() + ")");
cancelsGrid.setItems(cancels);
cancelsGrid.addColumn(MemberInfo::getName).setCaption("名前");
cancelsGrid.addColumn(MemberInfo::getComment).setCaption("コメント");
cancelsGrid.setWidth(100, Unit.PERCENTAGE);
cancelsGrid.setHeightByRows(cancels.size());
addComponent(cancelsGrid);
}
示例3: printAllMembers
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private void printAllMembers() {
List<Membership> memberships;
try {
memberships = membershipService.getAll();
} catch (RuntimeException e) {
ErrorView.show("會員一覧の取得に失敗しました。", e);
return;
}
Grid<MemberInfo> membershipGrid = new Grid<>();
membershipGrid.setItems(memberships.stream().map(MemberInfo::from).collect(Collectors.toList()));
membershipGrid.addColumn(MemberInfo::getName).setCaption("名前");
membershipGrid.addColumn(MemberInfo::getJavaTerm).setCaption("Java研修");
membershipGrid.addColumn(MemberInfo::getJava8Term).setCaption("Java8研修");
membershipGrid.addColumn(MemberInfo::getGoTerm).setCaption("Go研修");
membershipGrid.setWidth(100, Unit.PERCENTAGE);
membershipGrid.setHeightByRows(memberships.size());
addComponent(membershipGrid);
}
示例4: 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;
}
示例5: getRestGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Component getRestGrid(Collection<MetricsRest> metrics, Series httpSerie) {
List<MetricsRest> metricsItems = metrics.stream()
.filter(m -> m.valid() && m.getStatus().series() == httpSerie)
.collect(Collectors.toList());
if(metricsItems.isEmpty()) {
return new Label("No requests");
} else {
Grid<MetricsRest> gridCache = new Grid<>(MetricsRest.class);
gridCache.removeAllColumns();
gridCache.addColumn(MetricsRest::getName).setCaption("Path").setExpandRatio(1);
gridCache.addColumn(m -> m.getStatus() + " " + m.getStatus().getReasonPhrase()).setCaption("HTTP Status");
gridCache.addColumn(MetricsRest::getValue).setCaption("Hits");
gridCache.addColumn(MetricsRest::getLastResponseTime).setCaption("Last Response Time (ms)");
gridCache.setItems(metricsItems);
if(metricsItems.size() < 10) {
gridCache.setHeightByRows(metricsItems.size());
}
gridCache.setWidth(100, Unit.PERCENTAGE);
return gridCache;
}
}
示例6: getCacheGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Grid<MetricsCacheGridRow> getCacheGrid(Collection<MetricsCache> metricsCaches) {
List<MetricsCacheGridRow> metricsCacheItems = metricsCaches.stream()
.map(MetricsCacheGridRow::new)
.collect(Collectors.toList());
Grid<MetricsCacheGridRow> gridCache = new Grid<>(MetricsCacheGridRow.class);
gridCache.removeAllColumns();
gridCache.addColumn(MetricsCacheGridRow::getName).setCaption("Name").setExpandRatio(1);
gridCache.addColumn(MetricsCacheGridRow::getSize).setCaption("Size");
gridCache.addColumn(MetricsCacheGridRow::getHit).setCaption("Hit");
gridCache.addColumn(MetricsCacheGridRow::getMiss).setCaption("Miss");
gridCache.setItems(metricsCacheItems);
gridCache.setHeightByRows(metricsCacheItems.size());
return gridCache;
}
示例7: getTracesGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Grid<TraceGridRow> getTracesGrid(List<Trace> traces) {
List<TraceGridRow> tracesInfos = traces.stream()
.map(TraceGridRow::new)
.collect(Collectors.toList());
Grid<TraceGridRow> grid = new Grid<>(TraceGridRow.class);
grid.removeAllColumns();
grid.addColumn(TraceGridRow::getTimestamp).setCaption("Date");
grid.addColumn(t -> t.getMethod() + " " + t.getPath()).setCaption("HTTP Request").setExpandRatio(1);
grid.addColumn(t -> {
if(t.getResponseHttp().isPresent()) {
return t.getResponseHttp().get() + " " + t.getResponseHttp().get().getReasonPhrase();
}
return "";
}).setCaption("HTTP Response");
grid.addColumn(t -> t.getTimeTaken().isPresent() ? t.getTimeTaken().get().toMillis() : -1).setCaption("Time taken (ms)");
this.requestDetailsPopup(grid);
grid.setItems(tracesInfos);
grid.setSizeFull();
return grid;
}
示例8: presentTableData
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
@Override
public void presentTableData(RootResult rootrResult) {
ResultToListConverter resultToListConverter = new ResultToListConverter();
List<Result> resultList = resultToListConverter.apply(rootrResult);
Collections.sort(resultList, new Inverter<>(new ResultComparator()));
Grid<Result> grid = new Grid<>(TABLE_TITLE);
grid.addColumn(result -> result.getName()).setCaption(TABLE_COLUMN_METHOD_NAME).setId(TABLE_COLUMN_METHOD_NAME);
grid.addColumn(result -> result.getValue() + NONE).setCaption(TABLE_COLUMN_VALUE_NAME)
.setId(TABLE_COLUMN_VALUE_NAME);
grid.setColumnOrder(TABLE_COLUMN_METHOD_NAME, TABLE_COLUMN_VALUE_NAME);
grid.setStyleGenerator(result -> {
if (result.getValue() > MAX_ALLOWED_VALUES)
return ERROR_STYLE;
return NONE;
});
grid.setItems(resultList);
grid.setSizeFull();
grid.setWidth(70, Unit.REM);
mainPanel.addComponent(grid);
mainPanel.setComponentAlignment(grid, Alignment.MIDDLE_CENTER);
}
示例9: generateData
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private void generateData(Grid<RowData> g, int cols, int rows) {
g.addColumn(RowData::getRowNumber).setCaption("#");
for (int x = 0; x < cols; ++x) {
int row = x;
g.addColumn(t -> row < t.getValues().length ? t.getValues()[row] : "Empty")
.setCaption("Yet another dummy column with extremely long and pointless title " + (x + 1));
}
List<RowData> data = new ArrayList<>();
Random r = new Random();
for (int y = 0; y < rows; ++y) {
String[] values = new String[cols];
for (int x = 0; x < cols; ++x) {
values[x] = "" + r.nextInt() + " babies born last year";
}
data.add(new RowData(y, values));
}
g.setItems(data);
}
示例10: getDatasourceGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Grid<MetricsDatasource> getDatasourceGrid(Collection<MetricsDatasource> metrics) {
Grid<MetricsDatasource> grid = new Grid<>(MetricsDatasource.class);
grid.removeAllColumns();
grid.addColumn(MetricsDatasource::getName).setCaption("Datasource name").setExpandRatio(1);
grid.addColumn(MetricsDatasource::getActiveConnections).setCaption("Active connections");
grid.addColumn(MetricsDatasource::getConnectionPoolUsage).setCaption("Connection pool usage");
grid.setItems(metrics);
grid.setHeightByRows(metrics.size());
return grid;
}
示例11: getAllMetricsGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private Grid<MetricsGridRow> getAllMetricsGrid(Map<String, Number> metrics) {
allMetricsRows = metrics.entrySet().stream()
.map(MetricsGridRow::new)
.collect(Collectors.toList());
Grid<MetricsGridRow> grid = new Grid<>(MetricsGridRow.class);
grid.removeAllColumns();
Column<MetricsGridRow, String> nameColumn = grid.addColumn(MetricsGridRow::getName)
.setCaption("Name")
.setExpandRatio(1);
grid.addColumn(MetricsGridRow::getValue).setCaption("Value");
grid.setItems(allMetricsRows);
grid.sort(nameColumn);
grid.setSizeFull();
grid.setRowHeight(40);
TextField filterInput = new TextField();
filterInput.setPlaceholder("filter by metric...");
filterInput.addValueChangeListener(e -> updateMetrics(e.getValue()));
filterInput.setValueChangeMode(ValueChangeMode.LAZY);
filterInput.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(nameColumn).setComponent(filterInput);
return grid;
}
示例12: 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);
}
示例13: getEditLayer
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private VerticalLayout getEditLayer() {
VerticalLayout layout = new VerticalLayout();
Grid<String> grid = new Grid<>(EDIT_TABLE_TITLE);
grid.setItems(javaFileNames);
grid.addColumn(string -> string).setCaption(EDIT_TABLE_NAME_COLUMN);
grid.addColumn(string -> NOT_YET_IMPLEMENTED).setCaption(EDIT_TABLE_EDIT_COLUMN);
layout.addComponent(grid);
layout.setComponentAlignment(grid, Alignment.MIDDLE_CENTER);
return layout;
}
示例14: addGrid
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
private void addGrid() {
final Grid<TestFile> grid = new Grid<>("Attachment grid");
grid.addColumn(TestFile::getFileName).setCaption("File Name");
grid.addColumn(TestFile::isOpen).setHidable(true).setCaption("Is Open");
grid.addColumn(TestFile::createOpenLink, new HtmlRenderer()).setHidable(true).setCaption("Download");
grid.setColumnReorderingAllowed(true);
addComponent(grid);
extension = SidebarMenuExtension.create(grid);
grid.setItems(Stream.of("Test file 1", "Test file 2").map(TestFile::new));
}
示例15: getTargetComponent
import com.vaadin.ui.Grid; //導入方法依賴的package包/類
@Override
public Component getTargetComponent() {
final Grid<Person> grid = new Grid(Person.class);
grid.setSizeFull();
grid.setHeightMode(HeightMode.ROW);
grid.setHeightByRows(3);
grid.setItems(Arrays.asList(new Person("Arthur", 12),new Person("Ruben", 30),new Person("Ulises", 109)));
grid.setId("tocopie-grid");
return grid;
}