Example usage for com.vaadin.ui Notification setPosition

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

Introduction

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

Prototype

public void setPosition(Position position) 

Source Link

Document

Sets the position of the notification message.

Usage

From source file:facs.components.BookAdmin.java

License:Open Source License

private void showErrorNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(15000);//from ww w.  j a  v a2  s .  c  om
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.FROWN_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

From source file:facs.components.BookAdmin.java

License:Open Source License

private 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);/*from w  w w  . j a va  2 s . com*/
        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.MEH_O);
        notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    }
    notify.show(Page.getCurrent());
}

From source file:facs.components.Booking.java

License:Open Source License

private void showErrorNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(16000);/*from w  ww  . j  a  v a 2 s .  c o m*/
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.FROWN_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_ERROR + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

From source file:facs.components.Booking.java

License:Open Source License

private void showNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(8000);//from w  ww  .j ava  2  s.  co  m
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.MEH_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_TRAY + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

From source file:facs.components.Booking.java

License:Open Source License

private void showSuccessfulNotification(String title, String description) {
    Notification notify = new Notification(title, description);
    notify.setDelayMsec(8000);// w w w  . jav a  2 s .  c o m
    notify.setPosition(Position.TOP_CENTER);
    notify.setIcon(FontAwesome.SMILE_O);
    notify.setStyleName(ValoTheme.NOTIFICATION_SUCCESS + " " + ValoTheme.NOTIFICATION_CLOSABLE);
    notify.show(Page.getCurrent());
}

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);//from  w w w  .  java  2  s  .  co  m
    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 www. j a  v  a 2s.  com
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   ww  w. j a v a 2 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/*  w  w  w  .ja  v  a 2s.c o  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 . ja va2s  .  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);

    }
}