Example usage for com.vaadin.ui CheckBox getValue

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

Introduction

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

Prototype

@Override
    public Boolean getValue() 

Source Link

Usage

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private Component buildFields() {
    final VerticalLayout layout = new VerticalLayout();
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);/*from   ww  w . j av a2  s .c  o  m*/
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    final CheckBox checkBox = new CheckBox("Remember me", true);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            login(username.getValue(), password.getValue(), checkBox.getValue());
        }
    });

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    layout.setSpacing(true);
    layout.addComponent(fields);
    layout.addComponent(checkBox);
    return layout;
}

From source file:ch.bfh.ti.soed.hs16.srs.green.view.MyUI.java

License:Open Source License

/**
 * Method which actually creates the whole UI.
 *///w ww. ja  v a  2  s .c o m
@Override
protected void init(VaadinRequest vaadinRequest) {

    VerticalLayout layout = new VerticalLayout();

    Panel panel = new Panel("Login");
    panel.setSizeUndefined();

    FormLayout content = new FormLayout();
    userName = new TextField("Username");
    content.addComponent(userName);

    PasswordField password = new PasswordField("Password");
    content.addComponent(password);

    Button login = new Button("Login");
    register = new Button("Register");
    CheckBox askBox = new CheckBox("Are you a Roommanager?");

    login.setStyleName(Reindeer.BUTTON_SMALL);
    login.setWidth("86px");

    register.setStyleName(Reindeer.BUTTON_SMALL);
    register.setWidth("86px");
    askBox.setStyleName(Reindeer.BUTTON_SMALL);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.addComponent(login);
    hl.addComponent(register);
    hl.addComponent(askBox);

    content.addComponent(hl);
    content.setSizeUndefined();
    content.setMargin(true);

    panel.setContent(content);

    login.addClickListener(e -> {
        System.out.println(userName.getValue());
        System.out.println(password.getValue());
        try {
            if (controller.login(userName.getValue(), password.getValue())
                    || userName.equals(userName.getValue()) && password.equals(password.getValue())) {
                setContent(new ReservationUI());
            }
        } catch (Throwable e1) {
            e1.printStackTrace();
        }
    });

    register.addClickListener(e -> {
        try {
            Role x = askBox.getValue() ? Role.ROOMMANAGER : Role.CUSTOMER;
            controller.register(userName.getValue(), password.getValue(), x);
        } catch (Throwable e1) {
            e1.printStackTrace();
        }
    });

    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addComponent(panel);
    setContent(layout);
}

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

License:Apache License

Panel windows() {
    Panel p = new Panel("Dialogs");
    VerticalLayout content = new VerticalLayout() {
        final Window win = new Window("Window Caption");
        String prevHeight = "300px";
        boolean footerVisible = true;
        boolean autoHeight = false;
        boolean tabsVisible = false;
        boolean toolbarVisible = false;
        boolean footerToolbar = false;
        boolean toolbarLayout = false;
        String toolbarStyle = null;

        VerticalLayout windowContent() {
            VerticalLayout root = new VerticalLayout();

            if (toolbarVisible) {
                MenuBar menuBar = MenuBars.getToolBar();
                menuBar.setSizeUndefined();
                menuBar.setStyleName(toolbarStyle);
                Component toolbar = menuBar;
                if (toolbarLayout) {
                    menuBar.setWidth(null);
                    HorizontalLayout toolbarLayout = new HorizontalLayout();
                    toolbarLayout.setWidth("100%");
                    toolbarLayout.setSpacing(true);
                    Label label = new Label("Tools");
                    label.setSizeUndefined();
                    toolbarLayout.addComponents(label, menuBar);
                    toolbarLayout.setExpandRatio(menuBar, 1);
                    toolbarLayout.setComponentAlignment(menuBar, Alignment.TOP_RIGHT);
                    toolbar = toolbarLayout;
                }//w ww . j a v a 2s. c o  m
                toolbar.addStyleName("v-window-top-toolbar");
                root.addComponent(toolbar);
            }

            Component content = null;

            if (tabsVisible) {
                TabSheet tabs = new TabSheet();
                tabs.setSizeFull();
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                tabs.addTab(l, "Selected");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "Another");
                tabs.addTab(new Label("&nbsp;", ContentMode.HTML), "One more");
                tabs.addStyleName("padded-tabbar");
                tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {
                    @Override
                    public void selectedTabChange(final SelectedTabChangeEvent event) {
                        try {
                            Thread.sleep(600);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                });
                content = tabs;
            } else if (!autoHeight) {
                Panel p = new Panel();
                p.setSizeFull();
                p.addStyleName("borderless");
                if (!toolbarVisible || !toolbarLayout) {
                    p.addStyleName("scroll-divider");
                }
                VerticalLayout l = new VerticalLayout();
                l.addComponent(new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML));
                l.setMargin(true);
                p.setContent(l);
                content = p;
            } else {
                content = new Label(
                        "<h2>Subtitle</h2><p>Normal type for plain text. Etiam at risus et justo dignissim congue. Phasellus laoreet lorem vel dolor tempus vehicula.</p><p>Quisque ut dolor gravida, placerat libero vel, euismod. Etiam habebis sem dicantur magna mollis euismod. Nihil hic munitissimus habendi senatus locus, nihil horum? Curabitur est gravida et libero vitae dictum. Ullamco laboris nisi ut aliquid ex ea commodi consequat. Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</p>",
                        ContentMode.HTML);
                root.setMargin(true);
            }

            root.addComponent(content);

            if (footerVisible) {
                HorizontalLayout footer = new HorizontalLayout();
                footer.setWidth("100%");
                footer.setSpacing(true);
                footer.addStyleName("v-window-bottom-toolbar");

                Label footerText = new Label("Footer text");
                footerText.setSizeUndefined();

                Button ok = new Button("OK");
                ok.addStyleName("primary");

                Button cancel = new Button("Cancel");

                footer.addComponents(footerText, ok, cancel);
                footer.setExpandRatio(footerText, 1);

                if (footerToolbar) {
                    MenuBar menuBar = MenuBars.getToolBar();
                    menuBar.setStyleName(toolbarStyle);
                    menuBar.setWidth(null);
                    footer.removeAllComponents();
                    footer.addComponent(menuBar);
                }

                root.addComponent(footer);
            }

            if (!autoHeight) {
                root.setSizeFull();
                root.setExpandRatio(content, 1);
            }

            return root;
        }

        {
            setSpacing(true);
            setMargin(true);
            win.setWidth("380px");
            win.setHeight(prevHeight);
            win.setClosable(false);
            win.setResizable(false);
            win.setContent(windowContent());
            win.setCloseShortcut(KeyCode.ESCAPE, null);

            Command optionsCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Footer")) {
                        footerVisible = selectedItem.isChecked();
                    }
                    if (selectedItem.getText().equals("Auto Height")) {
                        autoHeight = selectedItem.isChecked();
                        if (!autoHeight) {
                            win.setHeight(prevHeight);
                        } else {
                            prevHeight = win.getHeight() + win.getHeightUnits().toString();
                            win.setHeight(null);
                        }
                    }
                    if (selectedItem.getText().equals("Tabs")) {
                        tabsVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top")) {
                        toolbarVisible = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Footer")) {
                        footerToolbar = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Top layout")) {
                        toolbarLayout = selectedItem.isChecked();
                    }

                    if (selectedItem.getText().equals("Borderless")) {
                        toolbarStyle = selectedItem.isChecked() ? "borderless" : null;
                    }

                    win.setContent(windowContent());
                }
            };

            MenuBar options = new MenuBar();
            options.setCaption("Content");
            options.addItem("Auto Height", optionsCommand).setCheckable(true);
            options.addItem("Tabs", optionsCommand).setCheckable(true);
            MenuItem option = options.addItem("Footer", optionsCommand);
            option.setCheckable(true);
            option.setChecked(true);
            options.addStyleName("small");
            addComponent(options);

            options = new MenuBar();
            options.setCaption("Toolbars");
            options.addItem("Footer", optionsCommand).setCheckable(true);
            options.addItem("Top", optionsCommand).setCheckable(true);
            options.addItem("Top layout", optionsCommand).setCheckable(true);
            options.addItem("Borderless", optionsCommand).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            Command optionsCommand2 = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Caption")) {
                        win.setCaption(selectedItem.isChecked() ? "Window Caption" : null);
                    } else if (selectedItem.getText().equals("Closable")) {
                        win.setClosable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Resizable")) {
                        win.setResizable(selectedItem.isChecked());
                    } else if (selectedItem.getText().equals("Modal")) {
                        win.setModal(selectedItem.isChecked());
                    }
                }
            };

            options = new MenuBar();
            options.setCaption("Options");
            MenuItem caption = options.addItem("Caption", optionsCommand2);
            caption.setCheckable(true);
            caption.setChecked(true);
            options.addItem("Closable", optionsCommand2).setCheckable(true);
            options.addItem("Resizable", optionsCommand2).setCheckable(true);
            options.addItem("Modal", optionsCommand2).setCheckable(true);
            options.addStyleName("small");
            addComponent(options);

            final Button show = new Button("Open Window", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    getUI().addWindow(win);
                    win.center();
                    win.focus();
                    event.getButton().setEnabled(false);
                }
            });
            show.addStyleName("primary");
            addComponent(show);

            final CheckBox hidden = new CheckBox("Hidden");
            hidden.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    win.setVisible(!hidden.getValue());
                }
            });
            addComponent(hidden);

            win.addCloseListener(new CloseListener() {
                @Override
                public void windowClose(final CloseEvent e) {
                    show.setEnabled(true);
                }
            });
        }
    };
    p.setContent(content);
    return p;

}

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

License:Apache License

public Tabsheets() {
    setMargin(true);/*w ww  .  j  a v  a2  s.  co 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);/* w w  w. ja 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);
    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  www. j av  a 2 s .c om*/
    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//from w w w . j  a v  a  2  s. 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.emuanalytics.vaadin.enhancedjavascript.BasicTestUI.java

License:Apache License

private Component createTestPanel() {

    TextField valueField = new TextField("Server value to send:");
    valueField.setId("server-value-input");

    Button setValueButton = new Button("Set Value From Server", clickEvent -> {
        sampleComponent.setValue(valueField.getValue());
    });/*w w w . ja va 2s. co  m*/
    setValueButton.setId("set-value-button");

    Button setTitleButton = new Button("Set Title From Server", clickEvent -> {
        sampleComponent.setTitle(valueField.getValue());
    });
    setTitleButton.setId("set-title-button");

    Button setValueRPCButton = new Button("Set Value Via RPC", clickEvent -> {
        sampleComponent.setValueViaRPC(valueField.getValue());
    });
    setValueRPCButton.setId("set-value-rpc-button");

    CheckBox immediateCheckbox = new CheckBox("Immediate variable notification");
    immediateCheckbox.addValueChangeListener(e -> {
        sampleComponent.setImmediate(immediateCheckbox.getValue());
    });
    immediateCheckbox.setId("immediate-checkbox");

    lastEventField = new TextField("Last event:");
    lastEventField.setId("last-event-field");

    lastVariableChangeField = new TextField("Last variable change:");
    lastVariableChangeField.setId("last-variable-change-field");

    VerticalLayout testLayout = new VerticalLayout(valueField, setValueButton, setTitleButton,
            setValueRPCButton, immediateCheckbox, lastEventField, lastVariableChangeField);

    testLayout.setWidth("300px");
    testLayout.setSpacing(true);

    for (Component c : testLayout) {
        c.setWidth("100%");
    }

    return testLayout;
}

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);/* w w  w.j  a  v  a 2  s  .co  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);//from   w ww  .java  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 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);
}