Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

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

License:Apache License

public SchedulePanel(RestClientService restClientService) {
    this.restClientService = restClientService;

    HorizontalLayout searchlayout = initSearchLayout(restClientService);
    HorizontalLayout dataLayout = initDataLayout();

    VerticalLayout rootVerticalLayout = new VerticalLayout();
    rootVerticalLayout.addComponent(searchlayout);
    rootVerticalLayout.addComponent(dataLayout);

    HorizontalLayout root = new HorizontalLayout();
    root.addComponent(rootVerticalLayout);
    root.setSpacing(true);/*  w ww  .  j a v  a  2 s  .c o m*/
    root.setMargin(true);
    root.setWidth("100%");
    root.setHeight("100%");
    root.setExpandRatio(rootVerticalLayout, 1f);

    setCompositionRoot(root);
}

From source file:org.activiti.explorer.ui.form.FormPropertiesForm.java

License:Apache License

protected void initButtons() {
    submitFormButton = new Button();
    cancelFormButton = new Button();

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);//from w w w  .j  a v a2s.c  o  m
    buttons.setWidth(100, UNITS_PERCENTAGE);
    buttons.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    buttons.addComponent(submitFormButton);
    buttons.setComponentAlignment(submitFormButton, Alignment.BOTTOM_RIGHT);

    buttons.addComponent(cancelFormButton);
    buttons.setComponentAlignment(cancelFormButton, Alignment.BOTTOM_RIGHT);

    Label buttonSpacer = new Label();
    buttons.addComponent(buttonSpacer);
    buttons.setExpandRatio(buttonSpacer, 1.0f);
    addComponent(buttons);
}

From source file:org.activiti.explorer.ui.management.admin.AdminCompletedInstancesPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);/*from www. j  a v a 2 s  .c  o  m*/
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded groupImage = new Embedded(null, Images.PROCESS_50);
    layout.addComponent(groupImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.ADMIN_COMPLETED_TITLE));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}

From source file:org.activiti.explorer.ui.management.admin.AdminDatabaseSettingsPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);/*from ww w. j av  a 2  s. co  m*/
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded databaseImage = new Embedded(null, Images.DATABASE_50);
    layout.addComponent(databaseImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.DATABASE_TITLE));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}

From source file:org.activiti.explorer.ui.management.admin.AdminRunningInstancesPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);/*w  w  w.  j  a  v a  2 s  . co m*/
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded groupImage = new Embedded(null, Images.PROCESS_50);
    layout.addComponent(groupImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.ADMIN_RUNNING_TITLE));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}

From source file:org.activiti.explorer.ui.management.db.DatabaseDetailPanel.java

License:Apache License

protected void addTableName() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100, UNITS_PERCENTAGE);
    header.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    header.setSpacing(true);// ww w  . j a va  2  s.c om

    // TODO: use right image
    Embedded image = new Embedded(null, Images.DATABASE_50);
    header.addComponent(image);
    header.setComponentAlignment(image, Alignment.MIDDLE_LEFT);
    header.setMargin(false, false, true, false);

    Label name = new Label(tableName);
    name.addStyleName(Reindeer.LABEL_H2);
    header.addComponent(name);

    header.setExpandRatio(name, 1.0f);
    header.setComponentAlignment(name, Alignment.MIDDLE_LEFT);
    addDetailComponent(header);

    Label spacer = new Label();
    spacer.setWidth(100, UNITS_PERCENTAGE);
    spacer.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    addDetailComponent(spacer);
}

From source file:org.activiti.explorer.ui.management.identity.GroupDetailPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);//  w ww  . j  a va  2 s .  c  o m
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded groupImage = new Embedded(null, Images.GROUP_50);
    layout.addComponent(groupImage);

    Label groupName = new Label(getGroupName(group));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);
}

From source file:org.activiti.explorer.ui.management.identity.UserDetailPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.setSpacing(true);//from  w  w w .  j ava 2  s .  com
    layout.setMargin(false, false, true, false);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    addDetailComponent(layout);

    Embedded userImage = new Embedded(null, Images.USER_50);
    layout.addComponent(userImage);

    Label userName = new Label(user.getFirstName() + " " + user.getLastName());
    userName.setSizeUndefined();
    userName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(userName);
    layout.setComponentAlignment(userName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(userName, 1.0f);
}

From source file:org.activiti.explorer.ui.profile.ProfilePanel.java

License:Apache License

protected void initAboutSection() {
    // Header/*from w w w .ja  v  a2 s . co m*/
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100, UNITS_PERCENTAGE);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    infoPanelLayout.addComponent(header);

    Label aboutLabel = createProfileHeader(infoPanelLayout, i18nManager.getMessage(Messages.PROFILE_ABOUT));
    header.addComponent(aboutLabel);
    header.setExpandRatio(aboutLabel, 1.0f);

    // only show edit/save buttons if current user matches
    if (isCurrentLoggedInUser) {
        Button actionButton = null;
        if (!editable) {
            actionButton = initEditProfileButton();
        } else {
            actionButton = initSaveProfileButton();
        }
        header.addComponent(actionButton);
        header.setComponentAlignment(actionButton, Alignment.MIDDLE_RIGHT);
    }

    // 'About' fields
    GridLayout aboutLayout = createInfoSectionLayout(2, 4);

    // Name
    if (!editable && (isDefined(user.getFirstName()) || isDefined(user.getLastName()))) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_NAME),
                user.getFirstName() + " " + user.getLastName());
    } else if (editable) {
        firstNameField = new TextField();
        firstNameField.focus();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_FIRST_NAME), firstNameField,
                user.getFirstName());
        lastNameField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LAST_NAME), lastNameField,
                user.getLastName());
    }

    // Job title
    if (!editable && isDefined(jobTitle)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitle);
    } else if (editable) {
        jobTitleField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitleField,
                jobTitle);
    }

    // Birthdate
    if (!editable && isDefined(birthDate)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDate);
    } else if (editable) {
        birthDateField = new DateField();
        birthDateField.setDateFormat(Constants.DEFAULT_DATE_FORMAT);
        birthDateField.setResolution(DateField.RESOLUTION_DAY);
        try {
            birthDateField.setValue(new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT).parse(birthDate));
        } catch (Exception e) {
        } // do nothing
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDateField,
                null);
    }

    // Location
    if (!editable && isDefined(location)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), location);
    } else if (editable) {
        locationField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), locationField,
                location);
    }
}

From source file:org.activiti.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, UNITS_PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);

    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {/* w w  w  . j  a  v a2  s .co m*/
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);

    descriptionLayout.addListener(new LayoutClickListener() {
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);

                // textarea
                final TextArea descriptionTextArea = new TextArea();
                descriptionTextArea.setNullRepresentation("");
                descriptionTextArea.setWidth(100, UNITS_PERCENTAGE);
                descriptionTextArea.setValue(task.getDescription());
                editLayout.addComponent(descriptionTextArea);

                // ok button
                Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                editLayout.addComponent(okButton);
                editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

                // replace
                descriptionLayout.replaceComponent(descriptionLabel, editLayout);

                // When OK is clicked -> update task data + ui
                okButton.addListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update data
                        task.setDescription(descriptionTextArea.getValue().toString());
                        taskService.saveTask(task);

                        // Update UI
                        descriptionLabel.setValue(task.getDescription());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}