Example usage for com.vaadin.ui Notification setDelayMsec

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

Introduction

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

Prototype

public void setDelayMsec(int delayMsec) 

Source Link

Document

Sets the delay before the notification disappears.

Usage

From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java

License:Open Source License

private boolean convertIFC2RDFDefault(File file, String name) {
    try {//from w  w w.ja v a 2 s.c  o m
        IfcModel model = IfcParserUtil.parseModel(file.getAbsolutePath());
        ComplexProcessorConfiguration groundingConfiguration = IfcModelAnalyser.getDefaultGroundingRuleSets();
        IfcModelAnalyser modelAnalyser = new IfcModelAnalyser(model);
        modelAnalyser.groundNodes(groundingConfiguration);

        OntModel modelExport = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF);
        Ifc2RdfExportUtil.exportModelToJenaModel(modelExport, model);

        RdfUtils.exportJenaModelToRdfFile(modelExport,
                DrumbeatConstants.marmotta_import_directory + file.getName(), RDFFormat.TURTLE, false);
        JenaModelFactoryBase jenaModelFactory = new MemoryJenaModelFactory();

        try {
            Model metaModelGraph = jenaModelFactory.createModel();

            try {
                metaModelGraph.read(DrumbeatConstants.metadata_location, "TURTLE");
            } catch (Exception e) {
                e.printStackTrace();
            }

            Ifc2RdfExportUtil.exportMetaModelToJenaModel(DrumbeatConstants.metadata_base + name, metaModelGraph,
                    model);
            FileOutputStream fout = new FileOutputStream(new File(DrumbeatConstants.metadata_location));
            RDFDataMgr.write(fout, metaModelGraph, RDFFormat.TURTLE_PRETTY);
            fout.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    } catch (Exception e) {
        e.printStackTrace();
        Notification n = new Notification("Default IFC2RDF export error ", e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(5000);
        n.show(Page.getCurrent());
        return false;
    }
    return true;
}

From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatFileHandler.java

License:Open Source License

@Override
public void uploadFailed(FailedEvent event) {
    Notification n = new Notification("Uploading the file failed.", Notification.Type.ERROR_MESSAGE);
    n.setDelayMsec(1000);
    n.show(Page.getCurrent());/*from w w  w .  j a v a 2s.  c  om*/
}

From source file:fr.amapj.view.engine.notification.NotificationHelper.java

License:Open Source License

static public void displayNotification(String message) {

    Notification notification = new Notification("Erreur", message, Type.ERROR_MESSAGE, true);
    notification.setPosition(Position.TOP_CENTER);
    notification.setDelayMsec(1000);
    notification.show(Page.getCurrent());
}

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
 *//*from   w w  w  . j  a  v  a2 s  . c  o  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:fr.univlorraine.mondossierweb.MdwTouchkitUI.java

License:Apache License

/**
 * Affiche du message d'intro//from   w  ww  . j  av a2  s  . com
 */
private void afficherMessageIntro(String text) {

    Notification note = new Notification(text, "", Notification.TYPE_TRAY_NOTIFICATION, true);
    note.setPosition(Position.MIDDLE_CENTER);
    note.setDelayMsec(6000);
    note.show(this.getPage());

    /**
     * ANCIENNE VERSION AVEC POPUP WINDOW
     */
    /*
    //Recuperer dans la base si l'utilisateur a une prfrence pour l'affichage le message
    String val  = userController.getPreference(Utils.SHOW_MESSAGE_INTRO_MOBILE_PREFERENCE);
            
    //Par dfaut on affiche le message
    boolean afficherMessage = true;
            
    //Si on a une prfrence pour l'utilisateur en ce qui concerne l'affichage du message d'accueil mobile
    if(StringUtils.hasText(val)){
       //On rcupre ce choix dans afficherMessage
       afficherMessage = Boolean.valueOf(val);
    }
            
    //Si on doit afficher le message
    if(afficherMessage){
            
       //Cration de la pop-pup contenant le message
       HelpMobileWindow hbw = new HelpMobileWindow(text,applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()),true);
            
       //Sur la fermeture de la fentre
       hbw.addCloseListener(g->{
    //On va enregistrer en base que l'utilisateur ne souhaite plus afficher le message si la checkbox propose par la pop-up a t coche
    boolean choix = hbw.getCheckBox().getValue();
    //Test si l'utilisateur a coch la case pour ne plus afficher le message
    if(choix){
       //mettre a jour dans la base de donnes
       userController.updatePreference(Utils.SHOW_MESSAGE_INTRO_MOBILE_PREFERENCE, "false");
    }
       });
            
       //Affichage de la pop_up
       UI.getCurrent().addWindow(hbw);
            
    }
     */
}

From source file:fr.univlorraine.mondossierweb.MdwTouchkitUI.java

License:Apache License

/**
 * Cration du menu tudiant//from  www . jav  a 2 s  .  co m
 */
private void initMenuEtudiant() {

    //Si le menuEtudiant n'a jamais t initialis
    if (menuEtudiant == null) {
        //On cr le menuEtudiant
        menuEtudiant = new TabBarView();
    }

    //Cration de l'onglet Informations
    tabInfoAnnuelles = menuEtudiant.addTab(informationsAnnuellesMobileView,
            applicationContext.getMessage("mobileUI.infoannuelles.title", null, getLocale()), FontAwesome.INFO);
    tabInfoAnnuelles.setId("tabInfoAnnuelles");

    //Cration de l'onglet Calendrier
    tabCalendrier = menuEtudiant.addTab(calendrierMobileView,
            applicationContext.getMessage("mobileUI.calendrier.title", null, getLocale()),
            FontAwesome.CALENDAR);
    tabCalendrier.setId("tabCalendrier");

    //Si le navigationManager des notes est null
    if (noteNavigationManager == null) {
        //On cr le navigationManager
        noteNavigationManager = new NavigationManager();
    }
    //le composant affich dans le navigationManager est la vue des notes
    noteNavigationManager.setCurrentComponent(notesMobileView);
    //le composant suivant  afficher dans le navigationManager est la vue du dtail des notes
    noteNavigationManager.setNextComponent(notesDetailMobileView);
    //Cration de l'onglet Rsultats
    tabNotes = menuEtudiant.addTab(noteNavigationManager,
            applicationContext.getMessage("mobileUI.resultats.title", null, getLocale()), FontAwesome.LIST);
    tabNotes.setId("tabNotes");

    //Dtection du retour sur la vue du dtail des notes pour mettre  jour le JS
    menuEtudiant.addListener(new SelectedTabChangeListener() {
        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            //test si on se rend sur la vue des notes
            if (menuEtudiant.getSelelectedTab().equals(tabNotes)) {
                //test si on se rend sur le dtail des notes
                if (noteNavigationManager.getCurrentComponent().equals(notesDetailMobileView)) {
                    //On met  jour le JS (qui est normalement perdu, sans explication)
                    notesDetailMobileView.refreshJavascript();
                }
            }

            //test si on se rend sur la vue calendrier
            if (menuEtudiant.getSelelectedTab().equals(tabCalendrier)) {
                /* Message d'info */
                if (applicationContext.getMessage(CalendrierMobileView.NAME + ".message.info", null,
                        getLocale()) != null) {
                    Notification note = new Notification(applicationContext
                            .getMessage(CalendrierMobileView.NAME + ".message.info", null, getLocale()), "",
                            Notification.TYPE_TRAY_NOTIFICATION, true);
                    note.setPosition(Position.MIDDLE_CENTER);
                    note.setDelayMsec(6000);
                    note.show(Page.getCurrent());
                    //Notification.show("", applicationContext.getMessage(CalendrierMobileView.NAME+".message.info", null, getLocale()), Notification.TYPE_TRAY_NOTIFICATION);
                }
            }
        }
    });

}

From source file:fr.univlorraine.mondossierweb.views.FavorisMobileView.java

License:Apache License

/**
 * Initialise la vue//from www  . j av  a  2s . co m
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        removeAllComponents();

        /* Style */
        setSizeFull();

        liste_types_inscrits = new LinkedList<String>();
        liste_types_inscrits.add("ELP");
        liste_types_inscrits.add("VET");

        liste_type_arbo = new LinkedList<String>();
        liste_type_arbo.add("CMP");
        liste_type_arbo.add("VET");

        List<Favoris> lfav = favorisController.getFavoris();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton info
        infoButton = new Button();
        infoButton.setIcon(FontAwesome.INFO);
        infoButton.setStyleName("v-nav-button");
        infoButton.addClickListener(e -> {
            /**
             * NOUVELLE VERSION
             */
            Notification note = new Notification(
                    applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()), "",
                    Notification.TYPE_TRAY_NOTIFICATION, true);
            note.setPosition(Position.MIDDLE_CENTER);
            note.setDelayMsec(6000);
            note.show(UI.getCurrent().getPage());
            /**
             * ANCIENNE VERSION
             */
            /*
            //afficher message
            HelpMobileWindow hbw = new HelpMobileWindow(applicationContext.getMessage("helpWindowMobile.text.enseignant", null, getLocale()),applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()),false);
                    
            UI.getCurrent().addWindow(hbw);
            */
        });
        navbar.addComponent(infoButton);
        navbar.setComponentAlignment(infoButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelFav = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelFav.setStyleName("v-label-navbar");
        navbar.addComponent(labelFav);
        navbar.setComponentAlignment(labelFav, Alignment.MIDDLE_CENTER);

        //Bouton Search
        Button searchButton = new Button();
        searchButton.setIcon(FontAwesome.SEARCH);
        searchButton.setStyleName("v-nav-button");
        navbar.addComponent(searchButton);
        navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);
        searchButton.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });
        navbar.setExpandRatio(labelFav, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);

        FormLayout labelLayout = new FormLayout();
        labelLayout.setSizeFull();
        labelLayout.setMargin(false);
        labelLayout.setSpacing(false);

        Label infoLabel = new Label(applicationContext.getMessage(NAME + ".info.label", null, getLocale()));
        infoLabel.setStyleName(ValoTheme.LABEL_SMALL);
        infoLabel.setIcon(FontAwesome.INFO_CIRCLE);
        infoLabel.setWidth("100%");

        labelLayout.addComponent(infoLabel);
        globalLayout.addComponent(labelLayout);

        if (lfav != null && lfav.size() > 0) {
            if (favorisContientVet(lfav)) {

                Panel vetPanel = new Panel(
                        applicationContext.getMessage(NAME + ".vetpanel.title", null, getLocale()));
                vetPanel.setStyleName("centertitle-panel");
                vetPanel.addStyleName("v-colored-panel-caption");
                vetPanel.setSizeFull();

                VerticalLayout vetLayout = new VerticalLayout();
                vetLayout.setSizeFull();
                vetLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.VET)) {
                        i++;

                        HorizontalLayout favVetLayout = new HorizontalLayout();
                        favVetLayout.setSizeFull();
                        favVetLayout.setMargin(true);
                        favVetLayout.setSpacing(true);
                        favVetLayout.setStyleName("v-layout-multiline");
                        favVetLayout.setWidth("100%");
                        favVetLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        codeButton.setCaption(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favVetLayout.addComponent(codeButton);
                        //favVetLayout.setComponentAlignment(codeButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.addComponent(libButton);
                        favVetLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favVetLayout.setExpandRatio(libButton, 1);
                        vetLayout.addComponent(favVetLayout);
                        if (i > 1) {
                            favVetLayout.addStyleName("line-separator");
                        }
                    }
                }
                vetPanel.setContent(vetLayout);
                globalLayout.addComponent(vetPanel);

            }

            if (favorisContientElp(lfav)) {
                Panel elpPanel = new Panel(
                        applicationContext.getMessage(NAME + ".elppanel.title", null, getLocale()));
                elpPanel.setStyleName("centertitle-panel");
                elpPanel.addStyleName("v-colored-panel-caption");
                elpPanel.setSizeFull();

                VerticalLayout elpLayout = new VerticalLayout();
                elpLayout.setSizeFull();
                elpLayout.setHeight(null);
                int i = 0;
                for (Favoris fav : lfav) {
                    if (fav.getId().getTypfav().equals(Utils.ELP)) {
                        i++;
                        HorizontalLayout favElpLayout = new HorizontalLayout();
                        favElpLayout.setSizeFull();
                        favElpLayout.setMargin(true);
                        favElpLayout.setSpacing(true);
                        favElpLayout.setStyleName("v-layout-multiline");
                        favElpLayout.setWidth("100%");
                        favElpLayout.setHeight("100%");

                        Button codeButton = new Button(fav.getId().getIdfav());
                        Utils.setButtonStyle(codeButton);
                        codeButton.setWidth("90px");
                        codeButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        Button libButton = new Button(favorisController.getLibObjFavori(fav.getId().getTypfav(),
                                fav.getId().getIdfav()));
                        Utils.setButtonStyle(libButton);
                        libButton.setHeight("100%");
                        libButton.setWidth("100%");
                        libButton.addClickListener(e -> {
                            accessToDetail(fav.getId().getIdfav(), fav.getId().getTypfav());
                        });

                        favElpLayout.addComponent(codeButton);
                        favElpLayout.addComponent(libButton);
                        favElpLayout.setComponentAlignment(libButton, Alignment.MIDDLE_CENTER);
                        favElpLayout.setExpandRatio(libButton, 1);
                        elpLayout.addComponent(favElpLayout);
                        if (i > 1) {
                            favElpLayout.addStyleName("line-separator");
                        }
                    }
                }
                elpPanel.setContent(elpLayout);
                globalLayout.addComponent(elpPanel);
            }

        }

        labelAucunFavoriLayout = new HorizontalLayout();
        labelAucunFavoriLayout.setMargin(true);
        labelAucunFavoriLayout.setSizeFull();
        Button aucunFavoris = new Button(
                applicationContext.getMessage(NAME + ".favoris.aucun", null, getLocale()));
        aucunFavoris.setStyleName("v-nav-button");
        aucunFavoris.addStyleName(ValoTheme.BUTTON_LINK);
        aucunFavoris.addClickListener(e -> {
            ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
        });

        labelAucunFavoriLayout.addComponent(aucunFavoris);
        labelAucunFavoriLayout.setVisible(false);
        globalLayout.addComponent(labelAucunFavoriLayout);

        if (lfav == null || lfav.size() == 0) {
            labelAucunFavoriLayout.setVisible(true);
        }

        //addComponent(globalLayout);
        contentLayout.setStyleName("v-scrollableelement");
        contentLayout.addComponent(globalLayout);
        addComponent(contentLayout);
        setExpandRatio(contentLayout, 1);

    }
}

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);
        notify.setIcon(FontAwesome.FROWN_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    } else if (type.equals("success")) {
        notify.setDelayMsec(8000);// w  ww.j  a  v  a  2 s  . c  o m
        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:life.qbic.utils.qOfferManagerUtils.java

License:Open Source License

/**
 * Displays a vaadin Notification with the respective title, description and type.
 * @param title: title of the displayNotification window
 * @param description: description of the displayNotification Window
 * @param type: one of "error", "success" and "warning". Changes the style and the delay of the displayNotification.
 *//* w ww .j  a va 2 s.  c  o  m*/
public static void displayNotification(String title, String description, String type) {
    com.vaadin.ui.Notification notify = new com.vaadin.ui.Notification(title, description);
    notify.setPosition(Position.TOP_CENTER);
    switch (type) {
    case "error":
        notify.setDelayMsec(16000);
        notify.setIcon(FontAwesome.FROWN_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    case "success":
        notify.setDelayMsec(8000);
        notify.setIcon(FontAwesome.SMILE_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    case "warning":
        notify.setDelayMsec(16000);
        notify.setIcon(FontAwesome.MEH_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_WARNING + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    default:
        notify.setDelayMsec(16000);
        notify.setIcon(FontAwesome.MEH_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
        break;
    }
    notify.show(Page.getCurrent());
}

From source file:org.activiti.explorer.NotificationManager.java

License:Apache License

public void showWarningNotification(String captionKey, String descriptionKey) {
    Notification notification = new Notification(i18nManager.getMessage(captionKey),
            i18nManager.getMessage(descriptionKey), Notification.TYPE_WARNING_MESSAGE);
    notification.setDelayMsec(-1); // click to hide
    mainWindow.showNotification(notification);
}