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.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java

License:Open Source License

private void displayTrayNotification(AbstractNotification item) {
    if (item instanceof NewUpdateAvailableNotification) {
        NewUpdateAvailableNotification updateNo = (NewUpdateAvailableNotification) item;
        Notification no;
        if (AppContext.isAdmin()) {
            no = new Notification(AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    AppContext.getMessage(
                            ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion())
                            + " "
                            + new A("javascript:com.mycollab.scripts.upgrade('" + updateNo.getVersion() + "','"
                                    + updateNo.getAutoDownloadLink() + "','" + updateNo.getManualDownloadLink()
                                    + "')").appendText(AppContext.getMessage(ShellI18nEnum.ACTION_UPGRADE)),
                    Notification.Type.TRAY_NOTIFICATION);
        } else {/*from w w  w. j  av  a 2 s. co  m*/
            no = new Notification(AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    AppContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion()),
                    Notification.Type.TRAY_NOTIFICATION);
        }

        no.setHtmlContentAllowed(true);
        no.setDelayMsec(300000);

        UI currentUI = UI.getCurrent();
        if (currentUI != null) {
            if (SiteConfiguration.getPullMethod() == SiteConfiguration.PullMethod.push) {
                no.show(currentUI.getPage());
                currentUI.push();
            } else {
                try {
                    UI.getCurrent().setPollInterval(1000);
                    no.show(currentUI.getPage());
                } finally {
                    UI.getCurrent().setPollInterval(-1);
                }
            }
        }
    }
}

From source file:com.etest.valo.Tables.java

License:Apache License

static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes,
        boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact,
        boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) {
    table.setSelectable(true);//  www.  jav  a  2  s .  co  m
    table.setMultiSelect(true);
    table.setSortEnabled(true);
    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    table.setPageLength(6);
    table.addActionHandler(MainUI.getActionHandler());
    table.setDragMode(TableDragMode.MULTIROW);
    table.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });
    table.setColumnAlignment(MainUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(MainUI.INDEX_PROPERTY, Align.CENTER);

    table.removeContainerProperty("textfield");
    table.removeGeneratedColumn("textfield");
    table.removeContainerProperty("button");
    table.removeGeneratedColumn("button");
    table.removeContainerProperty("label");
    table.removeGeneratedColumn("label");
    table.removeContainerProperty("checkbox");
    table.removeGeneratedColumn("checkbox");
    table.removeContainerProperty("datefield");
    table.removeGeneratedColumn("datefield");
    table.removeContainerProperty("combobox");
    table.removeGeneratedColumn("combobox");
    table.removeContainerProperty("optiongroup");
    table.removeGeneratedColumn("optiongroup");
    table.removeContainerProperty("slider");
    table.removeGeneratedColumn("slider");
    table.removeContainerProperty("progress");
    table.removeGeneratedColumn("progress");

    if (componentsInRows) {
        table.addContainerProperty("textfield", TextField.class, null);
        table.addGeneratedColumn("textfield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                TextField tf = new TextField();
                tf.setInputPrompt("Type here");
                // tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("datefield", TextField.class, null);
        table.addGeneratedColumn("datefield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField tf = new DateField();
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("combobox", TextField.class, null);
        table.addGeneratedColumn("combobox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ComboBox tf = new ComboBox();
                tf.setInputPrompt("Select");
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("button", Button.class, null);
        table.addGeneratedColumn("button", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Button b = new Button("Button");
                b.addStyleName("small");
                return b;
            }
        });

        table.addContainerProperty("label", TextField.class, null);
        table.addGeneratedColumn("label", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Label label = new Label("Label component");
                label.setSizeUndefined();
                label.addStyleName("bold");
                return label;
            }
        });

        table.addContainerProperty("checkbox", TextField.class, null);
        table.addGeneratedColumn("checkbox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                CheckBox cb = new CheckBox(null, true);
                return cb;
            }
        });

        table.addContainerProperty("optiongroup", TextField.class, null);
        table.addGeneratedColumn("optiongroup", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                OptionGroup op = new OptionGroup();
                op.addItem("Male");
                op.addItem("Female");
                op.addStyleName("horizontal");
                return op;
            }
        });

        table.addContainerProperty("slider", TextField.class, null);
        table.addGeneratedColumn("slider", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Slider s = new Slider();
                s.setValue(30.0);
                return s;
            }
        });

        table.addContainerProperty("progress", TextField.class, null);
        table.addGeneratedColumn("progress", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ProgressBar bar = new ProgressBar();
                bar.setValue(0.7f);
                return bar;
            }
        });
    }
    table.setFooterVisible(footer);
    if (footer) {
        table.setColumnFooter(MainUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(MainUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(MainUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(MainUI.INDEX_PROPERTY, "index");
    }

    if (sized) {
        table.setWidth("400px");
        table.setHeight("300px");
    } else {
        table.setSizeUndefined();
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(MainUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(MainUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0);

    if (!stripes) {
        table.addStyleName("no-stripes");
    } else {
        table.removeStyleName("no-stripes");
    }

    if (!verticalLines) {
        table.addStyleName("no-vertical-lines");
    } else {
        table.removeStyleName("no-vertical-lines");
    }

    if (!horizontalLines) {
        table.addStyleName("no-horizontal-lines");
    } else {
        table.removeStyleName("no-horizontal-lines");
    }

    if (borderless) {
        table.addStyleName("borderless");
    } else {
        table.removeStyleName("borderless");
    }

    if (!headers) {
        table.addStyleName("no-header");
    } else {
        table.removeStyleName("no-header");
    }

    if (compact) {
        table.addStyleName("compact");
    } else {
        table.removeStyleName("compact");
    }

    if (small) {
        table.addStyleName("small");
    } else {
        table.removeStyleName("small");
    }

    if (!rowIndex && !rowCaption && rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.HIDDEN);
    }

    if (rowIndex) {
        table.setRowHeaderMode(RowHeaderMode.INDEX);
    }

    if (rowCaption) {
        table.setRowHeaderMode(RowHeaderMode.PROPERTY);
        table.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

    if (rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        table.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    } else {
        table.setItemIconPropertyId(null);
    }
}

From source file:com.etest.valo.Trees.java

License:Apache License

public Trees() {
    setMargin(true);/*from  w w w .  ja  v  a2s.  c  om*/

    Label h1 = new Label("Trees");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Tree tree = new Tree();
    tree.setSelectable(true);
    tree.setMultiSelect(true);
    Container generateContainer = MainUI.generateContainer(10, true);
    tree.setContainerDataSource(generateContainer);
    tree.setDragMode(TreeDragMode.NODE);
    row.addComponent(tree);
    tree.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    tree.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    tree.expandItem(generateContainer.getItemIds().iterator().next());

    tree.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });

    // Add actions (context menu)
    tree.addActionHandler(MainUI.getActionHandler());
}

From source file:com.etest.view.notification.NotificationMainUI.java

public NotificationMainUI() {
    setSizeFull();/*from  www .j ava  2s  .  co m*/
    setSpacing(true);

    if (VaadinSession.getCurrent().getAttribute("userId") == null) {
        Page.getCurrent().setLocation("http://localhost:8080/");
    } else {
        addComponent(populateNoficationTable());
    }

    HorizontalLayout h = new HorizontalLayout();
    h.setWidth("950px");

    Button sendMsgBtn = new Button("Send Message");
    sendMsgBtn.setWidthUndefined();
    sendMsgBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    sendMsgBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    sendMsgBtn.addClickListener((Button.ClickEvent event) -> {
        Notification.show("Send Message!");
    });

    h.addComponent(sendMsgBtn);
    h.setComponentAlignment(sendMsgBtn, Alignment.MIDDLE_RIGHT);
    addComponent(h);
}

From source file:com.example.themes.valo.MenuBars.java

License:Apache License

static MenuBar getMenuBar() {
    Command click = new Command() {
        @Override/*from  ww  w.  jav  a 2s .  co m*/
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Clicked " + selectedItem.getText());
        }
    };

    MenuBar menubar = new MenuBar();
    menubar.setWidth("100%");
    final MenuBar.MenuItem file = menubar.addItem("Draft", null);
    final MenuBar.MenuItem newItem = file.addItem("New", null);
    file.addItem("Open file...", click);
    file.addSeparator();

    newItem.addItem("File", click);
    newItem.addItem("Folder", click);
    newItem.addItem("Project...", click);

    file.addItem("Close", click);
    file.addItem("Close All", click);
    file.addSeparator();

    file.addItem("Save", click);
    file.addItem("Save As...", click);
    file.addItem("Save All", click);

    final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
    edit.addItem("Undo", click);
    edit.addItem("Redo", click).setEnabled(false);
    edit.addSeparator();

    edit.addItem("Cut", click);
    edit.addItem("Copy", click);
    edit.addItem("Paste", click);
    edit.addSeparator();

    final MenuBar.MenuItem find = edit.addItem("Find/Replace", null);

    find.addItem("Google Search", click);
    find.addSeparator();
    find.addItem("Find/Replace...", click);
    find.addItem("Find Next", click);
    find.addItem("Find Previous", click);

    Command check = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show(selectedItem.isChecked() ? "Checked" : "Unchecked");
        }
    };

    final MenuBar.MenuItem view = menubar.addItem("View", null);
    view.addItem("Show Status Bar", check).setCheckable(true);
    MenuItem title = view.addItem("Show Title Bar", check);
    title.setCheckable(true);
    title.setChecked(true);
    view.addItem("Customize Toolbar...", click);
    view.addSeparator();

    view.addItem("Actual Size", click);
    view.addItem("Zoom In", click);
    view.addItem("Zoom Out", click);

    TestIcon testIcon = new TestIcon(50);

    MenuItem fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setChecked(true);

    fav = menubar.addItem("", check);
    fav.setIcon(testIcon.get());
    fav.setStyleName("icon-only");
    fav.setCheckable(true);
    fav.setCheckable(true);

    menubar.addItem("Attach", click).setIcon(FontAwesome.PAPERCLIP);
    menubar.addItem("Undo", click).setIcon(FontAwesome.UNDO);
    MenuItem redo = menubar.addItem("Redo", click);
    redo.setIcon(FontAwesome.REPEAT);
    redo.setEnabled(false);
    menubar.addItem("Upload", click).setIcon(FontAwesome.UPLOAD);

    return menubar;
}

From source file:com.example.tomeevaadin.ui.BookUI.java

private HorizontalLayout addInputFields() {
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(new Label("Enter a book"));
    TextField field = new TextField(stringModel);
    Button button = new Button("press this to save");
    button.addClickListener(new Button.ClickListener() {

        @Override/*  www  .  j av  a2  s  .c  om*/
        public void buttonClick(Button.ClickEvent event) {
            if (bookService == null) {
                System.out.println("uho, ejb is null");
            }
            Notification.show("button is pressed " + stringModel.getValue());
            Book book = new Book();
            book.setBookTitle(stringModel.getValue());
            bookService.addBook(book);
            updateBeanContainer();

        }
    });
    hl.addComponent(field);
    hl.addComponent(button);
    return hl;
}

From source file:com.foc.vaadin.FocWebEnvironment.java

License:Apache License

@Override
public void showNotification(String notificationMessage, String description, int notificationType, int delay,
        String styleName) {/*from  w ww.ja v  a2  s.c  om*/
    try {
        if (Globals.getApp() != null && Globals.getApp().isUnitTest()
                && FocUnitDictionary.getInstance() != null) {
            FocUnitDictionary.getInstance().expectedNotification_Occured(notificationMessage, description,
                    notificationType);
        } else {
            FocWebSession focWebSession = FocWebApplication.getFocWebSession_Static();
            if (focWebSession == null || focWebSession.isNotificationEnabled()) {
                Notification.Type type = Notification.Type.ERROR_MESSAGE;
                if (notificationType == IFocEnvironment.TYPE_ERROR_MESSAGE) {
                    FocLogger.getInstance().addError("Error Popup: " + notificationMessage + " " + description);
                } else if (notificationType == IFocEnvironment.TYPE_WARNING_MESSAGE) {
                    FocLogger.getInstance()
                            .addWarning("Warning Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.WARNING_MESSAGE;
                } else if (notificationType == IFocEnvironment.TYPE_HUMANIZED_MESSAGE) {
                    FocLogger.getInstance().addInfo("Info Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.HUMANIZED_MESSAGE;
                } else if (notificationType == IFocEnvironment.TYPE_TRAY_NOTIFICATION) {
                    FocLogger.getInstance().addInfo("Tray Popup: " + notificationMessage + " " + description);
                    type = Notification.Type.TRAY_NOTIFICATION;
                }
                Notification notification = new Notification(notificationMessage, description, type);
                notification.setDelayMsec(delay);

                if (!Utils.isStringEmpty(styleName))
                    notification.setStyleName(styleName);
                if (Page.getCurrent() != null) {
                    notification.show(Page.getCurrent());
                }
                /*
                FancyNotifications fancyNotifications = new FancyNotifications();
                fancyNotifications.setPosition(Position.BOTTOM_RIGHT);
                        
                FancyNotification fancyNotification = new FancyNotification(null, notificationMessage, description);
                fancyNotification.getTitleLabel().setContentMode(ContentMode.HTML);
                fancyNotification.getDescriptionLabel().setContentMode(ContentMode.HTML);
                fancyNotification.addLayoutClickListener(notificationClickEvent -> Page.getCurrent().setLocation("https://github.com/alump/FancyLayouts"));
                fancyNotifications.showNotification(fancyNotification);
                */
            }
        }
    } catch (Exception e) {
        Globals.logExceptionWithoutPopup(e);
    }
    //    Notification.show(notificationMessage, description, type);
}

From source file:com.foo01.components.ButtonToolBarLayout.java

public ButtonToolBarLayout(final Object caller) {
    setUpLayout();/*w  ww.j  a  v  a  2  s.  c  om*/

    //caller = ReservationView
    if (ReservationView.class == caller.getClass()) {
        ReservationView rdv = (ReservationView) caller;
        rdv.getReservation().getSource();

        //button Smazat
        leftButton.setCaption("SMAZAT");
        leftButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {

                ConfirmationDialog dialog = new ConfirmationDialog("Zamtnout rezervaci?",
                        "Opravdu zamtnout rezervaci?", new Button.ClickListener() {

                            @Override
                            public void buttonClick(Button.ClickEvent bevent) {
                                /*
                                 try {
                                 ((ErzetaUI) UI.getCurrent()).getReservationManager().validateReservation(((ErzetaUI) UI.getCurrent()).getUser(), (Reservation) object, false);
                                 } catch (BusinessException e) {
                                 // TODO Auto-generated catch block
                                 e.printStackTrace();
                                 }
                                 */
                                ((foo01TouchKitUI) UI.getCurrent()).NAVIGATIONMANAGER.navigateBack();
                                Notification.show("Rezervace byla zamtnuta");
                            }
                        }, false);
                dialog.showRelativeTo(leftButton);
                //Notification.show("DELETE!!!");
            }
        });

        rightButton.setCaption("ULOIT");

    } else {
        System.err.println("Wrong caller");
    }
}

From source file:com.freebox.engeneering.application.web.layout.LeftSideBarController.java

License:Apache License

private void createFooterSideBar() {
    VerticalLayout verticalLayout = super.getView();

    sideBarFooter.setSizeUndefined();/* w w  w . j  a  v  a2s .  c  o  m*/
    sideBarFooter.addStyleName("user");
    Image profilePic = new Image(null, new ThemeResource("img/profile-pic.png"));
    profilePic.setWidth("34px");
    sideBarFooter.addComponent(profilePic);
    Label userName = new Label("MOHELLEBI ATAF");
    userName.setSizeUndefined();
    sideBarFooter.addComponent(userName);

    Command cmd = new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            Notification.show("Not implemented in this demo");
        }
    };
    MenuBar settings = new MenuBar();
    MenuItem settingsMenu = settings.addItem("", null);
    settingsMenu.setStyleName("icon-cog");
    settingsMenu.addItem("Settings", cmd);
    settingsMenu.addItem("Preferences", cmd);
    settingsMenu.addSeparator();
    settingsMenu.addItem("My Account", cmd);
    sideBarFooter.addComponent(settings);

    Button exit = new NativeButton("Exit");
    exit.addStyleName("icon-cancel");
    exit.setDescription("Sign Out");
    sideBarFooter.addComponent(exit);
    exit.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
        }
    });

    verticalLayout.addComponent(sideBarFooter);
}

From source file:com.github.carljmosca.ui.MenuView.java

@PostConstruct
private void init() {
    setCaption("Menu");

    final VerticalComponentGroup content = new VerticalComponentGroup();
    Button btnSearch = new Button("Search");
    btnSearch.addClickListener((ClickEvent event) -> {
        getNavigationManager().navigateTo(searchView);
        Notification.show("navigateTo");
    });/*w ww .j  a  v  a 2  s.com*/
    content.addComponent(btnSearch);
    setContent(content);
}