Example usage for com.vaadin.data.validator EmailValidator EmailValidator

List of usage examples for com.vaadin.data.validator EmailValidator EmailValidator

Introduction

In this page you can find the example usage for com.vaadin.data.validator EmailValidator EmailValidator.

Prototype

public EmailValidator(String errorMessage) 

Source Link

Document

Creates a validator for checking that a string is a syntactically valid e-mail address.

Usage

From source file:annis.gui.admin.ImportPanel.java

License:Apache License

public ImportPanel() {

    setSizeFull();/*from www  .ja va 2 s.  c om*/

    layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    layout.setMargin(true);

    setContent(layout);

    FormLayout form = new FormLayout();
    layout.addComponent(form);

    cbOverwrite = new CheckBox("Overwrite existing corpus");
    form.addComponent(cbOverwrite);

    txtMail = new TextField("e-mail address for status updates");
    txtMail.addValidator(new EmailValidator("Must be a valid e-mail address"));
    form.addComponent(txtMail);

    txtAlias = new TextField("alias name");
    form.addComponent(txtAlias);

    HorizontalLayout actionBar = new HorizontalLayout();
    actionBar.setSpacing(true);
    actionBar.setWidth("100%");

    upload = new Upload("", this);
    upload.setButtonCaption("Upload ZIP file with relANNIS corpus and start import");
    upload.setImmediate(true);
    upload.addStartedListener(this);
    upload.addFinishedListener(this);
    upload.setEnabled(true);

    actionBar.addComponent(upload);

    progress = new ProgressBar();
    progress.setIndeterminate(true);
    progress.setVisible(false);

    actionBar.addComponent(progress);

    lblProgress = new Label();
    lblProgress.setWidth("100%");

    actionBar.addComponent(lblProgress);

    actionBar.setExpandRatio(lblProgress, 1.0f);
    actionBar.setComponentAlignment(lblProgress, Alignment.MIDDLE_LEFT);
    actionBar.setComponentAlignment(upload, Alignment.MIDDLE_LEFT);
    actionBar.setComponentAlignment(progress, Alignment.MIDDLE_LEFT);

    layout.addComponent(actionBar);

    btDetailedLog = new Button();
    btDetailedLog.setStyleName(BaseTheme.BUTTON_LINK);
    btDetailedLog.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setLogVisible(!isLogVisible());
        }
    });
    layout.addComponent(btDetailedLog);

    txtMessages = new TextArea();
    txtMessages.setSizeFull();
    txtMessages.setValue("");
    txtMessages.setReadOnly(true);
    layout.addComponent(txtMessages);

    layout.setExpandRatio(txtMessages, 1.0f);

    setLogVisible(false);
    appendMessage("Ready.");

}

From source file:annis.gui.MainToolbar.java

License:Apache License

public MainToolbar() {

    String bugmail = (String) VaadinSession.getCurrent().getAttribute(BUG_MAIL_KEY);
    if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${")
            && new EmailValidator("").isValid(bugmail)) {
        this.bugEMailAddress = bugmail;
    } else {//  w w w  .j  a va  2  s . c o  m
        this.bugEMailAddress = null;
    }

    UI ui = UI.getCurrent();
    if (ui instanceof CommonUI) {
        ((CommonUI) ui).getSettings().addedLoadedListener(MainToolbar.this);
    }

    setWidth("100%");
    setHeight("-1px");

    addStyleName("toolbar");
    addStyleName("border-layout");

    btAboutAnnis = new Button("About ANNIS");
    btAboutAnnis.addStyleName(ValoTheme.BUTTON_SMALL);
    btAboutAnnis.setIcon(new ThemeResource("images/annis_16.png"));
    btAboutAnnis.addClickListener(new AboutClickListener());

    btSidebar = new Button();
    btSidebar.setDisableOnClick(true);
    btSidebar.addStyleName(ValoTheme.BUTTON_SMALL);
    btSidebar.setDescription("Show and hide search sidebar");
    btSidebar.setIconAlternateText(btSidebar.getDescription());

    btBugReport = new Button("Report Problem");
    btBugReport.addStyleName(ValoTheme.BUTTON_SMALL);
    btBugReport.setDisableOnClick(true);
    btBugReport.setIcon(FontAwesome.ENVELOPE_O);
    btBugReport.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            reportBug();
        }
    });
    btBugReport.setVisible(this.bugEMailAddress != null);

    btNavigate = new Button();
    btNavigate.setVisible(false);
    btNavigate.setDisableOnClick(true);
    btNavigate.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            btNavigate.setEnabled(true);
            if (navigationTarget != null) {
                UI.getCurrent().getNavigator().navigateTo(navigationTarget.state);
            }
        }
    });
    lblUserName = new Label("not logged in");
    lblUserName.setWidth("-1px");
    lblUserName.setHeight("-1px");
    lblUserName.addStyleName("right-aligned-text");

    btLogin = new Button("Login", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            showLoginWindow(false);
        }
    });

    btLogout = new Button("Logout", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            // logout
            Helper.setUser(null);
            for (LoginListener l : loginListeners) {
                l.onLogout();
            }
            Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION);
            updateUserInformation();
        }
    });

    btLogin.setSizeUndefined();
    btLogin.setStyleName(ValoTheme.BUTTON_SMALL);
    btLogin.setIcon(FontAwesome.USER);

    btLogout.setSizeUndefined();
    btLogout.setStyleName(ValoTheme.BUTTON_SMALL);
    btLogout.setIcon(FontAwesome.USER);

    btOpenSource = new Button("Help us to make ANNIS better!");
    btOpenSource.setStyleName(BaseTheme.BUTTON_LINK);
    btOpenSource.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window w = new HelpUsWindow();
            w.setCaption("Help us to make ANNIS better!");
            w.setModal(true);
            w.setResizable(true);
            w.setWidth("600px");
            w.setHeight("500px");
            UI.getCurrent().addWindow(w);
            w.center();
        }
    });

    addComponent(btSidebar);
    setComponentAlignment(btSidebar, Alignment.MIDDLE_LEFT);

    addComponent(btAboutAnnis);
    addComponent(btBugReport);
    addComponent(btNavigate);

    addComponent(btOpenSource);

    setSpacing(true);
    setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT);
    setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT);
    setComponentAlignment(btNavigate, Alignment.MIDDLE_LEFT);

    setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER);
    setExpandRatio(btOpenSource, 1.0f);

    addLoginButton();

    btSidebar.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            btSidebar.setEnabled(true);

            // decide new state
            switch (sidebarState) {
            case VISIBLE:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.AUTO_VISIBLE;
                } else {
                    sidebarState = SidebarState.HIDDEN;
                }
                break;
            case HIDDEN:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.AUTO_HIDDEN;
                } else {
                    sidebarState = SidebarState.VISIBLE;
                }
                break;

            case AUTO_VISIBLE:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.VISIBLE;
                } else {
                    sidebarState = SidebarState.AUTO_HIDDEN;
                }
                break;
            case AUTO_HIDDEN:
                if (event.isCtrlKey()) {
                    sidebarState = SidebarState.HIDDEN;
                } else {
                    sidebarState = SidebarState.AUTO_VISIBLE;
                }
                break;
            }

            updateSidebarState();
        }
    });

    screenshotExtension = new ScreenshotMaker(this);

    JavaScript.getCurrent().addFunction("annis.gui.logincallback", new LoginCloseCallback());

    updateSidebarState();
    MainToolbar.this.updateUserInformation();
}

From source file:annis.gui.SearchUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    super.init(request);

    this.instanceConfig = getInstanceConfig(request);

    getPage().setTitle(instanceConfig.getInstanceDisplayName() + " (ANNIS Corpus Search)");

    queryController = new QueryController(this);

    refresh = new Refresher();
    // deactivate refresher by default
    refresh.setRefreshInterval(-1);/*  w  ww .  j av a  2  s .co  m*/
    refresh.addListener(queryController);
    addExtension(refresh);

    // always get the resize events directly
    setImmediate(true);

    VerticalLayout mainLayout = new VerticalLayout();
    setContent(mainLayout);

    mainLayout.setSizeFull();
    mainLayout.setMargin(false);

    final ScreenshotMaker screenshot = new ScreenshotMaker(this);
    addExtension(screenshot);

    css = new CSSInject(this);

    HorizontalLayout layoutToolbar = new HorizontalLayout();
    layoutToolbar.setWidth("100%");
    layoutToolbar.setHeight("-1px");

    mainLayout.addComponent(layoutToolbar);
    layoutToolbar.addStyleName("toolbar");
    layoutToolbar.addStyleName("border-layout");

    Button btAboutAnnis = new Button("About ANNIS");
    btAboutAnnis.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btAboutAnnis.setIcon(new ThemeResource("info.gif"));

    btAboutAnnis.addClickListener(new AboutClickListener());

    btBugReport = new Button("Report Bug");
    btBugReport.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btBugReport.setDisableOnClick(true);
    btBugReport.setIcon(new ThemeResource("../runo/icons/16/email.png"));
    btBugReport.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            screenshot.makeScreenshot();
            btBugReport.setCaption("bug report is initialized...");
        }
    });

    String bugmail = (String) VaadinSession.getCurrent().getAttribute("bug-e-mail");
    if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${")
            && new EmailValidator("").isValid(bugmail)) {
        this.bugEMailAddress = bugmail;
    }
    btBugReport.setVisible(this.bugEMailAddress != null);

    lblUserName = new Label("not logged in");
    lblUserName.setWidth("-1px");
    lblUserName.setHeight("-1px");
    lblUserName.addStyleName("right-aligned-text");

    btLoginLogout = new Button("Login", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (isLoggedIn()) {
                // logout
                Helper.setUser(null);
                Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION);
                updateUserInformation();
            } else {
                showLoginWindow();
            }
        }
    });
    btLoginLogout.setSizeUndefined();
    btLoginLogout.setStyleName(ChameleonTheme.BUTTON_SMALL);
    btLoginLogout.setIcon(new ThemeResource("../runo/icons/16/user.png"));

    Button btOpenSource = new Button("Help us to make ANNIS better!");
    btOpenSource.setStyleName(BaseTheme.BUTTON_LINK);
    btOpenSource.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Window w = new HelpUsWindow();
            w.setCaption("Help us to make ANNIS better!");
            w.setModal(true);
            w.setResizable(true);
            w.setWidth("600px");
            w.setHeight("500px");
            addWindow(w);
            w.center();
        }
    });

    layoutToolbar.addComponent(btAboutAnnis);
    layoutToolbar.addComponent(btBugReport);
    layoutToolbar.addComponent(btOpenSource);
    layoutToolbar.addComponent(lblUserName);
    layoutToolbar.addComponent(btLoginLogout);

    layoutToolbar.setSpacing(true);
    layoutToolbar.setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT);
    layoutToolbar.setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT);
    layoutToolbar.setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER);
    layoutToolbar.setComponentAlignment(lblUserName, Alignment.MIDDLE_RIGHT);
    layoutToolbar.setComponentAlignment(btLoginLogout, Alignment.MIDDLE_RIGHT);
    layoutToolbar.setExpandRatio(btOpenSource, 1.0f);

    //HorizontalLayout hLayout = new HorizontalLayout();
    final HorizontalSplitPanel hSplit = new HorizontalSplitPanel();
    hSplit.setSizeFull();

    mainLayout.addComponent(hSplit);
    mainLayout.setExpandRatio(hSplit, 1.0f);

    AutoGeneratedQueries autoGenQueries = new AutoGeneratedQueries("example queries", this);

    controlPanel = new ControlPanel(queryController, instanceConfig, autoGenQueries);
    controlPanel.setWidth(100f, Layout.Unit.PERCENTAGE);
    controlPanel.setHeight(100f, Layout.Unit.PERCENTAGE);
    hSplit.setFirstComponent(controlPanel);

    tutorial = new TutorialPanel();
    tutorial.setHeight("99%");

    mainTab = new TabSheet();
    mainTab.setSizeFull();
    mainTab.addTab(autoGenQueries, "example queries");
    mainTab.addTab(tutorial, "Tutorial");

    queryBuilder = new QueryBuilderChooser(queryController, this, instanceConfig);
    mainTab.addTab(queryBuilder, "Query Builder");

    hSplit.setSecondComponent(mainTab);
    hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS);
    hSplit.addSplitterClickListener(new AbstractSplitPanel.SplitterClickListener() {
        @Override
        public void splitterClick(AbstractSplitPanel.SplitterClickEvent event) {
            if (event.isDoubleClick()) {
                if (hSplit.getSplitPosition() == CONTROL_PANEL_WIDTH) {
                    // make small
                    hSplit.setSplitPosition(0.0f, Unit.PIXELS);
                } else {
                    // reset to default width
                    hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS);
                }
            }
        }
    });
    // hLayout.setExpandRatio(mainTab, 1.0f);

    addAction(new ShortcutListener("^Query builder") {
        @Override
        public void handleAction(Object sender, Object target) {
            mainTab.setSelectedTab(queryBuilder);
        }
    });

    addAction(new ShortcutListener("Tutor^eial") {
        @Override
        public void handleAction(Object sender, Object target) {
            mainTab.setSelectedTab(tutorial);
        }
    });

    getPage().addUriFragmentChangedListener(this);

    getSession().addRequestHandler(new RequestHandler() {
        @Override
        public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response)
                throws IOException {
            checkCitation(request);

            if (request.getPathInfo() != null && request.getPathInfo().startsWith("/vis-iframe-res/")) {
                String uuidString = StringUtils.removeStart(request.getPathInfo(), "/vis-iframe-res/");
                UUID uuid = UUID.fromString(uuidString);
                IFrameResourceMap map = VaadinSession.getCurrent().getAttribute(IFrameResourceMap.class);
                if (map == null) {
                    response.setStatus(404);
                } else {
                    IFrameResource res = map.get(uuid);
                    if (res != null) {
                        response.setStatus(200);
                        response.setContentType(res.getMimeType());
                        response.getOutputStream().write(res.getData());
                    }
                }
                return true;
            }

            return false;
        }
    });

    getSession().setAttribute(MediaController.class, new MediaControllerImpl());

    getSession().setAttribute(PDFController.class, new PDFControllerImpl());

    loadInstanceFonts();

    checkCitation(request);
    lastQueriedFragment = "";
    evaluateFragment(getPage().getUriFragment());

    updateUserInformation();
}

From source file:ch.bfh.ti.soed.hs16.srs.purple.controller.ValidationController.java

License:Open Source License

/**
 * Function checks if the value of the textfield is an email address
 *
 * @param textfield - The textfield to be checked
 *///from   ww  w . j a  v a2s.  c  o m
public static void checkIfEmail(TextField textfield) {
    textfield.addValidator(new EmailValidator("Ungltige E-Mail Adresse"));
}

From source file:com.anphat.list.ui.DialogCreateDepartment.java

@AutoGenerated
private GridLayout buildGridLayoutDepartInfo() {
    // common part: create layout
    gridLayoutDepartInfo = new GridLayout();
    gridLayoutDepartInfo.setStyleName("custom-feildset");
    gridLayoutDepartInfo//from w w w  .  j a v a 2  s.  c o  m
            .setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("department.fieldset.title.deptInfo")));
    gridLayoutDepartInfo.setCaptionAsHtml(true);
    gridLayoutDepartInfo.setImmediate(true);
    gridLayoutDepartInfo.setWidth("100.0%");
    gridLayoutDepartInfo.setHeight("-1px");
    gridLayoutDepartInfo.setMargin(true);
    gridLayoutDepartInfo.setSpacing(true);
    gridLayoutDepartInfo.setColumns(4);
    gridLayoutDepartInfo.setRows(7);

    // lblDepartmentCode
    lblDepartmentCode = new Label();
    lblDepartmentCode.setImmediate(true);
    lblDepartmentCode.setWidth("100.0%");
    lblDepartmentCode.setHeight("-1px");
    lblDepartmentCode.setValue(BundleUtils.getString("lb.deptstaff.dept.code"));
    gridLayoutDepartInfo.addComponent(lblDepartmentCode, 0, 0);

    // txtDepartmentCode
    txtDepartmentCode = new TextField();
    txtDepartmentCode.setImmediate(true);
    txtDepartmentCode.setWidth("100.0%");
    txtDepartmentCode.setHeight("-1px");
    txtDepartmentCode.setMaxLength(50);
    txtDepartmentCode.setRequired(true);
    txtDepartmentCode.addValidator(
            new RegexpValidator("^[a-zA-Z0-9-_]+$", BundleUtils.getString("lb.deptstaff.dept.code") + " "
                    + BundleUtils.getString("message.error.code.format")));
    gridLayoutDepartInfo.addComponent(txtDepartmentCode, 1, 0);

    // lblDepartmentName
    lblDepartmentName = new Label();
    lblDepartmentName.setImmediate(true);
    lblDepartmentName.setWidth("100.0%");
    lblDepartmentName.setHeight("-1px");
    lblDepartmentName.setValue(BundleUtils.getString("lb.deptstaff.dept.name"));
    gridLayoutDepartInfo.addComponent(lblDepartmentName, 2, 0);

    // txtDepartmentName
    txtDepartmentName = new TextField();
    txtDepartmentName.setImmediate(true);
    txtDepartmentName.setWidth("100.0%");
    txtDepartmentName.setHeight("-1px");
    txtDepartmentName.setMaxLength(100);
    txtDepartmentName.setRequired(true);
    gridLayoutDepartInfo.addComponent(txtDepartmentName, 3, 0);

    // lblSuperiorUnit
    //        lblSuperiorUnit = new Label();
    //        lblSuperiorUnit.setImmediate(true);
    //        lblSuperiorUnit.setWidth("100.0%");
    //        lblSuperiorUnit.setHeight("-1px");
    //        lblSuperiorUnit.setValue(BundleUtils.getString("lb.deptstaff.dept.level"));
    //        gridLayoutDepartInfo.addComponent(lblSuperiorUnit, 0, 1);

    // txtSuperiorUnit
    //        txtSuperiorUnit = new TextField();
    //        txtSuperiorUnit.setImmediate(true);
    //        txtSuperiorUnit.setWidth("100.0%");
    //        txtSuperiorUnit.setHeight("-1px");
    //        comboDeptTopLevel = new MappingCombobox(3, 1);
    //        comboDeptTopLevel.getNameCombo().setRequired(true);
    //        gridLayoutDepartInfo.addComponent(comboDeptTopLevel.getLayout(), 1, 1, 3, 1);

    // lblDescription
    lblDescription = new Label();
    lblDescription.setImmediate(true);
    lblDescription.setWidth("100.0%");
    lblDescription.setHeight("-1px");
    lblDescription.setValue(BundleUtils.getString("lb.deptstaff.desc"));
    gridLayoutDepartInfo.addComponent(lblDescription, 0, 1);

    // textArea_1
    textArea_1 = new TextArea();
    textArea_1.setImmediate(true);
    textArea_1.setWidth("100.0%");
    textArea_1.setHeight("-1px");
    textArea_1.setMaxLength(300);
    textArea_1.setStyleName("notRequireStyle");
    gridLayoutDepartInfo.addComponent(textArea_1, 1, 1, 3, 1);

    // lblStatus
    lblStatus = new Label();
    lblStatus.setImmediate(true);
    lblStatus.setWidth("100.0%");
    lblStatus.setHeight("-1px");
    lblStatus.setValue(BundleUtils.getString("lb.deptstaff.common.status"));
    gridLayoutDepartInfo.addComponent(lblStatus, 0, 2);

    // cbxStatus
    cbxStatus = new ComboBox();
    cbxStatus.setImmediate(true);
    cbxStatus.setTextInputAllowed(false);
    cbxStatus.setFilteringMode(FilteringMode.OFF);
    cbxStatus.setWidth("100.0%");
    cbxStatus.setHeight("-1px");
    cbxStatus.setRequired(true);
    gridLayoutDepartInfo.addComponent(cbxStatus, 1, 2);

    // lblPhoneNumber
    lblPhoneNumber = new Label();
    lblPhoneNumber.setImmediate(true);
    lblPhoneNumber.setWidth("100.0%");
    lblPhoneNumber.setHeight("-1px");
    lblPhoneNumber.setValue(BundleUtils.getString("lb.deptstaff.common.phone"));
    gridLayoutDepartInfo.addComponent(lblPhoneNumber, 2, 2);

    // txtPhoneNumber
    txtPhoneNumber = new TextField();
    txtPhoneNumber.setImmediate(true);
    txtPhoneNumber.setInputPrompt(BundleUtils.getString("common.phone.format"));
    txtPhoneNumber.setWidth("100.0%");
    txtPhoneNumber.setHeight("-1px");
    txtPhoneNumber.setMaxLength(100);
    //message
    //          StringBuilder messageErrorOrder = new StringBuilder();
    //        messageErrorOrder.append(BundleUtils.getString("lb.deptstaff.common.phone"));
    //        messageErrorOrder.append(BundleUtils.getString(" "));
    //        messageErrorOrder.append(BundleUtils.getString("message.error.phoneformat"));
    //        txtPhoneNumber.addValidator(new RegexpValidator("^\\(?(\\d{3,4})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", messageErrorOrder.toString()));
    txtPhoneNumber.setStyleName("notRequireStyle");
    gridLayoutDepartInfo.addComponent(txtPhoneNumber, 3, 2);

    // lblFax
    //        lblFax = new Label();
    //        lblFax.setImmediate(true);
    //        lblFax.setWidth("100.0%");
    //        lblFax.setHeight("-1px");
    //        lblFax.setValue(BundleUtils.getString("lb.deptstaff.fax"));
    //        gridLayoutDepartInfo.addComponent(lblFax, 0, 4);

    // txtFax
    //        txtFax = new TextField();
    //        txtFax.setImmediate(true);
    //        txtFax.setWidth("100.0%");
    //        txtFax.setHeight("-1px");
    //        txtFax.setMaxLength(100);
    //message
    //        StringBuilder messageErrorFax = new StringBuilder();
    //        messageErrorFax.append(BundleUtils.getString("lb.deptstaff.fax"));
    //        messageErrorFax.append(BundleUtils.getString(" "));
    //        messageErrorFax.append(BundleUtils.getString("message.error.numberformat"));
    //        txtFax.addValidator(new RegexpValidator("[0-9]+", messageErrorFax.toString()));
    //        txtFax.setStyleName("notRequireStyle");
    //        gridLayoutDepartInfo.addComponent(txtFax, 1, 4);

    // lblEmail
    lblEmail = new Label();
    lblEmail.setImmediate(true);
    lblEmail.setWidth("100.0%");
    lblEmail.setHeight("-1px");
    lblEmail.setValue(BundleUtils.getString("lb.deptstaff.common.email"));
    gridLayoutDepartInfo.addComponent(lblEmail, 2, 3);

    // txtEmail
    txtEmail = new TextField();
    txtEmail.setImmediate(true);
    txtEmail.addValidator(new EmailValidator(BundleUtils.getString("common.error.email")));
    txtEmail.setRequiredError(BundleUtils.getString("common.error.email"));
    txtEmail.setInputPrompt(BundleUtils.getString("common.email.hint.format"));
    txtEmail.setWidth("100.0%");
    txtEmail.setHeight("-1px");
    txtEmail.setMaxLength(100);
    txtEmail.setStyleName("notRequireStyle");
    gridLayoutDepartInfo.addComponent(txtEmail, 3, 3);

    // lblAddress
    lblAddress = new Label();
    lblAddress.setImmediate(true);
    lblAddress.setWidth("100.0%");
    lblAddress.setHeight("-1px");
    lblAddress.setValue(BundleUtils.getString("lb.deptstaff.dept.addr"));
    gridLayoutDepartInfo.addComponent(lblAddress, 0, 4);

    // txtAddress
    txtAddress = new TextField();
    txtAddress.setImmediate(true);
    txtAddress.setWidth("100.0%");
    txtAddress.setHeight("-1px");
    txtAddress.setMaxLength(300);
    //        txtAddress.addValidator(new StringLengthValidator(BundleUtils.getString("common.error.length"), 0, 200, true));
    txtAddress.setRequired(true);
    txtAddress.setStyleName("notRequireStyle");
    gridLayoutDepartInfo.addComponent(txtAddress, 1, 4, 3, 4);

    // lblContact
    //        lblContact = new Label();
    //        lblContact.setImmediate(true);
    //        lblContact.setWidth("100.0%");
    //        lblContact.setHeight("-1px");
    //        lblContact.setValue(BundleUtils.getString("lb.deptstaff.contact.person"));
    //        gridLayoutDepartInfo.addComponent(lblContact, 0, 5);
    //
    //        // txtContact
    //        txtContact = new TextField();
    //        txtContact.setImmediate(true);
    //        txtContact.setWidth("100.0%");
    //        txtContact.setHeight("-1px");
    //        txtContact.setMaxLength(200);
    //        txtContact.setStyleName("notRequireStyle");
    //        gridLayoutDepartInfo.addComponent(txtContact, 1, 5, 3, 5);

    return gridLayoutDepartInfo;
}

From source file:com.anphat.list.ui.DialogCreateStaff.java

@AutoGenerated
private GridLayout buildGridLayoutDepartInfo() {
    // common part: create layout
    gridLayoutDepartInfo = new GridLayout();
    gridLayoutDepartInfo.setStyleName("custom-feildset");
    gridLayoutDepartInfo.setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("caption.title.emp.info")));
    gridLayoutDepartInfo.setCaptionAsHtml(true);
    gridLayoutDepartInfo.setImmediate(true);
    gridLayoutDepartInfo.setWidth("100.0%");
    gridLayoutDepartInfo.setHeight("-1px");
    gridLayoutDepartInfo.setMargin(true);
    gridLayoutDepartInfo.setSpacing(true);
    gridLayoutDepartInfo.setColumns(4);/*  ww  w.j  a va2 s. c o  m*/
    gridLayoutDepartInfo.setRows(7);

    // lblDepartmentCode
    lblDepartmentCode = new Label();
    lblDepartmentCode.setImmediate(false);
    lblDepartmentCode.setWidth("100.0%");
    lblDepartmentCode.setHeight("-1px");
    lblDepartmentCode.setValue(BundleUtils.getString("lb.deptstaff.emp.code"));
    gridLayoutDepartInfo.addComponent(lblDepartmentCode, 0, 0);

    // txtStaffCode
    txtStaffCode = new TextField();
    txtStaffCode.setImmediate(true);
    txtStaffCode.setWidth("100.0%");
    txtStaffCode.setHeight("-1px");
    txtStaffCode.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    txtStaffCode.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(final FieldEvents.TextChangeEvent event) {
            String code = event.getText();
            if (code != null) {
                code = code.replaceAll(" ", "");
                if (!DataUtil.isStringNullOrEmpty(code)) {
                    txtStaffCode.setValue(code.toUpperCase());
                }
            }
        }
    });
    txtStaffCode.setMaxLength(50);
    txtStaffCode
            .addValidator(new RegexpValidator("^[a-zA-Z0-9-_]+$", BundleUtils.getString("lb.deptstaff.emp.code")
                    + " " + BundleUtils.getString("message.error.code.format")));
    txtStaffCode.setRequired(true);
    gridLayoutDepartInfo.addComponent(txtStaffCode, 1, 0);

    // lblDepartmentName
    lblDepartmentName = new Label();
    lblDepartmentName.setImmediate(false);
    lblDepartmentName.setWidth("100.0%");
    lblDepartmentName.setHeight("-1px");
    lblDepartmentName.setValue(BundleUtils.getString("lb.deptstaff.emp.name"));
    gridLayoutDepartInfo.addComponent(lblDepartmentName, 2, 0);

    // txtStaffName
    txtStaffName = new TextField();
    txtStaffName.setImmediate(true);
    txtStaffName.setWidth("100.0%");
    txtStaffName.setHeight("-1px");
    txtStaffName.setMaxLength(200);
    //        txtStaffName.addValidator(new StringLengthValidator(BundleUtils.getString("common.error.length"), 0, 200, true));
    txtStaffName.setRequired(true);
    gridLayoutDepartInfo.addComponent(txtStaffName, 3, 0);

    // lblSuperiorUnit
    lblSuperiorUnit = new Label();
    lblSuperiorUnit.setImmediate(false);
    lblSuperiorUnit.setWidth("100.0%");
    lblSuperiorUnit.setHeight("-1px");
    lblSuperiorUnit.setValue(BundleUtils.getString("lb.deptstaff.emp.dept"));
    gridLayoutDepartInfo.addComponent(lblSuperiorUnit, 0, 1);

    // txtSuperiorUnit
    txtSuperiorUnit = new TextField();
    txtSuperiorUnit.setImmediate(true);
    txtSuperiorUnit.setWidth("100.0%");
    txtSuperiorUnit.setHeight("-1px");
    comboDeptTopLevel = new MappingCombobox(3, 1);
    //        comboDeptTopLevel.getNameCombo().setRequired(true);
    gridLayoutDepartInfo.addComponent(comboDeptTopLevel.getLayout(), 1, 1, 3, 1);

    //        // lblStock
    //        lblStock = new Label();
    //        lblStock.setImmediate(false);
    //        lblStock.setWidth("100.0%");
    //        lblStock.setHeight("-1px");
    //        lblStock.setVisible(false);
    //        lblStock.setValue(BundleUtils.getString("lb.deptstaff.emp.stock"));
    //        gridLayoutDepartInfo.addComponent(lblStock, 0, 2);
    //
    //        // txtSuperiorUnit
    //        comboStock = new MappingCombobox(3, 1);
    ////        comboDeptTopLevel.getNameCombo().setRequired(true);
    //        comboStock.setVisible(false);
    //        gridLayoutDepartInfo.addComponent(comboStock.getLayout(), 1, 2,3 ,2);

    // lblSuperiorUnit
    lblStaffType = new Label();
    lblStaffType.setImmediate(false);
    lblStaffType.setWidth("100.0%");
    lblStaffType.setHeight("-1px");
    lblStaffType.setValue(BundleUtils.getString("lb.deptstaff.emp.type"));
    //        gridLayoutDepartInfo.addComponent(lblStaffType, 0, 3);
    gridLayoutDepartInfo.addComponent(lblStaffType, 0, 2);

    // txtSuperiorUnit
    cbxStaffType = new ComboBox();
    cbxStaffType.setImmediate(true);
    cbxStaffType.setRequired(true);
    cbxStaffType.setTextInputAllowed(false);
    cbxStaffType.setFilteringMode(FilteringMode.OFF);
    cbxStaffType.setWidth("100.0%");
    cbxStaffType.setHeight("-1px");
    //        cbxStaffType.setStyleName("notRequireStyle");
    //        gridLayoutDepartInfo.addComponent(cbxStaffType, 1, 3);
    gridLayoutDepartInfo.addComponent(cbxStaffType, 1, 2);

    // lblDescription
    lblDescription = new Label();
    lblDescription.setImmediate(false);
    lblDescription.setWidth("100.0%");
    lblDescription.setHeight("-1px");
    lblDescription.setValue(BundleUtils.getString("lb.deptstaff.common.phone"));
    //        gridLayoutDepartInfo.addComponent(lblDescription, 0, 4);
    gridLayoutDepartInfo.addComponent(lblDescription, 0, 3);

    // textArea_1
    txtPhoneNumber = new TextField();
    txtPhoneNumber.setImmediate(true);
    txtPhoneNumber.setWidth("100.0%");
    txtPhoneNumber.setHeight("-1px");
    txtPhoneNumber.setMaxLength(100);
    StringBuilder messageErrorOrder = new StringBuilder();
    messageErrorOrder.append(BundleUtils.getString("lb.deptstaff.common.phone"));
    messageErrorOrder.append(BundleUtils.getString(" "));
    messageErrorOrder.append(BundleUtils.getString("message.error.phoneformat"));
    txtPhoneNumber.addValidator(new RegexpValidator("^\\(?(\\d{3,4})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$",
            messageErrorOrder.toString()));
    txtPhoneNumber.setInputPrompt(BundleUtils.getString("common.phone.format"));
    txtPhoneNumber.setStyleName("notRequireStyle");
    //        gridLayoutDepartInfo.addComponent(txtPhoneNumber, 1, 4);
    gridLayoutDepartInfo.addComponent(txtPhoneNumber, 1, 3);

    // lblStatus
    lblStatus = new Label();
    lblStatus.setImmediate(false);
    lblStatus.setWidth("100.0%");
    lblStatus.setHeight("-1px");
    lblStatus.setValue(BundleUtils.getString("lb.deptstaff.common.status"));
    //        gridLayoutDepartInfo.addComponent(lblStatus, 2, 3);
    gridLayoutDepartInfo.addComponent(lblStatus, 2, 2);

    // cbxStatus
    cbxStatus = new ComboBox();
    cbxStatus.setImmediate(true);
    cbxStatus.setTextInputAllowed(false);
    cbxStatus.setFilteringMode(FilteringMode.OFF);
    cbxStatus.setWidth("100.0%");
    cbxStatus.setHeight("-1px");
    cbxStatus.setRequired(true);
    //        gridLayoutDepartInfo.addComponent(cbxStatus, 3, 3);
    gridLayoutDepartInfo.addComponent(cbxStatus, 3, 2);

    // lblPhoneNumber
    lblPhoneNumber = new Label();
    lblPhoneNumber.setImmediate(false);
    lblPhoneNumber.setWidth("100.0%");
    lblPhoneNumber.setHeight("-1px");
    lblPhoneNumber.setValue(BundleUtils.getString("lb.deptstaff.common.email"));
    //        gridLayoutDepartInfo.addComponent(lblPhoneNumber, 2, 4);
    gridLayoutDepartInfo.addComponent(lblPhoneNumber, 2, 3);

    // txtEmail
    txtEmail = new TextField();
    txtEmail.setImmediate(true);
    txtEmail.addValidator(new EmailValidator(BundleUtils.getString("common.error.email")));
    txtEmail.setRequiredError(BundleUtils.getString("common.error.email"));
    txtEmail.setInputPrompt(BundleUtils.getString("common.email.hint.format"));
    txtEmail.setWidth("100.0%");
    txtEmail.setHeight("-1px");
    txtEmail.setMaxLength(100);
    txtEmail.setStyleName("notRequireStyle");
    //        gridLayoutDepartInfo.addComponent(txtEmail, 3, 4);
    gridLayoutDepartInfo.addComponent(txtEmail, 3, 3);

    // lblFax
    lblFax = new Label();
    lblFax.setImmediate(false);
    lblFax.setWidth("100.0%");
    lblFax.setHeight("-1px");
    lblFax.setValue(BundleUtils.getString("lb.deptstaff.emp.birthDate"));
    //        gridLayoutDepartInfo.addComponent(lblFax, 0, 5);
    gridLayoutDepartInfo.addComponent(lblFax, 0, 4);

    // pdfBirthDate
    pdfBirthDate = new PopupDateField();
    pdfBirthDate.setLocale(mlocale);
    pdfBirthDate.setImmediate(true);
    pdfBirthDate.setWidth("100.0%");
    pdfBirthDate.setHeight("-1px");
    pdfBirthDate.setStyleName("notRequireStyle");
    pdfBirthDate.setDateFormat("dd/MM/yyyy");
    CommonUtils.addDateValidator(pdfBirthDate);
    //        gridLayoutDepartInfo.addComponent(pdfBirthDate, 1, 5);
    gridLayoutDepartInfo.addComponent(pdfBirthDate, 1, 4);
    //        
    //        lblVofficeAcc = new Label();
    //        lblVofficeAcc.setImmediate(false);
    //        lblVofficeAcc.setWidth("100.0%");
    //        lblVofficeAcc.setHeight("-1px");
    //        lblVofficeAcc.setValue("Ti khon V-Office");
    //        gridLayoutDepartInfo.addComponent(lblVofficeAcc,2,4);

    //        txtVofficeAcc = new TextField();
    //        txtVofficeAcc.setImmediate(true);
    //        txtVofficeAcc.setWidth("100.0%");
    //        txtVofficeAcc.setHeight("-1px");
    //        txtVofficeAcc.setMaxLength(100);
    //        gridLayoutDepartInfo.addComponent(txtVofficeAcc,3,4);
    //

    //        lblTtnsAcc = new Label();
    //        lblTtnsAcc.setImmediate(false);
    //        lblTtnsAcc.setWidth("100.0%");
    //        lblTtnsAcc.setHeight("-1px");
    //        lblTtnsAcc.setValue("Ti khon TTNS");
    //        gridLayoutDepartInfo.addComponent(lblTtnsAcc,0,5);
    //
    //        txtTtnsAcc = new TextField();
    //        txtTtnsAcc.setImmediate(true);
    //        txtTtnsAcc.setWidth("100.0%");
    //        txtTtnsAcc.setHeight("-1px");
    //        txtTtnsAcc.setMaxLength(100);
    //        gridLayoutDepartInfo.addComponent(txtTtnsAcc,1,5);
    //        //
    //        
    //        lblVofficeAcc = new Label();
    //        lblVofficeAcc.setImmediate(false);
    //        lblVofficeAcc.setWidth("100.0%");
    //        lblVofficeAcc.setHeight("-1px");
    //        lblVofficeAcc.setValue("Ti khon khc");
    //        gridLayoutDepartInfo.addComponent(lblVofficeAcc,2,5);
    //        //
    //        txtOtherAcc = new TextField();
    //        txtOtherAcc.setImmediate(true);
    //        txtOtherAcc.setWidth("100.0%");
    //        txtOtherAcc.setHeight("-1px");
    //        txtOtherAcc.setMaxLength(100);
    //        gridLayoutDepartInfo.addComponent(txtOtherAcc,3,5);

    return gridLayoutDepartInfo;
}

From source file:com.cerebro.gorgone.landingpage.SignIn.java

public SignIn() {
    email.focus();//from  w  w w . j  ava  2  s .  co m
    email.isRequired();
    email.addValidator(new EmailValidator("Indirizzo email non valido"));
    email.setImmediate(true);
    pwd.isRequired();
    pwd.addValidator(new PasswordValidator());
    pwd.setImmediate(true);
    pwd_conf.isRequired();
    pwd_conf.addValidator((Object value) -> {
        String password = (String) value;
        if (!password.equals(pwd.getValue())) {
            throw new InvalidValueException("Le password non coincidono");
        }
    });
    name.isRequired();
    lastname.isRequired();
    sex.addItems("Maschio", "Femmina");
    sex.isRequired();
    birthday.isRequired();
    birthday.setDateFormat("dd/MM/yyyy");
    signIn.addClickListener((Button.ClickEvent event) -> {
        logger.info("Registro un nuovo utente");
        if (email.isValid() && pwd.isValid() && pwd_conf.isValid() && name.isValid() && lastname.isValid()
                && sex.isValid() && birthday.isValid()) {
            logger.info("Tutti i parametri inseriti sono validi");
            User newUser = new User();
            newUser.setEmail(email.getValue());
            //                newUser.setPassword(new PasswordEncryp(pwd.getValue()).getPwd());
            newUser.setPassword(pwd.getValue());
            newUser.setNomeUtente(name.getValue());
            newUser.setCognomeUtente(lastname.getValue());
            newUser.setSessoUtente(sex.getValue().toString());
            newUser.setDataNascitaUtente(birthday.getValue());
            SignInWindow signInWindow = new SignInWindow(newUser, this);
            UI.getCurrent().addWindow(signInWindow);
        } else {
            logger.error("Alcuni campi non sono validi");
        }

    });

    this.addComponents(email, pwd, pwd_conf, name, lastname, sex, birthday, signIn);
}

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 va2 s  . co 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);// w ww  .  j a  va 2s. com
    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.demo.tutorial.agenda.ui.PersonForm.java

public PersonForm(MyUI app) {
    this.app = app;

    cmbCiudad.setNullSelectionAllowed(false);
    cmbCiudad.setTextInputAllowed(false);

    /* Poblar cmbCiudad usando las ciudades en el data container */
    PersonContainer ds = app.getDataSource();
    for (Person person : ds.getItemIds()) { //OPCION 1
        String city = (String) person.getCiudad();
        cmbCiudad.addItem(city);//from   w w  w  .j  a v a  2  s . c o  m
    }
    /*for (Iterator<Person> it = ds.getItemIds().iterator(); it.hasNext();) {       //OPCION 2
     String city = (it.next()).getCiudad();
     cmbCiudad.addItem(city);
     }*/

    /*setFormFieldFactory(new DefaultFieldFactory() {
     @Override
     public Field createField(Item item, Object propertyId,
     Component uiContext) {
     if (propertyId.equals("city")) {
     return cities;
     }
     Field field = super.createField(item, propertyId, uiContext);
     if (propertyId.equals("postalCode")) {
     TextField tf = (TextField) field;
            
     tf.setNullRepresentation("");
            
     tf.addValidator(new RegexpValidator("[1-9][0-9]{4}",
     "Postal code must be a five digit number and cannot start with a zero."));
     tf.setRequired(true);
     }
            
     return field;
     }
     });*/
    fldBinder.setBuffered(true);
    /**
     * * Si esta en FALSE el buffered actualiza inmediatamente con tan solo
     * seleccionar otra fila **
     */
    //fldBinder.bind(txtNombre, "nombre");
    //fldBinder.bind(txtApPaterno, "apPaterno");
    footer.setSpacing(true);
    footer.addComponent(btnGuardar);
    footer.addComponent(btnCancelar);
    footer.addComponent(btnEditar);
    footer.setVisible(false);

    /**
     * Para dar formato a numeros y no tenga separado de decimales
     */
    txtCodPostal.setNullRepresentation("");
    StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() {
        @Override
        protected java.text.NumberFormat getFormat(Locale locale) {
            NumberFormat format = super.getFormat(locale);
            format.setGroupingUsed(false);
            return format;
        }
    };
    txtCodPostal.setConverter(plainIntegerConverter);

    String regexp = "[1-9][0-9]{6}";
    String message = "{0} Cdigo Postal debe ser de 5 digitos numricos y no puede empezar con cero.";
    CSValidator validator = new CSValidator();
    validator.extend(txtCodPostal);
    validator.setRegExp(regexp);
    validator.setPreventInvalidTyping(true);
    validator.setErrorMessage("Deber ser nmero");
    txtCodPostal.setRequired(true);
    txtCodPostal.setValidationVisible(false);
    Validator postalCodeValidator = new RegexpValidator(regexp, message);
    //txtCodPostal.addValidator(postalCodeValidator);
    //txtCodPostal.addValidator(new StringLengthValidator(
    //        "La longitud debe de ser de 5 digitos (was {0})",
    //        1, 5, false));

    txtEmail.addValidator(new EmailValidator("Invalido email"));

    //btnGuardar.addClickListener(this);
    //btnCancelar.addClickListener(this);
    //btnEditar.addClickListener(this);
    addComponent(txtNombre);
    addComponent(txtApPaterno);
    addComponent(txtEmail);
    addComponent(txtTelefono);
    addComponent(txtDireccion);
    addComponent(txtCodPostal);
    addComponent(cmbCiudad);
    addComponent(footer);

}