Example usage for com.vaadin.ui LoginForm addListener

List of usage examples for com.vaadin.ui LoginForm addListener

Introduction

In this page you can find the example usage for com.vaadin.ui LoginForm addListener.

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:com.assemblade.ui.views.LoginScreen.java

License:Apache License

public LoginScreen() {
    app = CatApplication.getInstance();//from   w  ww.java 2  s . c  o m
    setSizeFull();
    Panel loginPanel = new Panel("Login");
    loginPanel.setWidth("400px");
    LoginForm loginForm = new LoginForm();
    loginForm.setUsernameCaption("Username: ");
    loginForm.setPasswordCaption("Password: ");
    loginForm.addListener(this);
    loginForm.setHeight("150px");
    loginPanel.addComponent(loginForm);
    addComponent(loginPanel);
    setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    addComponent(footer);
}

From source file:com.expressui.sample.view.LoginPage.java

License:Open Source License

@PostConstruct
@Override//  w  w w  . j av a 2s .  com
public void postConstruct() {
    super.postConstruct();

    setSizeFull();

    LoginForm loginForm = new LoginForm();
    loginForm.addStyleName("border");
    loginForm.setSizeUndefined();
    loginForm.setLoginButtonCaption(uiMessageSource.getMessage("loginPage.button"));
    loginForm.setUsernameCaption(uiMessageSource.getMessage("loginPage.username"));
    loginForm.setPasswordCaption(uiMessageSource.getMessage("loginPage.password"));
    loginForm.addListener(new LoginHandler());

    Panel panel = new Panel();
    panel.addStyleName("loginPage");
    panel.addStyleName("border");
    panel.setSizeUndefined();
    panel.setCaption(uiMessageSource.getMessage("loginPage.caption"));
    panel.addComponent(loginForm);
    panel.addComponent(new Label(uiMessageSource.getMessage("loginPage.tip")));

    addComponent(panel);
    setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
}

From source file:de.mediapool.web.ui.login.MediaLoginForm.java

License:Apache License

public MediaLoginForm() {

    setImmediate(true);/*from   w w  w .  j  ava2 s.  co m*/
    LoginForm login = new LoginForm();

    setMargin(false, false, false, true);
    setHeight("110px");
    login.setHeight("110px");
    setSpacing(true);
    login.addListener((LoginForm.LoginListener) this);
    addComponent(login);

}

From source file:de.mendelson.comm.as2.webclient2.AS2WebUI.java

/**
 * Init is invoked on application load (when a user accesses the application
 * for the first time)./*  ww w . j av  a  2s . c o  m*/
 */
@Override
public void init() {
    this.user = null;
    //display fav icon, set theme
    setTheme("mendelson");
    ICON_IN = new ThemeResource("images/in16x16.gif");
    ICON_OUT = new ThemeResource("images/out16x16.gif");
    ICON_PENDING = new ThemeResource("images/state_pending16x16.gif");
    ICON_STOPPED = new ThemeResource("images/state_stopped16x16.gif");
    ICON_FINISHED = new ThemeResource("images/state_finished16x16.gif");
    ICON_ALL = new ThemeResource("images/state_all16x16.gif");
    this.browser = ((WebApplicationContext) getContext()).getBrowser();
    //register the database drivers for the VM
    try {
        Class.forName("org.hsqldb.jdbcDriver");
    } catch (Exception e) {
        e.printStackTrace();
        mainWindow.showNotification("Fatal", e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
        return;
    }
    //establish database connection
    try {
        this.configConnection = DBDriverManager.getConnectionWithoutErrorHandling(DBDriverManager.DB_CONFIG,
                "localhost");
        this.runtimeConnection = DBDriverManager.getConnectionWithoutErrorHandling(DBDriverManager.DB_RUNTIME,
                "localhost");
    } catch (Exception e) {
        e.printStackTrace();
        mainWindow.showNotification("Fatal", e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE);
    }
    Embedded logoImage = new Embedded("", new ThemeResource("images/logo.jpg"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    this.mainWindow.addComponent(logoImage);
    LoginForm loginForm = new LoginForm();
    loginForm.addListener(new LoginListener() {
        @Override
        public void onLogin(LoginEvent event) {
            try {
                String username = event.getLoginParameter("username");
                String password = event.getLoginParameter("password");
                UserAccess access = new UserAccess(Logger.getAnonymousLogger());
                User foundUser = access.readUser(username);
                if (foundUser == null || foundUser.getPasswdCrypted() == null
                        || !(foundUser.getPasswdCrypted().equals(User.cryptPassword(password.toCharArray())))
                        || !foundUser.getPermission(1).equals("FULL")) {
                    mainWindow.showNotification("Login failed", "Wrong credentials or no permission",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                } else {
                    //login accepted
                    AS2WebUI.this.user = foundUser;
                    AS2WebUI.this.labelUsername.setValue("User: " + AS2WebUI.this.user.getName());
                    AS2WebUI.this.mainWindow.removeComponent(AS2WebUI.this.loginPanel);
                    AS2WebUI.this.mainWindow.addComponent(AS2WebUI.this.mainPanel);
                    AS2WebUI.this.refreshOverviewTableData();
                }
            } catch (Exception e) {
                e.printStackTrace();
                mainWindow.showNotification("Service not available",
                        "Login not possible at the moment - please try later",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            }
        }
    });
    this.loginPanel.addComponent(loginForm);
    this.mainWindow.addComponent(this.loginPanel);
    this.mainPanel.addComponent(this.createMenuBar());
    this.mainPanel.addComponent(this.createButtonBar());
    this.overviewTable = this.createOverviewTable();
    this.mainPanel.addComponent(overviewTable);
    this.footerLayout = new HorizontalLayout();
    footerLayout.setMargin(true, false, false, false);
    footerLayout.setSpacing(true);
    footerLayout.addComponent(this.footerTransactionSum);
    footerLayout.addComponent(this.footerTransactionOkSum);
    footerLayout.addComponent(this.footerTransactionPendingSum);
    footerLayout.addComponent(this.footerTransactionErrorSum);
    this.mainPanel.addComponent(footerLayout);
    this.setMainWindow(this.mainWindow);
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.login.LogInScreenViewImpl.java

License:Open Source License

/**
 * Diese Methode setzt den Titel (im Browser-Fenster) zu
 * "Business Horizon 2" und erstellt die LogIn Maske mit Listener. Der
 * Listener prft ruft die im LogIn Event gesammelten LogIn-Daten und
 * bergibt sie dem presenter zur Kontrolle. Je nach ausgang der Konrolle
 * wird dann eine Fehlermeldung aufgerufen. Zudem wird mittels dem
 * "registrieren" Button und dessen Listener eine Dialogfenster
 * bereitgestellt mit dessen sich ein neuer Anwender registrieren kann.
 * /*from   w ww .j a  va2s.  c  o  m*/
 * @author Christian Scherer
 */
private void generateUi() {
    setCaption("Business Horizon 2");
    logger.debug("berschrift fr Browser erstellt");

    vertical = new VerticalLayout();

    addStyleName("login_view");

    LoginForm login = new LoginForm();
    //Zur Anmeldung muss die Mailadresse als Benutzername angegeben werden
    login.setUsernameCaption("Mailadresse");
    login.setPasswordCaption("Passwort");
    login.setWidth(null);
    login.setStyleName("login_form");
    login.addListener(new LoginForm.LoginListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onLogin(LoginEvent event) {
            presenter.doLogin(event.getLoginParameter("username"), event.getLoginParameter("password"));

        }
    });

    vertical.addComponent(login);
    vertical.setComponentAlignment(login, Alignment.MIDDLE_CENTER);

    registerBtn = new Button("Registrieren", this);

    passwordForgotBtn = new Button("Passwort vergessen", this);
    passwordForgotBtn.setEnabled(false);

    vertical.addComponent(registerBtn);
    vertical.setComponentAlignment(registerBtn, Alignment.MIDDLE_CENTER);
    //vertical.addComponent(passwordForgotBtn);
    //vertical.setComponentAlignment(passwordForgotBtn, Alignment.MIDDLE_CENTER);

    logger.debug("LogIn UI erstellt und Listener gesetzt");

    addComponent(vertical);
}

From source file:eu.visioncloud.workflowWebUI.WorkflowUIApp.java

License:Apache License

@Override
public void init() {
    window = new Window("Workflow Management Service");

    setMainWindow(window);/*from www .  jav a  2 s. c o  m*/
    final LoginForm lf = new LoginForm();
    lf.setClosable(false);
    lf.center();
    lf.addListener(new Window.CloseListener() {

        @Override
        public void windowClose(CloseEvent e) {
            // TODO Auto-generated method stub
            LoginInfo login = lf.getLoginInfo();
            if (login != null) {
                tenant = login.tenant;
                userId = login.userId;
                password = login.password;
                auth = initCCIClient();
                if (oClient != null) {
                    mainComponent = new MainComponent(tenant, auth, oClient);
                    window.setContent(mainComponent);
                } else {
                    lf.showNotification("Invalid tenant name, user id or password");
                    lf.getApplication().close();
                }
            }
        }
    });
    window.addWindow(lf);
    setTheme("mytheme");
}

From source file:nz.co.senanque.vaadinsupport.viewmanager.LoginLayout.java

License:Apache License

public void afterPropertiesSet() throws Exception {
    setSizeFull();//from w  ww . jav  a  2 s  .  c o m
    Panel loginPanel = new Panel();
    AbstractLayout panelLayout = (AbstractLayout) loginPanel.getContent();
    panelLayout.setMargin(false);
    loginPanel.setWidth("460px");
    final MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource);
    final LoginForm loginForm = new LoginFormI18n(messageSourceAccessor.getMessage("username"),
            messageSourceAccessor.getMessage("password"), messageSourceAccessor.getMessage("login.button"),
            messageSourceAccessor.getMessage("welcome"));
    loginForm.setHeight("300px");
    loginForm.addListener(new LoginListener() {

        private static final long serialVersionUID = 5201900702970450254L;

        public void onLogin(LoginEvent event) {
            if (getLoginListener() != null) {
                try {
                    getLoginListener().onLogin(event);
                } catch (Exception e) {
                    Throwable cause = e.getCause();
                    if (cause == null || !(cause instanceof LoginException)) {
                        logger.error(e.getMessage(), e);
                    }
                    String message = messageSourceAccessor.getMessage("Bad.Login", "Bad Login");
                    getViewManager().getMainWindow().showNotification(message, Notification.TYPE_ERROR_MESSAGE);
                    return;
                }
            }
            getViewManager().loadApplication();
        }
    });
    loginPanel.addComponent(loginForm);
    addComponent(loginPanel);
    setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:org.vaadin.addons.serverpush.samples.chat.ManualPushChatApplication.java

License:Apache License

private void fireLoginWindow() {
    final Window window = new Window("Login");
    window.setModal(true);//w  ww . j ava2s  . c o  m
    window.setWidth("640px");
    window.setHeight("480px");
    LoginForm loginForm = new LoginForm();
    loginForm.setSizeFull();
    loginForm.addListener(new LoginForm.LoginListener() {
        public void onLogin(LoginForm.LoginEvent event) {
            doLogin(event);
            getMainWindow().removeWindow(window);
        }
    });
    window.setContent(loginForm);
    getMainWindow().addWindow(window);
    window.bringToFront();
}

From source file:org.vaadin.training.fundamentals.happening.ui.viewimpl.LoginViewImpl.java

License:Creative Commons License

@SuppressWarnings("serial")
private void showLoginWindow() {
    if (loginWindow != null && loginWindow.getParent() != null) {
        return;//ww w  . j av  a2  s. com
    }
    loginLayout = new CssLayout();
    loginLayout.setSizeFull();
    loginLayout.addStyleName("login");
    loginWindow = new Window(tr.getString("LoginWindow.Caption"), loginLayout);
    loginWindow.setWidth("60%");
    loginWindow.setHeight("60%");
    loginWindow.setClosable(false);
    loginWindow.setModal(true);
    loginWindow.center();

    LoginForm loginForm = new LoginForm();
    loginForm.setSizeUndefined();
    loginForm.addListener(new LoginListener() {
        @Override
        public void onLogin(LoginEvent event) {
            String accountId = event.getLoginParameter("username");
            String password = event.getLoginParameter("password");
            LoginViewImpl.this.getWindow().removeWindow(event.getComponent().getWindow());
            LoginViewImpl.this.fireEvent(new LoginAttemptEvent(LoginViewImpl.this, accountId, password));
        }
    });

    loginLayout.addComponent(loginForm);

    // Label photoAttribution = new Label(
    // "Photo by Curtis Fry. Licensed under Creative Commons");
    // photoAttribution.setSizeUndefined();
    // photoAttribution.addStyleName("photoAttribution");
    // loginLayout.addComponent(photoAttribution);

    // TextField username = new
    // TextField(tr.getString("LoginView.Username"));
    // loginLayout.addComponent(username, "username");
    // PasswordField password = new PasswordField(
    // tr.getString("LoginView.Password"));
    // loginLayout.addComponent(password, "password");
    //
    // Button registerButton = new Button(tr.getString("Button.Register"));
    // registerButton.addListener(new Button.ClickListener() {
    // @Override
    // public void buttonClick(ClickEvent event) {
    // }
    // });
    // loginLayout.addComponent(registerButton, "registerButton");

    getWindow().addWindow(loginWindow);
}

From source file:sweforce.vaadin.security.activitiesandplaces.login.LoginViewImpl.java

License:Apache License

public LoginViewImpl() {
    mainLayout.setSizeFull();/*from  w  ww .  j  a  v  a  2 s.co  m*/
    loginPanel = new Panel("Login");
    mainLayout.addComponent(loginPanel);
    mainLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    loginPanel.setSizeUndefined();

    LoginForm loginForm;
    loginForm = new LoginForm();
    loginPanel.setContent(loginForm);
    loginForm.setPasswordCaption("Password"); //i18n?
    loginForm.setUsernameCaption("User");
    loginForm.setLoginButtonCaption("Login");
    //        loginForm.setHeight("100px");
    loginForm.addListener(this);
}