Example usage for com.vaadin.ui Notification Notification

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

Introduction

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

Prototype

public Notification(String caption) 

Source Link

Document

Creates a "humanized" notification message.

Usage

From source file:de.gedoplan.webclients.vaadin.views.CustomerForm.java

private void configureActions() {
    speichern = new Button(Messages.save.value(), e -> {
        try {/*from w ww .  j a va  2s .c o m*/
            fieldGroup.commit();
            fieldGroup.setItemDataSource(
                    customerService.updateCustomer(fieldGroup.getItemDataSource().getBean()));
            Notification success = new Notification(Messages.save_success.value());
            success.setStyleName(ValoTheme.NOTIFICATION_SUCCESS);
            success.show(Page.getCurrent());
        } catch (FieldGroup.CommitException ex) {
            // Leer
        }
    });
    abbrechen = new Button(Messages.cancel.value(),
            e -> navigator.navigateTo(Konstanten.VAADIN_VIEW_CUSTOMERS));
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.RfeDialog.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
@SuppressWarnings("serial")
public RfeDialog(Object aplnId) {
    this.apId = aplnId;

    setCaption("Request for Expertise");
    setModal(true);//from   w  ww . jav  a 2 s.c  o  m
    setSizeUndefined();
    setWidth("500px");
    setHeight("400px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    vLay.setMargin(true);
    vLay.setSpacing(true);
    vLay.setSizeFull();

    IDButton searchButt = new IDButton("Option 1: Search for players with needed expertise", SEARCHCLICK, null);
    searchButt.enableAction(false); // do manually
    searchButt.addClickListener(new SearchListener());
    vLay.addComponent(searchButt);

    VerticalLayout nuts = new VerticalLayout();
    vLay.addComponent(nuts);
    nuts.setSizeFull();
    vLay.setExpandRatio(nuts, 1.0f);
    Label lab;
    /*vLay*/nuts.addComponent(lab = new Label("Option 2: Post help-wanted notice to action plan"));
    lab.addStyleName("m-font-bold11");

    final VerticalLayout helpWantedPan = new VerticalLayout();
    /*vLay*/nuts.addComponent(helpWantedPan);
    helpWantedPan.addStyleName("m-greyborder");
    helpWantedPan.setWidth("99%");
    helpWantedPan.setHeight("99%");
    helpWantedPan.setSpacing(true);
    helpWantedPan.setMargin(true);
    /*vLay*/nuts.setExpandRatio(helpWantedPan, 1.0f);

    helpWantedTA = new TextArea("Current posting");
    helpWantedTA.setWidth("100%");
    helpWantedTA.setHeight("100%");
    helpWantedTA.setNullRepresentation("");
    helpWantedPan.addComponent(helpWantedTA);
    helpWantedPan.setExpandRatio(helpWantedTA, 1.0f);

    HorizontalLayout buttLay = new HorizontalLayout();
    helpWantedPan.addComponent(buttLay);
    buttLay.setSpacing(true);
    buttLay.setWidth("100%");

    buttLay.addComponent(lab = new Label());
    lab.setWidth("10px");

    clearButt = new Button("Clear");
    buttLay.addComponent(clearButt);
    clearButt.addClickListener(clearButtLis = new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            ActionPlan ap = ActionPlan.getTL(apId);
            helpWantedTA.setValue(null);
            if (null != ap.getHelpWanted()) {
                ap.setHelpWanted(null);
                ActionPlan.updateTL(ap);
                Notification notif = new Notification("Cleared");
                notif.setDelayMsec(3000);
                notif.show(Page.getCurrent());
                GameEventLogger.logHelpWantedTL(ap);
                notifyAuthorsOfChangeTL(ap);
            }
            HSess.close();
        }
    });

    buttLay.addComponent(lab = new Label());
    buttLay.setExpandRatio(lab, 1.0f);

    postButt = new Button("Post");
    buttLay.addComponent(postButt);
    postButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            Object val = helpWantedTA.getValue();
            if (val == null || val.toString().length() <= 0) {
                clearButtLis.buttonClick(event);
                return;
            }

            HSess.init();
            String s = val.toString();
            ActionPlan ap = ActionPlan.getTL(apId);
            if (s == null ? ap.getHelpWanted() != null : !s.equals(ap.getHelpWanted())) {
                ap.setHelpWanted(s);
                ActionPlan.updateTL(ap);
                Notification notif = new Notification("Posted");
                notif.setDelayMsec(3000);
                notif.show(Page.getCurrent());
                GameEventLogger.logHelpWantedTL(ap);
                notifyAuthorsOfChangeTL(ap);
            }
            HSess.close();
        }
    });
    buttLay.addComponent(lab = new Label());
    lab.setWidth("10px");

    helpWantedPan.addComponent(lab = new Label());
    lab.setHeight("10px");

    IDButton troubleButt = new IDButton("Option 3: Post Trouble Report", POSTTROUBLECLICK, null);
    troubleButt.enableAction(false); // managed manually
    troubleButt.addClickListener(new TroubleListener());
    vLay.addComponent(troubleButt);

    Button closeButt = new Button("Close");
    vLay.addComponent(closeButt);
    closeButt.addClickListener(new CloseListener());

    vLay.setComponentAlignment(closeButt, Alignment.MIDDLE_RIGHT);

    ActionPlan ap = ActionPlan.getTL(apId);
    String s = ap.getHelpWanted();
    helpWantedTA.setValue(s);
}

From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java

License:Open Source License

private void loginAuthenticationFailedNotification() {
    final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.description"));
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(1_000);//from ww w  . j  ava2s.  com
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.AbstractHawkbitLoginUI.java

License:Open Source License

private void loginCredentialsExpiredNotification() {
    final Notification notification = new Notification(
            i18n.getMessage("notification.login.failed.credentialsexpired.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description"));
    notification.setDelayMsec(10_000);/*from ww w.  ja va  2  s.  c o  m*/
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closeable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.LoginView.java

License:Open Source License

void loginAuthenticationFailedNotification() {
    final Notification notification = new Notification(i18n.getMessage("notification.login.failed.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.description"));
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(1000);// ww  w .jav  a 2s  . c om
    notification.show(Page.getCurrent());
}

From source file:org.eclipse.hawkbit.ui.login.LoginView.java

License:Open Source License

void loginCredentialsExpiredNotification() {
    final Notification notification = new Notification(
            i18n.getMessage("notification.login.failed.credentialsexpired.title"));
    notification.setDescription(i18n.getMessage("notification.login.failed.credentialsexpired.description"));
    notification.setDelayMsec(10000);/* www .j  a v a2 s.c o  m*/
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("error closeable");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.show(Page.getCurrent());
}

From source file:ru.inovus.ui.SignInUI.java

License:Apache License

private void notification() {
    Notification notification = new Notification("!");
    notification.setDescription(/*from  ww  w .  java2s .c o m*/
            "<span> ??  ?  <b>User</b>  <b>password</b>.</span>");
    notification.setHtmlContentAllowed(true);
    notification.setStyleName("tray dark small closable login-help");
    notification.setPosition(Position.BOTTOM_CENTER);
    notification.setDelayMsec(20000);
    notification.show(Page.getCurrent());
}

From source file:to.hacklab.cardmanager.MyVaadinApplication.java

License:Apache License

@Override
public void init(VaadinRequest request) {
    VerticalLayout layout = new VerticalLayout();
    setContent(layout);//from  w  w  w.j a va2s  . com
    List<Card> cardList = new ArrayList<>();
    try {
        cardList = CardApi.getCards();
    } catch (IOException e) {
        Notification.show("Unable to load cards: " + e.getMessage());
    }

    final BeanItemContainer<Card> beanItemContainer = new BeanItemContainer<>(Card.class, cardList);

    final Table table = new Table("Cards");

    table.setContainerDataSource(beanItemContainer);
    table.setSortContainerPropertyId("name");
    table.setSelectable(true);
    table.setImmediate(true);

    layout.addComponent(table);

    CardForm cardForm = new CardForm();
    layout.addComponent(cardForm);

    FieldGroup fieldGroup = new FieldGroup(new BeanItem(new Card("Cow", "Moo")));
    fieldGroup.bindMemberFields(cardForm);
    fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() {
        @Override
        public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {

        }

        @Override
        public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
            // /send the form values!
        }
    });

    table.addValueChangeListener(
            event -> fieldGroup.setItemDataSource(beanItemContainer.getItem(table.getValue())));

    final Button saveButton = new Button("Save");
    final Button discardButton = new Button("Discard");
    layout.addComponent(saveButton);
    layout.addComponent(discardButton);
    discardButton.addClickListener(event -> fieldGroup.discard());
    saveButton.addClickListener(event -> {
        try {
            fieldGroup.commit();
        } catch (FieldGroup.CommitException e) {
            new Notification("Couldn't save: " + e.getMessage()).show(Page.getCurrent());
        }
    });

}

From source file:uicomponents.LigandExtractPanel.java

License:Open Source License

public boolean isValid() {
    boolean res = true;
    String error = "";
    for (Iterator i = extractionExperiments.getItemIds().iterator(); i.hasNext();) {
        // Get the current item identifier, which is an integer.
        int iid = (Integer) i.next();

        // Now get the actual item from the table.
        Item item = extractionExperiments.getItem(iid);

        TextField mass = (TextField) item.getItemProperty("Mass [mg]").getValue();
        try {/*from   w  w  w.jav  a 2s. co  m*/
            Integer.parseInt(mass.getValue());
        } catch (NumberFormatException e) {
            res = false;
            error = "Sample mass has to be a number!";
        }
        DateField d = (DateField) item.getItemProperty("Date").getValue();

        if (d.getValue() == null) {
            error = "Please select preparation dates for all samples!";
        }
        ComboBox ab1 = (ComboBox) item.getItemProperty("Antibody 1").getValue();
        TextField mass1 = (TextField) item.getItemProperty("Mass 1 [mg]").getValue();
        ComboBox ab2 = (ComboBox) item.getItemProperty("Antibody 2").getValue();
        TextField mass2 = (TextField) item.getItemProperty("Mass 2 [mg]").getValue();
        ComboBox ab3 = (ComboBox) item.getItemProperty("Antibody 3").getValue();
        TextField mass3 = (TextField) item.getItemProperty("Mass 3 [mg]").getValue();

        String antibodyError = "Please choose at least one antibody and fill in the mass.";

        if (ab1.getValue() != null && !mass1.getValue().isEmpty()) {
            try {
                Integer.parseInt(mass.getValue());
            } catch (NumberFormatException e) {
                res = false;
                error = "Antibody 1 mass has to be a number!";
            }
        } else {
            res = false;
            error = antibodyError;
        }
        if (ab2.getValue() != null && !mass2.getValue().isEmpty()) {
            try {
                Integer.parseInt(mass.getValue());
            } catch (NumberFormatException e) {
                res = false;
                error = "Antibody 2 mass has to be a number!";
            }
        }
        if (ab3.getValue() != null && !mass3.getValue().isEmpty()) {
            try {
                Integer.parseInt(mass.getValue());
            } catch (NumberFormatException e) {
                res = false;
                error = "Antibody 3 mass has to be a number!";
            }
        }
    }

    if (!res) {
        Notification n = new Notification(error);
        n.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE);
        n.setDelayMsec(-1);
        n.show(UI.getCurrent().getPage());
        return false;
    } else
        return true;
}

From source file:uicomponents.PoolingTable.java

License:Open Source License

private void initButtonMover(Table sourceTable, Table usedTable) {
    moveLeft.addClickListener(new Button.ClickListener() {

        /**// w  w  w  .ja  va 2 s  . c o m
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Table source = getActiveTable();
            Set<Object> ids = (Set<Object>) source.getValue();
            boolean atLeastOneNew = false;
            if (ids.size() > 0) {
                for (Object itemId : ids) {
                    atLeastOneNew |= moveSampleToPool(source, itemId);
                }
                resizeTable();
                if (!atLeastOneNew) {
                    Notification n = new Notification("Samples are already in this pool.");
                    n.setDelayMsec(3000);
                    n.show(Page.getCurrent());
                }
            }
        }
    });
}