Example usage for com.vaadin.ui Notification show

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

Introduction

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

Prototype

public static Notification show(String caption, String description, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.QuestionManager.java

License:LGPL

public QuestionManager(String quizName, IEngine engine) {
    setMargin(true);/*from  w w  w  .  j  a v a  2  s  . co  m*/
    title = HtmlLabel.getCenteredLabel("h1", quizName);
    addComponent(title);
    addComponent(questionHolder);

    addComponent(southLayout);

    next = new Button("Next question ->");
    next.addClickListener(e -> {
        e.getButton().setEnabled(false);
        try {
            iEngine.requestCalculation();
        } catch (EngineException e1) {
            Notification.show("Error on calculating the next question.", "Visit the log for more infos",
                    Type.ERROR_MESSAGE);
            LogHelper.logThrowable(e1);
        }
    });
    southLayout.addComponent(next, 2, 0);
    southLayout.setSizeFull();
    southLayout.setMargin(true);
    // Ensure we have an engine
    if (engine == null) {
        try {
            iEngine = new SimpleEngine();
        } catch (EngineException e1) {
            Notification.show("Engine could not be initialized", Type.ERROR_MESSAGE);
            LogHelper.logThrowable(e1);

        }
    } else {
        iEngine = engine;
    }
    // Register to engine events
    iEngine.addQuestionChangeListener(this);
    iEngine.addResultFiredListener(this);
    setResultView(VaadinResultView.class);
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.QuestionManager.java

License:LGPL

public void startQuiz() {
    iEngine.resetQuestions();/*from  w w w. j  a va  2s  .  c  o m*/
    loadQuestions();
    try {
        iEngine.start();
    } catch (EngineException e) {
        Notification.show("Engine could not be started", e.getCause().getMessage(), Type.ERROR_MESSAGE);
        LogHelper.logThrowable(e);
    }
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.topic.accounting.AccountingQuestionManager.java

License:LGPL

@Override
public void loadQuestions() {
    try {//from  w ww . j  av  a 2 s . c  om
        loadQuestions(new File(VaadinUI.Servlet.getQuestionFolderName()));
    } catch (JAXBException | IOException e1) {
        Notification.show("Questions could not be loaded - FATAL error", e1.getMessage() + e1.getMessage(),
                Type.ERROR_MESSAGE);
        LogHelper.logThrowable(e1);
    }

}

From source file:by.bigvova.LoginUI.java

License:Apache License

private void login() {
    try {/*from w  w  w.j  a  v  a  2 s.  c o m*/
        vaadinSecurity.login(userName.getValue(), passwordField.getValue(), rememberMe.getValue());
    } catch (AuthenticationException ex) {
        userName.focus();
        userName.selectAll();
        passwordField.setValue("");
        loginFailedLabel.setValue(String.format("Login failed: %s", ex.getMessage()));
        loginFailedLabel.setVisible(true);
        if (loggedOutLabel != null) {
            loggedOutLabel.setVisible(false);
        }
    } catch (Exception ex) {
        Notification.show("An unexpected error occurred", ex.getMessage(), Notification.Type.ERROR_MESSAGE);
        LoggerFactory.getLogger(getClass()).error("Unexpected error while logging in", ex);
    } finally {
        login.setEnabled(true);
    }
}

From source file:ch.bfh.ti.soed.hs16.srs.red.ui.views.LoginView.java

License:Open Source License

public LoginView(Navigator nav) {

    try {/*from  www  . j a  va  2s .c o  m*/
        // @TODO remove before release
        DevDemo devdemo = new DevDemo();
    } catch (Exception ex) {
        Notification.show("Demo Entries failed to initialize.", ex.getMessage(),
                Notification.Type.ERROR_MESSAGE);
    }
    /*---------------------------------
    initialize Objects
    ---------------------------------*/
    this.nav = nav;
    this.vertical = new VerticalLayout();
    this.loginName = new TextField("username");
    this.passwordField = new PasswordField("password");
    this.loginButton = new Button("Login", this);

    /*-------------------------------
    add to css
    -------------------------------*/
    vertical.setPrimaryStyleName("rootLogin");
    loginButton.setStyleName("buttonLogin");

    /*-------------------------------
    add Components to Layout
    --------------------------------*/
    vertical.addComponents(loginName, passwordField, loginButton);
    setCompositionRoot(vertical);
}

From source file:ch.bfh.ti.soed.hs16.srs.red.ui.views.LoginView.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent clickEvent) {

    // Store the current user in the service session
    Password pw = Password.getInstance();
    UserController uc = new UserController();
    try {//from   w  ww . ja  va2 s  . co  m
        User u = uc.logIn(loginName.getValue(), passwordField.getValue());
        getSession().setAttribute("username", u.getName());
        getSession().setAttribute("id", u.getID());
        getSession().setAttribute("role", u.getRole());
        // navigate to my reservation view
        nav.navigateTo("my Reservation");
    } catch (Exception ex) {
        Notification.show("Wrong Password or Username.", "Try again.", Notification.Type.WARNING_MESSAGE);
        passwordField.clear();
    }

}

From source file:co.edu.icesi.academ.client.perfiles.propietario.FactoresDeImpacto.java

License:Open Source License

@AutoGenerated
private AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);/*from w  w w  .j av  a  2  s  .c  o m*/
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // table_1
    initTable();

    // button_cargar
    button_cargar = new Button();
    button_cargar.setCaption("Cargar Factores");
    button_cargar.setImmediate(false);
    button_cargar.setWidth("-1px");
    button_cargar.setHeight("-1px");
    button_cargar.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            ControladorPropietario.getInstance().cargarFactoresImpacto();
        }
    });
    mainLayout.addComponent(button_cargar, "top:20.0px;left:10.0px;");

    // button_guardar
    button_guardar = new Button();
    button_guardar.setCaption("Guardar Factores");
    button_guardar.setImmediate(false);
    button_guardar.setWidth("-1px");
    button_guardar.setHeight("-1px");
    button_guardar.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                List<FactorDeImpactoBO> factoresDeImpacto = guardarFactoresDeImpacto();
                ControladorPropietario.getInstance().guardarFactoresDeImpacto(factoresDeImpacto);
            } catch (Exception e) {
                Notification.show("Error", "Debe cargar primero los factores de impacto",
                        Type.TRAY_NOTIFICATION);
            }
        }
    });
    mainLayout.addComponent(button_guardar, "top:20.0px;left:150.0px;");

    return mainLayout;
}

From source file:com.aaron.mbpet.views.users.UserEditor.java

License:Apache License

@Override
public void buttonClick(ClickEvent event) {
    if (event.getButton() == saveButton) {
        try {//from   ww  w . j a  va  2s. c  om
            editorForm.commit();
            fireEvent(new EditorSavedEvent(this, personItem));

            // update display name efter edit
            if (editMode) {

                JPAContainer<User> persons = ((MbpetUI) UI.getCurrent()).getPersons();
                currsessionuser = persons.getItem(personItem.getItemProperty("id").getValue()).getEntity();
                ((MbpetUI) UI.getCurrent()).setSessionUser(currsessionuser);

                String lname = currsessionuser.getLastname(); //String.valueOf(personItem.getItemProperty("lastname").getValue());
                if (personItem.getItemProperty("lastname").getValue() == null) {
                    lname = "";
                }
                //                  System.out.println("The user is updated to: " + 
                //                        ((MbpetUI) UI.getCurrent()).getSessionUser().getUsername() +
                //                        "/n" + currsessionuser.getFirstname() + " " + currsessionuser.getLastname());                  

                UI.getCurrent().getNavigator().navigateTo(MainView.NAME);

                //                 MBPeTMenu.updateMenuDisplayName(
                //                       String.valueOf(personItem.getItemProperty("firstname").getValue()) + " " +
                //                       lname);   //MainView.setDisplayName                             
            } else {
                //create user directory in file system
                FileSystemUtils fileUtils = new FileSystemUtils();
                fileUtils.createUserDir(personItem.getItemProperty("username").getValue().toString());

                //create uploads dir
                fileUtils.createUploadsDir(personItem.getItemProperty("username").getValue().toString());

                //                 //copy mbpet master to user dir
                //                 fileUtils.copyMasterToUserDir(personItem.getItemProperty("username").getValue().toString());
            }

        } catch (MethodException | PersistenceException e) {
            //               Field f = editorForm.getField("username");
            //               f.addStyleName("invalid-value");
            Notification.show("Error:", "that username is not available", Type.WARNING_MESSAGE);
            return;
        }
    } else if (event.getButton() == cancelButton) {
        editorForm.discard();
    }
    close();
}

From source file:com.cms.utils.CommonMessages.java

public static void showUpdateFail(String message) {
    Notification.show(
            BundleUtils.getString("common.noti.update.fail").replace("@s", BundleUtils.getString(message)),
            BundleUtils.getString("clickToClose"), Notification.Type.ERROR_MESSAGE);
}

From source file:com.cms.utils.CommonMessages.java

public static void showMessageFail(String message) {
    Notification.show(message, BundleUtils.getString("clickToClose"), Notification.Type.ERROR_MESSAGE);
}