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) 

Source Link

Document

Shows a notification message on the middle of the current page.

Usage

From source file:com.klwork.explorer.NotificationManager.java

License:Apache License

public void showWarningNotification(String captionKey, String descriptionKey, Object... params) {
    Notification notification = new Notification(i18nManager.getMessage(captionKey) + "<br/>",
            MessageFormat.format(i18nManager.getMessage(descriptionKey), params),
            Notification.Type.WARNING_MESSAGE);
    notification.setDelayMsec(5000); // click to hide
    notification.show(Page.getCurrent());
}

From source file:com.lst.deploymentautomation.vaadin.core.AppFormConnector.java

License:Open Source License

@Override
public void showNotification(Notification notif) {
    notif.show(Page.getCurrent());
}

From source file:com.lst.deploymentautomation.vaadin.core.LspsUI.java

License:Open Source License

/**
 * Shows informational message to the user.
 * @param key/* w w  w .  j  ava  2  s  .c  o m*/
 * @param args
 */
public void showInfoMessage(String key, Object... args) {
    String msg = getMessage(key, args);
    Notification.show(msg);
}

From source file:com.lst.deploymentautomation.vaadin.core.LspsUI.java

License:Open Source License

/**
 * Shows an error message to the user. If an exception is passed as an argument, it's message is used as the error message detail.
 * @param key/*from  w  w  w .ja v a 2s . c o  m*/
 * @param e
 * @param args
 */
public void showErrorMessage(String key, Throwable e, Object... args) {
    String msg = getMessage(key, args);
    String detail = e == null ? null : e.getMessage() == null ? e.toString() : e.getMessage();
    Notification notification = new Notification(msg, detail, Notification.Type.ERROR_MESSAGE);
    notification.show(getPage());
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private void showNotification(Notification notification) {
    // keep the notification visible a little while after moving the
    // mouse, or until clicked
    notification.setDelayMsec(2000);// w  w  w .  j av a 2s .c o m
    notification.show(Page.getCurrent());
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java

License:Apache License

public ProductForm(SampleCrudLogic sampleCrudLogic) {
    viewLogic = sampleCrudLogic;//from   www. ja  va 2  s  .c  om
    addStyleName("product-form-wrapper");
    setId("product-form");
    productName.setWidth("100%");

    price.setConverter(new EuroConverter());

    stockCount.setWidth("80px");

    availability.setNullSelectionAllowed(false);
    availability.setTextInputAllowed(false);
    for (Availability s : Availability.values()) {
        availability.addItem(s);
    }

    category.setWidth("100%");

    saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    cancelButton.addStyleName("cancel");
    removeButton.addStyleName(ValoTheme.BUTTON_DANGER);

    VerticalLayout layout = new VerticalLayout();
    layout.setHeight("100%");
    layout.setSpacing(true);
    layout.addStyleName("form-layout");

    HorizontalLayout priceAndStock = new HorizontalLayout(price, stockCount);
    priceAndStock.setSpacing(true);
    priceAndStock.setWidth("100%");
    price.setWidth("100%");
    stockCount.setWidth("100%");
    availability.setWidth("100%");

    layout.addComponent(productName);
    layout.addComponent(priceAndStock);
    layout.addComponent(availability);
    layout.addComponent(category);

    CssLayout expander = new CssLayout();
    expander.addStyleName("expander");
    layout.addComponent(expander);
    layout.setExpandRatio(expander, 1);

    layout.addComponent(saveButton);
    layout.addComponent(cancelButton);
    layout.addComponent(removeButton);

    addComponent(layout);

    fieldGroup = new BeanFieldGroup<Product>(Product.class);
    fieldGroup.bindMemberFields(this);

    // perform validation and enable/disable buttons while editing
    ValueChangeListener valueListener = new ValueChangeListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            formHasChanged();
        }
    };
    for (Field<?> f : fieldGroup.getFields()) {
        f.addValueChangeListener(valueListener);
    }

    fieldGroup.addCommitHandler(new CommitHandler() {

        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void preCommit(CommitEvent commitEvent) throws CommitException {
        }

        @Override
        public void postCommit(CommitEvent commitEvent) throws CommitException {
            DataService.get().updateProduct(fieldGroup.getItemDataSource().getBean());
        }
    });

    saveButton.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                fieldGroup.commit();

                // only if validation succeeds
                Product product = fieldGroup.getItemDataSource().getBean();
                viewLogic.saveProduct(product);
            } catch (CommitException e) {
                Notification n = new Notification("Please re-check the fields", Type.ERROR_MESSAGE);
                n.setDelayMsec(500);
                n.show(getUI().getPage());
            }
        }
    });

    cancelButton.setClickShortcut(KeyCode.ESCAPE);
    cancelButton.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            viewLogic.cancelProduct();
        }
    });

    removeButton.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Product product = fieldGroup.getItemDataSource().getBean();
            viewLogic.deleteProduct(product);
        }
    });
}

From source file:com.mechanicshop.components.DataEntryLayout.java

private void buildLayout() {
    FormLayout formLayout1 = new FormLayout();

    formLayout1.setMargin(new MarginInfo(false, false, false, true));
    formLayout1.setSpacing(true);//from   ww  w  .  j  a v a2 s  .c o m

    FormLayout formLayout2 = new FormLayout();
    formLayout2.setMargin(new MarginInfo(false, false, false, true));
    formLayout2.setSpacing(true);

    FormLayout formLayout3 = new FormLayout();
    formLayout3.setMargin(new MarginInfo(false, true, false, true));
    formLayout3.setSpacing(true);

    tfTag.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfTag.setWidth("180px");
    tfTag.setMaxLength(3);
    tfTag.setNullRepresentation("");
    tfPhone.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPhone.setWidth("180px");
    tfPhone.setNullRepresentation("");
    tfPhone.setMaxLength(11);
    tfName.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfName.setWidth("180px");
    tfName.setMaxLength(50);
    tfName.setNullRepresentation("");
    tfVehicle.setWidth("180px");
    tfVehicle.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfVehicle.setMaxLength(75);
    tfVehicle.setNullRepresentation("");
    tfLicensePlate.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfLicensePlate.setWidth("180px");
    tfLicensePlate.setMaxLength(10);
    tfLicensePlate.setNullRepresentation("");
    tfVin.setWidth("180px");
    tfVin.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfVin.setMaxLength(17);
    tfVin.setNullRepresentation("");
    dfInShop.setImmediate(true);
    dfInShop.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfInShop.setInputPrompt("Select");
    dfInShop.setWidth("120px");

    dfOutShop.setImmediate(true);
    dfOutShop.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfOutShop.setInputPrompt("Select");
    dfOutShop.setWidth("120px");

    nsStatus.addItems("In", "Out", "Pending", "Ready", "Comeback");
    nsStatus.setImmediate(true);
    nsStatus.setWidth("120px");
    nsStatus.setStyleName(ValoTheme.COMBOBOX_TINY);
    nsStatus.setValue("In");
    tfMileage.setWidth("120px");
    tfMileage.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfMileage.setMaxLength(6);
    tfMileage.setNullRepresentation("");
    tfPicked.setWidth("120px");
    tfPicked.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPicked.setMaxLength(3);
    tfPicked.setNullRepresentation("");
    tfPayment.setWidth("180px");
    tfPayment.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPayment.setMaxLength(50);
    tfPayment.setNullRepresentation("");
    taRemarks.setWidth("500px");
    taRemarks.setStyleName(ValoTheme.TEXTFIELD_TINY);
    taRemarks.setMaxLength(500);
    taRemarks.setNullRepresentation("");
    tfRebuilder.setWidth("180px");
    tfRebuilder.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfRebuilder.setMaxLength(20);
    tfRebuilder.setNullRepresentation("");
    tfInstaller.setWidth("180px");
    tfInstaller.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfInstaller.setMaxLength(20);
    tfInstaller.setNullRepresentation("");
    tfFirstCheckBy.setWidth("500px");
    tfFirstCheckBy.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfFirstCheckBy.setMaxLength(100);
    tfFirstCheckBy.setNullRepresentation("");
    tfSecondCheckBy.setWidth("500px");
    tfSecondCheckBy.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfSecondCheckBy.setMaxLength(100);
    tfSecondCheckBy.setNullRepresentation("");
    dfFirstCheckDate.setImmediate(true);
    dfFirstCheckDate.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfFirstCheckDate.setInputPrompt("Select");
    dfFirstCheckDate.setWidth("120px");

    dfSecondCheckDate.setImmediate(true);
    dfSecondCheckDate.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfSecondCheckDate.setInputPrompt("Select");
    dfSecondCheckDate.setWidth("120px");

    taMedia.setWidth("500px");
    taMedia.setStyleName(ValoTheme.TEXTFIELD_TINY);
    taMedia.setNullRepresentation("");
    taMedia2.setWidth("500px");
    taMedia2.setStyleName(ValoTheme.TEXTFIELD_TINY);
    taMedia2.setNullRepresentation("");
    tfReferedBy.setWidth("180px");
    tfReferedBy.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfReferedBy.setMaxLength(20);
    tfReferedBy.setNullRepresentation("");
    tfWarrantyLimit.setWidth("180px");
    tfWarrantyLimit.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfWarrantyLimit.setMaxLength(5);
    tfWarrantyLimit.setNullRepresentation("");
    nsWarranty.setWidth("120px");
    nsWarranty.setStyleName(ValoTheme.TEXTFIELD_TINY);
    nsWarranty.addItems("YES", "NO");
    nsWarranty.setValue("NO");
    nsWarranty.setStyleName(ValoTheme.COMBOBOX_TINY);

    nsSMS.setWidth("120px");
    nsSMS.setStyleName(ValoTheme.TEXTFIELD_TINY);
    nsSMS.addItems("YES", "NO");
    nsSMS.setValue("NO");
    nsComeback.setWidth("120px");
    nsComeback.setStyleName(ValoTheme.TEXTFIELD_TINY);
    nsComeback.addItems("YES", "NO");
    nsComeback.setValue("NO");
    nsComeback.setStyleName(ValoTheme.COMBOBOX_TINY);

    formLayout1.addComponents(tfTag, tfPhone, tfName, tfVehicle, tfPayment, tfRebuilder, tfInstaller,
            tfLicensePlate, tfVin, tfReferedBy, tfWarrantyLimit);

    formLayout2.addComponents(nsWarranty, dfInShop, dfOutShop, nsStatus, nsSMS, nsComeback, tfMileage, tfPicked,
            dfFirstCheckDate, dfSecondCheckDate);

    formLayout3.addComponents(tfFirstCheckBy, tfSecondCheckBy, taRemarks, taMedia, taMedia2);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(new MarginInfo(false, true, false, true));

    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            Integer tag = null;
            Integer mileage = null;
            if (tfTag.getValue() != null)
                if (!tfTag.getValue().isEmpty()) {
                    tag = (Integer.parseInt(tfTag.getValue()));
                } else
                    tag = null;

            if (tfMileage.getValue() != null)
                if (!tfMileage.getValue().isEmpty()) {
                    mileage = (Integer.parseInt(tfMileage.getValue()));
                } else
                    mileage = null;

            Object[] args = new Object[] { tag, tfPhone.getValue(), tfName.getValue(), tfVehicle.getValue(),
                    tfLicensePlate.getValue(), tfVin.getValue(), dfInShop.getValue(), dfOutShop.getValue(),
                    nsStatus.getValue(), mileage, tfPicked.getValue(), tfPayment.getValue(),
                    taRemarks.getValue(), tfRebuilder.getValue(), tfInstaller.getValue(),
                    tfFirstCheckBy.getValue(), tfSecondCheckBy.getValue(), dfFirstCheckDate.getValue(),
                    dfSecondCheckDate.getValue(), taMedia.getValue(), taMedia2.getValue(),
                    tfReferedBy.getValue(), tfWarrantyLimit.getValue(), nsWarranty.getValue(), nsSMS.getValue(),
                    nsComeback.getValue() };

            if (sendBtn.getCaption().equals("Add")) {
                try {
                    String status = nsStatus.getValue().toString();
                    searchService.insertCar(args, status);
                    Notification.show("Entry inserted succesfully");
                    close();
                } catch (Exception e) {
                    e.printStackTrace();
                    Notification.show("An error has occurred", Notification.Type.ERROR_MESSAGE);
                }
            } else {
                try {
                    searchService.editCar(args, tableName, no);
                    Notification.show("Entry edited succesfully");
                    close();
                } catch (Exception e) {
                    e.printStackTrace();
                    Notification.show("An error has occurred", Notification.Type.ERROR_MESSAGE);
                }

            }
        }

    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(sendBtn);

    hLayoutForms.addComponents(formLayout1, formLayout2, formLayout3);

    mainLayout.addComponent(hLayoutForms);
    mainLayout.addComponent(layoutButtons);
    mainLayout.setComponentAlignment(hLayoutForms, Alignment.MIDDLE_CENTER);
    mainLayout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_LEFT);
    mainLayout.setExpandRatio(hLayoutForms, 3);

}

From source file:com.mechanicshop.components.TableLayout.java

public void createCustomMessage() {
    final TextArea textArea = new TextArea();
    textArea.setImmediate(true);/*from w  w  w . j ava2s.c o  m*/
    textArea.setColumns(30);
    textArea.setRows(10);
    textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
    textArea.setRequired(true);
    final Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("350px");
    subWindow.setWidth("500px");
    subWindow.setCaption("Insert Message");
    subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR);
    subWindow.setClosable(false);
    subWindow.setResizable(false);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    Button sendBtn = new Button("Send");
    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                textArea.validate();
                String message = textArea.getValue();
                smsSenderService.sendMessageMassive(message);
                subWindow.close();
                Notification.show("Message Sent");
            } catch (Exception e) {

            }
        }
    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setStyleName(ValoTheme.BUTTON_TINY);
    cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    cancelBtn.setImmediate(true);
    cancelBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();

        }
    });

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(cancelBtn, sendBtn);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(textArea);
    layout.addComponent(layoutButtons);
    layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(textArea, 3);

    layout.setSizeFull();

    subWindow.setContent(layout);
    subWindow.center();

    getUI().addWindow(subWindow);
}

From source file:com.mh.ui.HelloUi.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    button = new Button("Click me!");
    button.addClickListener(new Button.ClickListener() {
        @Override/*from   w  w  w .  j  a  va2 s . c o  m*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            Notification.show("You are at: " + Page.getCurrent().getLocation());
        }
    });
    setContent(button);
}

From source file:com.mycollab.vaadin.ui.NotificationUtil.java

License:Open Source License

public static void showNotification(String caption, String description, Type type) {
    Notification notification = new Notification(caption, description, type);
    notification.setHtmlContentAllowed(true);
    notification.setDelayMsec(3000);//from w  ww. j a  v a  2  s  . c  o m

    if (Page.getCurrent() != null) {
        notification.show(Page.getCurrent());
    } else {
        LOG.error("Current page is null");
    }

}