當前位置: 首頁>>代碼示例>>Java>>正文


Java Grid類代碼示例

本文整理匯總了Java中com.vaadin.ui.Grid的典型用法代碼示例。如果您正苦於以下問題:Java Grid類的具體用法?Java Grid怎麽用?Java Grid使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Grid類屬於com.vaadin.ui包,在下文中一共展示了Grid類的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;
}
 
開發者ID:vianneyfaivre,項目名稱:Persephone,代碼行數:22,代碼來源:TracePage.java

示例2: 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;
}
 
開發者ID:eclipse,項目名稱:hawkbit,代碼行數:21,代碼來源:AbstractMetadataPopupLayout.java

示例3: init

import com.vaadin.ui.Grid; //導入依賴的package包/類
@Override
protected void init(VaadinRequest request) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);

    Grid grid = new Grid();

    initializeGrid(grid);
    grid.setWidth("700px");
    grid.setHeight("500px");

    applyDemoHacks(grid);

    layout.addComponent(grid);
}
 
開發者ID:Legioth,項目名稱:AllAboutGridWebinar,代碼行數:17,代碼來源:AllAboutGridUI.java

示例4: 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);
}
 
開發者ID:JumpMind,項目名稱:metl,代碼行數:27,代碼來源:ReleasesView.java

示例5: applyToGrid

import com.vaadin.ui.Grid; //導入依賴的package包/類
public void applyToGrid(Grid grid)
{
	final StackTraceElement[] trace = new Exception().getStackTrace();
	for (StackTraceElement call : trace)
	{
		if (!call.getClassName().contains("au.com.vaadinutils"))
		{
			if (call.getClassName().contains("."))
			{
				applyToGrid(grid, call.getClassName().substring(call.getClassName().lastIndexOf(".")));
			}
			else
			{
				applyToGrid(grid, call.getClassName());
			}

			return;
		}
	}

	throw new RuntimeException("Unable to determine calling class name, "
			+ " use applyToTable(Table table, String uniqueTableId) " + " instead of applyToTable(Table table)");
}
 
開發者ID:rlsutton1,項目名稱:VaadinUtils,代碼行數:24,代碼來源:GridHeadingPropertySet.java

示例6: 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);
}
 
開發者ID:JavaTrainingCourse,項目名稱:obog-manager,代碼行數:25,代碼來源:AttendeeListView.java

示例7: 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);
}
 
開發者ID:JavaTrainingCourse,項目名稱:obog-manager,代碼行數:19,代碼來源:MemberListView.java

示例8: DataTablesView

import com.vaadin.ui.Grid; //導入依賴的package包/類
public DataTablesView() {
    setFlexDirection(FlexDirection.COLUMN);
    setAlignSelf(AlignSelf.BASELINE);
    addStyleName(Margins.All.LARGE);
    addStyleName(Spacings.Bottom.LARGE);
    setWidth(100, Unit.PERCENTAGE);

    Grid g1 = createGrid();
    CssLayout c1 = createCard(g1);

    Grid g2 = createGrid();
    DataTableHeader h2 = new DataTableHeader("Nutrition", g2);
    CssLayout c2 = createCard(h2, g2);

    addComponents(c1, c2);
}
 
開發者ID:vaadin,項目名稱:material-theme-fw8,代碼行數:17,代碼來源:DataTablesView.java

示例9: 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;
}
 
開發者ID:vaadin,項目名稱:material-theme-fw8,代碼行數:17,代碼來源:DataTablesView.java

示例10: 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;
		}
	}
 
開發者ID:vianneyfaivre,項目名稱:Persephone,代碼行數:26,代碼來源:MetricsPage.java

示例11: 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;
}
 
開發者ID:vianneyfaivre,項目名稱:Persephone,代碼行數:17,代碼來源:MetricsPage.java

示例12: 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;
	}
 
開發者ID:vianneyfaivre,項目名稱:Persephone,代碼行數:26,代碼來源:TracePage.java

示例13: initApplicationsGrid

import com.vaadin.ui.Grid; //導入依賴的package包/類
private void initApplicationsGrid() {

		grid = new Grid<>();

		// Columns
		grid.removeAllColumns();
		Column<Application, String> appColumn = grid.addColumn(Application::getName).setCaption("Application").setExpandRatio(0);
		Column<Application, String> envColumn = grid.addColumn(Application::getEnvironment).setCaption("Environment").setExpandRatio(0);
		Column<Application, String> urlColumn = grid.addColumn(Application::getUrl).setCaption("URL").setExpandRatio(1);

		// Items
		grid.setItems(applications);

		// Header filter row
		initFilterRow(appColumn, envColumn, urlColumn);

		// Style
		grid.setStyleGenerator(app -> app.isUp() ? null : "app-down");
		grid.addItemClickListener(applicationOnClick());
		grid.setSizeFull();
		grid.setHeightByRows(applications.size());
		grid.sort(appColumn);
		grid.setRowHeight(40);
	}
 
開發者ID:vianneyfaivre,項目名稱:Persephone,代碼行數:25,代碼來源:ApplicationsPage.java

示例14: setSelectionMode

import com.vaadin.ui.Grid; //導入依賴的package包/類
@Override
public void setSelectionMode(com.holonplatform.vaadin.components.Selectable.SelectionMode selectionMode) {
	ObjectUtils.argumentNotNull(selectionMode, "SelectionMode must be not null");
	this.selectionMode = selectionMode;
	switch (selectionMode) {
	case MULTI:
		getGrid().setSelectionMode(com.vaadin.ui.Grid.SelectionMode.MULTI);
		((MultiSelectionModel<T>) getGrid().getSelectionModel())
				.setSelectAllCheckBoxVisibility((selectAllCheckBoxVisibility != null) ? selectAllCheckBoxVisibility
						: SelectAllCheckBoxVisibility.DEFAULT);
		break;
	case NONE:
		getGrid().setSelectionMode(com.vaadin.ui.Grid.SelectionMode.NONE);
		break;
	case SINGLE:
		getGrid().setSelectionMode(com.vaadin.ui.Grid.SelectionMode.SINGLE);
		break;
	default:
		break;
	}
}
 
開發者ID:holon-platform,項目名稱:holon-vaadin,代碼行數:22,代碼來源:DefaultItemListing.java

示例15: configureBeanGrid

import com.vaadin.ui.Grid; //導入依賴的package包/類
@Bean
@Scope(scopeName = "prototype")
@SuppressWarnings("unchecked")
public <ITEM> Grid<ITEM> configureBeanGrid(DependencyDescriptor dependencyDescriptor) {
	logger.debug("Configuring Vaadin Grid as bean");

	long timestamp = System.currentTimeMillis();

	ResolvableType injectionPointType = dependencyDescriptor.getResolvableType();
	if (!injectionPointType.hasGenerics()) {
		throw new IllegalStateException("Grid injection point is expected to declare a static item type");
	}

	ResolvableType genericType = injectionPointType.getGeneric();
	Class<ITEM> itemType = (Class<ITEM>) genericType.resolve();

	logger.debug("Vaadin Grid will use " + itemType.getCanonicalName() + " as item type");

	Grid<ITEM> grid = configureGridInstance(itemType);
	long configTime = System.currentTimeMillis() - timestamp;
	logger.debug("Done configuring Grid for " + itemType.getName() + " in " + configTime + "ms");

	return grid;
}
 
開發者ID:peterl1084,項目名稱:bean-grid,代碼行數:25,代碼來源:BeanGridConfiguration.java


注:本文中的com.vaadin.ui.Grid類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。