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:com.liferay.mail.vaadin.Composer.java

License:Open Source License

private FormLayout buildRecipientsLayout() {

    // common part: create layout
    recipientsLayout = new FormLayout();
    recipientsLayout.setSpacing(true);/*from   ww  w .jav a2 s  .co  m*/

    toField = new TextField();
    toField.setImmediate(false);
    toField.setHeight("-1px");
    toField.setWidth("100.0%");
    toField.setCaption(Lang.get("to"));
    recipientsLayout.addComponent(toField);

    ccField = new TextField();
    ccField.setImmediate(false);
    ccField.setHeight("-1px");
    ccField.setWidth("100.0%");
    ccField.setCaption(Lang.get("cc"));
    recipientsLayout.addComponent(ccField);

    bccField = new TextField();
    bccField.setImmediate(false);
    bccField.setHeight("-1px");
    bccField.setWidth("100.0%");
    bccField.setCaption(Lang.get("bcc"));
    recipientsLayout.addComponent(bccField);

    return recipientsLayout;
}

From source file:com.liferay.mail.vaadin.MessageView.java

License:Open Source License

public MessageView() {

    setMargin(false, true, true, true);//from w  w w .j a  va2 s .  c  o m

    messageLabel = new Label("", Label.CONTENT_XHTML);
    messageLabel.setSizeFull();

    headersLayout = new FormLayout();

    headersAndAttachmentLayout.setStyleName("message-header");
    headersAndAttachmentLayout.addComponent(headersLayout);
    headersAndAttachmentLayout.setVisible(false);

    addComponent(headersAndAttachmentLayout);
    addComponent(new Label("<hr />", Label.CONTENT_XHTML));
    addComponent(messageLabel);

    setExpandRatio(messageLabel, 1);
}

From source file:com.liferay.mail.vaadin.MessageView.java

License:Open Source License

public void showMessage(Message msg) {

    if (msg == null) {
        messageLabel.setVisible(false);/*from ww  w .  j a v a2  s . com*/
        headersAndAttachmentLayout.setVisible(false);
        return;
    } else {
        messageLabel.setVisible(true);
        headersAndAttachmentLayout.setVisible(true);
    }
    // Body
    String text = "";
    if (msg != null) {
        text = msg.getBody();
    }
    messageLabel.setValue(text);

    // Headers
    headersLayout = new FormLayout();
    headersLayout.setSpacing(false);
    headersLayout.setMargin(false);
    if (msg != null) {
        String to = msg.getTo();
        String cc = msg.getCc();
        // String replyTo = msg.get();

        Label subject = new Label(msg.getSubject());
        subject.setCaption(Lang.get("subject"));
        headersLayout.addComponent(subject);

        Label from = new Label(msg.getSender());
        from.setCaption(Lang.get("from"));
        headersLayout.addComponent(from);

        if (to != null && !to.equals("")) {
            Label toLabel = new Label(to);
            toLabel.setCaption(Lang.get("to"));
            headersLayout.addComponent(toLabel);
        }
        if (cc != null && !cc.equals("")) {
            Label ccLabel = new Label(cc);
            ccLabel.setCaption(Lang.get("cc"));
            headersLayout.addComponent(ccLabel);
        }

        Label date = new Label(formatDate(msg.getSentDate()));
        date.setCaption(Lang.get("date"));
        headersLayout.addComponent(date);

        if (MessageUtil.isImportant(msg)) {
            Label flag = new Label(Lang.get("important"));
            flag.setStyleName(MessageList.STYLE_IMPORTANT);
            flag.setCaption(Lang.get("flag"));
            headersLayout.addComponent(flag);

        }
    }

    // Attachments
    try {
        headersAndAttachmentLayout.removeAllComponents();
        headersAndAttachmentLayout.addComponent(headersLayout);

        Controller controller = Controller.get();
        List<Attachment> attachments = AttachmentLocalServiceUtil.getAttachments(msg.getMessageId());
        if (attachments != null && !attachments.isEmpty()) {
            for (Attachment attachment : attachments) {
                Button attachmentDownload = new Button();
                attachmentDownload.setStyleName(BaseTheme.BUTTON_LINK);

                attachmentDownload.setCaption(attachment.getFileName() + " "
                        + MessageUtil.formatSize(attachment.getSize(), controller.getUserLocale()));
                attachmentDownload.setData(attachment);
                attachmentDownload.addListener(this);

                headersAndAttachmentLayout.addComponent(attachmentDownload);
            }
        }
    } catch (SystemException e) {
        _log.debug(e);
    }
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.LoginWidget.java

public LoginWidget() {
    setMargin(true);//w  w  w.ja  v a2  s  . com
    setSpacing(true);

    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setSizeUndefined();

    addComponent(iPanel);

    TextField iTextField = new TextField("Username");
    iTextField.setWidth("300px");
    iTextField.setRequired(true);
    iTextField.setInputPrompt("Your username (eg. joe@email.com)");
    iTextField.setIcon(FontAwesome.USER);
    iTextField.addValidator(new EmailValidator("Username must be an email address"));
    iTextField.setInvalidAllowed(true);
    iTextField.focus();

    PasswordField iPasswordField = new PasswordField("Password");
    iPasswordField.setIcon(FontAwesome.KEY);
    iPasswordField.setWidth("300px");
    iPasswordField.setRequired(true);
    iPasswordField.setValue("");
    iPasswordField.setNullRepresentation("");

    Button iButton = new Button("Login");
    iButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addComponent(new Label("Login Successfully"));
        }
    });

    FormLayout iFormLayout = new FormLayout();
    iFormLayout.setSpacing(true);
    iFormLayout.setMargin(true);
    iFormLayout.addComponent(iTextField);
    iFormLayout.addComponent(iPasswordField);
    iFormLayout.addComponent(iButton);
    iPanel.setContent(iFormLayout);

}

From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java

License:Open Source License

private VerticalLayout createUserDataSection(LspsUI ui, Person user) {
    VerticalLayout userData = new VerticalLayout();

    Label userDataHeader = new Label("<h2>" + ui.getMessage("settings.userSection") + "</h2>",
            ContentMode.HTML);/*from  www .  ja va  2  s . c  o m*/
    userData.addComponent(userDataHeader);

    FormLayout userDataContent = new FormLayout();

    if ((userRights.contains(OsRights.CHANGE_OWN_PASSWORD)) || (userRights.contains(OsRights.MANAGE_PERSON))) {
        this.passwordField = new PasswordField(ui.getMessage("settings.password"));
        passwordField.setWidth("100%");
        userDataContent.addComponent(passwordField);

        this.confirmation = new PasswordField(ui.getMessage("settings.passwordVerification"));
        confirmation.setWidth("100%");
        userDataContent.addComponent(confirmation);
    }

    this.email = new TextField(ui.getMessage("settings.email"));
    email.setWidth("100%");
    email.setValue(user.getEmail());
    email.setNullRepresentation("");
    userDataContent.addComponent(email);

    this.telephone = new TextField(ui.getMessage("settings.phoneNumber"));
    telephone.setWidth("100%");
    telephone.setValue(user.getPhone());
    telephone.setNullRepresentation("");
    userDataContent.addComponent(telephone);

    userData.addComponent(userDataContent);
    return userData;
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * @param audioFile/* www  . ja  va 2  s . co m*/
 * @return
 */
private CssLayout addDetails(AudioFile audioFile) {
    CssLayout details = new CssLayout();
    details.setWidth("100%");

    Label title = new Label("<h3>" + audioFile.getArtist() + "&ndash;" + audioFile.getTitle() + "</h3>",
            ContentMode.HTML);
    details.addComponent(title);
    title.setSizeUndefined();

    TabSheet tabs = new TabSheet();
    tabs.addStyleName(Runo.TABSHEET_SMALL);
    tabs.setWidth("100%");
    tabs.setHeight("180px");
    details.addComponent(tabs);

    FormLayout formLayout = new FormLayout();
    tabs.addTab(formLayout, "Info");

    Label text = new Label(audioFile.getTitle());
    text.setCaption("Title:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getArtist());
    text.setCaption("Artist:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getAlbum());
    text.setCaption("Album:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getGenre());
    text.setCaption("Genre:");
    formLayout.addComponent(text);

    text = new Label(audioFile.getPrice() + "$");
    text.setCaption("Price");
    formLayout.addComponent(text);

    formLayout = new FormLayout();
    tabs.addTab(formLayout, "Decription");
    text = new Label(audioFile.getAbout());
    formLayout.addComponent(text);

    formLayout = new FormLayout();
    tabs.addTab(formLayout, "Lyrics");
    text = new Label(audioFile.getLyrics());
    formLayout.addComponent(text);

    return details;
}

From source file:com.mcparland.john.vaadin_cookbook.CRUD.java

License:Apache License

/**
 * Create the form for the given item.//from   ww  w .j a v a 2 s.c  o  m
 * 
 * @param item
 *            the item.
 * @return a layout for the form.
 */
@SuppressWarnings("serial")
private Layout createForm(Item item) {
    FormLayout layout = new FormLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    final FieldGroup group = new FieldGroup(item);
    for (Object propertyId : group.getUnboundPropertyIds()) {
        layout.addComponent(group.buildAndBind(propertyId));
    }
    Button button = new Button("Commmit");
    button.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                group.commit();
            } catch (CommitException e) {
                Notification.show(e.getCause().getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    layout.addComponent(button);
    return layout;
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java

License:Apache License

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();/* w ww  . j a  v a  2  s . c  om*/
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField("Username", "admin"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField("Password"));
    password.setWidth(15, Unit.EM);
    password.setDescription("Write anything");
    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);

    buttons.addComponent(login = new Button("Login"));
    login.setDisableOnClick(true);
    login.addClickListener(new Button.ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                login();
            } finally {
                login.setEnabled(true);
            }
        }
    });
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    buttons.addComponent(forgotPassword = new Button("Forgot password?"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            showNotification(new Notification("Hint: Try anything"));
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    return loginForm;
}

From source file:com.mechanicshop.components.DataEntryLayout.java

private void buildLayout() {
    FormLayout formLayout1 = new FormLayout();

    formLayout1.setMargin(new MarginInfo(false, false, false, true));
    formLayout1.setSpacing(true);/*from  w  w  w  .j  a v  a 2 s  . c  o m*/

    FormLayout formLayout2 = new FormLayout();
    formLayout2.setMargin(new MarginInfo(false, false, false, true));
    formLayout2.setSpacing(true);

    FormLayout formLayout3 = new FormLayout();
    formLayout3.setMargin(new MarginInfo(false, true, false, true));
    formLayout3.setSpacing(true);

    tfTag.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfTag.setWidth("180px");
    tfTag.setMaxLength(3);
    tfTag.setNullRepresentation("");
    tfPhone.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPhone.setWidth("180px");
    tfPhone.setNullRepresentation("");
    tfPhone.setMaxLength(11);
    tfName.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfName.setWidth("180px");
    tfName.setMaxLength(50);
    tfName.setNullRepresentation("");
    tfVehicle.setWidth("180px");
    tfVehicle.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfVehicle.setMaxLength(75);
    tfVehicle.setNullRepresentation("");
    tfLicensePlate.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfLicensePlate.setWidth("180px");
    tfLicensePlate.setMaxLength(10);
    tfLicensePlate.setNullRepresentation("");
    tfVin.setWidth("180px");
    tfVin.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfVin.setMaxLength(17);
    tfVin.setNullRepresentation("");
    dfInShop.setImmediate(true);
    dfInShop.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfInShop.setInputPrompt("Select");
    dfInShop.setWidth("120px");

    dfOutShop.setImmediate(true);
    dfOutShop.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfOutShop.setInputPrompt("Select");
    dfOutShop.setWidth("120px");

    nsStatus.addItems("In", "Out", "Pending", "Ready", "Comeback");
    nsStatus.setImmediate(true);
    nsStatus.setWidth("120px");
    nsStatus.setStyleName(ValoTheme.COMBOBOX_TINY);
    nsStatus.setValue("In");
    tfMileage.setWidth("120px");
    tfMileage.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfMileage.setMaxLength(6);
    tfMileage.setNullRepresentation("");
    tfPicked.setWidth("120px");
    tfPicked.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPicked.setMaxLength(3);
    tfPicked.setNullRepresentation("");
    tfPayment.setWidth("180px");
    tfPayment.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPayment.setMaxLength(50);
    tfPayment.setNullRepresentation("");
    taRemarks.setWidth("500px");
    taRemarks.setStyleName(ValoTheme.TEXTFIELD_TINY);
    taRemarks.setMaxLength(500);
    taRemarks.setNullRepresentation("");
    tfRebuilder.setWidth("180px");
    tfRebuilder.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfRebuilder.setMaxLength(20);
    tfRebuilder.setNullRepresentation("");
    tfInstaller.setWidth("180px");
    tfInstaller.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfInstaller.setMaxLength(20);
    tfInstaller.setNullRepresentation("");
    tfFirstCheckBy.setWidth("500px");
    tfFirstCheckBy.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfFirstCheckBy.setMaxLength(100);
    tfFirstCheckBy.setNullRepresentation("");
    tfSecondCheckBy.setWidth("500px");
    tfSecondCheckBy.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfSecondCheckBy.setMaxLength(100);
    tfSecondCheckBy.setNullRepresentation("");
    dfFirstCheckDate.setImmediate(true);
    dfFirstCheckDate.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfFirstCheckDate.setInputPrompt("Select");
    dfFirstCheckDate.setWidth("120px");

    dfSecondCheckDate.setImmediate(true);
    dfSecondCheckDate.addStyleName(ValoTheme.DATEFIELD_TINY);
    dfSecondCheckDate.setInputPrompt("Select");
    dfSecondCheckDate.setWidth("120px");

    taMedia.setWidth("500px");
    taMedia.setStyleName(ValoTheme.TEXTFIELD_TINY);
    taMedia.setNullRepresentation("");
    taMedia2.setWidth("500px");
    taMedia2.setStyleName(ValoTheme.TEXTFIELD_TINY);
    taMedia2.setNullRepresentation("");
    tfReferedBy.setWidth("180px");
    tfReferedBy.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfReferedBy.setMaxLength(20);
    tfReferedBy.setNullRepresentation("");
    tfWarrantyLimit.setWidth("180px");
    tfWarrantyLimit.setStyleName(ValoTheme.TEXTFIELD_TINY);
    tfWarrantyLimit.setMaxLength(5);
    tfWarrantyLimit.setNullRepresentation("");
    nsWarranty.setWidth("120px");
    nsWarranty.setStyleName(ValoTheme.TEXTFIELD_TINY);
    nsWarranty.addItems("YES", "NO");
    nsWarranty.setValue("NO");
    nsWarranty.setStyleName(ValoTheme.COMBOBOX_TINY);

    nsSMS.setWidth("120px");
    nsSMS.setStyleName(ValoTheme.TEXTFIELD_TINY);
    nsSMS.addItems("YES", "NO");
    nsSMS.setValue("NO");
    nsComeback.setWidth("120px");
    nsComeback.setStyleName(ValoTheme.TEXTFIELD_TINY);
    nsComeback.addItems("YES", "NO");
    nsComeback.setValue("NO");
    nsComeback.setStyleName(ValoTheme.COMBOBOX_TINY);

    formLayout1.addComponents(tfTag, tfPhone, tfName, tfVehicle, tfPayment, tfRebuilder, tfInstaller,
            tfLicensePlate, tfVin, tfReferedBy, tfWarrantyLimit);

    formLayout2.addComponents(nsWarranty, dfInShop, dfOutShop, nsStatus, nsSMS, nsComeback, tfMileage, tfPicked,
            dfFirstCheckDate, dfSecondCheckDate);

    formLayout3.addComponents(tfFirstCheckBy, tfSecondCheckBy, taRemarks, taMedia, taMedia2);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(new MarginInfo(false, true, false, true));

    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            Integer tag = null;
            Integer mileage = null;
            if (tfTag.getValue() != null)
                if (!tfTag.getValue().isEmpty()) {
                    tag = (Integer.parseInt(tfTag.getValue()));
                } else
                    tag = null;

            if (tfMileage.getValue() != null)
                if (!tfMileage.getValue().isEmpty()) {
                    mileage = (Integer.parseInt(tfMileage.getValue()));
                } else
                    mileage = null;

            Object[] args = new Object[] { tag, tfPhone.getValue(), tfName.getValue(), tfVehicle.getValue(),
                    tfLicensePlate.getValue(), tfVin.getValue(), dfInShop.getValue(), dfOutShop.getValue(),
                    nsStatus.getValue(), mileage, tfPicked.getValue(), tfPayment.getValue(),
                    taRemarks.getValue(), tfRebuilder.getValue(), tfInstaller.getValue(),
                    tfFirstCheckBy.getValue(), tfSecondCheckBy.getValue(), dfFirstCheckDate.getValue(),
                    dfSecondCheckDate.getValue(), taMedia.getValue(), taMedia2.getValue(),
                    tfReferedBy.getValue(), tfWarrantyLimit.getValue(), nsWarranty.getValue(), nsSMS.getValue(),
                    nsComeback.getValue() };

            if (sendBtn.getCaption().equals("Add")) {
                try {
                    String status = nsStatus.getValue().toString();
                    searchService.insertCar(args, status);
                    Notification.show("Entry inserted succesfully");
                    close();
                } catch (Exception e) {
                    e.printStackTrace();
                    Notification.show("An error has occurred", Notification.Type.ERROR_MESSAGE);
                }
            } else {
                try {
                    searchService.editCar(args, tableName, no);
                    Notification.show("Entry edited succesfully");
                    close();
                } catch (Exception e) {
                    e.printStackTrace();
                    Notification.show("An error has occurred", Notification.Type.ERROR_MESSAGE);
                }

            }
        }

    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(sendBtn);

    hLayoutForms.addComponents(formLayout1, formLayout2, formLayout3);

    mainLayout.addComponent(hLayoutForms);
    mainLayout.addComponent(layoutButtons);
    mainLayout.setComponentAlignment(hLayoutForms, Alignment.MIDDLE_CENTER);
    mainLayout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_LEFT);
    mainLayout.setExpandRatio(hLayoutForms, 3);

}

From source file:com.morevaadin.eventbus.ui.AggregateView.java

License:Apache License

public AggregateView() {

    EventBus bus = new EventBus();

    FormLayout layout = new FormLayout();

    FirstComponent first = new FirstComponent(bus);

    SecondComponent second = new SecondComponent();

    bus.register(second);/*from   w ww .ja  v  a 2 s .  c om*/

    layout.addComponent(first);
    layout.addComponent(second);

    setCompositionRoot(layout);
}