Example usage for com.vaadin.ui CheckBox setValue

List of usage examples for com.vaadin.ui CheckBox setValue

Introduction

In this page you can find the example usage for com.vaadin.ui CheckBox setValue.

Prototype

@Override
public void setValue(Boolean value) 

Source Link

Document

Sets the value of this CheckBox.

Usage

From source file:annis.gui.flatquerybuilder.SpanBox.java

License:Apache License

public SpanBox(final String ebene, final FlatQueryBuilder sq, boolean isRegex) {
    this.ebene = ebene;
    this.sq = sq;
    sb = new HorizontalLayout();
    sb.setImmediate(true);/*from  ww  w .  ja  v  a2  s.c  o m*/
    sb.setSpacing(true);
    sb.setMargin(true);
    ConcurrentSkipListSet<String> annos = new ConcurrentSkipListSet<>();
    for (String a : sq.getAvailableAnnotationLevels(ebene)) {
        annos.add(a);
    }
    this.annonames = annos;
    Label tf = new Label(ebene);
    sb.addComponent(tf);
    this.cb = new SensitiveComboBox();
    cb.setWidth(SB_CB_WIDTH);
    cb.addStyleName(Helper.CORPUS_FONT_FORCE);
    // configure & load content
    cb.setImmediate(true);
    cb.setNewItemsAllowed(true);
    cb.setTextInputAllowed(true);
    for (String annoname : this.annonames) {
        cb.addItem(annoname);
    }
    cb.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_OFF);
    cb.addListener((FieldEvents.TextChangeListener) this);
    sb.addComponent(cb);
    HorizontalLayout sbtoolbar = new HorizontalLayout();
    sbtoolbar.setSpacing(true);
    // searchbox tickbox for regex
    CheckBox tb = new CheckBox("Regex");
    tb.setImmediate(true);
    tb.setValue(isRegex);
    sbtoolbar.addComponent(tb);
    tb.addValueChangeListener(new ValueChangeListener() {
        // TODO make this into a nice subroutine
        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean r = reBox.getValue();
            if (!r) {
                SpanBox.buildBoxValues(cb, ebene, sq);
            } else if (cb.getValue() != null) {
                String escapedItem = sq.escapeRegexCharacters(cb.getValue().toString());
                cb.addItem(escapedItem);
                cb.setValue(escapedItem);
            }
        }
    });
    reBox = tb;
    // close the searchbox
    btClose = new Button(BUTTON_CLOSE_LABEL, (Button.ClickListener) this);
    btClose.setStyleName(ChameleonTheme.BUTTON_SMALL);
    sbtoolbar.addComponent(btClose);
    // make visable
    sb.addComponent(sbtoolbar);
    setContent(sb);
}

From source file:be.rvponp.build.CommitViewerUI.java

License:Apache License

private HorizontalLayout createFiltersLayout(Table table, VerticalLayout files, VerticalLayout filesLayout) {
    HorizontalLayout filtersLayout = new HorizontalLayout();

    FormLayout formReleaseLayout = new FormLayout();
    fromVersion = new ComboBox("From release");
    toVersion = new ComboBox("To release");
    filtersLayout.addComponent(formReleaseLayout);
    formReleaseLayout.setDescription("formReleaseLayout");

    formReleaseLayout.addComponent(fromVersion);
    formReleaseLayout.addComponent(toVersion);
    formReleaseLayout.setSizeUndefined();

    //        FormLayout jiraTreeLayout = new FormLayout();
    final Tree tree = createTreeComponent();
    //        jiraTreeLayout.addComponent(tree);
    filtersLayout.addComponent(tree);// w  ww  . j  ava 2  s  .co m

    CheckBox jiraParsing = new CheckBox("Jira Parsing");
    jiraParsing.setValue(true);
    //        filtersLayout.addComponent(jiraParsing);

    FormLayout buttonsLayout = new FormLayout();
    CompareButton compareButton = new CompareButton(fromVersion, toVersion, table, files, jiraParsing, tree,
            filesLayout);
    RefreshButton refreshButton = new RefreshButton(this, fromVersion, toVersion);
    //        refreshButton.buttonClick(null);
    //        compareButton.buttonClick(null);
    buttonsLayout.addComponent(refreshButton);
    buttonsLayout.addComponent(compareButton);
    buttonsLayout.setSizeUndefined();
    filtersLayout.addComponent(buttonsLayout);
    filtersLayout.setSizeUndefined();
    return filtersLayout;
}

From source file:com.cavisson.gui.dashboard.components.controls.Tabsheets.java

License:Apache License

public Tabsheets() {
    setMargin(true);/*from ww  w  .j  av  a2 s.c  o m*/

    Label h1 = new Label("Tabs");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.addStyleName("wrapping");
    addComponent(wrap);

    final CheckBox closable = new CheckBox("Closable");
    closable.setImmediate(true);
    wrap.addComponent(closable);

    final CheckBox overflow = new CheckBox("Overflow");
    overflow.setImmediate(true);
    wrap.addComponent(overflow);

    final CheckBox caption = new CheckBox("Captions", true);
    caption.setImmediate(true);
    wrap.addComponent(caption);

    final CheckBox icon = new CheckBox("Icons");
    icon.setImmediate(true);
    wrap.addComponent(icon);

    final CheckBox disable = new CheckBox("Disable tabs");
    disable.setImmediate(true);
    wrap.addComponent(disable);

    Label h3 = new Label("Additional Styles");
    h3.addStyleName("h3");
    addComponent(h3);

    wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.addStyleName("wrapping");
    wrap.setMargin(new MarginInfo(false, false, true, false));
    addComponent(wrap);

    final CheckBox framed = new CheckBox("Framed", true);
    framed.setImmediate(true);
    wrap.addComponent(framed);

    final CheckBox centered = new CheckBox("Centered tabs");
    centered.setImmediate(true);
    wrap.addComponent(centered);

    final CheckBox rightAlign = new CheckBox("Right-aligned tabs");
    rightAlign.setImmediate(true);
    wrap.addComponent(rightAlign);

    final CheckBox equal = new CheckBox("Equal-width tabs");
    equal.setImmediate(true);
    wrap.addComponent(equal);

    final CheckBox padded = new CheckBox("Padded tabbar");
    padded.setImmediate(true);
    wrap.addComponent(padded);

    final CheckBox compact = new CheckBox("Compact");
    compact.setImmediate(true);
    wrap.addComponent(compact);

    final CheckBox iconsOnTop = new CheckBox("Icons on top");
    iconsOnTop.setImmediate(true);
    wrap.addComponent(iconsOnTop);

    final CheckBox selectedOnly = new CheckBox("Selected tab closable");
    selectedOnly.setImmediate(true);
    wrap.addComponent(selectedOnly);

    ValueChangeListener update = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String style = framed.getValue() ? "framed " : "";
            style += centered.getValue() ? " centered-tabs" : "";
            style += rightAlign.getValue() ? " right-aligned-tabs" : "";
            style += equal.getValue() ? " equal-width-tabs" : "";
            style += padded.getValue() ? " padded-tabbar" : "";
            style += compact.getValue() ? " compact-tabbar" : "";
            style += iconsOnTop.getValue() ? " icons-on-top" : "";
            style += selectedOnly.getValue() ? " only-selected-closable" : "";

            if (tabs != null) {
                removeComponent(tabs);
            }
            tabs = getTabSheet(caption.getValue(), style.trim(), closable.getValue(), overflow.getValue(),
                    icon.getValue(), disable.getValue());
            addComponent(tabs);
        }
    };
    closable.addValueChangeListener(update);
    overflow.addValueChangeListener(update);
    caption.addValueChangeListener(update);
    icon.addValueChangeListener(update);
    disable.addValueChangeListener(update);
    framed.addValueChangeListener(update);
    centered.addValueChangeListener(update);
    rightAlign.addValueChangeListener(update);
    equal.addValueChangeListener(update);
    padded.addValueChangeListener(update);
    compact.addValueChangeListener(update);
    iconsOnTop.addValueChangeListener(update);
    selectedOnly.addValueChangeListener(update);

    // Generate initial view
    icon.setValue(true);
}

From source file:com.cerebro.provevaadin.smtp.ConfigurazioneSMTP.java

public ConfigurazioneSMTP() {

    this.setMargin(true);

    TextField smtpHost = new TextField("SMTP Host Server");
    smtpHost.setRequired(true);//from  w  w  w. j a  v a2 s  .com
    TextField smtpPort = new TextField("SMTP Port");
    smtpPort.setRequired(true);
    TextField smtpUser = new TextField("SMTP Username");
    smtpUser.setRequired(true);
    TextField smtpPwd = new TextField("SMTP Password");
    smtpPwd.setRequired(true);
    TextField pwdConf = new TextField("Conferma la Password");
    pwdConf.setRequired(true);
    CheckBox security = new CheckBox("Sicurezza del server");

    Properties props = new Properties();
    InputStream config = VaadinServlet.getCurrent().getServletContext()
            .getResourceAsStream("/WEB-INF/config.properties");
    if (config != null) {
        System.out.println("Carico file di configurazione");
        try {
            props.load(config);
        } catch (IOException ex) {
            Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    smtpHost.setValue(props.getProperty("smtp_host"));
    smtpUser.setValue(props.getProperty("smtp_user"));
    security.setValue(Boolean.parseBoolean(props.getProperty("smtp_sec")));

    Button salva = new Button("Salva i parametri");
    salva.addClickListener((Button.ClickEvent event) -> {
        System.out.println("Salvo i parametri SMTP");
        if (smtpHost.isValid() && smtpPort.isValid() && smtpUser.isValid() && smtpPwd.isValid()
                && smtpPwd.getValue().equals(pwdConf.getValue())) {
            props.setProperty("smtp_host", smtpHost.getValue());
            props.setProperty("smtp_port", smtpPort.getValue());
            props.setProperty("smtp_user", smtpUser.getValue());
            props.setProperty("smtp_pwd", smtpPwd.getValue());
            props.setProperty("smtp_sec", security.getValue().toString());
            String webInfPath = VaadinServlet.getCurrent().getServletConfig().getServletContext()
                    .getRealPath("WEB-INF");
            File f = new File(webInfPath + "/config.properties");
            try {
                OutputStream o = new FileOutputStream(f);
                try {
                    props.store(o, "Prova");
                } catch (IOException ex) {
                    Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex);
            }
            Notification.show("Parametri salvati");
        } else {
            Notification.show("Ricontrolla i parametri");
        }

    });

    TextField emailTest = new TextField("Destinatario Mail di Prova");
    emailTest.setImmediate(true);
    emailTest.addValidator(new EmailValidator("Mail non valida"));

    Button test = new Button("Invia una mail di prova");
    test.addClickListener((Button.ClickEvent event) -> {
        System.out.println("Invio della mail di prova");
        if (emailTest.isValid()) {
            try {
                System.out.println("Invio mail di prova a " + emailTest.getValue());
                HtmlEmail email = new HtmlEmail();
                email.setHostName(props.getProperty("smtp_host"));
                email.setSmtpPort(Integer.parseInt(props.getProperty("smtp_port")));
                email.setSSLOnConnect(Boolean.parseBoolean(props.getProperty("smtp_sec")));
                email.setAuthentication(props.getProperty("smtp_user"), props.getProperty("smtp_pwd"));
                email.setFrom("prova@prova.it");
                email.setSubject("Mail di prova");
                email.addTo(emailTest.getValue());
                email.setHtmlMsg("This is the message");
                email.send();
            } catch (EmailException ex) {
                Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex);
            }

        } else {
            Notification.show("Controlla l'indirizzo mail del destinatario");
        }
    });

    this.addComponents(smtpHost, smtpPort, smtpUser, smtpPwd, pwdConf, security, salva, emailTest, test);

}

From source file:com.cerebro.provevaadin.smtp.ConfigurazioneSMTPSpring.java

public ConfigurazioneSMTPSpring() {

    TextField smtpHost = new TextField("SMTP Host Server");
    smtpHost.setRequired(true);/*from   w  w  w.  j  a  v  a  2  s .c o  m*/
    TextField smtpPort = new TextField("SMTP Port");
    smtpPort.setRequired(true);
    TextField smtpUser = new TextField("SMTP Username");
    smtpUser.setRequired(true);
    PasswordField smtpPwd = new PasswordField("SMTP Password");
    smtpPwd.setRequired(true);
    PasswordField pwdConf = new PasswordField("Conferma la Password");
    pwdConf.setRequired(true);
    CheckBox security = new CheckBox("Sicurezza del server");

    Properties props = new Properties();
    InputStream config = VaadinServlet.getCurrent().getServletContext()
            .getResourceAsStream("/WEB-INF/config.properties");
    if (config != null) {
        System.out.println("Carico file di configurazione");
        try {
            props.load(config);
        } catch (IOException ex) {
            Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    smtpHost.setValue(props.getProperty("mail.smtp.host"));
    smtpUser.setValue(props.getProperty("smtp_user"));
    security.setValue(Boolean.parseBoolean(props.getProperty("smtp_sec")));

    Button salva = new Button("Salva i parametri");
    salva.addClickListener((Button.ClickEvent event) -> {
        System.out.println("Salvo i parametri SMTP");
        if (smtpHost.isValid() && smtpPort.isValid() && smtpUser.isValid() && smtpPwd.isValid()
                && smtpPwd.getValue().equals(pwdConf.getValue())) {
            System.out.println(smtpHost.getValue() + smtpPort.getValue() + smtpUser.getValue()
                    + smtpPwd.getValue() + security.getValue().toString());
            props.setProperty("mail.smtp.host", smtpHost.getValue());
            props.setProperty("mail.smtp.port", smtpPort.getValue());
            props.setProperty("smtp_user", smtpUser.getValue());
            props.setProperty("smtp_pwd", smtpPwd.getValue());
            props.setProperty("mail.smtp.ssl.enable", security.getValue().toString());
            String webInfPath = VaadinServlet.getCurrent().getServletConfig().getServletContext()
                    .getRealPath("WEB-INF");
            File f = new File(webInfPath + "/config.properties");
            try {
                OutputStream o = new FileOutputStream(f);
                try {
                    props.store(o, "Prova");
                } catch (IOException ex) {
                    Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex);
            }
            Notification.show("Parametri salvati");
        } else {
            Notification.show("Ricontrolla i parametri");
        }

    });

    TextField emailTest = new TextField("Destinatario Mail di Prova");
    emailTest.setImmediate(true);
    emailTest.addValidator(new EmailValidator("Mail non valida"));

    Button test = new Button("Invia una mail di prova");
    test.addClickListener((Button.ClickEvent event) -> {
        System.out.println("Invio della mail di prova");
        if (emailTest.isValid() && !emailTest.isEmpty()) {
            System.out.println("Invio mail di prova a " + emailTest.getValue());
            JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
            mailSender.setJavaMailProperties(props);
            mailSender.setUsername(props.getProperty("smtp_user"));
            mailSender.setPassword(props.getProperty("smtp_pwd"));
            MimeMessage message = mailSender.createMimeMessage();
            MimeMessageHelper helper = new MimeMessageHelper(message);
            try {
                helper.setFrom("dottmatteocasagrande@gmail.com");
                helper.setSubject("Subject");
                helper.setText("It works!");
                helper.addTo(emailTest.getValue());
                mailSender.send(message);
            } catch (MessagingException ex) {
                Logger.getLogger(ConfigurazioneSMTPSpring.class.getName()).log(Level.SEVERE, null, ex);
            }

        } else {
            Notification.show("Controlla l'indirizzo mail del destinatario");
        }
    });

    this.addComponents(smtpHost, smtpPort, smtpUser, smtpPwd, pwdConf, security, salva, emailTest, test);

}

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

public void generateColumn(final CustomPageTableFilter<IndexedContainer> tbl) {
    tbl.addGeneratedColumn(Constants.CHECKBOX_COLUMN, new CustomTable.ColumnGenerator() {
        @Override// w w w.  java2s  . c o  m
        public Object generateCell(final CustomTable source, final Object itemId, Object columnId) {
            setHeader(tbl);
            final CheckBox checkBox = new CheckBox("");
            checkBox.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                    // Don't react to the event if we're being changed from the table-value-change event
                    Boolean selected = (Boolean) valueChangeEvent.getProperty().getValue();
                    if (selected) {
                        source.select(itemId);
                    } else {
                        source.unselect(itemId);
                    }

                }
            });
            //                set value 
            checkBox.setValue(isItemIdSelected(source, itemId));

            // Let's keep track of the checkboxes
            checkBox.addAttachListener(new ClientConnector.AttachListener() {
                @Override
                public void attach(ClientConnector.AttachEvent event) {
                    itemIdToCheckbox.put(itemId, checkBox);
                }
            });

            return checkBox;
        }
    });
    tbl.addItemClickListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            //                return
            Object newSelectionValue = event.getItemId();
            CheckBox cb = itemIdToCheckbox.get(newSelectionValue);
            if (!event.isCtrlKey()) {
                Collection<Object> collection = (Collection<Object>) tbl.getValue();
                if (collection.size() > 1) {
                    cb.setValue(true);
                } else {
                    cb.setValue(!cb.getValue());
                }

                for (Object item : itemIdToCheckbox.keySet()) {
                    if (item != newSelectionValue) {
                        itemIdToCheckbox.get(item).setValue(false);
                    }
                }
            } else {

                cb.setValue(!cb.getValue());
            }
        }
    });

    tbl.addListener(new CustomTable.HeaderClickListener() {

        @Override
        public void headerClick(CustomTable.HeaderClickEvent event) {
            if (Constants.CHECKBOX_COLUMN.equals(event.getPropertyId())) {
                String currentPage = String.valueOf(tbl.getCurrentPage());
                if (mapPageSelected.get(currentPage) == null) {
                    mapPageSelected.put(currentPage, false);
                }
                if (!mapPageSelected.get(currentPage)) {
                    List<Object> lstObject = (List<Object>) tbl.getContainerDataSource().getItemIds();
                    for (Object itemId : lstObject) {
                        setCheckBoxes(itemId, true);
                        tbl.select(itemId);
                    }

                    // Change the header value
                    tbl.setColumnHeader(Constants.CHECKBOX_COLUMN, "<span class=\"v-checkbox v-widget\">\n"
                            + "<input  checked=\"\" type=\"checkbox\" >\n" + "<label></label>\n" + "</span>");
                } else {
                    for (Object itemId : tbl.getItemIds()) {
                        setCheckBoxes(itemId, false);
                        tbl.unselect(itemId);
                    }
                    tbl.setColumnHeader(Constants.CHECKBOX_COLUMN, "<span class=\"v-checkbox v-widget\">\n"
                            + "<input  type=\"checkbox\" >\n" + "<label></label>\n" + "</span>");
                }
                mapPageSelected.put(currentPage, !mapPageSelected.get(currentPage));
            }
        }
    });

    /* Just some cosmetics : no caption for the checkbox, and make it the first column */
    tbl.setColumnHeader(Constants.CHECKBOX_COLUMN, "<span class=\"v-checkbox v-widget\">\n"
            + "<input  type=\"checkbox\" >\n" + "<label></label>\n" + "</span>");
    tbl.setColumnAlignment(Constants.CHECKBOX_COLUMN, CustomTable.Align.CENTER);
}

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

private void setCheckBox(Object id, boolean value) {
    CheckBox checkBox = itemIdToCheckbox.get(id);
    if (checkBox != null) {
        checkBox.setValue(value);
    }/*  w w  w  .  j  a  va  2  s.  c o  m*/

}

From source file:com.esofthead.mycollab.mobile.module.crm.view.CrmLoginViewImpl.java

License:Open Source License

private void initUI() {
    this.setStyleName("login-view");
    this.setSizeFull();

    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setStyleName("content-wrapper");
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    contentLayout.setMargin(true);//from ww  w.ja  va  2  s .c  o m
    contentLayout.setSpacing(true);
    contentLayout.setWidth("320px");

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    Label welcomeText = new Label("Login to CRM");
    welcomeText.setWidth("150px");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeTextWrapper);

    final EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.setInputPrompt("E-mail Address");
    emailField.setStyleName("email-input");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    pwdField.setInputPrompt("Password");
    pwdField.setStyleName("password-input");
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox();
    rememberPassword.setWidth("100%");
    rememberPassword.setCaption("Remember password");
    rememberPassword.setValue(true);
    contentLayout.addComponent(rememberPassword);

    Button signInBtn = new Button("Sign In");
    signInBtn.setWidth("100%");
    signInBtn.addStyleName(UIConstants.BUTTON_BIG);
    signInBtn.addStyleName(UIConstants.COLOR_BLUE);
    signInBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new CrmEvent.PlainLogin(this, new String[] {
                    emailField.getValue(), pwdField.getValue(), String.valueOf(rememberPassword.getValue()) }));
        }
    });
    contentLayout.addComponent(signInBtn);

    Button createAccountBtn = new Button("Create Account");
    createAccountBtn.setWidth("100%");
    createAccountBtn.addStyleName(UIConstants.BUTTON_BIG);
    createAccountBtn.addStyleName(UIConstants.COLOR_GRAY);
    contentLayout.addComponent(createAccountBtn);

    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.mobile.module.project.view.ProjectLoginViewImpl.java

License:Open Source License

private void initUI() {
    this.setStyleName("login-view");
    this.setSizeFull();

    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setStyleName("content-wrapper");
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    contentLayout.setMargin(true);/* ww  w. ja v  a 2  s. c  om*/
    contentLayout.setSpacing(true);
    contentLayout.setWidth("320px");

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    Label welcomeText = new Label("Login to Projects");
    welcomeText.setWidth("150px");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeTextWrapper);

    final EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.setInputPrompt("E-mail Address");
    emailField.setStyleName("email-input");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    pwdField.setInputPrompt("Password");
    pwdField.setStyleName("password-input");
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox();
    rememberPassword.setWidth("100%");
    rememberPassword.setCaption("Remember password");
    rememberPassword.setValue(true);
    contentLayout.addComponent(rememberPassword);

    Button signInBtn = new Button("Sign In");
    signInBtn.setWidth("100%");
    signInBtn.addStyleName(UIConstants.BUTTON_BIG);
    signInBtn.addStyleName(UIConstants.COLOR_BLUE);
    signInBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new ProjectEvent.PlainLogin(this, new String[] {
                    emailField.getValue(), pwdField.getValue(), String.valueOf(rememberPassword.getValue()) }));
        }
    });
    contentLayout.addComponent(signInBtn);

    Button createAccountBtn = new Button("Create Account");
    createAccountBtn.setWidth("100%");
    createAccountBtn.addStyleName(UIConstants.BUTTON_BIG);
    createAccountBtn.addStyleName(UIConstants.COLOR_GRAY);
    contentLayout.addComponent(createAccountBtn);

    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.mobile.module.user.view.LoginViewImpl.java

License:Open Source License

private void initUI() {
    this.setStyleName("login-view");
    this.setSizeFull();

    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setStyleName("content-wrapper");
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    contentLayout.setMargin(true);//from   w  w  w.j a v  a2s.  c o m
    contentLayout.setSpacing(true);
    contentLayout.setWidth("320px");

    Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png"));
    contentLayout.addComponent(mainLogo);

    Label introText = new Label(
            "MyCollab helps you do all your office jobs on the computers, phones and tablets you use");
    introText.setStyleName("intro-text");
    contentLayout.addComponent(introText);

    CssLayout welcomeTextWrapper = new CssLayout();
    welcomeTextWrapper.setStyleName("welcometext-wrapper");
    welcomeTextWrapper.setWidth("100%");
    welcomeTextWrapper.setHeight("15px");
    Label welcomeText = new Label("Welcome Back!");
    welcomeText.setWidth("150px");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeTextWrapper);

    final EmailField emailField = new EmailField();
    emailField.setWidth("100%");
    emailField.setInputPrompt("E-mail Address");
    emailField.setStyleName("email-input");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    pwdField.setInputPrompt("Password");
    pwdField.setStyleName("password-input");
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox();
    rememberPassword.setWidth("100%");
    rememberPassword.setCaption("Remember password");
    rememberPassword.setValue(true);
    contentLayout.addComponent(rememberPassword);

    Button signInBtn = new Button("Sign In");
    signInBtn.setWidth("100%");
    signInBtn.addStyleName(UIConstants.BUTTON_BIG);
    signInBtn.addStyleName(UIConstants.COLOR_BLUE);
    signInBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ShellController.doLogin(emailField.getValue(), pwdField.getValue(), rememberPassword.getValue());
        }
    });
    contentLayout.addComponent(signInBtn);

    Button createAccountBtn = new Button("Create Account");
    createAccountBtn.setWidth("100%");
    createAccountBtn.addStyleName(UIConstants.BUTTON_BIG);
    createAccountBtn.addStyleName(UIConstants.COLOR_GRAY);
    contentLayout.addComponent(createAccountBtn);

    this.addComponent(contentLayout);
}