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, String description) 

Source Link

Document

Creates a "humanized" notification message with a bigger caption and smaller description.

Usage

From source file:fr.univlorraine.mondossierweb.controllers.UiController.java

License:Apache License

/**
 * Permet la saisie et l'envoi d'un message  tous les clients connects
 *//*  w w  w .j a v  a  2  s  .  co  m*/
public void sendMessage() {
    InputWindow inputWindow = new InputWindow(
            applicationContext.getMessage("admin.sendMessage.message", null, UI.getCurrent().getLocale()),
            applicationContext.getMessage("admin.sendMessage.title", null, UI.getCurrent().getLocale()));
    inputWindow.addBtnOkListener(text -> {
        if (text instanceof String && !text.isEmpty()) {
            Notification notification = new Notification(
                    applicationContext.getMessage("admin.sendMessage.notificationCaption",
                            new Object[] { text }, UI.getCurrent().getLocale()),
                    Type.TRAY_NOTIFICATION);
            notification.setDelayMsec(-1);
            notification.setDescription("\n" + applicationContext.getMessage(
                    "admin.sendMessage.notificationDescription", null, UI.getCurrent().getLocale()));
            notification.setPosition(Position.TOP_CENTER);
            sendNotification(notification);
        }
    });
    UI.getCurrent().addWindow(inputWindow);
}

From source file:helpers.Utils.java

License:Open Source License

public static void Notification(String title, String description, String type) {
    Notification notify = new Notification(title, description);
    notify.setPosition(Position.TOP_CENTER);
    if (type.equals("error")) {
        notify.setDelayMsec(16000);/*  w w  w. j  av  a  2  s  . c  om*/
        notify.setIcon(FontAwesome.FROWN_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    } else if (type.equals("success")) {
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.SMILE_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    } else {
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.COMMENT);
        notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    }
    notify.show(Page.getCurrent());
}

From source file:org.esn.esobase.view.tab.QuestsTab.java

private void SaveForm() {
    try {/*w  ww. ja  v  a 2 s  .co m*/
        fieldGroup.commit();
        Quest entity = (Quest) currentItem.getBean();
        service.saveEntity(entity);
        CloseForm();
        LoadTable();
        Notification notification = new Notification("? ?",
                Notification.Type.HUMANIZED_MESSAGE);
        notification.setDelayMsec(2000);
        notification.show(this.getUI().getPage());
    } catch (FieldGroup.CommitException ex) {
        Logger.getLogger(QuestsTab.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.esn.esobase.view.tab.SystemSettingsTab.java

public SystemSettingsTab(DBService service_) {
    this.service = service_;

    FormLayout fl = new FormLayout();
    isAutoSyncEnabledBox = new CheckBox("??? ");
    fl.addComponent(isAutoSyncEnabledBox);
    HorizontalLayout hl = new HorizontalLayout();
    Button saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override/*w w w .  jav  a 2  s . co  m*/
        public void buttonClick(Button.ClickEvent event) {
            service.setIsAutoSynchronizationEnabled(isAutoSyncEnabledBox.getValue());
            LoadData();
            Notification notification = new Notification("?? ? ?",
                    Notification.Type.HUMANIZED_MESSAGE);
            notification.setDelayMsec(2000);
            notification.show(isAutoSyncEnabledBox.getUI().getPage());
        }
    });
    Button cancelButton = new Button("");
    cancelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadData();
        }
    });
    hl.addComponent(cancelButton);
    hl.addComponent(saveButton);
    fl.addComponent(hl);
    this.addComponent(fl);
    LoadData();
}

From source file:org.jumpmind.metl.ui.views.admin.LoggingPanel.java

License:Open Source License

private StreamResource getLogFileResource() {
    StreamSource ss = new StreamSource() {
        public InputStream getStream() {
            try {
                return new BufferedInputStream(new FileInputStream(logFile));
            } catch (FileNotFoundException e) {
                Notification note = new Notification("File Not Found",
                        "Could not find " + logFile.getName() + " to download");
                note.show(Page.getCurrent());
                return null;
            }/*from  w w  w.j a v  a 2 s  .  c o m*/
        }
    };
    return new StreamResource(ss, logFile.getName());
}

From source file:org.jumpmind.metl.ui.views.design.ImportXmlTemplateWindow.java

License:Open Source License

protected void importXml(String text) {
    SAXBuilder builder = new SAXBuilder();
    builder.setXMLReaderFactory(XMLReaders.NONVALIDATING);
    builder.setFeature("http://xml.org/sax/features/validation", false);
    try {/*from  ww  w.  j  a v a2s  . c  om*/
        Document document = builder.build(new StringReader(text));
        String rootName = document.getRootElement().getName();
        if (rootName.equals("definitions")) {
            importFromWsdl(text);
        } else if (rootName.equals("schema")) {
            importFromXsd(text);
        } else {
            Notification note = new Notification("Unrecognized Content", "The XML file has a root element of "
                    + rootName + ", but expected \"definitions\" for WSDL or \"schema\" for XSD.");
            note.show(Page.getCurrent());
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.jumpmind.metl.ui.views.design.ImportXmlTemplateWindow.java

License:Open Source License

protected void importFromWsdl(String text) throws Exception {
    File wsdlFile = File.createTempFile("import", "wsdl");
    FileUtils.write(wsdlFile, text);//  ww w . j a v a 2s  .c o m
    final Wsdl wsdl = Wsdl.parse(wsdlFile.toURI().toURL());
    List<SoapOperation> allOperations = new ArrayList<>();
    List<QName> bindings = wsdl.getBindings();
    for (QName binding : bindings) {
        SoapBuilder builder = wsdl.getBuilder(binding);
        List<SoapOperation> operations = builder.getOperations();
        allOperations.addAll(operations);
    }

    if (allOperations.size() == 0) {
        Notification note = new Notification("No operations", "No operations found in the WSDL.");
        note.show(Page.getCurrent());
    } else if (allOperations.size() == 1) {
        importFromWsdl(wsdl, allOperations.get(0));
    } else {
        ChooseWsdlServiceOperationWindow dialog = new ChooseWsdlServiceOperationWindow(allOperations,
                new ServiceChosenListener() {
                    public boolean onOk(SoapOperation operation) {
                        importFromWsdl(wsdl, operation);
                        return true;
                    }
                });
        UI.getCurrent().addWindow(dialog);
    }
}

From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewsConfigUI.java

License:Open Source License

/**
 * Method for displaying notification for the user.
 *
 * @param message     the message to be displayed
 * @param description the description of this message
 * @param type        the type of this notification
 *///from  w w  w .  j  av  a  2  s.c o m
public void notifyMessage(String message, String description, Notification.Type type) {
    Notification m_notification = new Notification("Message", type);

    m_notification.setCaption(message);
    m_notification.setDescription(description);
    m_notification.setDelayMsec(1000);

    if (getUI() != null) {
        if (getPage() != null) {
            m_notification.show(getUI().getPage());
        }
    }
}

From source file:tad.grupo7.ccamistadeslargas.AmigosLayout.java

/**
 * Muestra una amistad en concreto.//from   ww w.  j  a va 2 s.  com
 * @param p Participante
 */
private void mostrarParticipante(Participante p) {
    //FORMULARIO POR SI SE QUIERE EDITAR EL PARTICIPANTE
    TextField nombre = new TextField("Nombre");
    nombre.setValue(p.getNombre());
    final Button eliminar = new Button("Eliminar Participante");
    final Button actualizar = new Button("Actualizar Participante");

    //BOTN PARA ACTUALIZAR EL PARTICIPANTE
    actualizar.addClickListener(clickEvent -> {
        if (ParticipanteDAO.read(nombre.getValue(), usuario.getId()) == null) {
            ParticipanteDAO.update(p.getId(), nombre.getValue());
            UsuarioDAO.updateAmigo(nombre.getValue(), p.getId(), usuario.getId());
            Notification n = new Notification("Amigo actualizado", Notification.Type.ASSISTIVE_NOTIFICATION);
            n.setPosition(Position.TOP_CENTER);
            n.show(Page.getCurrent());
            removeAllComponents();
            mostrarAmistades();
        } else {
            Notification n = new Notification("Ya existe un amigo con el mismo nombre",
                    Notification.Type.WARNING_MESSAGE);
            n.setPosition(Position.TOP_CENTER);
            n.show(Page.getCurrent());
        }

    });
    //BOTN PARA ELIMINAR EL PARTICIPANTE
    eliminar.addClickListener(clickEvent -> {
        ParticipanteDAO.delete(p.getId());
        UsuarioDAO.removeAmigo(nombre.getValue(), usuario.getId());
        removeAllComponents();
        mostrarAmistades();
    });

    //AADIMOS LOS COMPONENTES
    FormLayout form = new FormLayout(nombre, actualizar, eliminar);
    VerticalLayout l = new VerticalLayout(form);
    l.setMargin(true);
    setSecondComponent(l);
}

From source file:tad.grupo7.ccamistadeslargas.AmigosLayout.java

/**
 * Muestra el formulario para aadir una nueva amistad.
 *//*  w w w .j ava2 s  . co m*/
private void mostrarFormularioAddAmistad() {
    TextField nombre = new TextField("Nombre");
    nombre.setRequired(true);

    final Button add = new Button("Crear Participante");
    add.addStyleName(ValoTheme.BUTTON_PRIMARY);
    FormLayout form = new FormLayout(nombre, add);
    add.addClickListener(clickEvent -> {
        try {
            nombre.validate();
            if (ParticipanteDAO.read(nombre.getValue(), usuario.getId()) == null) {
                ParticipanteDAO.create(nombre.getValue(), usuario.getId());
                UsuarioDAO.addAmigo(nombre.getValue(), usuario.getId());
                mostrarAmistades();
            } else {
                Notification n = new Notification("Ya existe un amigo con el mismo nombre",
                        Notification.Type.WARNING_MESSAGE);
                n.setPosition(Position.TOP_CENTER);
                n.show(Page.getCurrent());
            }
        } catch (Validator.InvalidValueException ex) {
            Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE);
            n.setPosition(Position.TOP_CENTER);
            n.show(Page.getCurrent());
        }
    });
    form.setMargin(true);
    setSecondComponent(form);
}