Example usage for com.vaadin.ui Notification show

List of usage examples for com.vaadin.ui Notification show

Introduction

In this page you can find the example usage for com.vaadin.ui Notification show.

Prototype

public static Notification show(String caption, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:com.thingtrack.vaadin.desktop.MyVaadinUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();// www .  j  av a2 s . com
    mainLayout.setMargin(true);
    setContent(mainLayout);

    mainLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    textArea = new TextArea();
    textArea.setInputPrompt("Send message");
    mainLayout.addComponent(textArea);

    Button button = new Button("Send");
    button.setImmediate(true);
    button.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            if (publisher == null) {
                publisher = new Publisher();
                publisher.start();
            }

            String message = textArea.getValue();

            try {
                publisher.send(message);
            } catch (MqttException e) {
                Notification.show(e.getMessage(), Type.ERROR_MESSAGE);
            }
        }
    });

    mainLayout.addComponent(button);
}

From source file:com.timtripcony.AbstractDocumentMapModel.java

License:Apache License

/**
 * Overloaded save method, allowing navigation handling to force return to a
 * view, if required//from   w  w w  .ja  v  a2 s  .  c om
 *
 * @param goToView
 *            boolean whether or not to go to the view
 * @return String navigationRule name (defaults are xsp-success for going to
 *         next page, xsp-current to stay on current page)
 */
public String save(boolean goToView) {
    String retVal_ = "";
    try {
        if (save()) {
            if (goToView) {
                retVal_ = "xsp-success";
            } else {
                retVal_ = "xsp-current";
            }
        } else {
            Notification.show("Save failed", com.vaadin.ui.Notification.Type.ERROR_MESSAGE);
        }
    } catch (final Throwable t) {
        KeyDateDatabaseUtils.handleException(t);
    }
    return retVal_;
}

From source file:com.trender.user.component.UserForm.java

private void singIn() {
    try {/*from   w  w  w .  ja  v a2 s  .c  o m*/
        emailField.validate();
        passwordField.validate();
        if (passwordField.isValid() && emailField.isValid()) {
            // ?   ? 
            Notification.show("ok", Notification.Type.ERROR_MESSAGE);
        }
    } catch (Validator.InvalidValueException e) {
        Notification.show(" ? ? !",
                Notification.Type.ERROR_MESSAGE);
    }
}

From source file:com.trender.user.component.UserForm.java

private void singUp() {
    try {/*w  w w. jav a2  s  .c  o m*/
        emailField.validate();
        passwordField.validate();
        surnameField.validate();
        nameField.validate();
        if (emailField.isValid() && passwordField.isValid() && surnameField.isValid() && nameField.isValid()) {

            User user = new User();
            user.setEmail(emailField.getValue());
            user.setFirstName(surnameField.getValue());
            user.setPassword(Hash.getPassword(passwordField.getValue()));
            user.setSecondName(nameField.getValue());

            Set<Role> role = new HashSet<>();
            role.add(roleService.getById(2L));
            user.setRoles(role);

            userService.create(user);
            Notification.show(
                    " ? ??!   ?   !",
                    Notification.Type.TRAY_NOTIFICATION);
            loginForm();
        }
    } catch (Validator.InvalidValueException e) {
        Notification.show(" ? ? !",
                Notification.Type.ERROR_MESSAGE);
    } catch (ServiceException ex) {
        Notification.show(" ??   !",
                Notification.Type.TRAY_NOTIFICATION);
        Logger.getLogger(IndexPageView.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.trender.user.component.UserForm.java

private void chengProfil() {
    try {//from   www. ja  va  2  s  . c om
        passwordField.validate();
        surnameField.validate();
        nameField.validate();
        if (passwordField.isValid() && surnameField.isValid() && nameField.isValid()) {

            User user = new User();
            user.setFirstName(surnameField.getValue());
            user.setPassword(Hash.getPassword(passwordField.getValue()));
            user.setSecondName(nameField.getValue());

            Set<Role> role = new HashSet<>();
            role.add(roleService.getById(2L));
            user.setRoles(role);

            userService.create(user);
            Notification.show(
                    " ? ??!   ?   !",
                    Notification.Type.TRAY_NOTIFICATION);
            loginForm();
        }
    } catch (Validator.InvalidValueException e) {
        Notification.show(" ? ? !",
                Notification.Type.ERROR_MESSAGE);
    } catch (ServiceException ex) {
        Notification.show(" ??   !",
                Notification.Type.TRAY_NOTIFICATION);
        Logger.getLogger(IndexPageView.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.ui.UploadStatePanel.java

License:Apache License

private boolean isValidFileSize(StreamVariable.StreamingStartEvent event) {
    if (event.getContentLength() > multiUpload.getMaxFileSize() || event.getContentLength() <= 0) {
        //the client side file size check may not work in old browsers
        interruptUpload(uploadQueue.get(0));
        String formattedErrorMsg = UploadUtil.getSizeErrorMessage(multiUpload.getSizeErrorMsg(),
                multiUpload.getMaxFileSize(), event.getContentLength(), event.getFileName());
        Notification.show(formattedErrorMsg, Notification.Type.WARNING_MESSAGE);
        return false;
    }// w  w w.  j a v a2 s.  com
    return true;
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.ui.UploadStatePanel.java

License:Apache License

private boolean isValidMimeType(StreamVariable.StreamingStartEvent event) {
    if (multiUpload.getAcceptedMimeTypes() != null && !multiUpload.getAcceptedMimeTypes().isEmpty()
            && !multiUpload.getAcceptedMimeTypes().contains(event.getMimeType())) {
        logger.log(Level.FINE, "Mime type is not valid! File name: {0}, Mime type: {1}",
                new Object[] { event.getFileName(), event.getMimeType() });

        interruptUpload(uploadQueue.get(0));
        String formattedErrorMsg = UploadUtil.getMimeTypeErrorMessage(multiUpload.getMimeTypeErrorMsgPattern(),
                event.getFileName());/*  w  w  w .  j av  a2s . co m*/
        Notification.show(formattedErrorMsg, Notification.Type.WARNING_MESSAGE);
        return false;
    }

    return true;
}

From source file:com.wcs.wcslib.vaadin.widget.recaptcha.demo.DummyRegWithReCaptcha.java

License:Apache License

@Override
public void buttonClick(Button.ClickEvent event) {
    try {//from   w ww . ja va 2 s.  c  om
        fieldGroup.commit();
    } catch (FieldGroup.CommitException ex) {
        Notification.show("All fields are required!", Notification.Type.ERROR_MESSAGE);
        fieldGroup.discard();
        return;
    }
    if (!regBean.password.equals(regBean.passwordAgain)) {
        Notification.show("passwords do not match", Notification.Type.ERROR_MESSAGE);
        regBean.password = "";
        regBean.passwordAgain = "";
        fieldGroup.discard();
        return;
    }

    //captcha should be the last validation
    if (!reCaptcha.validate()) {
        if (++captchaFailCount > 2) {
            content.setEnabled(false);
            Notification.show("You are an evil bot!", Notification.Type.ERROR_MESSAGE);
        } else {
            if (!reCaptcha.isEmpty()) {
                Notification.show("Invalid Captcha!", Notification.Type.ERROR_MESSAGE);
                reCaptcha.reload();
            } else {
                Notification.show("Please fill the captcha!", Notification.Type.ERROR_MESSAGE);
            }
        }
        return;
    }

    //after a successfull captcha validation you should hide it
    //since you can use a code just once
    content.removeAllComponents();
    content.addComponent(new Label("Congratulations!"));
}

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  www  .  ja  va 2 s .  c o  m*/
        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 uriFragmentChanged(String frag) {
    try {/*from w  w w .  j av a  2 s .  c om*/
        String reportPath = EBRConf.INSTANCE.getValue(EBRParams.REPORTS_JRXML_PATH,
                "/home/myururdurmaz/reports");
        File reportDir = new File(reportPath);
        File reportFile = new File(reportDir, frag);
        if (reportFile.exists()) {
            if (FilenameUtils.getExtension(reportFile.getName()).equalsIgnoreCase("sql")) {
                sql = FileUtils.readFileToString(reportFile, "utf-8").trim();
                report = sqlReport;
                reportDefinition = ((SQLReport) report).loadDefinition(JasperReport.getReportFile(frag));
            } else if (FilenameUtils.getExtension(reportFile.getName()).equalsIgnoreCase("jrxml")) {
                sql = "";
                report = jasperReport;
                reportDefinition = ((JasperReport) report).loadDefinition(JasperReport.getReportFile(frag));
            } else {
                Notification.show(frag + " bilinmeyen rapor tr", Notification.Type.ERROR_MESSAGE);
            }
            this.reportName = frag;
            showFields(reportDefinition, window, formLayout);
        } else {
            Notification.show(frag + " raporu sisteminizde yok", Notification.Type.ERROR_MESSAGE);
        }
    } catch (IOException | ReportException ex) {
        Notification.show("Hata", Notification.Type.ERROR_MESSAGE);
        Logger.getLogger(ReportWindow.class.getName()).log(Level.SEVERE, null, ex);
    }
}