List of usage examples for com.vaadin.ui Window Window
public Window(String caption)
From source file:at.meikel.nentis.Nentis.java
License:Apache License
private void initMain(TabSheet tabSheet) { final VerticalLayout mainTab = new VerticalLayout(); tabSheet.addTab(mainTab);//from w w w.j ava 2s .com tabSheet.getTab(mainTab).setCaption("Main"); final HorizontalLayout buttons = new HorizontalLayout(); mainTab.addComponent(buttons); final VerticalLayout state = new VerticalLayout(); mainTab.addComponent(state); final VerticalLayout info = new VerticalLayout(); mainTab.addComponent(info); Button createTicket = new Button("Create a new ticket"); createTicket.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent clickEvent) { state.removeAllComponents(); Ticket ticket = nentisApi.createTicket("Ticket (" + new Date() + ")"); state.addComponent( new Label("Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created.")); } }); buttons.addComponent(createTicket); Button listAllTickets = new Button("List all existing tickets"); listAllTickets.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent clickEvent) { state.removeAllComponents(); List<Ticket> allTickets = nentisApi.getAllTickets(); info.removeAllComponents(); if (allTickets != null) { for (Ticket ticket : allTickets) { info.addComponent(new Label( "Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created.")); } } } }); buttons.addComponent(listAllTickets); final Button openSubWindow = new Button("Open a sub window"); openSubWindow.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent clickEvent) { buttons.removeComponent(openSubWindow); Window subWindow = new Window("Sub window"); mainWindow.addWindow(subWindow); } }); buttons.addComponent(openSubWindow); }
From source file:at.meikel.sudoku.MyVaadinApplication.java
License:Apache License
@Override public void init() { window = new Window("My Vaadin Application"); setMainWindow(window);/*from w w w .ja va 2s. c o m*/ Button button = new Button("Click Me"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { window.addComponent(new Label("Thank you for clicking")); } }); window.addComponent(button); }
From source file:at.peppol.webgui.app.components.InvoiceLineWindow.java
License:Mozilla Public License
public InvoiceLineWindow(final TabInvoiceLine parent) { this.parent = parent; invln = new InvoiceLineAdapter(); // line = new Line(); // BeanItem<InvoiceLineAdapter> invoiceLine = new BeanItem<InvoiceLineAdapter>(invln); // parent.setItemDataSource(invoiceLine); // BeanItem<Line> invoiceLine = new BeanItem<Line>(line); // parent.setItemDataSource(invoiceLine); subwindow = new Window("Invoice Line"); subwindow.setModal(true);/* www.j a va 2s . c o m*/ VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); Button btnClose = new Button("Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); Button btnSave = new Button("Save", new Button.ClickListener() { public void buttonClick(ClickEvent event) { //update GUI table !! ///parent.getTable().addInvoiceLine (invln); //update actual invoice line item ///parent.items.add (invln); //close popup (subwindow.getParent()).removeWindow(subwindow); } }); try { layout.addComponent(createInvoiceLineForm()); } catch (Exception e) { e.printStackTrace(); } layout.addComponent(btnSave); layout.addComponent(btnClose); layout.setComponentAlignment(btnClose, Alignment.BOTTOM_RIGHT); }
From source file:at.peppol.webgui.app.components.InvoiceTabForm.java
License:Mozilla Public License
private void initElements() { supplierForm = new PartyDetailForm("Supplier", supplier.getParty()); supplierForm.setImmediate(true);//from w w w .j a v a 2s . co m customerForm = new PartyDetailForm("Customer", customer.getParty()); customerForm.setImmediate(true); //supplierForm.setSizeFull (); //customerForm.setSizeFull (); final HorizontalLayout footerLayout = new HorizontalLayout(); footerLayout.setSpacing(true); footerLayout.setMargin(true); footerLayout.addComponent(new Button("Save Invoice", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { SetCommonCurrency(); ValidatorHandler vh = new ValidatorHandler(footerLayout); AbstractUBLDocumentMarshaller.setGlobalValidationEventHandler(vh); vh.clearErrors(); clearTabErrorStyles(); boolean invoiceHasErrors = false; List<ValidationError> errors = GlobalValidationsRegistry.runAll(); if (errors.size() > 0) { invoiceHasErrors = true; Window errorWindow = new Window("Errors"); //position and size of the window errorWindow.setPositionX(200); errorWindow.setPositionY(200); errorWindow.setWidth("600px"); errorWindow.setHeight("300px"); //add the error messages String errorMessage = "<ol>"; for (int i = 0; i < errors.size(); i++) { errorMessage += "<li style=\"margin-top: 4px;\"><b>" + errors.get(i).getRuleID() + "</b>: " + errors.get(i).getErrorInfo() + "</li>"; //mark the appropriate Tab as error Tab tab = invTabSheet.getTab(errors.get(i).getMainComponent()); if (tab != null) tab.setStyleName("test111"); } errorMessage += "</ol>"; errorWindow.addComponent(new Label(errorMessage, Label.CONTENT_XHTML)); //show the error window getParent().getWindow().addWindow(errorWindow); errors.clear(); } ValidatorsList.validateListenersNotify(); if (ValidatorsList.validateListeners() == false) { invoiceHasErrors = true; } if (invoiceHasErrors) { getWindow().showNotification("Validation error. Could not save invoice", Notification.TYPE_TRAY_NOTIFICATION); } else { try { if (invoiceFilePath.equals("")) { UBL20DocumentMarshaller.writeInvoice(invoice, new StreamResult(new File(um.getDrafts().getFolder().toString() + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis() + ".xml"))); invoiceFilePath = um.getDrafts().getFolder().toString() + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis() + ".xml"; } else { UBL20DocumentMarshaller.writeInvoice(invoice, new StreamResult(new File(invoiceFilePath))); } getWindow() .showNotification( "Validation passed. Invoice saved in " + um.getDrafts().getName().toUpperCase() + " folder", Notification.TYPE_TRAY_NOTIFICATION); } catch (Exception e) { getWindow().showNotification("Disk access error. Could not save invoice", Notification.TYPE_ERROR_MESSAGE); } } /*PEPPOL validation * final ValidationPyramid vp = new ValidationPyramid (EValidationDocumentType.INVOICE, ValidationTransaction.createUBLTransaction (ETransaction.T10)); final List <ValidationPyramidResultLayer> aResults = vp.applyValidation (new FileSystemResource ("invoice.xml")) .getAllValidationResultLayers (); if (aResults.isEmpty ()) System.out.println (" The document is valid!"); else for (final ValidationPyramidResultLayer aResultLayer : aResults) for (final IResourceError aError : aResultLayer.getValidationErrors ()) System.out.println (" " + aResultLayer.getValidationLevel () + " " + aError.getAsString (Locale.US)); */ /*ValidatorsList.validateListenersNotify(); if (ValidatorsList.validateListeners() == false) { getParent().getWindow().showNotification("Validation error... ",Notification.TYPE_TRAY_NOTIFICATION); } else getParent().getWindow().showNotification("Validation passed! ",Notification.TYPE_TRAY_NOTIFICATION); */ } })); /* footerLayout.addComponent (new Button ("Save Invoice", new Button.ClickListener () { @Override public void buttonClick (final Button.ClickEvent event) { try { SetCommonCurrency (); System.out.println (invoice.getDelivery ().get (0).getDeliveryAddress ().getStreetName ().getValue ()); } catch (final Exception ex) { LOGGER.error ("Error creating files. ", ex); } } })); */ footerLayout.addComponent(new Button("Read Invoice from disk", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { try { SetCommonCurrency(); InvoiceType inv = UBL20DocumentMarshaller .readInvoice(new StreamSource(new FileInputStream(new File("invoice.xml")))); } catch (final Exception ex) { LOGGER.error("Error creating files. ", ex); } } })); getFooter().addComponent(footerLayout); }
From source file:at.peppol.webgui.app.components.InvoiceUploadWindow.java
License:Mozilla Public License
public InvoiceUploadWindow() { this.setSpacing(true); subwindow = new Window("Upload Invoice"); subwindow.addComponent(status);/*ww w . j a v a 2s. c om*/ subwindow.addComponent(progressLayout); subwindow.addComponent(upload); subwindow.addStyleName("upload-popup"); subwindow.setModal(true); upload.setImmediate(true); upload.setButtonCaption("Select local invoice"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(pi); progressLayout.setComponentAlignment(pi, Alignment.MIDDLE_LEFT); final Button cancelProcessing = new Button("Cancel"); cancelProcessing.addListener(new Button.ClickListener() { @Override public void buttonClick(final com.vaadin.ui.Button.ClickEvent event) { upload.interruptUpload(); } }); cancelProcessing.setStyleName("small"); progressLayout.addComponent(cancelProcessing); upload.addListener(new Upload.StartedListener() { @Override public void uploadStarted(final StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); progressLayout.setVisible(true); pi.setValue(Float.valueOf(0f)); pi.setPollingInterval(500); status.setValue("Uploading file \"" + event.getFilename() + "\""); } }); upload.addListener(new Upload.ProgressListener() { public void updateProgress(final long readBytes, final long contentLength) { // This method gets called several times during the update pi.setValue(new Float(readBytes / (float) contentLength)); } }); upload.addListener(new Upload.SucceededListener() { @Override public void uploadSucceeded(final SucceededEvent event) { // This method gets called when the upload finished successfully status.setValue("Uploading file \"" + event.getFilename() + "\" succeeded"); if (ur != null) { ur.setSuccess(true); } else { logger.warn("Invoice upload succeeded, but no Upload request present!"); } } }); upload.addListener(new Upload.FailedListener() { @Override public void uploadFailed(final FailedEvent event) { status.setValue("Uploading interrupted"); if (ur != null) { ur.setSuccess(false); } else { logger.warn("Invoice upload failed, but no Upload request present!"); } } }); upload.addListener(new Upload.FinishedListener() { @Override public void uploadFinished(final FinishedEvent event) { // This method gets called always when the upload finished, either // succeeding or failing progressLayout.setVisible(false); upload.setVisible(true); upload.setCaption("Select another file more filesss"); } }); }
From source file:at.peppol.webgui.app.components.OrderUploadWindow.java
License:Mozilla Public License
public OrderUploadWindow() { this.setSpacing(true); subwindow = new Window("Upload Order"); subwindow.addComponent(status);// w w w . ja v a 2 s . c o m subwindow.addComponent(progressLayout); subwindow.addComponent(upload); subwindow.addStyleName("upload-popup"); subwindow.setModal(true); upload.setImmediate(true); upload.setButtonCaption("Select local order"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(pi); progressLayout.setComponentAlignment(pi, Alignment.MIDDLE_LEFT); final Button cancelProcessing = new Button("Cancel"); cancelProcessing.addListener(new Button.ClickListener() { @Override public void buttonClick(final com.vaadin.ui.Button.ClickEvent event) { upload.interruptUpload(); } }); cancelProcessing.setStyleName("small"); progressLayout.addComponent(cancelProcessing); upload.addListener(new Upload.StartedListener() { @Override public void uploadStarted(final StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); progressLayout.setVisible(true); pi.setValue(Float.valueOf(0f)); pi.setPollingInterval(500); status.setValue("Uploading file \"" + event.getFilename() + "\""); } }); upload.addListener(new Upload.ProgressListener() { public void updateProgress(final long readBytes, final long contentLength) { // This method gets called several times during the update pi.setValue(new Float(readBytes / (float) contentLength)); } }); upload.addListener(new Upload.SucceededListener() { @Override public void uploadSucceeded(final SucceededEvent event) { // This method gets called when the upload finished successfully status.setValue("Uploading file \"" + event.getFilename() + "\" succeeded"); if (ur != null) ur.setSuccess(true); else logger.warn("Order upload succeeded, but no Upload request present!"); } }); upload.addListener(new Upload.FailedListener() { @Override public void uploadFailed(final FailedEvent event) { status.setValue("Uploading interrupted"); if (ur != null) ur.setSuccess(false); else logger.warn("Order upload failed, but no Upload request present!"); } }); upload.addListener(new Upload.FinishedListener() { @Override public void uploadFinished(final FinishedEvent event) { // This method gets called always when the upload finished, either // succeeding or failing progressLayout.setVisible(false); upload.setVisible(true); upload.setCaption("Select another file"); } }); }
From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.topic.accounting.AccountingQuestionManager.java
License:LGPL
public AccountingQuestionManager(String quizName) { super(quizName); Button openKontenplan = new Button("Open Kontenplan"); openKontenplan.addClickListener(e -> { openKontenplan.setEnabled(false); // Create Window with layout Window window = new Window("Kontenplan"); GridLayout layout = new GridLayout(1, 1); layout.addComponent(AccountingDataProvider.getInstance().toHtmlTable()); layout.setSizeFull();/*from w w w. j a va 2 s . c o m*/ window.setContent(layout); window.center(); window.setWidth("60%"); window.setHeight("80%"); window.setResizable(false); window.addCloseListener(e1 -> openKontenplan.setEnabled(true)); getUI().addWindow(window); }); addHelpButton(openKontenplan); }
From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.VaadinResultView.java
License:LGPL
public VaadinResultView(ResultFiredArgs args, String title) { setSpacing(true);/*from w w w . j a v a 2 s. c o m*/ addComponent(new HtmlLabel(title)); addComponent(HtmlLabel.getCenteredLabel("h2", "Finished test")); addComponent(HtmlLabel.getCenteredLabel("The test ended, because we " + (args.outOfQuestions ? "did not have any more questions" : "determined your skill level"))); addComponent(HtmlLabel.getCenteredLabel( "This are the difficulties and your answers. On top are your last answers. The first column indicates the difficulty.")); addComponent(HtmlLabel.getCenteredLabel( "Closer to -INF means easy question, to +INF dificult questions. This also applies to your skill level!")); // Create HTML table of the history Table table = new Table(); final String solution = "Solution", userAnswewr = "Yourt answer"; table.addContainerProperty("Question difficulty", Float.class, null); table.addContainerProperty("Result", String.class, null); table.addContainerProperty(userAnswewr, Button.class, null); table.addContainerProperty(solution, Button.class, null); List<HistoryEntry> entries = Lists.reverse(args.history); for (HistoryEntry entry : entries) { Button qAnswer = null, qSolution = null; if (entry.question instanceof Component && entry.question != null) { try { Class<? extends AnswerStorage> dataStorageClass = entry.question.getSolution().getClass(); Constructor<? extends IQuestion> constructor = entry.question.getClass() .getConstructor(dataStorageClass, dataStorageClass, float.class, String.class); // The following casts can not fail, because the question is // a component as well Component iQuestionSolution = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getSolution(), entry.question.getDifficulty(), entry.question.getQuestionText()); Component iQuestionUser = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getUserAnswer(), entry.question.getDifficulty(), entry.question.getQuestionText()); // Create the 2 needed click listeners ClickListener clickListenerSol = event -> { Window window = new Window(solution); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionSolution); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionSolution instanceof Sizeable) { Sizeable sizeable = iQuestionSolution; sizeable.setSizeFull(); } getUI().addWindow(window); }; ClickListener clickListenerUA = event -> { Window window = new Window(userAnswewr); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionUser); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionUser instanceof Sizeable) { Sizeable sizeable = iQuestionUser; sizeable.setSizeFull(); } getUI().addWindow(window); }; // Create the two buttons qAnswer = new Button(userAnswewr, clickListenerUA); qSolution = new Button(solution, clickListenerSol); } catch (Exception e) { // Ignore this line in the table LogHelper.logInfo("1 entry's solution/ user answer are missing on the final screen." + entry.question.getClass().getName() + " does not implement the constructors required by" + IQuestion.class.getName()); } } table.addItem(new Object[] { entry.question.getDifficulty(), isCorrect(entry.points, entry.question.getMaxPoints()), qAnswer, qSolution }, null); } int size = table.size(); if (size > 10) { size = 10; } table.setPageLength(size); addComponent(table); setComponentAlignment(table, Alignment.MIDDLE_CENTER); addComponent(HtmlLabel.getCenteredLabel("h3", "Your skill level is: <b>" + args.skillLevel + "</b>")); addComponent(HtmlLabel.getCenteredLabel("Delta (Valus close to 0 are best): " + args.delta)); }
From source file:au.org.scoutmaster.views.ContactView.java
private void showMailForm(final TextField emailField) { final Window mailWindow = new Window("Send Email"); mailWindow.setWidth("80%"); mailWindow.setHeight("80%"); final User sender = (User) getSession().getAttribute("user"); mailWindow.setContent(new EmailForm(mailWindow, sender, getCurrent(), emailField.getValue())); mailWindow.setVisible(true);/*from www . j a va2s . c om*/ mailWindow.center(); UI.getCurrent().addWindow(mailWindow); }
From source file:br.com.anteros.mobileserver.util.UserMessages.java
License:Apache License
public Window confirm(String title, String message, String okTitle, String cancelTitle, Button.ClickListener listener) { if (title == null) { title = CONFIRM_OK_TITLE;//w w w . j a v a2 s.com } if (cancelTitle == null) { cancelTitle = CONFIRM_CANCEL_TITLE; } if (okTitle == null) { okTitle = CONFIRM_OK_TITLE; } final Window confirm = new Window(title); this.confirm = confirm; win.addWindow(confirm); confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { Object data = ce.getWindow().getData(); if (data != null) { try { } catch (Exception exception) { error("Unhandled Exception", exception); } } } }); int chrW = 5; int chrH = 15; int txtWidth = Math.max(250, Math.min(350, message.length() * chrW)); int btnHeight = 25; int vmargin = 100; int hmargin = 40; int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth; confirm.setWidth((txtWidth + hmargin) + "px"); confirm.setHeight((vmargin + txtHeight + btnHeight) + "px"); confirm.getContent().setSizeFull(); confirm.center(); confirm.setModal(true); Label text = new Label(message); text.setWidth("100%"); text.setHeight("100%"); HorizontalLayout buttons = new HorizontalLayout(); buttons.setHeight(btnHeight + 5 + "px"); buttons.setWidth("100%"); buttons.setSpacing(true); buttons.setMargin(false); Button cancel = new Button(cancelTitle, listener); cancel.setIcon(new ThemeResource("icons/16/no.png")); cancel.setData(USER_CONFIRM_CANCEL); cancel.setClickShortcut(KeyCode.ESCAPE); Button ok = new Button(okTitle, listener); ok.setIcon(new ThemeResource("icons/16/yes.png")); ok.setData(USER_CONFIRM_OK); ok.setClickShortcut(KeyCode.ENTER); buttons.addComponent(ok); buttons.setExpandRatio(ok, 1); buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT); buttons.addComponent(cancel); buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT); confirm.addComponent(text); confirm.addComponent(buttons); ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f); confirm.setResizable(false); return confirm; }