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:info.magnolia.about.app.AboutViewImpl.java

License:Open Source License

private Component createInstallationSection() {

    // build and bind fields
    Component mgnlEdition = buildAndBind(AboutView.MAGNOLIA_EDITION_KEY,
            i18n.translate("about.app.main.mgnledition"));
    Component mgnlVersion = buildAndBind(AboutView.MAGNOLIA_VERSION_KEY,
            i18n.translate("about.app.main.mgnlversion"));
    Component mgnlInstance = buildAndBind(AboutView.MAGNOLIA_INSTANCE_KEY,
            i18n.translate("about.app.main.instance"));

    Component osInfo = buildAndBind(AboutView.OS_INFO_KEY, i18n.translate("about.app.main.os"));
    Component javaInfo = buildAndBind(AboutView.JAVA_INFO_KEY, i18n.translate("about.app.main.java"));
    Component serverInfo = buildAndBind(AboutView.SERVER_INFO_KEY, i18n.translate("about.app.main.server"));
    Component dbInfo = buildAndBind(AboutView.DB_INFO_KEY, i18n.translate("about.app.main.dbinfo"));
    Component dbDriverInfo = buildAndBind(AboutView.DB_DRIVER_INFO_KEY,
            i18n.translate("about.app.main.dbdriverinfo"));
    Component jcrInfo = buildAndBind(AboutView.JCR_INFO_KEY, i18n.translate("about.app.main.repository"));

    // layout/*from  w  w  w  . ja  v  a 2s  .  c  o  m*/
    FormLayout layout = new FormLayout();

    Label sectionTitle = new Label(i18n.translate("about.app.main.installation.title"));
    sectionTitle.addStyleName("section-title");
    layout.addComponent(sectionTitle);

    layout.addComponent(createFieldsetTitle(i18n.translate("about.app.main.magnolia.title")));
    layout.addComponent(mgnlEdition);
    layout.addComponent(mgnlVersion);
    layout.addComponent(mgnlInstance);

    Component environmentTitle = createFieldsetTitle(i18n.translate("about.app.main.environment.title"));
    environmentTitle.addStyleName("spacer");
    layout.addComponent(environmentTitle);
    layout.addComponent(osInfo);
    layout.addComponent(javaInfo);
    layout.addComponent(serverInfo);
    layout.addComponent(dbInfo);
    layout.addComponent(dbDriverInfo);
    layout.addComponent(jcrInfo);

    return layout;
}

From source file:info.magnolia.messages.app.MessagesViewImpl.java

License:Open Source License

@Inject
public MessagesViewImpl(SimpleTranslator i18n) {

    this.i18n = i18n;

    // create form and data item
    final Message message = new Message(); // message POJO
    BeanItem<Message> messageItem = new BeanItem<Message>(message);

    final FieldGroup form = new FieldGroup();
    form.setItemDataSource(messageItem);

    Field<String> subjectField = createSubjectTextField();
    Field<String> messageBodyField = createMessageBodyTextField();
    Field<?> typeField = createTypeSelectionField();
    Field<?> scopeField = createScopeSelectionField();
    userOrGroupIdField = createUserOrGroupIdTextField();

    // disable user/group field if not necessary
    scopeField.addValueChangeListener(new ValueChangeListener() {

        @Override/*from w ww.j ava  2  s  . c o  m*/
        public void valueChange(ValueChangeEvent event) {
            updateUserOrGroupField((String) event.getProperty().getValue());
        }
    });

    form.bind(subjectField, "title");
    form.bind(messageBodyField, "content");
    form.bind(typeField, "type");
    form.bind(scopeField, "scope");
    form.bind(userOrGroupIdField, "user");
    // FieldGroup overrides fields' own enabled property with its own.
    updateUserOrGroupField(message.getScope());

    FormLayout layout = new FormLayout();
    layout.addComponent(subjectField);
    layout.addComponent(messageBodyField);
    layout.addComponent(typeField);
    layout.addComponent(scopeField);
    layout.addComponent(userOrGroupIdField);

    layout.setSpacing(true);
    layout.setMargin(false);
    layout.setWidth("100%");

    // send button
    NativeButton sendButton = new NativeButton(i18n.translate("messages-app.app.button.sendMessage"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    try {
                        form.commit();
                        String subject = message.getTitle();
                        String content = message.getContent();
                        MessageType type = message.getType();
                        String scope = message.getScope();

                        if (MESSAGE_SCOPE_LOCAL.equals(scope)) {
                            listener.handleLocalMessage(type, subject, content);
                        } else if (MESSAGE_SCOPE_GLOBAL.equals(scope)) {
                            listener.handleGlobalMessage(type, subject, content);
                        } else if (MESSAGE_SCOPE_GROUP.equals(scope)) {
                            // message is bound to FieldGroup - hence the group name is to be retrieved from the user field of the message
                            final String groupName = message.getUser();
                            listener.handleGroupMessage(groupName, type, subject, content);
                        } else {
                            // User...
                            final String userName = message.getUser();
                            listener.handleUserMessage(userName, type, subject, content);
                        }
                    } catch (CommitException e) {

                    }
                }
            });
    sendButton.addStyleName("btn-dialog");
    sendButton.addStyleName("commit");

    // reset button
    NativeButton resetButton = new NativeButton(i18n.translate("messages-app.app.button.reset"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    message.reset();
                    form.discard();
                }
            });
    resetButton.addStyleName("btn-dialog");
    resetButton.addStyleName("cancel");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.addStyleName("buttons");
    buttons.setSpacing(true);
    buttons.addComponent(sendButton);
    buttons.addComponent(resetButton);
    layout.addComponent(buttons);

    // intro text
    Label intro = new Label(i18n.translate("messages-app.app.label.intro"), ContentMode.HTML);
    intro.addStyleName("intro");

    CssLayout container = new CssLayout();
    container.setSizeFull();
    container.addStyleName("small-app-panel");
    container.addComponent(layout);

    CssLayout root = new CssLayout();
    root.setSizeFull();
    root.setWidth("900px");
    root.setStyleName("small-app");
    root.addComponent(intro);
    root.addComponent(container);

    component = root;
}

From source file:info.magnolia.photoreview.app.config.PhotoReviewConfigViewImpl.java

License:Open Source License

private Component createFormLayout() {

    formLayout = new FormLayout();

    Label sectionTitle = new Label(i18n.translate("photoreview.config.title"));
    sectionTitle.addStyleName("section-title");
    formLayout.addComponent(sectionTitle);

    Button saveButton = new Button(i18n.translate("photoreview.main.saveSettings.label"));
    saveButton.addStyleName("commit");
    saveButton.addClickListener(new ClickListener() {

        @Override// www .  j a  v  a  2 s . c  om
        public void buttonClick(ClickEvent event) {
            listener.saveSettings(dataSource);
        }
    });
    formLayout.addComponent(saveButton);

    return formLayout;
}

From source file:info.magnolia.ui.form.field.component.AbstractBaseItemContentPreviewComponent.java

License:Open Source License

@Override
public Component refreshContentDetail(Item item) {
    FormLayout fileInfo = new FormLayout();
    fileInfo.setSizeUndefined();//from w ww  . j  ava2  s.  co m
    fileInfo.addStyleName("file-details");
    try {
        List<Component> res = createFieldDetail(item);
        fileInfo.addComponents(res.toArray(new Component[res.size()]));
    } catch (RepositoryException e) {
        log.warn("Could not get the related File node", e);
    }
    return fileInfo;
}

From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java

License:Open Source License

/**
 * Initialize a Component displaying some File Informations.
 * Override getFileDetail...() in order to display custom info's you may want to display.
 *
 * @return A file Info Component. Generally a {@link FormLayout}.
 *///from   ww  w. j  av a  2s  . c om
private Component createFileInfoComponent() {
    FormLayout fileInfo = new FormLayout();
    fileInfo.setSizeUndefined();
    fileInfo.addStyleName("file-details");
    fileInfo.addComponent(getFileDetailHeader());
    fileInfo.addComponent(getFileDetailFileName());
    fileInfo.addComponent(getFileDetailSize());
    fileInfo.addComponent(getFileDetailFileFormat());
    return fileInfo;
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * are el dilogo para autenticarse/*from w  w  w. j a v a2s .co m*/
 */
private void openLoginDialog(boolean gohome) {

    // Create a sub-window and set the content
    Window subWindow = new Window("Login");

    subWindow.setWidth("375px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    TextField l;
    f.addComponent(l = new TextField("Username"));
    PasswordField p;
    f.addComponent(p = new PasswordField("Password"));
    Label e;
    f.addComponent(e = new Label());

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

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

    Button forgot = new Button("Forgot password", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Asking for email...");
            io.mateu.ui.core.client.app.MateuUI.getBaseService().forgotPassword(l.getValue(),
                    new AsyncCallback<Void>() {

                        @Override
                        public void onFailure(Throwable caught) {
                            e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            e.setValue("Email sent. Please check your inbox");
                        }
                    });
        }
    });
    //forgot.addStyleName(ValoTheme.BUTTON_);

    Button ok = new Button("Login", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Authenticating...");
            io.mateu.ui.core.client.app.MateuUI.getBaseService().authenticate(l.getValue(), p.getValue(),
                    new AsyncCallback<UserData>() {

                        @Override
                        public void onFailure(Throwable caught) {
                            e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(UserData result) {
                            e.setValue("OK!");
                            getApp().setUserData(result);
                            VaadinSession.getCurrent().setAttribute("usuario", "admin");
                            subWindow.close();

                            if (MateuUI.getApp().isFavouritesAvailable())
                                linkFavoritos.setVisible(true);
                            if (MateuUI.getApp().isLastEditedAvailable())
                                linkUltimosRegistros.setVisible(true);
                            if (MateuUI.getApp().isFavouritesAvailable())
                                linkNuevoFavorito.setVisible(true);

                            refreshSettings();
                            refreshMenu(null, null);
                            System.out.println("STATE:" + navigator.getState());
                            System.out.println("URIFRAGMENT:" + Page.getCurrent().getUriFragment());
                            navigator.navigateTo((gohome) ? "" : navigator.getState());
                        }
                    });
        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

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

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    l.focus();
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre el dilogo para cambiar el password
 *
 */// ww  w  . j a v  a  2s .com
private void changePassword() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Change password");

    subWindow.setWidth("375px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    PasswordField l;
    f.addComponent(l = new PasswordField("Current password"));
    PasswordField p;
    f.addComponent(p = new PasswordField("New password"));
    PasswordField p2;
    f.addComponent(p2 = new PasswordField("Repeat password"));
    Label e;
    f.addComponent(e = new Label());

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

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

    Button ok = new Button("Change it!", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            if (l.getValue() == null || "".equals(l.getValue().trim()))
                e.setValue("Old password is required");
            else if (p.getValue() == null || "".equals(p.getValue().trim()))
                e.setValue("New password is required");
            else if (p2.getValue() == null || "".equals(p2.getValue().trim()))
                e.setValue("New password repeated is required");
            else if (!p.getValue().equals(p2.getValue()))
                e.setValue("New password and new password repeated must be equal");
            else {
                e.setValue("Changing password...");

                io.mateu.ui.core.client.app.MateuUI.getBaseService().changePassword(
                        getApp().getUserData().getLogin(), l.getValue(), p.getValue(),
                        new AsyncCallback<Void>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                            }

                            @Override
                            public void onSuccess(Void result) {
                                e.setValue("OK!");
                                subWindow.close();
                            }
                        });

            }
        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

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

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    l.focus();
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre el dilogo para editar el perfil//from w  w  w.ja v  a2s .  c o m
 *
 */
private void editProfile() {
    // Create a sub-window and set the content
    Window subWindow = new Window("My profile");

    subWindow.setWidth("375px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    TextField l;
    f.addComponent(l = new TextField("Name"));
    l.setValue(getApp().getUserData().getName());
    TextField p;
    f.addComponent(p = new TextField("Email"));
    p.setValue(getApp().getUserData().getEmail());
    Label e;
    f.addComponent(e = new Label());

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

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

    Button ok = new Button("Update it!", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Authenticating...");
            io.mateu.ui.core.client.app.MateuUI.getBaseService().updateProfile(
                    getApp().getUserData().getLogin(), l.getValue(), p.getValue(), null,
                    new AsyncCallback<Void>() {

                        @Override
                        public void onFailure(Throwable caught) {
                            e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            e.setValue("OK!");
                            getApp().getUserData().setName(l.getValue());
                            getApp().getUserData().setEmail(p.getValue());
                            subWindow.close();
                            refreshSettings();
                        }
                    });
        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

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

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    l.focus();
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre el dilogo para cambiar la foto//from  ww w.j av  a  2s . c o  m
 *
 *
 */
private void uploadFoto() {
    // Create a sub-window and set the content
    Window subWindow = new Window("My photo");

    subWindow.setWidth("475px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    Label e = new Label();

    Image image = new Image();

    class MyUploader implements Upload.Receiver, Upload.SucceededListener {

        File file;

        public File getFile() {
            return file;
        }

        public OutputStream receiveUpload(String fileName, String mimeType) {
            // Create and return a file output stream

            System.out.println("receiveUpload(" + fileName + "," + mimeType + ")");

            FileOutputStream os = null;
            if (fileName != null && !"".equals(fileName)) {

                long id = fileId++;
                String extension = ".tmp";
                if (fileName == null || "".equals(fileName.trim()))
                    fileName = "" + id + extension;
                if (fileName.lastIndexOf(".") < fileName.length() - 1) {
                    extension = fileName.substring(fileName.lastIndexOf("."));
                    fileName = fileName.substring(0, fileName.lastIndexOf("."));
                }
                File temp = null;
                try {
                    temp = File.createTempFile(fileName, extension);
                    os = new FileOutputStream(file = temp);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            return os;
        }

        public void uploadSucceeded(Upload.SucceededEvent event) {
            // Show the uploaded file in the image viewer
            image.setSource(new FileResource(file));
            System.out.println("uploadSucceeded(" + file.getAbsolutePath() + ")");

        }

        public FileLocator getFileLocator() throws IOException {

            String extension = ".tmp";
            String fileName = file.getName();

            if (file.getName() == null || "".equals(file.getName().trim()))
                fileName = "" + getId();
            if (fileName.lastIndexOf(".") < fileName.length() - 1) {
                extension = fileName.substring(fileName.lastIndexOf("."));
                fileName = fileName.substring(0, fileName.lastIndexOf(".")).replaceAll(" ", "_");
            }

            java.io.File temp = (System.getProperty("tmpdir") == null)
                    ? java.io.File.createTempFile(fileName, extension)
                    : new java.io.File(new java.io.File(System.getProperty("tmpdir")), fileName + extension);

            System.out.println("java.io.tmpdir=" + System.getProperty("java.io.tmpdir"));
            System.out.println("Temp file : " + temp.getAbsolutePath());

            if (System.getProperty("tmpdir") == null || !temp.exists()) {
                System.out.println("writing temp file to " + temp.getAbsolutePath());
                Files.copy(file, temp);
            } else {
                System.out.println("temp file already exists");
            }

            String baseUrl = System.getProperty("tmpurl");
            URL url = null;
            try {
                if (baseUrl == null) {
                    url = file.toURI().toURL();
                } else
                    url = new URL(baseUrl + "/" + file.getName());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            return new FileLocator(0, file.getName(), url.toString(), file.getAbsolutePath());
        }
    }
    ;
    MyUploader receiver = new MyUploader();

    Upload upload = new Upload(null, receiver);
    //upload.setImmediateMode(false);
    upload.addSucceededListener(receiver);

    f.addComponent(image);

    f.addComponent(upload);

    f.addComponent(e);

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

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

    Button ok = new Button("Change it!", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Changing photo...");
            try {
                FileLocator loc = receiver.getFileLocator();

                io.mateu.ui.core.client.app.MateuUI.getBaseService()
                        .updateFoto(getApp().getUserData().getLogin(), loc, new AsyncCallback<Void>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                            }

                            @Override
                            public void onSuccess(Void result) {
                                e.setValue("OK!");
                                getApp().getUserData().setPhoto(loc.getUrl());
                                foto = (getApp().getUserData().getPhoto() != null)
                                        ? new ExternalResource(getApp().getUserData().getPhoto())
                                        : new ClassResource("profile-pic-300px.jpg");
                                subWindow.close();

                                refreshSettings();

                            }
                        });

            } catch (IOException e1) {
                e1.printStackTrace();
                io.mateu.ui.core.client.app.MateuUI.alert("" + e1.getClass().getName() + ":" + e1.getMessage());
            }

        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

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

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    upload.focus();
}

From source file:local.ikram.assesment.web.SimpleFormComponent.java

private void initForm() {

    employeeId = new TextField("Employee Id: ");
    employeeId.setIcon(FontAwesome.FILE_PICTURE_O);
    employeeId.setRequired(true);//from   w  ww  . j  a v  a 2  s .  c  om
    employeeId.addValidator(new StringLengthValidator("Must be btw 7 and 9 characters", 7, 9, false));

    firstName = new TextField("First Name: ");
    firstName.setIcon(FontAwesome.USER);
    firstName.setRequired(true);
    firstName.addValidator(new NullValidator("Cannot be empty", false));

    lastName = new TextField("Last Name: ");
    lastName.setIcon(FontAwesome.USER);
    lastName.setRequired(true);
    lastName.addValidator(new NullValidator("Cannot be empty", false));

    phoneNumber = new TextField("Phone Number: ");
    phoneNumber.setIcon(FontAwesome.PHONE_SQUARE);
    phoneNumber.setRequired(true);
    phoneNumber.addValidator(new NullValidator("Cannot be empty", false));

    department = new TextField("Department: ");
    department.setIcon(FontAwesome.DESKTOP);
    department.setRequired(true);
    department.addValidator(new NullValidator("Cannot be empty", false));

    saveBtn = new Button("Save", FontAwesome.SAVE);
    saveBtn.addStyleName("save-btn");
    saveBtn.addClickListener((Button.ClickEvent e) -> {
        try {
            employeeId.validate();
            firstName.validate();
            lastName.validate();
            phoneNumber.validate();
            department.validate();
            update(getEmployee());
        } catch (Validator.InvalidValueException ex) {
            Logger.getLogger(SimpleFormComponent.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(),
                    ex);
        }
    });
    deleteBtn = new Button("Delete", FontAwesome.RECYCLE);
    deleteBtn.addStyleName("delete-btn");
    deleteBtn.addClickListener((Button.ClickEvent e) -> {
        delete(getEmployee());
    });
    addBtn = new Button("Add Employee", FontAwesome.PLUS_SQUARE);
    addBtn.addStyleName("add-btn");
    addBtn.addClickListener((Button.ClickEvent e) -> {
        clear();
    });

    final HorizontalLayout buttonLayout = new HorizontalLayout(saveBtn, deleteBtn);
    buttonLayout.setSpacing(true);

    final FormLayout formLayout = new FormLayout();
    formLayout.setSizeUndefined();
    formLayout.setMargin(true);
    formLayout.setData(this);
    formLayout.addComponents(employeeId, firstName, lastName, phoneNumber, department, buttonLayout);
    setCompositionRoot(formLayout);

    setEmployee(new Employee());
    BeanFieldGroup.bindFieldsUnbuffered(employee, this);
}