Example usage for com.vaadin.ui FormLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:nl.kpmg.lcm.ui.view.transfer.components.StartTransferWindow.java

License:Apache License

private void init(String remoteLcmUrl, String remoteMetadataId, String remoteMetadataName) {
    FormLayout commonContentPanel = initCommonContentPanel(remoteMetadataId, remoteMetadataName);
    tabsheet.addTab(commonContentPanel, "Common");

    FormLayout settingsContent = initSettingsPanel();
    tabsheet.addTab(settingsContent, "Settings");

    startButton.addClickListener(this);
    FormLayout mainPanel = new FormLayout();
    mainPanel.addComponent(tabsheet);

    createExpirationTimeWarning();//from ww  w .j  a v a 2s  .c o  m
    if (expirationTimeWarning != null) {
        mainPanel.addComponent(expirationTimeWarning);
    }

    mainPanel.addComponent(startButton);

    this.setWidth(DIALOG_WIDTH);
    this.setModal(true);

    this.setContent(mainPanel);
}

From source file:nl.kpmg.lcm.ui.view.transfer.components.StartTransferWindow.java

License:Apache License

private FormLayout initSettingsPanel() throws UnsupportedOperationException {
    FormLayout settingsContent = new FormLayout();
    overwriteComboBox = new ComboBox("Overwrite existing data");
    overwriteComboBox.addItem("true");
    overwriteComboBox.setItemCaption("true", "true");
    overwriteComboBox.addItem("false");
    overwriteComboBox.setItemCaption("false", "false");
    writeChunkSizeField = new TextField("Write chunck size");
    varcharSizeField = new TextField("Varchar size");
    decimalPrecisionField = new TextField("Decinal precision");
    initSettings();/*ww w.ja v  a  2s. com*/

    settingsContent.addComponent(overwriteComboBox);
    settingsContent.addComponent(writeChunkSizeField);
    settingsContent.addComponent(varcharSizeField);
    settingsContent.addComponent(decimalPrecisionField);
    settingsContent.setHeight(TAB_HEIGHT);
    settingsContent.setMargin(true);
    return settingsContent;
}

From source file:nl.kpmg.lcm.ui.view.transfer.components.StartTransferWindow.java

License:Apache License

private FormLayout initCommonContentPanel(String metadataId, String metadataName)
        throws UnsupportedOperationException {
    remoteLcmLabel = new Label();
    remoteLcmLabel.setCaption("Remote LCM");
    remoteLcmLabel.setValue(remoteLcmUrl);
    metadataIdLabel = new Label();
    metadataIdLabel.setCaption("Metadata Id");
    metadataIdLabel.setValue(metadataId);
    metadataNameLabel = new Label();
    metadataNameLabel.setCaption("Metadata Name");
    metadataNameLabel.setValue(metadataName);

    FormLayout commonContentPanel = new FormLayout();
    commonContentPanel.setMargin(true);//  w  w  w.ja  v  a 2 s .c  om
    storageListComboBox = initStorageListComboBox();
    metadataNameSpaceField = new TextField("Namespace path");
    commonContentPanel.addComponent(remoteLcmLabel);
    commonContentPanel.addComponent(metadataIdLabel);
    commonContentPanel.addComponent(metadataNameLabel);
    commonContentPanel.addComponent(storageListComboBox);
    commonContentPanel.addComponent(metadataNameSpaceField);
    commonContentPanel.addComponent(startButton);
    commonContentPanel.setMargin(true);
    commonContentPanel.setHeight(TAB_HEIGHT);
    return commonContentPanel;
}

From source file:org.apache.ace.useradmin.ui.vaadin.EditUserInfoWindow.java

License:Apache License

/**
 * Creates a new {@link EditUserInfoWindow} instance.
 *///from  ww  w.  j ava  2s  .  c  o m
public EditUserInfoWindow() {
    setCaption("My info");
    setWidth("20%");

    m_usernameTextField = new TextField();
    m_usernameTextField.setEnabled(false);
    m_usernameTextField.setCaption("Username");

    m_passwordTextField = new PasswordField();
    m_passwordTextField.setCaption("Password");
    m_passwordTextField.setImmediate(true);
    m_passwordTextField.addListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean changed = passwordChanged();
            m_applyButton.setEnabled(changed);
        }
    });

    m_groupField = new TextField();
    m_groupField.setEnabled(false);
    m_groupField.setCaption("Role");

    m_applyButton = new Button();
    m_applyButton.setCaption("Apply changes");
    m_applyButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            storeUserInfo();
        }
    });

    FormLayout formLayout = new FormLayout();
    formLayout.setMargin(false, false, false, true);
    formLayout.addComponent(m_usernameTextField);
    formLayout.addComponent(m_passwordTextField);
    formLayout.addComponent(m_groupField);
    formLayout.addComponent(m_applyButton);

    addComponent(formLayout);
}

From source file:org.apache.ace.useradmin.ui.vaadin.UserAdminWindow.java

License:Apache License

/**
 * Creates a new {@link UserAdminWindow} instance.
 *///from  w w w  . jav  a  2  s  .  c  om
public UserAdminWindow() {
    setCaption("Manage users");
    setWidth("30%");

    m_userTable = new Table();
    m_userTable.setSizeFull();
    m_userTable.setImmediate(true);
    m_userTable.setSelectable(true);
    m_userTable.setSortDisabled(false);
    m_userTable.addContainerProperty("User", UserDTO.class, null);
    m_userTable.addListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            selectUser((UserDTO) m_userTable.getValue());
        }
    });

    VerticalLayout usersList = new VerticalLayout();
    usersList.setSizeFull();
    usersList.addComponent(m_userTable);

    Button addUserButton = new Button("+");
    addUserButton.setStyleName(Reindeer.BUTTON_SMALL);
    addUserButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            prepareForNewUser();
        }
    });

    m_removeUserButton = new Button();
    m_removeUserButton.setStyleName(Reindeer.BUTTON_SMALL);
    m_removeUserButton.setCaption("-");
    m_removeUserButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            removeSelectedUser((UserDTO) m_userTable.getValue());
        }
    });

    HorizontalLayout addRemoveUserButtons = new HorizontalLayout();
    addRemoveUserButtons.setMargin(true, false, false, false);
    addRemoveUserButtons.setSpacing(true);
    addRemoveUserButtons.addComponent(addUserButton);
    addRemoveUserButtons.addComponent(m_removeUserButton);
    usersList.addComponent(addRemoveUserButtons);

    usersList.setExpandRatio(m_userTable, 1.0f);
    usersList.setExpandRatio(addRemoveUserButtons, 0.0f);

    ValueChangeListener changeListener = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            m_applyButton.setEnabled(isCurrentFormValid());
            m_cancelButton.setEnabled(true);
        }
    };

    m_usernameTextField = new TextField();
    m_usernameTextField.setCaption("Username");
    m_usernameTextField.setImmediate(true);
    m_usernameTextField.setRequired(true);
    m_usernameTextField.addListener(changeListener);

    m_passwordTextField = new PasswordField();
    m_passwordTextField.setCaption("Password");
    m_passwordTextField.setImmediate(true);
    m_passwordTextField.setRequired(true);
    m_passwordTextField.addListener(changeListener);

    m_groupSelect = new Select();
    m_groupSelect.setCaption("Role");
    m_groupSelect.setImmediate(true);
    m_groupSelect.setNullSelectionAllowed(false);
    m_groupSelect.setRequired(true);
    m_groupSelect.addListener(changeListener);

    FormLayout formLayout = new FormLayout();
    formLayout.addComponent(m_usernameTextField);
    formLayout.addComponent(m_passwordTextField);
    formLayout.addComponent(m_groupSelect);

    m_applyButton = new Button();
    m_applyButton.setCaption("Apply changes");
    m_applyButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            storeUserInfo();
        }
    });

    m_cancelButton = new Button();
    m_cancelButton.setEnabled(false);
    m_cancelButton.setCaption("Cancel");
    m_cancelButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            selectUser((UserDTO) m_userTable.getValue());
        }
    });

    HorizontalLayout addUserButtons = new HorizontalLayout();
    addUserButtons.setMargin(true, false, false, false);
    addUserButtons.setSpacing(true);
    addUserButtons.addComponent(m_applyButton);
    addUserButtons.addComponent(m_cancelButton);

    formLayout.addComponent(addUserButtons);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    horizontalLayout.setSpacing(true);
    horizontalLayout.addComponent(usersList);
    horizontalLayout.addComponent(formLayout);

    horizontalLayout.setExpandRatio(usersList, 0.35f);
    horizontalLayout.setExpandRatio(formLayout, 0.65f);

    addComponent(horizontalLayout);

    updateState(null, false /* editAllowed */);
}

From source file:org.apache.usergrid.chop.webapp.view.chart.layout.ChartLayout.java

License:Apache License

protected void addParamsItems() {

    testNameCombo = UIUtil.createCombo("Test Name:", null);
    testNameCombo.setWidth("155px");

    metricCombo = UIUtil.createCombo("Metric:", Metric.values());
    metricCombo.setWidth("155px");

    percentileCombo = UIUtil.createCombo("Percentile:",
            new String[] { "100", "90", "80", "70", "60", "50", "40", "30", "20", "10" });
    percentileCombo.setWidth("155px");

    failureCombo = UIUtil.createCombo("Points to Plot:", FailureType.values());
    failureCombo.setWidth("155px");

    Button submitButton = new Button("Submit");
    submitButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            loadChart();//from   w  ww .j  a va  2  s.c o  m
        }
    });

    FormLayout formLayout = addFormLayout();
    formLayout.addComponent(testNameCombo);
    formLayout.addComponent(metricCombo);
    formLayout.addComponent(percentileCombo);
    formLayout.addComponent(failureCombo);
    formLayout.addComponent(submitButton);
}

From source file:org.apache.usergrid.chop.webapp.view.user.UserLayout.java

License:Apache License

private void addItems() {

    FormLayout formLayout = addFormLayout(300, 350);
    formLayout.addComponent(formTitle);
    formLayout.addComponent(usernameField);
    formLayout.addComponent(passwordField);
    formLayout.addComponent(accessKeyField);
    formLayout.addComponent(imageField);
    formLayout.addComponent(instanceTypeField);
    formLayout.addComponent(secretKeyField);
    formLayout.addComponent(keyPairNameField);
    formLayout.addComponent(addButtonLayout());

    addComponent(keyListLayout, "left: 650px; top: 50px;");
}

From source file:org.apache.usergrid.chop.webapp.view.user.UserLayout.java

License:Apache License

private void addItems(boolean hasAuthority) {
    if (!hasAuthority) {
        FormLayout formLayout = addFormLayout(300, 150);
        formLayout.addComponent(formTitle);
        formLayout.addComponent(usernameField);
        formLayout.addComponent(passwordField);
        formLayout.addComponent(addButtonLayout());
    } else {/*from   w  ww. j a va 2s.c  o  m*/
        FormLayout formLayout = addFormLayout(300, 350);
        formLayout.addComponent(formTitle);
        formLayout.addComponent(usernameField);
        formLayout.addComponent(passwordField);
        formLayout.addComponent(accessKeyField);
        formLayout.addComponent(imageField);
        formLayout.addComponent(instanceTypeField);
        formLayout.addComponent(secretKeyField);
        formLayout.addComponent(keyPairNameField);
        formLayout.addComponent(addButtonLayout());
    }
    addComponent(keyListLayout, "left: 650px; top: 50px;");
}

From source file:org.azrul.langkuik.framework.customtype.attachment.AttachmentCustomTypeUICreator.java

@Override
public Component createUIForForm(final C currentBean, final Class<? extends CustomType> attachmentClass,
        final String pojoFieldName, final BeanView beanView, final DataAccessObject<C> conatainerClassDao,
        final DataAccessObject<? extends CustomType> customTypeDao,
        final RelationManagerFactory relationManagerFactory, final Configuration config,
        final ComponentState componentState, final Window window) {
    final FormLayout form = new FormLayout();

    final DataAccessObject<AttachmentCustomType> attachmentDao = ((DataAccessObject<AttachmentCustomType>) customTypeDao);
    final Collection<AttachmentCustomType> attachments = attachmentDao.find(currentBean, pojoFieldName, null,
            true, 0, Integer.parseInt(config.get("uploadCountLimit")));

    final WebEntityItemContainer attachmentIC = new WebEntityItemContainer(attachmentClass);
    if (!attachments.isEmpty()) {
        attachmentIC.addAll(attachments);
    }/*w  ww  . j a  v a2  s .c  om*/
    final ListSelect attachmentList = new ListSelect("", attachmentIC);
    createAtachmentList(attachmentList, attachments, config, beanView, form);

    final String relativePath = currentBean.getClass().getCanonicalName() + File.separator
            + conatainerClassDao.getIdentifierValue(currentBean);
    final String fullPath = config.get("attachmentRepository") + File.separator + relativePath;
    MyUploadHandler<C> uploadFinishHandler = new MyUploadHandler<>(currentBean,
            Integer.parseInt(config.get("uploadCountLimit").trim()), pojoFieldName, fullPath, relativePath,
            attachmentList, attachmentIC, customTypeDao, attachmentClass, relationManagerFactory);

    //File upload/download/delete buttons
    HorizontalLayout attachmentButtons = new HorizontalLayout();
    attachmentButtons.setSpacing(true);

    UploadStateWindow uploadStateWindow = new UploadStateWindow();
    MultiFileUpload fileUpload = new MultiFileUpload(uploadFinishHandler, uploadStateWindow);
    uploadFinishHandler.setFileUpload(fileUpload);

    fileUpload.getSmartUpload().setEnabled(true);
    fileUpload.getSmartUpload().setMaxFileSize(Integer.parseInt(config.get("uploadSizeLimit").trim()));
    fileUpload.getSmartUpload().setUploadButtonCaptions("Upload files", "Upload files");
    fileUpload.getSmartUpload().setId("Upload files");
    fileUpload.setId("Upload files2");

    Button deleteAttachmentBtn = new Button("Delete file", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList
                    .getValue();
            if (!attachments.isEmpty()) {
                customTypeDao.unlinkAndDelete(attachments, currentBean, pojoFieldName,
                        relationManagerFactory.create(currentBean.getClass(), attachmentClass));
                Collection<AttachmentCustomType> a = attachmentDao.find(currentBean, pojoFieldName, null, true,
                        0, Integer.parseInt(config.get("uploadCountLimit")));
                attachmentIC.removeAllItems();
                attachmentIC.addAll(a);
                attachmentIC.refreshItems();
            }
        }
    });
    deleteAttachmentBtn.setId(deleteAttachmentBtn.getCaption());

    Button downloadAttachmentBtn = new Button("Download file", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {

            Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList
                    .getValue();
            if (!attachments.isEmpty()) {
                AttachmentCustomType attachment = attachments.iterator().next();
                final String fullPath = config.get("attachmentRepository") + File.separator
                        + attachment.getRelativeLocation() + File.separator + attachment.getFileName();
                FileResource res = new FileResource(new File(fullPath));
                beanView.setViewResource("DOWNLOAD", res);
                ResourceReference rr = ResourceReference.create(res, beanView, "DOWNLOAD");
                Page.getCurrent().open(rr.getURL(), null);
            }
        }
    });
    downloadAttachmentBtn.setId(downloadAttachmentBtn.getCaption());

    Button closeWindowBtn = new Button("Close", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            window.close();
        }
    });
    closeWindowBtn.setId(closeWindowBtn.getCaption());

    if (componentState.equals(ComponentState.EDITABLE)) {
        attachmentButtons.addComponent(fileUpload);
        attachmentButtons.addComponent(deleteAttachmentBtn);
    }

    if (componentState.equals(ComponentState.EDITABLE) || componentState.equals(ComponentState.READ_ONLY)) {
        attachmentButtons.addComponent(downloadAttachmentBtn);
    }

    attachmentButtons.addComponent(closeWindowBtn);

    form.addComponent(attachmentButtons);
    form.setMargin(true);
    //beanView.addComponent(form);
    return form;
}

From source file:org.azrul.langkuik.framework.customtype.attachment.AttachmentCustomTypeUICreator.java

private void createAtachmentList(final ListSelect attachmentList,
        final Collection<? extends CustomType> attachments, final Configuration config, final BeanView view,
        final FormLayout form) {

    attachmentList.setHeight(attachments.size() + 2, Sizeable.Unit.EM);
    attachmentList.setMultiSelect(true);
    VerticalLayout attachmentListCont = new VerticalLayout();
    attachmentListCont.setCaption("Attachments");
    attachmentListCont.addComponent(attachmentList);
    attachmentListCont.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override/* ww w  .  j  a v a 2  s .  c o  m*/
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (event.getClickedComponent() == null) {
                return;
            }
            if (event.getClickedComponent().equals(attachmentList)) {
                Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList
                        .getValue();
                if (!attachments.isEmpty()) {
                    AttachmentCustomType attachment = attachments.iterator().next();
                    final String fullPath = config.get("attachmentRepository") + File.separator
                            + attachment.getRelativeLocation() + File.separator + attachment.getFileName();
                    FileResource res = new FileResource(new File(fullPath));
                    view.setViewResource("DOWNLOAD", res);
                    ResourceReference rr = ResourceReference.create(res, view, "DOWNLOAD");

                    Page.getCurrent().open(rr.getURL(), null);
                }
            }
        }
    });
    form.addComponent(attachmentListCont);
}