Example usage for com.vaadin.ui FormLayout FormLayout

List of usage examples for com.vaadin.ui FormLayout FormLayout

Introduction

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

Prototype

public FormLayout() 

Source Link

Usage

From source file:org.investovator.ui.main.components.DataUploadWindow.java

License:Open Source License

private void setLayout() {

    //Window Properties
    setCaption("Upload Data");
    setResizable(false);//from  ww w  .  j a  va  2  s . c  o m
    setClosable(true);
    setModal(true);
    center();

    content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(true);

    companySelectLayout = new HorizontalLayout();
    companyDetailUploadLayout = new HorizontalLayout();
    newCompanyForm = new FormLayout();

    newCompanyCheckBox = new CheckBox("New Company");

    companySelect = new ComboBox();

    companySelect = new ComboBox();
    companySelect.setNullSelectionAllowed(false);
    companySelect.setImmediate(true);

    dataTypeSelect = new ComboBox();
    dataTypeSelect.setNullSelectionAllowed(false);

    dataUpload = new Upload();
    dataUpload.setCaption("Select Data File");
    dataUpload.setButtonCaption(null);

    detailUpload = new Upload();
    detailUpload.setCaption("select Company Info XML");
    detailUpload.setButtonCaption(null);

    symbol = new TextField("Company Symbol");
    symbol.setRequired(true);
    companyName = new TextField("Company Name");
    companyName.setRequired(true);

    submitButton = new Button("Upload Data");

    newCompanyForm.addComponent(symbol);
    newCompanyForm.addComponent(companyName);

    companyDetailUploadLayout.addComponent(detailUpload);

    companySelectLayout.addComponent(companySelect);
    companySelectLayout.addComponent(newCompanyCheckBox);

    content.addComponent(companySelectLayout);
    content.addComponent(dataTypeSelect);
    content.addComponent(dataUpload);
    content.addComponent(submitButton);

    content.setComponentAlignment(submitButton, Alignment.MIDDLE_CENTER);

    setContent(content);
    setDefaults();
    bindListeners();

}

From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicMainView.java

License:Open Source License

private Component setupBuySellForm() {
    VerticalLayout formContent = new VerticalLayout();

    FormLayout form = new FormLayout();

    //account balance
    this.accBalance = new Label("");
    this.accBalance.setCaption("Account Balance");

    //stocks list
    final ComboBox stocksList = new ComboBox();
    stocksList.setCaption("Stock");
    stocksList.setNullSelectionAllowed(false);
    for (String stock : DataPlaybackEngineStates.playingSymbols) {
        stocksList.addItem(stock);//from   www. ja v  a 2 s.c o m
    }
    //stocksList.setWidth("75%");

    //side
    final NativeSelect orderSide = new NativeSelect();
    orderSide.setCaption("Side");
    orderSide.addItem(OrderType.BUY);
    orderSide.addItem(OrderType.SELL);
    //orderSide.setWidth("90%");
    orderSide.setSizeFull();
    orderSide.select(OrderType.BUY);
    orderSide.setNullSelectionAllowed(false);
    orderSide.setImmediate(true);

    //Quantity
    final TextField quantity = new TextField("Amount");
    //quantity.setWidth("75%");

    form.addComponent(accBalance);
    form.addComponent(stocksList);
    form.addComponent(orderSide);
    form.addComponent(quantity);

    formContent.addComponent(form);

    HorizontalLayout bBar = getBuySellForumButtons(stocksList, quantity, orderSide);
    formContent.addComponent(bBar);
    formContent.setComponentAlignment(bBar, Alignment.BOTTOM_RIGHT);
    //content.setComponentAlignment(nextDayB, Alignment.MIDDLE_CENTER);

    return formContent;
}

From source file:org.jpos.qi.eeuser.UsersView.java

License:Open Source License

private Panel createPasswordPanel() {
    passwordPanel = new Panel(getApp().getMessage("changePassword"));
    passwordPanel.setIcon(VaadinIcons.LOCK);
    passwordPanel.addStyleName("color1");
    passwordPanel.addStyleName("margin-top-panel");

    VerticalLayout panelContent = new VerticalLayout();
    panelContent.setSizeFull();//from   ww w . ja v a 2 s.co  m
    panelContent.setMargin(true);
    panelContent.setSpacing(true);

    FormLayout form = new FormLayout();
    form.setSizeFull();
    panelContent.addComponent(form);
    panelContent.setExpandRatio(form, 1f);

    passwordBinder = new Binder<>();
    passwordBinder.setReadOnly(true);
    binderIsReadOnly = true;
    if (selectedU.getId() != null) {
        currentPasswordField = new PasswordField(getApp().getMessage("passwordForm.currentPassword"));
        currentPasswordField.setWidth("80%");

        passwordBinder.forField(currentPasswordField)
                .asRequired(getApp().getMessage("errorMessage.req", currentPasswordField.getCaption()))
                .withValidator(((UsersHelper) getHelper()).getCurrentPasswordMatchValidator())
                .bind(string -> string, null);
        form.addComponent(currentPasswordField);
    }

    PasswordField newPasswordField = new PasswordField(getApp().getMessage("passwordForm.newPassword"));
    newPasswordField.setWidth("80%");
    passwordBinder.forField(newPasswordField)
            .asRequired(getApp().getMessage("errorMessage.req", newPasswordField.getCaption()))
            .withValidator(((UsersHelper) getHelper()).getNewPasswordNotUsedValidator())
            .bind(string -> string, null);
    form.addComponent(newPasswordField);

    repeatPasswordField = new PasswordField(getApp().getMessage("passwordForm.confirmPassword"));
    repeatPasswordField.setWidth("80%");
    passwordBinder.forField(repeatPasswordField)
            .asRequired(getApp().getMessage("errorMessage.req", repeatPasswordField.getCaption()))
            .withValidator(((UsersHelper) getHelper()).getPasswordsMatchValidator(newPasswordField))
            .bind(string -> string, null);
    form.addComponent(repeatPasswordField);
    passwordPanel.setVisible(forcePasswordChange);
    passwordPanel.setContent(panelContent);
    return passwordPanel;
}

From source file:org.jpos.qi.login.LoginView.java

License:Open Source License

private FormLayout createForm() {
    FormLayout formLayout = new FormLayout();
    formLayout.setMargin(false);/*from w  w  w.  j  av a  2  s . c o m*/
    formLayout.setSizeUndefined();

    binder = new Binder<>(String.class);
    username = new TextField(app.getMessage("login.username"));
    username.setMaxLength(60);

    binder.forField(username)
            .withValidator(new RegexpValidator(
                    app.getMessage("errorMessage.invalidField", username.getCaption()), USERNAME_PATTERN))
            .bind(string -> string, null);
    binder.setBean("");
    username.focus();
    username.setReadOnly(false);
    password = new PasswordField();
    password.setCaption(app.getMessage("login.password"));
    password.setMaxLength(64);
    binder.forField(password).asRequired(app.getMessage("errorMessage.req", password.getCaption()))
            .withValidator(new RegexpValidator(
                    app.getMessage("errorMessage.invalidField", password.getCaption()), PASSWORD_PATTERN))
            .bind(string -> string, null);
    password.setReadOnly(false);

    rememberMe = new CheckBox(app.getMessage("login.remember"));
    rememberMe.setDescription(app.getMessage("login.rememberDesc"));

    formLayout.addComponent(username);
    formLayout.addComponent(password);
    if (helper.isRememberEnabled())
        formLayout.addComponent(rememberMe);
    return formLayout;
}

From source file:org.jpos.qi.QIEntityView.java

License:Open Source License

protected Layout createLayout() {
    FormLayout layout = new FormLayout();
    layout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    layout.addStyleName("qi-form");
    layout.setMargin(new MarginInfo(false));
    addFields(layout);/*  ww w.  j  a  v  a 2  s  . c o m*/
    return layout;
}

From source file:org.jumpmind.metl.ui.views.admin.GeneralSettingsPanel.java

License:Open Source License

public GeneralSettingsPanel(final ApplicationContext context, TabbedPanel tabbedPanel) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;

    final GlobalSetting systemTextSetting = getGlobalSetting(GlobalSetting.SYSTEM_TEXT, "");

    FormLayout form = new FormLayout();
    form.setSpacing(true);//w  w w  . j  a v a  2 s.  c  o m

    ImmediateUpdateTextField systemTextField = new ImmediateUpdateTextField("System Text") {
        protected void save(String value) {
            saveSetting(systemTextSetting, value);
        }
    };
    systemTextField.setDescription(
            "Set HTML content to be displayed in the top bar that can identify a particular environment");
    systemTextField.setValue(systemTextSetting.getValue());
    systemTextField.setWidth(25f, Unit.EM);
    form.addComponent(systemTextField);
    systemTextField.focus();

    addComponent(form);
    setMargin(true);
}

From source file:org.jumpmind.metl.ui.views.admin.GroupEditPanel.java

License:Open Source License

public GroupEditPanel(ApplicationContext context, Group group) {
    this.context = context;
    this.group = group;

    FormLayout layout = new FormLayout();

    TextField nameField = new TextField("Group Name", StringUtils.trimToEmpty(group.getName()));
    nameField.addValueChangeListener(new NameChangeListener());
    layout.addComponent(nameField);//www .  j  a va 2 s.c  o  m
    nameField.focus();

    CheckBox readOnly = new CheckBox("Read Only");
    readOnly.setImmediate(true);
    readOnly.setValue(group.isReadOnly());
    readOnly.addValueChangeListener(new ReadOnlyChangeListener());
    layout.addComponent(readOnly);

    TwinColSelect privSelect = new TwinColSelect();
    for (Privilege priv : Privilege.values()) {
        privSelect.addItem(priv.name());
    }
    lastPrivs = new HashSet<String>();
    for (GroupPrivilege groupPriv : group.getGroupPrivileges()) {
        lastPrivs.add(groupPriv.getName());
    }
    privSelect.setValue(lastPrivs);
    privSelect.setRows(20);
    privSelect.setNullSelectionAllowed(true);
    privSelect.setMultiSelect(true);
    privSelect.setImmediate(true);
    privSelect.setLeftColumnCaption("Available privileges");
    privSelect.setRightColumnCaption("Selected privileges");
    privSelect.addValueChangeListener(new PrivilegeChangeListener());
    layout.addComponent(privSelect);

    addComponent(layout);
    setMargin(true);
}

From source file:org.jumpmind.metl.ui.views.admin.MailServerPanel.java

License:Open Source License

public MailServerPanel(final ApplicationContext context, TabbedPanel tabbedPanel) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;

    final GlobalSetting hostNameSetting = getGlobalSetting(MailSession.SETTING_HOST_NAME, "localhost");
    final GlobalSetting transportSetting = getGlobalSetting(MailSession.SETTING_TRANSPORT, "smtp");
    final GlobalSetting portSetting = getGlobalSetting(MailSession.SETTING_PORT_NUMBER, "25");
    final GlobalSetting fromSetting = getGlobalSetting(MailSession.SETTING_FROM, "metl@localhost");
    final GlobalSetting usernameSetting = getGlobalSetting(MailSession.SETTING_USERNAME, "");
    final GlobalSetting passwordSetting = getGlobalSetting(MailSession.SETTING_PASSWORD, "");
    final GlobalSetting useTlsSetting = getGlobalSetting(MailSession.SETTING_USE_TLS, "false");
    final GlobalSetting useAuthSetting = getGlobalSetting(MailSession.SETTING_USE_AUTH, "false");

    FormLayout form = new FormLayout();
    form.setSpacing(true);/* w  w  w . j ava2s .c o m*/

    ImmediateUpdateTextField hostField = new ImmediateUpdateTextField("Host name") {
        protected void save(String value) {
            saveSetting(hostNameSetting, value);
        }
    };
    hostField.setValue(hostNameSetting.getValue());
    hostField.setWidth(25f, Unit.EM);
    form.addComponent(hostField);
    hostField.focus();

    NativeSelect transportField = new NativeSelect("Transport");
    transportField.addItem("smtp");
    transportField.addItem("smtps");
    transportField.select(transportSetting.getValue() == null ? "smtp" : transportSetting.getValue());
    transportField.setNullSelectionAllowed(false);
    transportField.setImmediate(true);
    transportField.setWidth(10f, Unit.EM);
    transportField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            saveSetting(transportSetting, (String) event.getProperty().getValue());
        }
    });
    form.addComponent(transportField);

    ImmediateUpdateTextField portField = new ImmediateUpdateTextField("Port") {
        protected void save(String value) {
            saveSetting(portSetting, value);
        }
    };
    portField.setValue(portSetting.getValue());
    portField.setWidth(25f, Unit.EM);
    form.addComponent(portField);

    ImmediateUpdateTextField fromField = new ImmediateUpdateTextField("From Address") {
        protected void save(String value) {
            saveSetting(fromSetting, value);
        }
    };
    fromField.setValue(fromSetting.getValue());
    fromField.setWidth(25f, Unit.EM);
    form.addComponent(fromField);

    CheckBox tlsField = new CheckBox("Use TLS", Boolean.valueOf(useTlsSetting.getValue()));
    tlsField.setImmediate(true);
    tlsField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            saveSetting(useTlsSetting, ((Boolean) event.getProperty().getValue()).toString());
        }
    });
    form.addComponent(tlsField);

    final ImmediateUpdateTextField userField = new ImmediateUpdateTextField("Username") {
        protected void save(String value) {
            saveSetting(usernameSetting, value);
        }
    };
    userField.setValue(usernameSetting.getValue());
    userField.setWidth(25f, Unit.EM);

    final ImmediateUpdatePasswordField passwordField = new ImmediateUpdatePasswordField("Password") {
        protected void save(String value) {
            saveSetting(passwordSetting, value);
        }
    };
    passwordField.setValue(passwordSetting.getValue());
    passwordField.setWidth(25f, Unit.EM);

    CheckBox authField = new CheckBox("Use Authentication", Boolean.valueOf(useAuthSetting.getValue()));
    authField.setImmediate(true);
    authField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            Boolean isEnabled = (Boolean) event.getProperty().getValue();
            saveSetting(useAuthSetting, isEnabled.toString());
            userField.setEnabled(isEnabled);
            passwordField.setEnabled(isEnabled);
        }
    });
    form.addComponent(authField);
    userField.setEnabled(authField.getValue());
    form.addComponent(userField);
    passwordField.setEnabled(authField.getValue());
    form.addComponent(passwordField);

    Button testButton = new Button("Test Connection");
    testButton.addClickListener(new TestClickListener());
    form.addComponent(testButton);

    addComponent(form);
    setMargin(true);
}

From source file:org.jumpmind.metl.ui.views.admin.NotificationEditPanel.java

License:Open Source License

public NotificationEditPanel(final ApplicationContext context, final Notification notification) {
    this.context = context;
    this.notification = notification;

    sampleSubjectByEvent = new HashMap<String, String>();
    sampleSubjectByEvent.put(Notification.EventType.FLOW_START.toString(), "Flow $(_flowName) started");
    sampleSubjectByEvent.put(Notification.EventType.FLOW_END.toString(), "Flow $(_flowName) ended");
    sampleSubjectByEvent.put(Notification.EventType.FLOW_ERROR.toString(), "Flow $(_flowName) - ERROR");

    sampleMessageByEvent = new HashMap<String, String>();
    sampleMessageByEvent.put(Notification.EventType.FLOW_START.toString(),
            "Started flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)");
    sampleMessageByEvent.put(Notification.EventType.FLOW_END.toString(),
            "Ended flow $(_flowName) on agent $(_agent) at $(_time) on $(_date)");
    sampleMessageByEvent.put(Notification.EventType.FLOW_ERROR.toString(),
            "Error in flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)\n\n$(_errorText)");

    FormLayout form = new FormLayout();
    form.setSizeFull();// www  . j a  va 2  s. c  o m
    form.setSpacing(true);

    levelField = new NativeSelect("Level");
    for (Notification.Level level : Notification.Level.values()) {
        levelField.addItem(level.toString());
    }
    levelField.setNullSelectionAllowed(false);
    levelField.setImmediate(true);
    levelField.setWidth(15f, Unit.EM);
    levelField.addValueChangeListener(new LevelFieldListener());
    form.addComponent(levelField);

    linkField = new ComboBox("Linked To");
    linkField.setNullSelectionAllowed(false);
    linkField.setImmediate(true);
    linkField.setWidth(15f, Unit.EM);
    linkField.addValueChangeListener(new LinkFieldListener());
    form.addComponent(linkField);

    eventField = new NativeSelect("Event");
    eventField.setNullSelectionAllowed(false);
    eventField.setImmediate(true);
    eventField.setWidth(15f, Unit.EM);
    eventField.addValueChangeListener(new EventFieldListener());
    form.addComponent(eventField);

    nameField = new ImmediateUpdateTextField("Name") {
        protected void save(String value) {
            notification.setName(value);
            saveNotification();
        }
    };
    nameField.setValue(StringUtils.trimToEmpty(notification.getName()));
    nameField.setWidth(20f, Unit.EM);
    nameField.setDescription("Display name for the notification");
    form.addComponent(nameField);

    ImmediateUpdateTextArea recipientsField = new ImmediateUpdateTextArea("Recipients") {
        protected void save(String value) {
            notification.setRecipients(value);
            saveNotification();
        }
    };
    recipientsField.setValue(StringUtils.trimToEmpty(notification.getRecipients()));
    recipientsField.setColumns(20);
    recipientsField.setRows(10);
    recipientsField.setInputPrompt("address1@example.com\r\naddress2@example.com");
    recipientsField.setDescription("Email addresses of recipients, separated by commas.");
    form.addComponent(recipientsField);

    subjectField = new ImmediateUpdateTextField("Subject") {
        protected void save(String value) {
            notification.setSubject(value);
            saveNotification();
        }
    };
    subjectField.setValue(StringUtils.trimToEmpty(notification.getSubject()));
    subjectField.setWidth(40f, Unit.EM);
    subjectField.setDescription("The subject of the email can contain...");
    form.addComponent(subjectField);

    messageField = new ImmediateUpdateTextArea("Message") {
        protected void save(String value) {
            notification.setMessage(value);
            saveNotification();
        }
    };
    messageField.setValue(StringUtils.trimToEmpty(notification.getMessage()));
    messageField.setColumns(40);
    messageField.setRows(10);
    messageField.setDescription("The body of the email can contain...");
    form.addComponent(messageField);

    CheckBox enableField = new CheckBox("Enabled", notification.isEnabled());
    enableField.setImmediate(true);
    enableField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            notification.setEnabled((Boolean) event.getProperty().getValue());
            saveNotification();
        }
    });
    form.addComponent(enableField);

    if (notification.getLevel() == null) {
        isInit = true;
        levelField.setValue(Notification.Level.GLOBAL.toString());
        notification.setLevel(Notification.Level.GLOBAL.toString());
        notification.setNotifyType(Notification.NotifyType.MAIL.toString());
        updateLinks();
        updateEventTypes();
        updateName();
    } else {
        levelField.setValue(notification.getLevel());
        updateLinks();
        updateEventTypes();
        linkField.setValue(notification.getLinkId());
        eventField.setValue(notification.getEventType());
        isInit = true;
    }

    addComponent(form);
    setMargin(true);
    autoSave = true;
}

From source file:org.jumpmind.metl.ui.views.admin.UserEditPanel.java

License:Open Source License

public UserEditPanel(ApplicationContext context, User user) {
    this.context = context;
    this.user = user;

    FormLayout form = new FormLayout();
    form.setSpacing(true);/*from w w  w .  j  a  v  a 2s .  co m*/

    TextField loginField = new TextField("Login ID", StringUtils.trimToEmpty(user.getLoginId()));
    form.addComponent(loginField);
    loginField.addValueChangeListener(new LoginChangeListener());
    loginField.focus();

    TextField nameField = new TextField("Full Name", StringUtils.trimToEmpty(user.getName()));
    nameField.addValueChangeListener(new NameChangeListener());
    form.addComponent(nameField);

    PasswordField passwordField = new PasswordField("Password", NOCHANGE);
    passwordField.addValueChangeListener(new PasswordChangeListener());
    form.addComponent(passwordField);

    List<Group> groups = context.getConfigurationService().findGroups();
    groupsById = new HashMap<String, Group>();
    TwinColSelect groupSelect = new TwinColSelect();
    for (Group group : groups) {
        groupSelect.addItem(group.getId());
        groupSelect.setItemCaption(group.getId(), group.getName());
        groupsById.put(group.getId(), group);
    }
    lastGroups = new HashSet<String>();
    for (Group group : user.getGroups()) {
        lastGroups.add(group.getId());
    }
    groupSelect.setValue(lastGroups);
    groupSelect.setRows(20);
    groupSelect.setNullSelectionAllowed(true);
    groupSelect.setMultiSelect(true);
    groupSelect.setImmediate(true);
    groupSelect.setLeftColumnCaption("Available groups");
    groupSelect.setRightColumnCaption("Selected groups");
    groupSelect.addValueChangeListener(new GroupChangeListener());
    form.addComponent(groupSelect);

    addComponent(form);
    setMargin(true);
}