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, Type type) 

Source Link

Document

Creates a notification message of the specified type, with a bigger caption and smaller description.

Usage

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void showStartNotification(String exportType) {
    Notification notif = new Notification("",
            "Export of " + exportType
                    + " begun.  Results may appear in another browser window (unless popups blocked).",
            Notification.Type.WARNING_MESSAGE); // not warning, but want yellow

    notif.setPosition(Position.MIDDLE_CENTER);
    notif.setDelayMsec(-1);//from   w w  w  . j a v  a  2s  .c  o m
    notif.show(Page.getCurrent());
}

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void showEndNotification(String exportType) {
    Notification notif = new Notification("",
            "Export of " + exportType
                    + " complete.  Results may appear in another browser window (unless popups blocked).",
            Notification.Type.WARNING_MESSAGE);

    notif.setPosition(Position.TOP_CENTER);
    notif.setDelayMsec(5000);/*from   www.ja v a  2  s.  co m*/
    notif.show(Page.getCurrent());
}

From source file:edu.nps.moves.mmowgli.export.GameExporter.java

License:Open Source License

@Override
public void exportToBrowser(String title) {
    AppMaster.instance().pokeReportGenerator();
    //Doesn't show for very long
    Notification notification = new Notification("", "Report publication initiated",
            Notification.Type.WARNING_MESSAGE);
    notification.setPosition(Position.TOP_CENTER);
    notification.setDelayMsec(5000);/*from w w  w. jav  a 2 s. com*/
    notification.show(Page.getCurrent());

    String url = AppMaster.instance().getAppUrlString(); //.toExternalForm();
    if (!url.endsWith("/"))
        url = url + "/";
    BrowserWindowOpener.open(url + "reports", "_blank");
}

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

License:Open Source License

@Override
public boolean actionPlanEditBeginEvent(Serializable apId, String msg) {
    if (apId != this.apId)
        return false;

    if (imAuthor) {
        Notification notif = new Notification("", "", Notification.Type.HUMANIZED_MESSAGE);
        notif.setPosition(Position.TOP_LEFT);
        notif.setStyleName("m-actionplan-edit-notification");
        notif.setDelayMsec(3000); // 3 secs to disappear

        notif.setCaption("");
        notif.setDescription(msg);//ww  w  .j a  v a2 s.c  o m
        notif.show(Page.getCurrent());
        return true;
    }
    return false;
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java

License:Open Source License

private void doCACNotif(String title, String text) {
    Notification notif = new Notification(title, text, Notification.Type.HUMANIZED_MESSAGE);
    notif.setPosition(Position.BOTTOM_CENTER);
    notif.setHtmlContentAllowed(true);/*from  ww  w  . j  ava  2s  . co m*/
    notif.setDelayMsec(2000);
    notif.show(Page.getCurrent());
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java

License:Open Source License

@Override
@MmowgliCodeEntry//from  w w w. j a v  a 2s.  c o m
@HibernateConditionallyOpened
@HibernateConditionallyClosed
@HibernateUpdate
@HibernateUserUpdate
@HibernateUserRead
public void buttonClick(ClickEvent event) {
    MSysOut.println(DEBUG_LOGS, "RegistrationPageBase multi-button handler entered");

    killQuickLoginThread(); // if running

    if (lockedOut)
        return;

    if (event.getButton() == signupButt) {
        //String url = VaadinServletService.getCurrentServletRequest().getRequestURI();
        String url = AppMaster.getUrlString();
        if (url.endsWith("PUSH/")) //todo figure this out
            url = url.substring(0, url.length() - 5);
        if (url.endsWith("PUSH"))
            url = url.substring(0, url.length() - 4);
        if (url.endsWith("/"))
            url = url + "signup";
        else
            url = url + "/signup";

        Mmowgli2UI.getAppUI().getSession().close(); //app.close();
        Mmowgli2UI.getAppUI().getPage().setLocation(url);
        return;
    }
    Object key = HSess.checkInit();
    if (event.getButton() == imNewButt) {
        MSysOut.println(NEWUSER_CREATION_LOGS, "\"I'm new to Mmowgli\" clicked");
        if (!CACManager.canRegisterTL(Mmowgli2UI.getGlobals().getCACInfo())) {
            Notification notif = new Notification("Can't Register", "CAC card required",
                    Notification.Type.ERROR_MESSAGE);
            notif.show(Page.getCurrent());
        } else {
            RegistrationPageAgreementCombo comboPg = new RegistrationPageAgreementCombo(this);
            openPopup(comboPg, comboPg.getUsualWidth());
        }
        HSess.checkClose(key);
        return;
    }

    if (event.getButton() == guestButt) {
        LoginPopup lp = new LoginPopup(this, true);
        if (lp.userID != null) {
            handleLoginReturnTL(lp.userID);
            HSess.checkClose(key);
            return;
        }
        // Here is we clicked guest button, but no guest user in db or guest has been deemed locked out ("accountDisabled");
        Notification.show("Can't login!", "No guest account registered.  Please submit a trouble report.",
                Notification.Type.ERROR_MESSAGE);

        // Continue to allow login with other name
        openPopup(lp, lp.getUsualWidth());
        HSess.checkClose(key);
        return;
    }

    if (currentPopup instanceof RegistrationPageAgreementCombo) {
        closePopup(currentPopup);
        boolean rejected = ((RegistrationPageAgreementCombo) currentPopup).getRejected();
        Game g = Game.getTL();
        if (rejected) {
            // Either let them try again or close and say thank you
            handleLoginReturnTL(null); // back to try again
            //Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getThanksForInterestLink());  // bye bye
            HSess.checkClose(key);
            return;
        }
        if (g.isSecondLoginPermissionPage()) {
            RegistrationPageSecondPermissionPopup p2 = new RegistrationPageSecondPermissionPopup(this);
            openPopup(p2, p2.getUsualWidth());
            HSess.checkClose(key);
            return;
        }
        RegistrationPageSurvey surv = new RegistrationPageSurvey(this);
        openPopup(surv, surv.getUsualWidth());
        HSess.checkClose(key);
        return;
    }
    if (currentPopup instanceof RegistrationPageSecondPermissionPopup) {
        closePopup(currentPopup);
        boolean rejected = ((RegistrationPageSecondPermissionPopup) currentPopup).getRejected();
        if (rejected) {
            // Either let them try again or close and say thankyou
            handleLoginReturnTL(null); // back to try again
            //Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getThanksForInterestLink());  // bye bye
            HSess.checkClose(key);
            return;
        }

        RegistrationPageSurvey surv = new RegistrationPageSurvey(this);
        openPopup(surv, surv.getUsualWidth());
        HSess.checkClose(key);
        return;
    }
    /*    if (currentPopup instanceof RegistrationPageConsent) {
          app.getMainWindow().removeWindow(currentPopup);
          boolean rejected = ((RegistrationPageConsent)currentPopup).getRejected();
          if(rejected) {
            app.getMainWindow().setScrollTop(0);
            return;
          }
          //else
          RegistrationPageAUP aup = new RegistrationPageAUP(app,this);
          openPopup(aup,aup.getUsualWidth());
          return;
        }
        if(currentPopup instanceof RegistrationPageAUP) {
          app.getMainWindow().removeWindow(currentPopup);
          boolean rejected = ((RegistrationPageAUP)currentPopup).getRejected();
          if(rejected) {
            app.getMainWindow().setScrollTop(0);
            return;
          }
          //else
          RegistrationPageSurvey surv = new RegistrationPageSurvey(app,this);
          openPopup(surv,surv.getUsualWidth());
          return;
        }
        */
    if (currentPopup instanceof RegistrationPageSurvey) {
        closePopup(currentPopup);
        if (((RegistrationPageSurvey) currentPopup).wasCancelButtonClicked()) {
            // Either let them try again or close and say thankyou
            handleLoginReturnTL(null); // back to try again
            //Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getThanksForInterestLink());  // bye bye
            HSess.checkClose(key);
            return;
        }
        // don't have to do the survey
        boolean rejected = ((RegistrationPageSurvey) currentPopup).getRejected();
        okSurvey = !rejected;
        if (!rejected)
            MSysOut.println(NEWUSER_CREATION_LOGS, "Accept survey clicked");
        else
            MSysOut.println(NEWUSER_CREATION_LOGS, "Reject survey clicked");

        RegistrationPagePopupFirstA pa = new RegistrationPagePopupFirstA(this);
        openPopup(pa, pa.getUsualWidth());
        HSess.checkClose(key);
        return;
    }

    if (currentPopup instanceof RegistrationPagePopupFirstA) {
        closePopup(currentPopup);
        userId = ((RegistrationPagePopupFirstA) currentPopup).getUserId();
        if (userId == null) { // cancelled
            UI.getCurrent().setScrollTop(0);
            HSess.checkClose(key);
            return;
        }
        RegistrationPagePopupFirstB pb = new RegistrationPagePopupFirstB(this, userId);
        openPopup(pb, pb.getUsualWidth());
        HSess.checkClose(key);
        return;
    }

    if (event.getButton() == imRegisteredButt) {
        if (!CACManager.canLoginTL(Mmowgli2UI.getGlobals().getCACInfo())) {
            Notification notif = new Notification("Can't Login", "CAC card required",
                    Notification.Type.ERROR_MESSAGE);
            notif.show(Page.getCurrent());
        } else {
            LoginPopup lp = new LoginPopup(this);
            openPopup(lp, lp.getUsualWidth());
        }
        HSess.checkClose(key);
        return;
    }
    if (currentPopup instanceof RegistrationPagePopupFirstB) {
        closePopup(currentPopup);
        userId = ((RegistrationPagePopupFirstB) currentPopup).getUserId();
        if (userId == null) { // cancelled
            UI.getCurrent().setScrollTop(0);
            HSess.checkClose(key);
            return;
        }
        // That user is detached from our session right now
        RegistrationPagePopupSecond p2 = new RegistrationPagePopupSecond(this, userId);
        openPopup(p2, p2.getUsualWidth());
        HSess.checkClose(key);
        return;
    }
    if (currentPopup instanceof RegistrationPagePopupSecond) {
        closePopup(currentPopup);
        userId = ((RegistrationPagePopupSecond) currentPopup).getUserId();
        if (userId == null) {
            UI.getCurrent().setScrollTop(0);
            HSess.checkClose(key);
            return;
        }
        RoleSelectionPage rsp = new RoleSelectionPage(this, userId);
        openPopup(rsp, rsp.getUsualWidth());
        HSess.checkClose(key);
        return;
    }
    if (currentPopup instanceof RoleSelectionPage) {
        // check for good stuff
        // put up warning if can't do it
        closePopup(currentPopup);
        userId = ((RoleSelectionPage) currentPopup).getUserId();
        if (userId == null) {
            UI.getCurrent().setScrollTop(0);
            HSess.checkClose(key);
            return;
        }

        User _usr = User.getTL(userId); // into this session
        doOtherUserInit(_usr);
        _usr.setOkSurvey(okSurvey); // saved above
        Game g = Game.getTL();
        _usr.setRegisteredInMove(g.getCurrentMove()); // this is now redundant...done on new User()

        User.updateTL(_usr);

        Mmowgli2UI.getGlobals().getScoreManager().userCreatedTL(_usr); // give him his points if appropriate

        UI.getCurrent().setScrollTop(0);
        wereInTL(_usr);
        HSess.checkClose(key);

        MSysOut.println(NEWUSER_CREATION_LOGS,
                "New user registration successful, userID " + _usr.getUserName());
        return;
    }
    if (currentPopup instanceof LoginPopup) {
        handleLoginReturnTL(((LoginPopup) currentPopup).getUserId());
        HSess.checkClose(key);
        return;
    }
    HSess.checkClose(key);

    System.err.println("Program logic error in RegistrationPageBase.buttonClick()");
}

From source file:edu.nps.moves.mmowgli.signupServer.SignupServer.java

License:Open Source License

private void doRedirNotification(final String url) {
    Notification notif = new Notification("<center>Welcome to MMOWGLI!<center>",
            "<br/><center>We're taking you directly to the game.<center>", Notification.Type.HUMANIZED_MESSAGE);

    notif.setDelayMsec(5000);//w w  w. ja  va 2s  . c  o m
    notif.setPosition(Position.MIDDLE_CENTER);
    notif.setHtmlContentAllowed(true);
    notif.setStyleName("m-green-notification");
    notif.show(Page.getCurrent());

    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            UI.getCurrent().access(new Runnable() {
                @Override
                public void run() {
                    quitUIAndGoTo(url);
                }
            });
        }
    }, 4000);
}

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

License:Open Source License

public OutputStream receiveUpload(String filename, String mimeType) {
    file = null;//from  ww  w .  j  a  v a 2s . com
    if ((filename == null) || filename.length() == 0) {
        Notification n = new Notification("A file has to be selected", " ", Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(5000);
        n.show(Page.getCurrent());
        return null;
    }
    if (!filename.toLowerCase().endsWith(".ifc")) {
        Notification n = new Notification("The file extension has to be .ifc", " ",
                Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(5000);
        n.show(Page.getCurrent());
        return null;

    }

    // Create upload stream
    FileOutputStream fos = null; // Stream to write to
    try {
        // Open the file for writing.
        file = new File(uploads + filename);
        fos = new FileOutputStream(file);
    } catch (final java.io.FileNotFoundException e) {
        Notification n = new Notification("Could not open file ", e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(5000);
        n.show(Page.getCurrent());
        return null;
    }
    return fos; // Return the output stream to write to
}

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

License:Open Source License

public void receiveFileFromURL(String url_string) {
    if (url_string == null || url_string.length() == 0) {
        return;/*from   w  w w . j av a  2 s  . c om*/
    }
    if (!url_string.toLowerCase().endsWith(".ifc")) {
        Notification n = new Notification("The file extension has to be .ifc", " ",
                Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(5000);
        n.show(Page.getCurrent());
        return;
    }
    CloseableHttpClient httpClient = HttpClientBuilder.create().build();
    HttpGet httpget = new HttpGet(url_string);
    HttpResponse response;
    String urlfile = null;
    if (url_string != null) {
        urlfile = url_string.substring(url_string.lastIndexOf('/') + 1, url_string.length());
    }
    if (urlfile == null) {
        return;
    }

    try {
        response = httpClient.execute(httpget);
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            InputStream inputStream = entity.getContent();
            File targetFile = new File(uploads + urlfile);
            OutputStream outputStream = new FileOutputStream(targetFile);
            IOUtils.copy(inputStream, outputStream);
            outputStream.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
        Notification n = new Notification("Could not read the URL: ", e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(5000);
        n.show(Page.getCurrent());
        return;
    } finally {
        try {
            httpClient.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    File readyFile = new File(uploads + urlfile);
    if (readyFile.exists())
        handleNewFile(readyFile);
}

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

License:Open Source License

private void handleNewFile(File file) {
    Properties prop = new Properties();
    OutputStream output = null;//  w w w . j a  va 2  s.  c  o  m
    if (file == null)
        return;

    String realEstate = parent.getSite();
    // set the properties value
    String[] fname_array = file.getName().split("\\.");

    try {

        output = new FileOutputStream(DrumbeatConstants.marmotta_import_config_file);

        prop.setProperty("context",
                DrumbeatConstants.marmotta_contexts_baseurl + realEstate + "." + fname_array[0]);
        prop.setProperty("label", realEstate + "." + fname_array[0]);
        parent.createDataset(fname_array[0]);
        // save properties to project root folder
        prop.store(output, null);
    } catch (Exception e) {
        e.printStackTrace();
        Notification n = new Notification("File name error", file.getName() + " ; " + e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(5000);
        n.show(Page.getCurrent());
        return;
    } finally {
        if (output != null) {
            try {
                output.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    if (!convertIFC2RDFDefault(file, realEstate + "." + fname_array[0]))
        return; // Stop if the conversion fails

    try {
        BIMFileLoader bfl = new BIMFileLoader();
        bfl.load(file);
    } catch (Exception e) {
        Notification n = new Notification("BIMFileLoader error ", e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
        n.setDelayMsec(50000);
        n.show(Page.getCurrent());
        return;
    }
    Notification.show("File was uploaded");
    parent.updateData();
}