Package com.vaadin.ui

Examples of com.vaadin.ui.Notification


        return 6097;
    }

    @Override
    public void buttonClick(ClickEvent event) {
        Notification n = makeNotification();
        n.show(Page.getCurrent());
    }
View Full Code Here


    }

    private void createNotification(String caption, String message,
            Notification.Type type) {

        Notification notification;

        if (message == null) {
            notification = new Notification(caption, type);
        } else {
            notification = new Notification(caption, message, type);
        }

        if (styleName != null) {
            notification.setStyleName(styleName);
        }

        notification.setDelayMsec(-1);
        notification.show(parent.getUI().getPage());
    }
View Full Code Here

        MenuItem item = menubar.addItem("auto-open", null);
        item.addItem("sub-item 1", new MenuBar.Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {
                Notification notification = new Notification("Test",
                        Type.HUMANIZED_MESSAGE);
                notification.show(Page.getCurrent());
            }
        });
        return menubar;
    }
View Full Code Here

        // Editable if we're in editmode
        tf.setEnabled(!inViewMode);

        // Show notification about current mode and state
        getPage().showNotification(
                new Notification("Portlet status", "Mode: "
                        + request.getPortletMode() + " State: "
                        + request.getWindowState(), Type.WARNING_MESSAGE));

        // Display current user info
        Map<?, ?> uinfo = (Map<?, ?>) request
View Full Code Here

            public void buttonClick(Button.ClickEvent event) {
                Set<Integer> selected = (Set<Integer>) table.getValue();

                for (Integer item : selected) {
                    if (null == item) {
                        new Notification(
                                "ERROR",
                                "Table value has null in Set of selected items!",
                                Type.ERROR_MESSAGE).show(getPage());
                    }
                    table.removeItem(item);
View Full Code Here

        l.addComponent(new Label("Humanized", ContentMode.HTML));
        Button show = new Button("Humanized Notification",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        Notification notification = new Notification(
                                title.getValue(), message.getValue());
                        notification.setHtmlContentAllowed(true);
                        notification.show(Page.getCurrent());
                    }
                });
        l.addComponent(show);

        l.addComponent(new Label("Warning", ContentMode.HTML));
        show = new Button("Warning Notification", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                new Notification(title.getValue(), message.getValue(),
                        Notification.TYPE_WARNING_MESSAGE, true).show(Page
                        .getCurrent());

            }
        });
        l.addComponent(show);

        l.addComponent(new Label("Error", ContentMode.HTML));
        show = new Button("Error Notification", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                new Notification(title.getValue(), message.getValue(),
                        Notification.TYPE_ERROR_MESSAGE, true).show(Page
                        .getCurrent());

            }
        });
        l.addComponent(show);

        l.addComponent(new Label("Tray", ContentMode.HTML));
        show = new Button("Tray Notification", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                new Notification(title.getValue(), message.getValue(),
                        Notification.TYPE_TRAY_NOTIFICATION, true).show(Page
                        .getCurrent());

            }
        });
View Full Code Here

        Notification n = makeNotification();
        n.show(Page.getCurrent());
    }

    private Notification makeNotification() {
        Notification n = new Notification(captionField.getValue(),
                messageField.getValue(), Notification.TYPE_HUMANIZED_MESSAGE,
                htmlAllowedBox.getValue());
        return n;
    }
View Full Code Here

        return null;
    }

    @Override
    public void buttonClick(ClickEvent event) {
        Notification n = new Notification(tf.getValue(), (Type) type.getValue());
        n.setHtmlContentAllowed(true);
        n.show(Page.getCurrent());
    }
View Full Code Here

    }

    Panel notifications() {
        Panel p = new Panel("Notifications");
        VerticalLayout content = new VerticalLayout() {
            Notification notification = new Notification("");
            TextField title = new TextField("Title");
            TextArea description = new TextArea("Description");
            MenuBar style = new MenuBar();
            MenuBar type = new MenuBar();
            String typeString = "";
            String styleString = "";
            TextField delay = new TextField();
            {
                setSpacing(true);
                setMargin(true);

                title.setInputPrompt("Title for the notification");
                title.addValueChangeListener(new ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        if (title.getValue() == null
                                || title.getValue().length() == 0) {
                            notification.setCaption(null);
                        } else {
                            notification.setCaption(title.getValue());
                        }
                    }
                });
                title.setValue("Notification Title");
                title.setWidth("100%");
                addComponent(title);

                description.setInputPrompt("Description for the notification");
                description.addStyleName("small");
                description.addValueChangeListener(new ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        if (description.getValue() == null
                                || description.getValue().length() == 0) {
                            notification.setDescription(null);
                        } else {
                            notification.setDescription(description.getValue());
                        }
                    }
                });
                description
                        .setValue("A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
                description.setWidth("100%");
                addComponent(description);

                Command typeCommand = new Command() {
                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        if (selectedItem.getText().equals("Humanized")) {
                            typeString = "";
                            notification.setStyleName(styleString.trim());
                        } else {
                            typeString = selectedItem.getText().toLowerCase();
                            notification
                                    .setStyleName((typeString + " " + styleString
                                            .trim()).trim());
                        }
                        for (MenuItem item : type.getItems()) {
                            item.setChecked(false);
                        }
                        selectedItem.setChecked(true);
                    }
                };

                type.setCaption("Type");
                MenuItem humanized = type.addItem("Humanized", typeCommand);
                humanized.setCheckable(true);
                humanized.setChecked(true);
                type.addItem("Tray", typeCommand).setCheckable(true);
                type.addItem("Warning", typeCommand).setCheckable(true);
                type.addItem("Error", typeCommand).setCheckable(true);
                type.addItem("System", typeCommand).setCheckable(true);
                addComponent(type);
                type.addStyleName("small");

                Command styleCommand = new Command() {
                    @Override
                    public void menuSelected(MenuItem selectedItem) {
                        styleString = "";
                        for (MenuItem item : style.getItems()) {
                            if (item.isChecked()) {
                                styleString += " "
                                        + item.getText().toLowerCase();
                            }
                        }
                        if (styleString.trim().length() > 0) {
                            notification
                                    .setStyleName((typeString + " " + styleString
                                            .trim()).trim());
                        } else if (typeString.length() > 0) {
                            notification.setStyleName(typeString.trim());
                        } else {
                            notification.setStyleName(null);
                        }
                    }
                };

                style.setCaption("Additional style");
                style.addItem("Dark", styleCommand).setCheckable(true);
                style.addItem("Success", styleCommand).setCheckable(true);
                style.addItem("Failure", styleCommand).setCheckable(true);
                style.addItem("Bar", styleCommand).setCheckable(true);
                style.addItem("Small", styleCommand).setCheckable(true);
                style.addItem("Closable", styleCommand).setCheckable(true);
                addComponent(style);
                style.addStyleName("small");

                CssLayout group = new CssLayout();
                group.setCaption("Fade delay");
                group.addStyleName("v-component-group");
                addComponent(group);

                delay.setInputPrompt("Infinite");
                delay.addStyleName("align-right");
                delay.addStyleName("small");
                delay.setWidth("7em");
                delay.addValueChangeListener(new ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        try {
                            notification.setDelayMsec(Integer.parseInt(delay
                                    .getValue()));
                        } catch (Exception e) {
                            notification.setDelayMsec(-1);
                            delay.setValue("");
                        }

                    }
                });
                delay.setValue("1000");
                group.addComponent(delay);

                Button clear = new Button(null, new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        delay.setValue("");
                    }
                });
                clear.setIcon(FontAwesome.TIMES_CIRCLE);
                clear.addStyleName("last");
                clear.addStyleName("small");
                clear.addStyleName("icon-only");
                group.addComponent(clear);
                group.addComponent(new Label("&nbsp; msec", ContentMode.HTML));

                GridLayout grid = new GridLayout(3, 3);
                grid.setCaption("Show in position");
                addComponent(grid);
                grid.setSpacing(true);

                Button pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.TOP_LEFT);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.TOP_CENTER);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.TOP_RIGHT);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.MIDDLE_LEFT);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.MIDDLE_CENTER);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.MIDDLE_RIGHT);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.BOTTOM_LEFT);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.BOTTOM_CENTER);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);

                pos = new Button("", new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        notification.setPosition(Position.BOTTOM_RIGHT);
                        notification.show(Page.getCurrent());
                    }
                });
                pos.addStyleName("small");
                grid.addComponent(pos);
View Full Code Here

    public void handleAction(Action action, final Object sender,
        Object target) {

      if (addAction == action) {
        if (addItem((Table) sender)) {
          Notification nota = new Notification("<b>Nota:</b>",
              "Añadido correctamente...", Type.TRAY_NOTIFICATION,
              true);
          nota.setPosition(Position.BOTTOM_LEFT);
          nota.show(UI.getCurrent().getPage());
        } else {
          Notification nota = new Notification("<b>Nota:</b><br/>",
              "Seleccione correctamente para añadir...",
              Type.WARNING_MESSAGE, true);
          nota.setPosition(Position.BOTTOM_RIGHT);
          nota.show(UI.getCurrent().getPage());
        }
      } else if (delAction == action) {
        ConfirmDialog.show(((Table) sender).getUI(), "Nota:",
            "Esta seguro de eliminar el item seleccionado?",
            "Si, Eliminalo", "NO, cancelar",
            new ConfirmDialog.Listener() {

              /**
               *
               */
              private static final long serialVersionUID = 4701072457618740495L;

              @Override
              public void onClose(ConfirmDialog dialog) {

                if (dialog.isConfirmed()) {
                  if (delItem((Table) sender)) {
                    Notification nota = new Notification(
                        "<b>Nota:</b>",
                        "Eliminado correctamente...",
                        Type.TRAY_NOTIFICATION, true);
                    nota.setPosition(Position.BOTTOM_LEFT);
                    nota.show(UI.getCurrent().getPage());
                  } else {
                    Notification nota = new Notification(
                        "<b>Nota:</b><br/>",
                        "Item no pudo ser Eliminado... <br/>"
                            + "Corrobore si información esta relacionada...",
                        Type.WARNING_MESSAGE, true);
                    nota.setPosition(Position.BOTTOM_RIGHT);
                    nota.show(UI.getCurrent().getPage());
                  }

                }
              }
            });
View Full Code Here

TOP

Related Classes of com.vaadin.ui.Notification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.