List of usage examples for com.vaadin.ui Grid addSelectionListener
public Registration addSelectionListener(SelectionListener<T> listener) throws UnsupportedOperationException
From source file:com.hack23.cia.web.impl.ui.application.views.common.gridfactory.impl.GridFactoryImpl.java
License:Apache License
/** * Configure listeners./* w ww . j av a 2 s . com*/ * * @param listener * the listener * @param grid * the grid */ private static void configureListeners(final SelectionListener listener, final Grid grid) { if (listener != null) { grid.addSelectionListener(listener); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.AddPatientView.java
License:Open Source License
/** * //from w w w .j a v a 2s.c om * @return */ void initOptionLayout() { optionLayout.removeAllComponents(); optionLayout.setWidth("100%"); optionLayout.setVisible(false); VerticalLayout optionLayoutContent = new VerticalLayout(); Button addSample = new Button("Add Sample"); addSample.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { sampleOptions.addBean(new NewIvacSampleBean("", 0, "", false, false, false, "", "")); } }); optionLayoutContent.setMargin(new MarginInfo(true, false, false, false)); optionLayoutContent.setHeight(null); optionLayoutContent.setWidth("100%"); optionLayoutContent.setSpacing(true); final Grid optionGrid = new Grid(); optionGrid.setWidth("80%"); // optionGrid.setCaption("Which biological samples are available for the patient(s) and which // experiments will be performed?"); gridInfo = new CustomVisibilityComponent(new Label("")); ((Label) gridInfo.getInnerComponent()).addStyleName(ValoTheme.LABEL_LARGE); Component gridInfoContent = Utils.questionize(gridInfo, "Which biological samples are available for the patient(s) and which experiments will be performed?", "Extracted Samples"); // optionGrid.setSelectionMode(SelectionMode.MULTI); optionGrid.setEditorEnabled(true); optionGrid.setContainerDataSource(sampleOptions); optionGrid.setColumnOrder("type", "secondaryName", "tissue", "amount", "dnaSeq", "rnaSeq", "deepSeq"); optionLayoutContent.addComponent(gridInfoContent); optionLayoutContent.addComponent(optionGrid); optionLayoutContent.addComponent(addSample); final GridEditForm form = new GridEditForm( datahandler.getOpenBisClient().getVocabCodesForVocab("Q_PRIMARY_TISSUES"), datahandler.getOpenBisClient().getVocabCodesForVocab("Q_SEQUENCER_DEVICES")); optionLayoutContent.addComponent(form); form.setVisible(false); optionGrid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { BeanItem<NewIvacSampleBean> item = sampleOptions.getItem(optionGrid.getSelectedRow()); form.fieldGroup.setItemDataSource(item); form.setVisible(true); } }); optionLayout.addComponent(optionLayoutContent); }
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public ArchiveView() { HorizontalLayout optionsLayout = new HorizontalLayout(); optionsLayout.setWidth("100%"); Grid<Clipping> gridClippings = new Grid<>(); Set<Clipping> clippings = ClippingUtils.getUserClippings(UserUtils.getCurrent(), LocalDate.now(ZoneId.of("Europe/Berlin"))); gridClippings.setItems(clippings);//from www. j ava2s . c o m InlineDateTimeField datePicker = new InlineDateTimeField(); datePicker.setValue(LocalDateTime.now(ZoneId.of("Europe/Berlin"))); datePicker.setLocale(Locale.GERMANY); datePicker.setResolution(DateTimeResolution.DAY); datePicker.addValueChangeListener(date -> { Set<Clipping> clippingsOfDate = ClippingUtils.getUserClippings(UserUtils.getCurrent(), date.getValue().toLocalDate()); gridClippings.setItems(clippingsOfDate); gridClippings.getDataProvider().refreshAll(); }); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM); formatter.withZone(ZoneId.of("Europe/Berlin")); Column columnTime = gridClippings.addColumn(c -> { return c.getDate().format(formatter); }); Language.setCustom(Word.TIME, s -> columnTime.setCaption(s)); Column columnAmountArticles = gridClippings.addColumn(c -> { long amountArticles = c.getArticles().values().stream().flatMap(l -> l.stream()).count(); amountArticles += c.getArticlesFromGroup().values().stream().flatMap(l -> l.stream()).count(); if (amountArticles != 1) { return amountArticles + " " + Language.get(Word.ARTICLES); } else { return amountArticles + " " + Language.get(Word.ARTICLE); } }); Language.setCustom(Word.ARTICLES, s -> { columnAmountArticles.setCaption(s); gridClippings.getDataProvider().refreshAll(); }); gridClippings.setHeight("100%"); gridClippings.setSelectionMode(Grid.SelectionMode.SINGLE); gridClippings.addSelectionListener(c -> { if (c.getFirstSelectedItem().isPresent()) { currentClipping = c.getFirstSelectedItem().get(); showClippingBy(currentClipping, currentSort); } }); optionsLayout.addComponents(datePicker, gridClippings); optionsLayout.setComponentAlignment(datePicker, Alignment.BOTTOM_CENTER); optionsLayout.setComponentAlignment(gridClippings, Alignment.BOTTOM_RIGHT); optionsLayout.setExpandRatio(gridClippings, 5); VerticalLayout sortLayout = new VerticalLayout(); comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY)); Language.setCustom(Word.SORT_BY, s -> { comboBoxSortOptions.setCaption(s); comboBoxSortOptions.getDataProvider().refreshAll(); }); comboBoxSortOptions.setItems(EnumSet.allOf(ClippingView.SortOptions.class)); comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName()); comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon()); comboBoxSortOptions.setValue(currentSort); comboBoxSortOptions.setTextInputAllowed(false); comboBoxSortOptions.setEmptySelectionAllowed(false); comboBoxSortOptions.addStyleName("comboboxsort"); comboBoxSortOptions.addValueChangeListener(e -> { currentSort = e.getValue(); showClippingBy(currentClipping, currentSort); }); comboBoxSortOptions.setVisible(false); sortLayout.setMargin(false); sortLayout.setSpacing(false); sortLayout.addComponent(comboBoxSortOptions); clippingArticlesLayout = new VerticalLayout(); clippingArticlesLayout.setSpacing(true); clippingArticlesLayout.setMargin(false); clippingArticlesLayout.setSizeFull(); addComponents(optionsLayout, sortLayout, clippingArticlesLayout); }
From source file:facs.components.Statistics.java
License:Open Source License
private Component initialGrid() { VerticalLayout gridLayout = new VerticalLayout(); createInvoice.setEnabled(false);/*from w w w .j ava 2 s . c o m*/ downloadInvoice.setEnabled(false); String buttonRefreshTitle = "Refresh"; Button refresh = new Button(buttonRefreshTitle); refresh.setIcon(FontAwesome.REFRESH); refresh.setDescription("Click here to reload the data from the database!"); refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY); refresh.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496269L; @Override public void buttonClick(ClickEvent event) { refreshDataSources(); } }); Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); System.out.println(ft.format(dNow) + " INFO Statistics accessed! - User: " + LiferayAndVaadinUtils.getUser().getScreenName()); // Add some generated properties IndexedContainer container = getEmptyContainer(); gpcontainer = new GeneratedPropertyContainer(container); Grid grid = new Grid(gpcontainer); grid.setWidth("100%"); setRenderers(grid); fillRows(grid); // compute total costs float totalCosts = 0.0f; for (Object itemId : gpcontainer.getItemIds()) totalCosts += ((Number) gpcontainer.getContainerProperty(itemId, costCaption).getValue()).floatValue(); // compute total time in milliseconds long total = 0; for (Object itemId : gpcontainer.getItemIds()) { long s = ((Date) gpcontainer.getContainerProperty(itemId, startCaption).getValue()).getTime(); long e = ((Date) gpcontainer.getContainerProperty(itemId, endCaption).getValue()).getTime(); total += e - s; } // set footer to contain total cost and time in hours:minutes FooterRow footer = grid.appendFooterRow(); FooterCell footerCellCost = footer.getCell(costCaption); footerCellCost.setText(String.format("%1$.2f total", totalCosts)); FooterCell footerCellEnd = footer.getCell(endCaption); footerCellEnd.setText(Formatter.toHoursAndMinutes(total)); // "%1$.0f hours" // Set up a filter for all columns HeaderRow filterRow = grid.appendHeaderRow(); addRowFilter(filterRow, deviceCaption, container, footer, gpcontainer); addRowFilter(filterRow, kostenstelleCaption, container, footer, gpcontainer); Label infoLabel = new Label( DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName()) + " " + LiferayAndVaadinUtils.getUser().getScreenName()); infoLabel.addStyleName("h4"); // createInvoice.setSizeFull(); // downloadInvoice.setSizeFull(); gridLayout.setWidth("100%"); gridLayout.setCaption("Statistics"); // add components to the grid layout // gridLayout.addComponent(infoLabel, 0, 0, 3, 0); // gridLayout.addComponent(grid, 0, 1, 5, 1); // gridLayout.addComponent(createInvoice, 0, 3); // gridLayout.addComponent(downloadInvoice, 1, 3); gridLayout.addComponent(grid); gridLayout.addComponent(refresh); gridLayout.addComponent(createInvoice); gridLayout.addComponent(downloadInvoice); gridLayout.setMargin(true); gridLayout.setSpacing(true); // grid.setEditorEnabled(true); grid.setSelectionMode(SelectionMode.SINGLE); grid.addSelectionListener(new SelectionListener() { /** * */ private static final long serialVersionUID = -2683274060620429050L; @Override public void select(SelectionEvent event) { // Notification.show("Select row: " + grid.getSelectedRow() + " Name: " // + gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption).getValue()); downloadInvoice.setEnabled(false); ReceiverPI = (String) gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption) .getValue(); createInvoice.setEnabled(true); } }); createInvoice.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 5512585967145932560L; private File bill; private FileDownloader fileDownloader; @Override public void buttonClick(ClickEvent event) { String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); Paths.get(basepath, "WEB-INF/billingTemplates"); // System.out.println("Basepath: " + basepath); try { int setUserId = DBManager.getDatabaseInstance().findUserByFullName(ReceiverPI); if (setUserId > 0) { Billing billing = new Billing(Paths.get(basepath, "WEB-INF/billingTemplates").toFile(), "Angebot.tex"); UserBean user = setUserId > 0 ? DBManager.getDatabaseInstance().getUserById(setUserId) : null; billing.setReceiverPI(ReceiverPI); billing.setReceiverInstitution(user.getInstitute()); billing.setReceiverStreet(user.getStreet()); billing.setReceiverPostalCode(user.getPostcode()); billing.setReceiverCity(user.getCity()); billing.setSenderName("Dr. rer. nat. Stella Autenrieth"); billing.setSenderFunction("Leiterin"); billing.setSenderPostalCode("72076"); billing.setSenderCity("Tbingen"); billing.setSenderStreet("Otfried-Mller-Strae 10"); billing.setSenderPhone("+49 (0) 7071 29-83156"); billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de"); billing.setSenderUrl("www.medizin.uni-tuebingen.de"); billing.setSenderFaculty("Medizinischen Fakultt"); if (user.getKostenstelle() != null) billing.setProjectDescription("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectDescription("Keine kostenstelle verfgbar."); billing.setProjectShortDescription("Dieses Angebot beinhaltet jede Menge Extras."); if (user.getProject() != null) billing.setProjectNumber("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectNumber("Keine project nummer verfgbar."); float cost = ((Number) gpcontainer.getContainerProperty(grid.getSelectedRow(), costCaption) .getValue()).floatValue(); long s = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), startCaption) .getValue()).getTime(); long e = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), endCaption) .getValue()).getTime(); long timeFrame = e - s; Date start = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), startCaption) .getValue()); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy"); String date = ft.format(start); String description = "No Description is Available"; String time_frame = Formatter.toHoursAndMinutes(timeFrame); ArrayList<CostEntry> entries = new ArrayList<CostEntry>(); entries.add(billing.new CostEntry(date, time_frame, description, cost)); billing.setCostEntries(entries); float totalCosts = 0.0f; // calculates the total cost of items // for (Object itemId : gpcontainer.getItemIds()) { // totalCosts += // ((Number) gpcontainer.getContainerProperty(itemId, costCaption).getValue()) // .floatValue(); // } totalCosts = ((Number) gpcontainer.getContainerProperty(grid.getSelectedRow(), costCaption) .getValue()).floatValue(); billing.setTotalCost(String.format("%1$.2f", totalCosts)); bill = billing.createPdf(); // System.out.println(bill.getAbsolutePath()); if (fileDownloader != null) downloadInvoice.removeExtension(fileDownloader); fileDownloader = new FileDownloader(new FileResource(bill)); fileDownloader.extend(downloadInvoice); downloadInvoice.setEnabled(true); showSuccessfulNotification("Congratulations!", "Invoice is created and available for download."); downloadInvoice.setEnabled(true); } else { createInvoice.setEnabled(false); downloadInvoice.setEnabled(false); showErrorNotification("No such user found!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user in the database."); } } catch (Exception e) { showErrorNotification("What the heck!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user or it can not run program 'pdflatex'."); e.printStackTrace(); } // for all entries /* * try { Billing billing = new Billing(Paths.get(basepath, * "WEB-INF/billingTemplates").toFile(), "Angebot.tex"); * billing.setRecieverInstitution("BER - Berliner Flughafen"); * billing.setRecieverPI("Klaus Something"); * billing.setRecieverStreet("am berliner flughafen 12"); * billing.setRecieverPostalCode("D-12345"); billing.setRecieverCity("Berlin"); * * billing.setSenderName("Dr. rer. nat. Stella Autenrieth"); * billing.setSenderFunction("Leiterin"); billing.setSenderPostalCode("72076"); * billing.setSenderCity("Tbingen"); billing.setSenderStreet("Otfried-Mller-Strae 10"); * billing.setSenderPhone("+49 (0) 7071 29-83156"); * billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de"); * billing.setSenderUrl("www.medizin.uni-tuebingen.de"); * billing.setSenderFaculty("Medizinischen Fakultt"); * * billing.setProjectDescription("Dieses Angebot beinhaltet jede Menge Extras."); * billing.setProjectShortDescription("jede Menge Extras."); * billing.setProjectNumber("QA2014016"); * * ArrayList<CostEntry> entries = new ArrayList<CostEntry>(); for (Object itemId : * gpcontainer.getItemIds()) { float cost = ((Number) * gpcontainer.getContainerProperty(itemId, costCaption).getValue()) .floatValue(); long s = * ((Date) gpcontainer.getContainerProperty(itemId, startCaption).getValue()) .getTime(); * long e = ((Date) gpcontainer.getContainerProperty(itemId, * endCaption).getValue()).getTime(); long timeFrame = e - s; Date start = ((Date) * gpcontainer.getContainerProperty(itemId, startCaption).getValue()); SimpleDateFormat ft = * new SimpleDateFormat("dd.MM.yyyy"); String date = ft.format(start); String description = * "No Description is Available"; String time_frame = * Formatter.toHoursAndMinutes(timeFrame); entries.add(billing.new CostEntry(date, * time_frame, description, cost)); } billing.setCostEntries(entries); float totalCosts = * 0.0f; for (Object itemId : gpcontainer.getItemIds()) { totalCosts += ((Number) * gpcontainer.getContainerProperty(itemId, costCaption).getValue()) .floatValue(); } * * billing.setTotalCost(String.format("%1$.2f", totalCosts)); * * bill = billing.createPdf(); System.out.println(bill.getAbsolutePath()); if * (fileDownloader != null) downloadBill.removeExtension(fileDownloader); fileDownloader = * new FileDownloader(new FileResource(bill)); fileDownloader.extend(downloadBill); * downloadBill.setEnabled(true); showSuccessfulNotification("Congratulations!", * "Invoice is created and available for download."); } catch (Exception e) { * showErrorNotification( "What the heck!", * "An error occured while trying to create the invoice. The common problem occurs to be: cannot run program 'pdflatex'" * ); e.printStackTrace(); } */ } }); return gridLayout; }
From source file:facs.components.Statistics.java
License:Open Source License
private Component newMatchedGrid() { Button createInvoiceMatched = new Button("Create Invoice"); Button downloadInvoiceMatched = new Button("Download Invoice"); String buttonRefreshTitle = "Refresh"; Button refreshMatched = new Button(buttonRefreshTitle); refreshMatched.setIcon(FontAwesome.REFRESH); refreshMatched.setDescription("Click here to reload the data from the database!"); refreshMatched.addStyleName(ValoTheme.BUTTON_FRIENDLY); createInvoiceMatched.setEnabled(false); downloadInvoiceMatched.setEnabled(false); Grid matchedGrid; refreshMatched.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496269L; @Override/*from w w w . ja v a2 s .c om*/ public void buttonClick(ClickEvent event) { refreshDataSources(); } }); IndexedContainer mcontainer = getEmptyContainer(); GeneratedPropertyContainer mpc = new GeneratedPropertyContainer(mcontainer); VerticalLayout matchedLayout = new VerticalLayout(); matchedGrid = new Grid(mpc); setRenderers(matchedGrid); fillMatchedRows(matchedGrid); // compute total costs float totalCosts = 0.0f; for (Object itemId : mpc.getItemIds()) totalCosts += ((Number) mpc.getContainerProperty(itemId, costCaption).getValue()).floatValue(); // compute total time in milliseconds long total = 0; for (Object itemId : mpc.getItemIds()) { long s = ((Date) mpc.getContainerProperty(itemId, startCaption).getValue()).getTime(); long e = ((Date) mpc.getContainerProperty(itemId, endCaption).getValue()).getTime(); total += e - s; } // set footer to contain total cost and time in hours:minutes FooterRow footer = matchedGrid.appendFooterRow(); FooterCell footerCellCost = footer.getCell(costCaption); footerCellCost.setText(String.format("%1$.2f total", totalCosts)); FooterCell footerCellEnd = footer.getCell(endCaption); footerCellEnd.setText(Formatter.toHoursAndMinutes(total)); // "%1$.0f hours" // Set up a filter for all columns HeaderRow filterRow = matchedGrid.appendHeaderRow(); addRowFilter(filterRow, deviceCaption, mcontainer, footer, mpc); addRowFilter(filterRow, kostenstelleCaption, mcontainer, footer, mpc); matchedLayout.setMargin(true); matchedLayout.setSpacing(true); // devicesGrid.setWidth("100%"); matchedGrid.setSizeFull(); matchedGrid.setSelectionMode(SelectionMode.SINGLE); matchedLayout.addComponent(matchedGrid); matchedGrid.setSelectionMode(SelectionMode.SINGLE); matchedGrid.addSelectionListener(new SelectionListener() { /** * */ private static final long serialVersionUID = -2683274060620429050L; @Override public void select(SelectionEvent event) { // Notification.show("Select row: " + grid.getSelectedRow() + " Name: " // + gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption).getValue()); downloadInvoiceMatched.setEnabled(false); ReceiverPI = (String) mpc.getContainerProperty(matchedGrid.getSelectedRow(), nameCaption) .getValue(); createInvoiceMatched.setEnabled(true); } }); createInvoiceMatched.addClickListener(new ClickListener() { private File bill; private FileDownloader fileDownloader; @Override public void buttonClick(ClickEvent event) { String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); Paths.get(basepath, "WEB-INF/billingTemplates"); // System.out.println("Basepath: " + basepath); try { int setUserId = DBManager.getDatabaseInstance().findUserByFullName(ReceiverPI); if (setUserId > 0) { Billing billing = new Billing(Paths.get(basepath, "WEB-INF/billingTemplates").toFile(), "Angebot.tex"); UserBean user = setUserId > 0 ? DBManager.getDatabaseInstance().getUserById(setUserId) : null; billing.setReceiverPI(ReceiverPI); billing.setReceiverInstitution(user.getInstitute()); billing.setReceiverStreet(user.getStreet()); billing.setReceiverPostalCode(user.getPostcode()); billing.setReceiverCity(user.getCity()); billing.setSenderName("Dr. rer. nat. Stella Autenrieth"); billing.setSenderFunction("Leiterin"); billing.setSenderPostalCode("72076"); billing.setSenderCity("Tbingen"); billing.setSenderStreet("Otfried-Mller-Strae 10"); billing.setSenderPhone("+49 (0) 7071 29-83156"); billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de"); billing.setSenderUrl("www.medizin.uni-tuebingen.de"); billing.setSenderFaculty("Medizinischen Fakultt"); if (user.getKostenstelle() != null) billing.setProjectDescription("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectDescription("Keine kostenstelle verfgbar."); billing.setProjectShortDescription("Dieses Angebot beinhaltet jede Menge Extras."); if (user.getProject() != null) billing.setProjectNumber("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectNumber("Keine project nummer verfgbar."); float cost = ((Number) mpc.getContainerProperty(matchedGrid.getSelectedRow(), costCaption) .getValue()).floatValue(); long s = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), startCaption) .getValue()).getTime(); long e = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), endCaption) .getValue()).getTime(); long timeFrame = e - s; Date start = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), startCaption) .getValue()); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy"); String date = ft.format(start); String description = "No Description is Available"; String time_frame = Formatter.toHoursAndMinutes(timeFrame); ArrayList<CostEntry> entries = new ArrayList<CostEntry>(); entries.add(billing.new CostEntry(date, time_frame, description, cost)); billing.setCostEntries(entries); float totalCosts = 0.0f; totalCosts = ((Number) mpc.getContainerProperty(matchedGrid.getSelectedRow(), costCaption) .getValue()).floatValue(); billing.setTotalCost(String.format("%1$.2f", totalCosts)); bill = billing.createPdf(); // System.out.println(bill.getAbsolutePath()); if (fileDownloader != null) downloadInvoiceMatched.removeExtension(fileDownloader); fileDownloader = new FileDownloader(new FileResource(bill)); fileDownloader.extend(downloadInvoiceMatched); downloadInvoiceMatched.setEnabled(true); showSuccessfulNotification("Congratulations!", "Invoice is created and available for download."); downloadInvoiceMatched.setEnabled(true); } else { createInvoiceMatched.setEnabled(false); downloadInvoiceMatched.setEnabled(false); showErrorNotification("No such user found!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user in the database."); } } catch (Exception e) { showErrorNotification("What the heck!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user or it can not run program 'pdflatex'."); e.printStackTrace(); } } }); matchedLayout.addComponent(refreshMatched); matchedLayout.addComponent(createInvoiceMatched); matchedLayout.addComponent(downloadInvoiceMatched); return matchedLayout; }
From source file:fi.jasoft.dragdroplayouts.demo.DemoUI.java
License:Apache License
private Grid<DemoView> createViewSelection() { Grid<DemoView> select = new Grid<>(); select.addColumn(view -> view.getCaption()); select.setWidth("200px"); select.setHeight("100%"); select.addSelectionListener((change) -> { navigator.navigateTo(change.getFirstSelectedItem().get().getName()); });// www . j a v a2 s . c o m select.setItems(views); return select; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java
License:Apache License
private Component displayIssueTypes() { VerticalLayout vl = new VerticalLayout(); Grid grid = new Grid(TRANSLATOR.translate(ISSUE_TYPE)); BeanItemContainer<IssueType> types = new BeanItemContainer<>(IssueType.class); types.addAll(new IssueTypeJpaController(DataBaseManager.getEntityManagerFactory()).findIssueTypeEntities()); grid.setContainerDataSource(types);// w ww.j a v a 2s . c om grid.setSelectionMode(SelectionMode.SINGLE); grid.setColumns("typeName", DESC); Grid.Column name = grid.getColumn("typeName"); name.setHeaderCaption(TRANSLATOR.translate("general.name")); name.setConverter(new TranslationConverter()); Grid.Column desc = grid.getColumn(DESC); desc.setHeaderCaption(TRANSLATOR.translate("general.description")); desc.setConverter(new TranslationConverter()); grid.setSizeFull(); vl.addComponent(grid); grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(types.size() > 5 ? 5 : types.size()); //Menu HorizontalLayout hl = new HorizontalLayout(); Button add = new Button(TRANSLATOR.translate("general.create")); add.addClickListener(listener -> { VMWindow w = new VMWindow(); w.setContent(new IssueTypeComponent(new IssueType(), true)); ((VMUI) UI.getCurrent()).addWindow(w); w.addCloseListener(l -> { ((VMUI) UI.getCurrent()).updateScreen(); }); }); hl.addComponent(add); Button delete = new Button(TRANSLATOR.translate("general.delete")); delete.setEnabled(false); delete.addClickListener(listener -> { IssueType selected = (IssueType) ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null && selected.getId() >= 1000) { try { new IssueTypeJpaController(DataBaseManager.getEntityManagerFactory()).destroy(selected.getId()); ((VMUI) UI.getCurrent()).updateScreen(); } catch (IllegalOrphanException | NonexistentEntityException ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate(DELETE_ERROR), TRANSLATOR.translate(DELETE_ERROR), Notification.Type.ERROR_MESSAGE); } } }); hl.addComponent(delete); vl.addComponent(hl); grid.addSelectionListener(event -> { // Java 8 // Get selection from the selection model IssueType selected = (IssueType) ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); //Only delete custom ones. delete.setEnabled(selected != null && selected.getId() >= 1000); }); return vl; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java
License:Apache License
private Component displayIssueResolutions() { VerticalLayout vl = new VerticalLayout(); Grid grid = new Grid(TRANSLATOR.translate(ISSUE_RESOLUTION)); BeanItemContainer<IssueResolution> types = new BeanItemContainer<>(IssueResolution.class); types.addAll(new IssueResolutionJpaController(DataBaseManager.getEntityManagerFactory()) .findIssueResolutionEntities()); grid.setContainerDataSource(types);//from w w w .ja v a 2s .c o m grid.setSelectionMode(SelectionMode.SINGLE); grid.setColumns(NAME); Grid.Column name = grid.getColumn(NAME); name.setHeaderCaption(TRANSLATOR.translate("general.name")); name.setConverter(new TranslationConverter()); grid.setSizeFull(); vl.addComponent(grid); grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(types.size() > 5 ? 5 : types.size()); //Menu HorizontalLayout hl = new HorizontalLayout(); Button add = new Button(TRANSLATOR.translate("general.create")); add.addClickListener(listener -> { VMWindow w = new VMWindow(); w.setContent(new IssueResolutionComponent(new IssueResolution(), true)); ((VMUI) UI.getCurrent()).addWindow(w); w.addCloseListener(l -> { ((VMUI) UI.getCurrent()).updateScreen(); }); }); hl.addComponent(add); Button delete = new Button(TRANSLATOR.translate("general.delete")); delete.setEnabled(false); delete.addClickListener(listener -> { IssueResolution selected = (IssueResolution) ((SingleSelectionModel) grid.getSelectionModel()) .getSelectedRow(); if (selected != null && selected.getId() >= 1000) { try { new IssueResolutionJpaController(DataBaseManager.getEntityManagerFactory()) .destroy(selected.getId()); ((VMUI) UI.getCurrent()).updateScreen(); } catch (IllegalOrphanException | NonexistentEntityException ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate(DELETE_ERROR), TRANSLATOR.translate(DELETE_ERROR), Notification.Type.ERROR_MESSAGE); } } }); hl.addComponent(delete); vl.addComponent(hl); grid.addSelectionListener(event -> { // Java 8 // Get selection from the selection model IssueResolution selected = (IssueResolution) ((SingleSelectionModel) grid.getSelectionModel()) .getSelectedRow(); //Only delete custom ones. delete.setEnabled(selected != null && selected.getId() >= 1000); }); return vl; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java
License:Apache License
private Component displayRequirementTypes() { VerticalLayout vl = new VerticalLayout(); Grid grid = new Grid(TRANSLATOR.translate(REQUIREMENT_TYPE)); BeanItemContainer<RequirementType> types = new BeanItemContainer<>(RequirementType.class); types.addAll(new RequirementTypeJpaController(DataBaseManager.getEntityManagerFactory()) .findRequirementTypeEntities()); grid.setContainerDataSource(types);/*from w w w .j av a 2 s .c om*/ grid.setSelectionMode(SelectionMode.SINGLE); grid.setColumns(NAME, DESC); Grid.Column name = grid.getColumn(NAME); name.setHeaderCaption(TRANSLATOR.translate("general.name")); name.setConverter(new TranslationConverter()); Grid.Column desc = grid.getColumn(DESC); desc.setHeaderCaption(TRANSLATOR.translate("general.description")); desc.setConverter(new TranslationConverter()); grid.setSizeFull(); vl.addComponent(grid); grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(types.size() > 5 ? 5 : types.size()); //Menu HorizontalLayout hl = new HorizontalLayout(); Button add = new Button(TRANSLATOR.translate("general.create")); add.addClickListener(listener -> { VMWindow w = new VMWindow(); w.setContent(new RequirementTypeComponent(new RequirementType(), true)); ((VMUI) UI.getCurrent()).addWindow(w); w.addCloseListener(l -> { ((VMUI) UI.getCurrent()).updateScreen(); }); }); hl.addComponent(add); Button delete = new Button(TRANSLATOR.translate("general.delete")); delete.setEnabled(false); delete.addClickListener(listener -> { RequirementType selected = (RequirementType) ((SingleSelectionModel) grid.getSelectionModel()) .getSelectedRow(); if (selected != null && selected.getId() >= 1000) { try { new RequirementTypeJpaController(DataBaseManager.getEntityManagerFactory()) .destroy(selected.getId()); ((VMUI) UI.getCurrent()).updateScreen(); } catch (IllegalOrphanException | NonexistentEntityException ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate(DELETE_ERROR), TRANSLATOR.translate(DELETE_ERROR), Notification.Type.ERROR_MESSAGE); } } }); hl.addComponent(delete); vl.addComponent(hl); grid.addSelectionListener(event -> { // Java 8 // Get selection from the selection model RequirementType selected = (RequirementType) ((SingleSelectionModel) grid.getSelectionModel()) .getSelectedRow(); //Only delete custom ones. delete.setEnabled(selected != null && selected.getId() >= 1000); }); return vl; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.notification.NotificationScreenProvider.java
License:Apache License
@Override public Component getContent() { VerticalLayout vs = new VerticalLayout(); //On top put a list of notifications BeanItemContainer<Notification> container = new BeanItemContainer<>(Notification.class); ValidationManagerUI.getInstance().getUser().getNotificationList().forEach(n -> { container.addBean(n);//from w ww.j a va 2 s. c o m }); // Unable to use VerticalSplitPanel as I hoped. // See: https://github.com/vaadin/framework/issues/9460 // VerticalSplitPanel vs = new VerticalSplitPanel(); // vs.setSplitPosition(25, Sizeable.Unit.PERCENTAGE); TextArea text = new TextArea(TRANSLATOR.translate("general.text")); text.setWordwrap(true); text.setReadOnly(true); text.setSizeFull(); Grid grid = new Grid(TRANSLATOR.translate("general.notifications"), container); grid.setColumns("notificationType", "author", "creationDate", "archieved"); if (container.size() > 0) { grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(container.size() > 5 ? 5 : container.size()); } GridCellFilter filter = new GridCellFilter(grid); filter.setBooleanFilter("archieved", new GridCellFilter.BooleanRepresentation(VaadinIcons.CHECK, TRANSLATOR.translate("general.yes")), new GridCellFilter.BooleanRepresentation(VaadinIcons.CLOSE, TRANSLATOR.translate("general.no"))); filter.setDateFilter("creationDate", new SimpleDateFormat(VMSettingServer.getSetting("date.format").getStringVal()), true); grid.sort("creationDate"); Column nt = grid.getColumn("notificationType"); nt.setHeaderCaption(TRANSLATOR.translate("notification.type")); nt.setConverter(new Converter<String, NotificationType>() { @Override public NotificationType convertToModel(String value, Class<? extends NotificationType> targetType, Locale locale) throws Converter.ConversionException { for (NotificationType n : new NotificationTypeJpaController( DataBaseManager.getEntityManagerFactory()).findNotificationTypeEntities()) { if (Lookup.getDefault().lookup(InternationalizationProvider.class).translate(n.getTypeName()) .equals(value)) { return n; } } return null; } @Override public String convertToPresentation(NotificationType value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { return Lookup.getDefault().lookup(InternationalizationProvider.class) .translate(value.getTypeName()); } @Override public Class<NotificationType> getModelType() { return NotificationType.class; } @Override public Class<String> getPresentationType() { return String.class; } }); Column author = grid.getColumn("author"); author.setConverter(new UserToStringConverter()); author.setHeaderCaption(TRANSLATOR.translate("notification.author")); Column creation = grid.getColumn("creationDate"); creation.setHeaderCaption(TRANSLATOR.translate("creation.time")); Column archive = grid.getColumn("archieved"); archive.setHeaderCaption(TRANSLATOR.translate("general.archived")); archive.setConverter(new Converter<String, Boolean>() { @Override public Boolean convertToModel(String value, Class<? extends Boolean> targetType, Locale locale) throws Converter.ConversionException { return value.equals(TRANSLATOR.translate("general.yes")); } @Override public String convertToPresentation(Boolean value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { return value ? TRANSLATOR.translate("general.yes") : TRANSLATOR.translate("general.no"); } @Override public Class<Boolean> getModelType() { return Boolean.class; } @Override public Class<String> getPresentationType() { return String.class; } }); grid.setSelectionMode(SelectionMode.SINGLE); grid.setSizeFull(); ContextMenu menu = new ContextMenu(grid, true); menu.addItem(TRANSLATOR.translate("notification.mark.unread"), (MenuItem selectedItem) -> { Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { NotificationServer ns = new NotificationServer((Notification) selected); ns.setAcknowledgeDate(null); try { ns.write2DB(); ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } }); menu.addItem(TRANSLATOR.translate("notification.archive"), (MenuItem selectedItem) -> { Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { NotificationServer ns = new NotificationServer((Notification) selected); ns.setArchieved(true); try { ns.write2DB(); ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } }); grid.addSelectionListener(selectionEvent -> { // Get selection from the selection model Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { text.setReadOnly(false); Notification n = (Notification) selected; text.setValue(n.getContent()); text.setReadOnly(true); if (n.getAcknowledgeDate() != null) { try { //Mark as read NotificationServer ns = new NotificationServer((Notification) n); ns.setAcknowledgeDate(new Date()); ns.write2DB(); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } } }); vs.addComponent(grid); vs.addComponent(text); vs.setSizeFull(); vs.setId(getComponentCaption()); return vs; }