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.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 (UserUIContext.isAdmin()) {
            no = new Notification(UserUIContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    UserUIContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion())
                            + " "
                            + new A("javascript:com.mycollab.scripts.upgrade('" + updateNo.getVersion() + "','"
                                    + updateNo.getAutoDownloadLink() + "','" + updateNo.getManualDownloadLink()
                                    + "')").appendText(UserUIContext.getMessage(ShellI18nEnum.ACTION_UPGRADE)),
                    Notification.Type.TRAY_NOTIFICATION);
        } else {// w  ww .  j av  a 2 s .  com
            no = new Notification(UserUIContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE),
                    UserUIContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION,
                            ((NewUpdateAvailableNotification) item).getVersion()),
                    Notification.Type.TRAY_NOTIFICATION);
        }

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

        UI currentUI = this.getUI();
        AsyncInvoker.access(getUI(), new AsyncInvoker.PageCommand() {
            @Override
            public void run() {
                no.show(currentUI.getPage());
            }
        });
    }
}

From source file:com.mycompany.vaadinviews.FieldBinderWithBeanValidation.java

public FieldBinderWithBeanValidation() {
    //addComponent(log);
    //this.//from  w ww . jav a2s  . c o m
    //getContent().
    Layout layout = new VerticalLayout();
    final BeanFieldGroup<PersonWithBeanValidationAnnotations> fieldGroup = new BeanFieldGroup<PersonWithBeanValidationAnnotations>(
            PersonWithBeanValidationAnnotations.class);

    fieldGroup.buildAndBindMemberFields(this);
    //fieldGroup.
    //Layout hlayout = new HorizontalLayout();
    layout.addComponent(firstName);
    //layout.addComponent(hlayout);
    layout.addComponent(lastName);
    layout.addComponent(email);
    layout.addComponent(age);
    layout.addComponent(sex);
    layout.addComponent(deceased);

    Button commitButton = new Button("Commit", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String msg = "Commit succesful";
            try {
                fieldGroup.commit();
            } catch (CommitException e) {
                msg = "Commit failed: " + e.getMessage();
            }
            Notification.show(msg);
            //log.log(msg);
        }
    });

    Button discardButton = new Button("Discard", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            fieldGroup.discard();
            //log.log("Discarded changes");

        }
    });
    Button showBean = new Button("Show bean values", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show(getPerson(fieldGroup).toString());

        }
    });
    layout.addComponent(commitButton);
    layout.addComponent(discardButton);
    layout.addComponent(showBean);
    sex.setPageLength(0);

    PersonWithBeanValidationAnnotations p = new PersonWithBeanValidationAnnotations("John", "Doe",
            "john@doe.com", 64, Sex.MALE, new Address("John street", 11223, "John's town", Country.USA));
    fieldGroup.setItemDataSource(new BeanItem<PersonWithBeanValidationAnnotations>(p));
    setContent(layout);
}

From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java

License:Open Source License

/**
 * Authenticate a user//from w  w w. j a va 2  s  .  com
 * @param username user name
 * @param password user password
 * @return True if the user was authenticated, false otherwise.
 */
private boolean authenticate(String username, String password) {
    if (authenticateService != null) {
        Subject subject = authenticateService.authenticate(username, password);
        if (subject != null) {
            securityManager = new SecurityManager(subject);
            getSession().setAttribute("is.logged", true);
            getSession().setAttribute("security.manager", securityManager);
            return true;
        }
    } else {
        Notification.show("There is no authentication service. Please review your configuration");
    }
    return false;
}

From source file:com.peter.vaadin.components.vaadin.chart.timeline.MyTimelineDemo.java

public MyTimelineDemo() {

    timeline = new Timeline("My graph");
    timeline.setSizeFull();//  w  w  w.j  av a  2  s .com
    timeline.setVerticalAxisRange(-1f, 2f);
    timeline.setZoomLevelsVisible(false);
    timeline.setDateSelectVisible(false);

    // Create the data sources
    firstDataSource = createGraphDataSource();
    datasourcesList.add(firstDataSource);
    final Container.Indexed markerDataSource = createMarkerDataSource();
    final Container.Indexed eventDataSource = createEventDataSource();

    // Add our data sources
    timeline.addGraphDataSource(firstDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.VALUE);

    // Markers and events
    timeline.setMarkerDataSource(markerDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION,
            Timeline.PropertyId.VALUE);
    timeline.setEventDataSource(eventDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION);

    // Set the caption of the graph
    timeline.setGraphLegend(firstDataSource, "Our cool graph");

    // Set the color of the graph
    timeline.setGraphOutlineColor(firstDataSource, SolidColor.RED);

    // Set the fill color of the graph
    timeline.setGraphFillColor(firstDataSource, new SolidColor(255, 0, 0, 128));

    // Set the width of the graph
    timeline.setGraphOutlineThickness(1);

    // Set the color of the browser graph
    timeline.setBrowserOutlineColor(firstDataSource, SolidColor.BLACK);

    // Set the fill color of the graph
    timeline.setBrowserFillColor(firstDataSource, new SolidColor(0, 0, 0, 128));

    // Add some zoom levels
    timeline.addZoomLevel("Day", 86400000L);
    timeline.addZoomLevel("Week", 7 * 86400000L);
    timeline.addZoomLevel("Month", 2629743830L);

    // Listen to click events from events
    timeline.addListener(new Timeline.EventClickListener() {
        @Override
        public void eventClick(EventButtonClickEvent event) {
            Item item = eventDataSource.getItem(event.getItemIds().iterator().next());
            Date sunday = (Date) item.getItemProperty(Timeline.PropertyId.TIMESTAMP).getValue();
            SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, ''yy");

            Notification.show(formatter.format(sunday));
        }
    });

    addComponent(timeline);

    HorizontalLayout addDateForm = new HorizontalLayout();
    final DateField dateField = new DateField();
    dateField.setImmediate(true);
    addDateForm.addComponent(dateField);
    final TextField valueField = new TextField();
    valueField.setImmediate(true);
    addDateForm.addComponent(valueField);
    Button addBtn = new Button("Add", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            java.util.Date d = dateField.getValue();
            Date date = new Date(d.getTime());
            float value = Float.valueOf(valueField.getValue().toString());

            // Create a point in time
            Item item = firstDataSource.addItem(date.getTime());

            if (item == null) {
                item = firstDataSource.getItem(date.getTime());
            }

            // Set the timestamp property
            item.getItemProperty(Timeline.PropertyId.TIMESTAMP).setValue(date);

            // Set the value property
            item.getItemProperty(Timeline.PropertyId.VALUE).setValue(value);
        }
    });
    addDateForm.addComponent(addBtn);
    addComponent(addDateForm);

    Button addGraphDataSource = new Button("Add graph data source", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Container.Indexed ds = createGraphDataSource();
            datasourcesList.add(ds);
            timeline.addGraphDataSource(ds);
            timeline.setGraphFillColor(ds, SolidColor.BLACK);
        }
    });
    addComponent(addGraphDataSource);

    Button removeGraphDataSource = new Button("Remove graph data source", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (datasourcesList.size() > 1) {
                Container.Indexed ds = datasourcesList.get(datasourcesList.size() - 1);
                timeline.removeGraphDataSource(ds);
                datasourcesList.remove(ds);
            }
        }
    });
    addComponent(removeGraphDataSource);

    CheckBox stacked = new CheckBox("Stacked graphs", false);
    stacked.setImmediate(true);
    stacked.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            timeline.setGraphStacking((Boolean) event.getProperty().getValue());
        }
    });
    addComponent(stacked);

    CheckBox lock = new CheckBox("Selection lock", true);
    lock.setImmediate(true);
    lock.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            timeline.setBrowserSelectionLock((Boolean) event.getProperty().getValue());
        }
    });
    addComponent(lock);

    setExpandRatio(timeline, 1);
}

From source file:com.rex.components.valo.Tables.java

License:Apache License

static void configure(Table table, Grid grid, 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);/*w ww .j  a v a 2 s . c o  m*/
    table.setMultiSelect(true);
    grid.setSelectionMode(SelectionMode.MULTI);

    table.setSortEnabled(true);
    for (Column c : grid.getColumns()) {
        if (!c.getPropertyId().equals("icon")) {
            c.setSortable(true);
        }
        c.setHidable(true);
    }

    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    grid.setColumnReorderingAllowed(true);

    table.setPageLength(6);
    grid.setHeightByRows(6);

    table.addActionHandler(ReportEngineUI.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(ReportEngineUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(ReportEngineUI.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(ReportEngineUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(ReportEngineUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(ReportEngineUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(ReportEngineUI.INDEX_PROPERTY, "index");
    }

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

    if (componentsInRows) {
        table.setWidth("100%");
    } else {
        table.setWidth(null);
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(ReportEngineUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(ReportEngineUI.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(ReportEngineUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

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

From source file:com.rex.components.valo.Trees.java

License:Apache License

public Trees() {
    setMargin(true);/*from   w ww.j a  va 2s  .  co  m*/

    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 = ReportEngineUI.generateContainer(10, true);
    tree.setContainerDataSource(generateContainer);
    tree.setDragMode(TreeDragMode.NODE);
    row.addComponent(tree);
    tree.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    tree.setItemIconPropertyId(ReportEngineUI.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(ReportEngineUI.getActionHandler());
}

From source file:com.save.views.ClientsPromoView.java

public ClientsPromoView() {
    setSizeFull();

    addComponent(new ClientPromoUI());
    Notification.show("Client View");
}

From source file:com.snowy.NewUserSubWindow.java

public void build() {
    //setClosable(false);
    setModal(true);// w  w w. j a  v a 2 s  . c o m
    setResizable(false);
    setResponsive(true);
    setDraggable(false);
    FormLayout fl = new FormLayout();
    fl.setMargin(true);
    //fl.setSizeFull();
    fl.setSizeUndefined();
    fl.setSpacing(true);
    TextField uname = new TextField("Username");
    uname.setRequired(true);

    //uname.addValidator(null);
    fl.addComponent(uname);
    TextField email = new TextField("Email");

    email.setRequired(true);
    email.addValidator(new EmailValidator("A Valid Email is Required"));
    fl.addComponent(email);
    PasswordField pf1 = new PasswordField("Password");
    pf1.setRequired(true);
    pf1.addValidator(new StringLengthValidator("Password must be between 8 and 60 characters", 8, 60, false));
    fl.addComponent(pf1);

    PasswordField pf2 = new PasswordField("Confirm Password");
    pf2.setRequired(true);
    pf2.addValidator((Object value) -> {
        if (!pf2.getValue().equals(pf1.getValue())) {
            throw new InvalidValueException("Passwords Must Match");
        }
    });
    //pf2.setImmediate(true);
    fl.addComponent(pf2);
    Button b = new Button("Submit");

    b.addClickListener((Button.ClickEvent e) -> {

        if (uname.isValid() && email.isValid() && pf1.isValid() && pf2.isValid()) {

            String result = d.createUser(uname.getValue(), pf2.getValue(), email.getValue());
            if (result.equals("Creation Sucess")) {
                fl.removeAllComponents();
                fl.addComponent(new Label("User Created Sucessfully"));
                fl.addComponent(new Button("Close", (ee) -> {
                    this.close();
                }));

            } else {
                Notification.show(result);
            }
        } else {
            b.setComponentError(new UserError("Issues with required fields"));
        }
        //d.close();
    });
    fl.addComponent(b);
    setContent(fl);

}

From source file:com.squadd.technical.Authorizator.java

public static boolean successAuthorization(LoginUI loginUI, Contact contact) {
    DBManager manager = new DBManager();
    Contact cont = manager.getContactByLogin(loginUI.getUsername().getValue());
    if (cont == null) {
        return false;
    } else {/*ww  w  . j a  v  a 2s  .  c  om*/
        try {
            if (cont.getToken().equals(SHA1Password(loginUI))) {
                contact.setAuthorized(true);
                contact.setLogin(cont.getLogin());
                contact.setId(cont.getId());
                contact.setToken(cont.getToken());
                contact.setUserInfo(cont.getUserInfo());
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            Notification.show("System error");
            return false;
        }
    }
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
    super.enter(event); //To change body of generated methods, choose Tools | Templates.
    if (!Strings.isNullOrEmpty(parameters) && NumberUtils.isNumber(parameters)) {
        Appointment find = appointmentService.find(Long.valueOf(parameters));
        if (find != null) {
            Window open = open(find);
            open.addCloseListener(new com.vaadin.ui.Window.CloseListener() {

                @Override/*from   ww w.j av a 2 s  .  c om*/
                public void windowClose(com.vaadin.ui.Window.CloseEvent e) {
                    UI.getCurrent().getNavigator().getDisplay().showView(event.getOldView());
                }
            });
        } else {
            Notification.show("La cita no existe");
            getUI().getNavigator().getDisplay().showView(event.getOldView());
        }
    }
}