List of usage examples for com.vaadin.ui Grid Grid
public Grid()
From source file:ch.wscr.management.ui.view.MemberView.java
/** * Erstellt das Grid fr die Anwendung, befllt es mit Daten aus dem BeanItemContainer * * @return das Grid fr die Mitgliederverwaltung *//*w w w . j ava 2 s . co m*/ private Grid buildGrid() { final Grid grid = new Grid(); grid.setSizeFull(); // propertyContainer = new GeneratedPropertyContainer(memberBeanItemContainer); // propertyContainer.addGeneratedProperty("edit", getPropertyValueGenerator(".")); grid.setContainerDataSource(memberBeanItemContainer); setColumnHeaders(grid); setColumnRenderers(grid); setHeaderRow(grid); setEditorFields(grid); setCommitHandler(grid); return grid; }
From source file:com.coatl.vaadin.grids.ixGridTabla.java
public void armarTabla() { this.tabla = getTabla(pagina, 25); grid = new Grid(); grid.setSelectionMode(Grid.SelectionMode.MULTI); grid.addSelectionListener(this); grid.addListener(new ItemClickEvent.ItemClickListener() { @Override/*from w ww. j a va 2 s . c om*/ public void itemClick(ItemClickEvent item) { if (item.isDoubleClick()) { Object[] renglon = tabla.getRenglon((Integer) item.getItemId() - 1); Map<String, Object> m = tabla.getRenglonComoMapa(renglon); dobleClick(m); } } }); String[] colVis = this.getArregloColumnasVisibles(); for (String t : colVis) { Class cl = getTabla().getClaseColumna(t); String titulo = getTituloColumna(t); grid.addColumn(titulo, cl); } //this.configurarEncabezados(grid); List<Object[]> lista = getTabla().getDatos(); for (Object[] renglonOriginal : lista) { Object[] renglonGrid = new Object[colVis.length]; int nc = 0; for (String t : colVis) { Object o = renglonOriginal[getTabla().getIndiceDeColumna(t)]; if (o instanceof Boolean) { if (((Boolean) o).booleanValue()) { renglonGrid[nc] = ""; } else { //renglonGrid[nc] = ""; renglonGrid[nc] = " "; } } else if (o != null) { renglonGrid[nc] = o.toString(); } else { renglonGrid[nc] = null; } nc++; } grid.addRow(renglonGrid); } grid.setSizeFull(); hacerPaginador(); this.setComponenteMedio(grid); seleccionar(); }
From source file:com.github.cjm.TmdbUI.java
private void addTvShowGrid() { tvShowGridLayout.setSpacing(true);/*from ww w .j a v a2 s .co m*/ tvShowGridLayout.setWidth("100%"); tvShowGrid = new Grid(); tvShowGrid.setSizeFull(); tvShows = new BeanItemContainer<>(TvShow.class); tvShowGrid.setColumns("name", "popularity", "voteAverage", "firstAirDate"); tvShowGrid.setHeaderVisible(true); tvShowGrid.setContainerDataSource(tvShows); HeaderRow filterRow = tvShowGrid.appendHeaderRow(); // Not really loading "all"; multiple pages up to some reasonable/polite limit // (API is throttled and this is a demo afterall). tvShows.addAll( tvShowService.loadAll(TvShowService.RESOURCE_TV_POPULAR, TvShowCollection.class).getResults()); tvShowGridLayout.addComponent(tvShowGrid); mainLayout.addComponent(tvShowGridLayout); tvShowGrid.getContainerDataSource().getContainerPropertyIds().stream().forEach((pid) -> { if (tvShowGrid.getColumn(pid) != null) { Grid.HeaderCell cell = filterRow.getCell(pid); TextField filterField = new TextField(); filterField.setColumns(8); // Update filter When the filter input is changed filterField.addTextChangeListener(change -> { // Can't modify filters so need to replace tvShows.removeContainerFilters(pid); // (Re)create the filter if necessary if (!change.getText().isEmpty()) { tvShows.addContainerFilter(new SimpleStringFilter(pid, change.getText(), true, false)); } }); filterField.setImmediate(true); cell.setComponent(filterField); } }); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); DateRenderer dateRenderer = new DateRenderer(dateFormat); tvShowGrid.getColumn("firstAirDate").setRenderer(dateRenderer); tvShowGrid.addItemClickListener((ItemClickEvent event) -> { if (event.isDoubleClick()) { User u = (User) username.getValue(); if (u != null) { users.removeItem(u); TvShow tvShow = getSelectedTvShow(); if (tvShow != null) { favorites.addBean(tvShow); List<Integer> i = new ArrayList<>(); favorites.getItemIds().stream().forEach((t) -> { i.add(t.getId()); }); u.setFavoriteTvShows(new Integer[i.size()]); u.setFavoriteTvShows(i.toArray(u.getFavoriteTvShows())); userDao.save(u); users.addBean(u); } } } }); }
From source file:com.yoncabt.ebr.ui.ReportStatusWindow.java
private Grid makeGrid() { Grid ret = new Grid(); ret.setId("reportsGrid"); ret.addColumn("uuid", String.class); ret.addColumn("data source", String.class); ret.addColumn("report", String.class); ret.addColumn("ext", String.class); ret.addColumn("started", String.class); ret.addColumn("ended", String.class); ret.addColumn("iptal", String.class) .setRenderer(new ButtonRenderer((ClickableRenderer.RendererClickEvent e) -> { String uuid = (String) grid.getContainerDataSource().getItem(e.getItemId()) .getItemProperty("uuid").getValue(); reportWS.cancel(uuid);// w ww. jav a 2 s. c o m Notification.show(uuid + " durduruldu"); })); ret.addColumn("gster", String.class) .setRenderer(new ButtonRenderer((ClickableRenderer.RendererClickEvent e) -> { String uuid = (String) grid.getContainerDataSource().getItem(e.getItemId()) .getItemProperty("uuid").getValue(); if (reportWS.status(uuid) == Status.FINISH) { Page.getCurrent().open("/ebr/ws/1.0/output/" + uuid, "_new", false); } else { Notification.show("Bitmi bir rapor yok"); } })); ret.addColumn("durum", String.class); ret.addColumn("exception", String.class); ret.setSizeFull(); return ret; }
From source file:com.yoncabt.ebr.ui.ReportWindow.java
@Override protected void init(VaadinRequest request) { reportType.setNullSelectionAllowed(false); reportLocale.setNullSelectionAllowed(false); reportLocale.addItem("tr_TR"); reportLocale.setItemCaption("tr_TR", "Trke"); reportLocale.addItem("en_US"); reportLocale.setItemCaption("en_US", "English"); email.setEnabled(mailSender.isConfigured()); grid = new Grid(); try {//from w ww .j a v a2s . c om MenuBar mb = createMenuBar(); HorizontalLayout hl = new HorizontalLayout(mb); setContent(hl); } catch (IOException | JRException ex) { Notification.show("Hata", Notification.Type.ERROR_MESSAGE); Logger.getLogger(ReportWindow.class.getName()).log(Level.SEVERE, null, ex); } Button btnReload = new Button(FontAwesome.LIST_ALT); btnReload.setDisableOnClick(true); btnReload.addClickListener((Button.ClickEvent event) -> { try { fillTheGrid(); } catch (Exception ex) { Notification.show("Hata", Notification.Type.ERROR_MESSAGE); Logger.getLogger(ReportWindow.class.getName()).log(Level.SEVERE, null, ex); } event.getButton().setEnabled(true); }); gridLayout = new HorizontalLayout(); if (report instanceof SQLReport) { createGrid(); } btnExport = YoncaGridXLSExporter.createDownloadButton(grid, "raporlar.xls"); gridLayout.setSizeFull(); window.setSizeUndefined(); window.setContent(new VerticalLayout(formLayout, new HorizontalLayout(btnExport, btnReload), gridLayout)); window.setClosable(false); addWindow(window); window.center(); getPage().addUriFragmentChangedListener((Page.UriFragmentChangedEvent event) -> { String frag = event.getUriFragment(); ReportWindow.this.uriFragmentChanged(frag); }); if (StringUtils.isNotEmpty(getPage().getUriFragment())) { ReportWindow.this.uriFragmentChanged(getPage().getUriFragment()); } }
From source file:com.yoncabt.ebr.ui.ReportWindow.java
private void createGrid() { grid = new Grid(); grid.setWidth("800px"); grid.setHeight("600px"); grid.setHeightMode(HeightMode.CSS); gridLayout.addComponent(grid);//from w w w . j a v a 2 s .c o m if (btnExport != null) { btnExport.setData(grid); } }
From source file:de.datenhahn.vaadin.componentrenderer.demo.ClassicGridTab.java
License:Apache License
private void init() { setSizeFull();//ww w .ja v a2s . c o m setMargin(true); setSpacing(true); addComponent( new Label("Look at the sourcecode to see the difference between the typed ComponentGrid and using" + " the classic grid")); Grid grid = new Grid(); ComponentCellKeyExtension.extend(grid); focusPreserveExtension = FocusPreserveExtension.extend(grid); DetailsKeysExtension.extend(grid); addComponent(ViewComponents.createEnableDisableCheckBox(grid)); grid.setSizeFull(); // Initialize Containers BeanItemContainer<Customer> bc = new BeanItemContainer<>(Customer.class); GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(bc); grid.setContainerDataSource(gpc); // Load the data bc.addAll(CustomerProvider.createDummyData()); // Initialize DetailsGenerator (Caution: the DetailsGenerator is set to null // when grid#setContainerDatasource is called, so make sure you call setDetailsGenerator // after setContainerDatasource grid.setDetailsGenerator(new CustomerDetailsGenerator()); gpc.addGeneratedProperty(Customer.FOOD, new PropertyValueGenerator<Component>() { @Override public Component getValue(Item item, Object itemId, Object propertyId) { return ViewComponents.createClassicFoodSelector(grid, focusPreserveExtension, (Customer) itemId); } @Override public Class<Component> getType() { return Component.class; } // You must override getSortProperties to allow sorting by the values // underlying of the GeneratedValue. The default is that generated // property columns cannot be sorted (see PropertyValueGenerator default implementation) // if the generated column is not shadowing a real data column DO NOT overwrite this method // otherwise an exception is thrown when you sort it because the bean property cannot be found @Override public SortOrder[] getSortProperties(SortOrder order) { return new SortOrder[] { order }; } }); // Don't forget to set the ComponentRenderer AFTER adding the column grid.getColumn(Customer.FOOD).setRenderer(new ComponentRenderer()); gpc.addGeneratedProperty(GENERATED_FOOD_ICON, new PropertyValueGenerator<Component>() { @Override public Component getValue(Item item, Object itemId, Object propertyId) { return ViewComponents.createFoodIcon((Customer) itemId); } @Override public Class<Component> getType() { return Component.class; } // You must override getSortProperties to allow sorting by the values // underlying of the GeneratedValue. The default is that generated // property columns cannot be sorted (see PropertyValueGenerator default implementation) // if the generated column is not shadowing a real data column DO NOT overwrite this method // otherwise an exception is thrown when you sort it because the bean property cannot be found @Override public SortOrder[] getSortProperties(SortOrder order) { return new SortOrder[] { order }; } }); // Don't forget to set the ComponentRenderer AFTER adding the column grid.getColumn(GENERATED_FOOD_ICON).setRenderer(new ComponentRenderer()); gpc.addGeneratedProperty(GENERATED_RATING, new PropertyValueGenerator<Component>() { @Override public Component getValue(Item item, Object itemId, Object propertyId) { return ViewComponents.createRating((Customer) itemId); } @Override public Class<Component> getType() { return Component.class; } }); // Don't forget to set the ComponentRenderer AFTER adding the column grid.getColumn(GENERATED_RATING).setRenderer(new ComponentRenderer()); gpc.addGeneratedProperty(GENERATED_DELETE, new PropertyValueGenerator<Component>() { @Override public Component getValue(Item item, Object itemId, Object propertyId) { return ViewComponents.createClassicDeleteButton(grid, focusPreserveExtension, bc, (Customer) itemId); } @Override public Class<Component> getType() { return Component.class; } }); // Don't forget to set the ComponentRenderer AFTER adding the column grid.getColumn(GENERATED_DELETE).setRenderer(new ComponentRenderer()); gpc.addGeneratedProperty(GENERATED_DETAILS_ICONS, new PropertyValueGenerator<Component>() { @Override public Component getValue(Item item, Object itemId, Object propertyId) { return ViewComponents.createDetailsIcons(grid, (Customer) itemId); } @Override public Class<Component> getType() { return Component.class; } }); // Don't forget to set the ComponentRenderer AFTER adding the column grid.getColumn(GENERATED_DETAILS_ICONS).setRenderer(new ComponentRenderer()); // always display the details column grid.setFrozenColumnCount(1); grid.setColumns(GENERATED_DETAILS_ICONS, Customer.ID, Customer.FIRST_NAME, Customer.LAST_NAME, Customer.FOOD, GENERATED_FOOD_ICON, GENERATED_RATING, GENERATED_DELETE); addComponent(grid); setExpandRatio(grid, 1.0f); }
From source file:de.datenhahn.vaadin.componentrenderer.demo.ClassicGridWithDecoratorTab.java
License:Apache License
private void init() { setSizeFull();//from w ww . j av a 2 s. c o m setMargin(true); setSpacing(true); addComponent(new Label("This grid is editable using the grid's editor")); Grid grid = new Grid(); grid.setContainerDataSource(new BeanItemContainer<Customer>(Customer.class)); ComponentGridDecorator<Customer> componentGridDecorator = new ComponentGridDecorator<>(grid, Customer.class); componentGridDecorator.addAll(CustomerProvider.createDummyData()); addComponent(ViewComponents.createEnableDisableCheckBox(grid)); grid.setSizeFull(); grid.setEditorEnabled(true); grid.setEditorBuffered(false); // Initialize DetailsGenerator (Caution: the DetailsGenerator is set to null // when grid#setContainerDatasource is called, so make sure you call setDetailsGenerator // after setContainerDatasource grid.setDetailsGenerator(new CustomerDetailsGenerator()); componentGridDecorator.addComponentColumn(Customer.PREMIUM, cust -> ViewComponents.createPremiumCheckbox(componentGridDecorator, cust)); componentGridDecorator.addComponentColumn(Customer.FOOD, cust -> ViewComponents.createFoodSelector(componentGridDecorator, cust)); componentGridDecorator.addComponentColumn(GENERATED_FOOD_ICON, cust -> ViewComponents.createFoodIcon(cust)); componentGridDecorator.addComponentColumn(GENERATED_RATING, cust -> ViewComponents.createRating(cust)); componentGridDecorator.addComponentColumn(GENERATED_DELETE, cust -> ViewComponents.createDeleteButton(componentGridDecorator, cust)).setEditable(false); componentGridDecorator .addComponentColumn(GENERATED_DETAILS_ICONS, cust -> ViewComponents.createDetailsIcons(grid, cust)) .setEditable(false); // always display the details column grid.setFrozenColumnCount(1); grid.setColumns(GENERATED_DETAILS_ICONS, Customer.ID, Customer.PREMIUM, Customer.FIRST_NAME, Customer.LAST_NAME, Customer.FOOD, GENERATED_FOOD_ICON, GENERATED_RATING, GENERATED_DELETE); //grid.setColumns(Customer.PREMIUM, Customer.FIRST_NAME, Customer.LAST_NAME, GENERATED_RATING); componentGridDecorator.generateHeaders(new ResourceBundleTextHeaderGenerator(ViewComponents.getLabels())); addComponent(grid); setExpandRatio(grid, 1.0f); }
From source file:de.datenhahn.vaadin.componentrenderer.demo.ClassicGridWithStaticContainerTab.java
License:Apache License
private void init() { setSizeFull();//ww w . j a v a 2 s.co m setMargin(true); setSpacing(true); addComponent( new Label("Look at the sourcecode to see the difference between the typed ComponentGrid and using" + " the classic grid")); Grid grid = new Grid(); ComponentCellKeyExtension.extend(grid); focusPreserveExtension = FocusPreserveExtension.extend(grid); DetailsKeysExtension.extend(grid); addComponent(ViewComponents.createEnableDisableCheckBox(grid)); grid.setSelectionMode(Grid.SelectionMode.SINGLE); ((Grid.SingleSelectionModel) grid.getSelectionModel()).setDeselectAllowed(false); grid.setImmediate(true); grid.setSizeFull(); // Initialize Containers BeanItemContainer<StaticCustomer> bc = new BeanItemContainer<>(StaticCustomer.class); grid.setContainerDataSource(bc); // Load the data bc.addAll(StaticCustomerProvider.createDummyData()); // Initialize DetailsGenerator (Caution: the DetailsGenerator is set to null // when grid#setContainerDatasource is called, so make sure you call setDetailsGenerator // after setContainerDatasource grid.setDetailsGenerator(new StaticCustomerDetailsGenerator()); // always display the details column grid.setFrozenColumnCount(1); grid.getColumn(Customer.FOOD).setRenderer(new ComponentRenderer()); grid.setColumns(StaticCustomer.ID, StaticCustomer.FIRST_NAME, StaticCustomer.LAST_NAME, StaticCustomer.FOOD); addComponent(grid); setExpandRatio(grid, 1.0f); }
From source file:de.datenhahn.vaadin.componentrenderer.demo.NotABeanGridWithDecoratorTab.java
License:Apache License
private void init() { setSizeFull();/*from ww w . j a v a 2 s.co m*/ setMargin(true); setSpacing(true); addComponent( new Label("Look at the sourcecode to see the difference between the typed ComponentGrid and using" + " the classic grid")); Grid grid = new Grid(); grid.addColumn("foo"); grid.addRow("1"); grid.addRow("2"); grid.addRow("3"); grid.addRow("4"); ComponentGridDecorator componentGridDecorator = new ComponentGridDecorator<>(grid, null); addComponent(ViewComponents.createEnableDisableCheckBox(grid)); grid.setSizeFull(); // Initialize DetailsGenerator (Caution: the DetailsGenerator is set to null // when grid#setContainerDatasource is called, so make sure you call setDetailsGenerator // after setContainerDatasource grid.setDetailsGenerator(new CustomerDetailsGenerator()); componentGridDecorator.addComponentColumn("Just some", e -> new Label("some" + e)); grid.setColumns("Just some"); addComponent(grid); setExpandRatio(grid, 1.0f); }