Example usage for com.vaadin.ui VerticalLayout setExpandRatio

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

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout 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:org.jdal.vaadin.ui.table.PageableTable.java

License:Apache License

@SuppressWarnings("unchecked")
@PostConstruct//w  w w .  j  a  v a2 s.  com
public void init() {
    // build Component
    VerticalLayout verticalLayout = getVerticalLayout();
    verticalLayout.setSizeUndefined();
    verticalLayout.setSpacing(true);

    // filter 
    if (filterEditor != null && filterForm == null) {
        filterForm = (VaadinView<Filter>) getGuiFactory().getView(filterEditor);
    }

    if (filterForm != null) {
        if (beanFilter != null) {
            filterForm.setModel(beanFilter);
        } else {
            beanFilter = filterForm.getModel();
        }
        verticalLayout.addComponent((Component) filterForm.getPanel());
    }

    // action group
    if (getActions().size() > 0) {
        verticalLayout.addComponent(createButtonBox());
    }
    // table
    verticalLayout.addComponent(getTable());
    verticalLayout.setExpandRatio(getTable(), 1.0f);

    // paginator
    if (paginator != null) {
        paginator.setModel(page);
        paginator.addPaginatorListener(this);
        paginator.setNativeButtons(isNativeButtons());
        page.setPageableDataSource(getService());
        // set external sorting, ie don't call Container.sort()
        getTable().setSorter(new PageSorter());
        Component p = paginator.getPanel();
        verticalLayout.addComponent(p);
        verticalLayout.setComponentAlignment(p, Alignment.MIDDLE_CENTER);
        getTable().setPageLength(page.getPageSize());
        if (beanFilter != null)
            page.setFilter(beanFilter);

        // get initial page and wrap data in container
        paginator.firstPage();
    }

    getTable().addItemClickListener(this);
    this.setSizeUndefined();

}

From source file:org.jdal.vaadin.ui.table.TableEditor.java

License:Apache License

@PostConstruct
public void init() {
    ListBeanContainer c = new ListBeanContainer(getEntityClass());
    setContainer(c);//from w w  w .ja v  a 2s .  c  o m
    getTable().setContainerDataSource(c);
    getTable().addItemClickListener(this);
    VerticalLayout vl = getVerticalLayout();
    vl.setSpacing(true);
    vl.addComponent(this.buttonBar);
    vl.addComponent(getTable());
    vl.setExpandRatio(getTable(), 1);
    this.buttonBar.setSpacing(true);
}

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   www.  j  a va 2s.c  o 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.jumpmind.metl.ui.init.AppUI.java

License:Open Source License

@Override
public void login(User user) {
    WebApplicationContext ctx = getWebApplicationContext();

    VerticalLayout root = new VerticalLayout();
    root.setSizeFull();//from   w  ww  .  ja  v a  2  s  . c  om
    setContent(root);

    VerticalLayout contentArea = new VerticalLayout();
    contentArea.setSizeFull();

    ApplicationContext appCtx = ctx.getBean(ApplicationContext.class);
    appCtx.setUser(user);

    List<ProjectVersion> openProjects = appCtx.getOpenProjects();
    openProjects.clear();

    List<String> projectIds = user.getList(UserSetting.SETTING_CURRENT_PROJECT_ID_LIST);
    for (String projectId : projectIds) {
        ProjectVersion projectVersion = appCtx.getConfigurationService().findProjectVersion(projectId);
        if (projectVersion != null) {
            openProjects.add(projectVersion);
        }
    }

    viewManager = ctx.getBean(ViewManager.class);
    viewManager.init(this, contentArea);

    TopBar menu = new TopBar(viewManager, appCtx);

    //        HorizontalLayout bottom = new HorizontalLayout();
    //        bottom.setWidth(100, Unit.PERCENTAGE);
    //        bottom.setMargin(false);
    //        Embedded right = new Embedded(null, new ThemeResource(
    //                "../apptheme/images/powered-by-jumpmind.png"));
    //        bottom.addComponents(right);
    //        bottom.setComponentAlignment(right, Alignment.BOTTOM_RIGHT);

    root.addComponents(menu, contentArea);
    root.setExpandRatio(contentArea, 1);
}

From source file:org.jumpmind.metl.ui.views.AdminView.java

License:Open Source License

@PostConstruct
protected void init() {
    setSizeFull();//from  w  ww . jav a  2s.  com

    tabbedPanel = new TabbedPanel();

    HorizontalSplitPanel leftSplit = new HorizontalSplitPanel();
    leftSplit.setSizeFull();
    leftSplit.setSplitPosition(AppConstants.DEFAULT_LEFT_SPLIT, Unit.PIXELS);

    VerticalLayout container = new VerticalLayout();
    container.setSizeFull();
    container.addComponent(tabbedPanel);
    leftSplit.setSecondComponent(container);

    table = new TreeTable();
    table.addStyleName(ValoTheme.TREETABLE_NO_HORIZONTAL_LINES);
    table.addStyleName(ValoTheme.TREETABLE_NO_STRIPES);
    table.addStyleName(ValoTheme.TREETABLE_NO_VERTICAL_LINES);
    table.addStyleName(ValoTheme.TREETABLE_BORDERLESS);
    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    table.setSizeFull();
    table.setCacheRate(100);
    table.setPageLength(100);
    table.setImmediate(true);
    table.setSelectable(true);
    table.addItemClickListener(this);
    table.addStyleName("noselect");
    table.addContainerProperty("id", String.class, null);
    table.setVisibleColumns(new Object[] { "id" });
    table.setColumnExpandRatio("id", 1);
    addItem("Users", Icons.USER);
    addItem("Groups", Icons.GROUP);
    addItem("REST", Icons.REST);
    addItem("General Settings", Icons.SETTINGS);
    addItem("Mail Server", Icons.EMAIL);
    addItem("Notifications", Icons.NOTIFICATION);
    addItem("Logging", Icons.LOGGING);
    addItem("About", FontAwesome.QUESTION);

    VerticalLayout navigator = new VerticalLayout();
    navigator.addStyleName(ValoTheme.MENU_ROOT);
    navigator.setSizeFull();
    leftSplit.setFirstComponent(navigator);

    MenuBar leftMenuBar = new MenuBar();
    leftMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    leftMenuBar.setWidth(100, Unit.PERCENTAGE);
    navigator.addComponent(leftMenuBar);

    navigator.addComponent(table);
    navigator.setExpandRatio(table, 1);

    addComponent(leftSplit);

}

From source file:org.jumpmind.metl.ui.views.deploy.FlowSelectWindow.java

License:Open Source License

@SuppressWarnings({ "serial" })
public FlowSelectWindow(ApplicationContext context, String caption, String introText,
        boolean includeTestFlows) {
    super(caption);
    this.context = context;

    tree.setMultiSelect(true);//  w  w  w. ja v a2  s. co m
    tree.addContainerProperty("name", String.class, "");
    tree.setItemCaptionPropertyId("name");
    tree.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    tree.addExpandListener(new ExpandListener() {
        public void nodeExpand(ExpandEvent event) {
            Object itemId = event.getItemId();
            if (itemId instanceof ProjectVersion) {
                addFlowsToVersion((ProjectVersion) itemId, includeTestFlows);
            }
        }
    });
    addProjects();

    setWidth(600.0f, Unit.PIXELS);
    setHeight(600.0f, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.addComponent(new Label(introText));

    Panel scrollable = new Panel();
    scrollable.addStyleName(ValoTheme.PANEL_BORDERLESS);
    scrollable.addStyleName(ValoTheme.PANEL_SCROLL_INDICATOR);
    scrollable.setSizeFull();
    scrollable.setContent(tree);
    layout.addComponent(scrollable);
    layout.setExpandRatio(scrollable, 1.0f);
    addComponent(layout, 1);

    Button cancelButton = new Button("Cancel");
    Button selectButton = new Button("Select");
    addComponent(buildButtonFooter(cancelButton, selectButton));

    cancelButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    selectButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            Collection<FlowName> flowCollection = getFlowCollection(includeTestFlows);
            listener.selected(flowCollection);
            close();
        }
    });
}

From source file:org.jumpmind.metl.ui.views.design.EditFlowPanel.java

License:Open Source License

public EditFlowPanel(ApplicationContext context, String flowId, DesignNavigator designNavigator,
        TabbedPanel tabs) {/*from  w  ww. ja  v  a 2 s.c o  m*/

    this.configurationService = context.getConfigurationService();
    this.flow = configurationService.findFlow(flowId);
    this.readOnly = context.isReadOnly(configurationService.findProjectVersion(flow.getProjectVersionId()),
            Privilege.DESIGN);
    this.context = context;
    this.tabs = tabs;
    this.designNavigator = designNavigator;

    this.propertySheet = new PropertySheet(context, tabs, readOnly);
    this.propertySheet.setListener((components) -> {
        List<FlowStep> steps = new ArrayList<FlowStep>();
        for (Component c : components) {
            steps.add(EditFlowPanel.this.flow.findFlowStepWithComponentId(c.getId()));
        }
        refreshStepOnDiagram(steps);
    });
    this.propertySheet.setCaption("Property Sheet");

    this.componentPalette = new EditFlowPalette(this, context, flow.getProjectVersionId());

    addComponent(componentPalette);

    VerticalLayout rightLayout = new VerticalLayout();
    rightLayout.setSizeFull();

    rightLayout.addComponent(buildButtonBar());

    VerticalSplitPanel splitPanel = new VerticalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setSplitPosition(50, Unit.PERCENTAGE);

    diagramLayout = new VerticalLayout();
    diagramLayout.setWidth(10000, Unit.PIXELS);
    diagramLayout.setHeight(10000, Unit.PIXELS);

    DragAndDropWrapper wrapper = new DragAndDropWrapper(diagramLayout);
    wrapper.setSizeUndefined();
    wrapper.setDropHandler(new DropHandler());

    flowPanel = new Panel();
    flowPanel.setSizeFull();
    flowPanel.addStyleName(ValoTheme.PANEL_WELL);
    flowPanel.setContent(wrapper);

    splitPanel.addComponent(flowPanel);
    splitPanel.addComponent(propertySheet);

    rightLayout.addComponent(splitPanel);
    rightLayout.setExpandRatio(splitPanel, 1);

    addComponent(rightLayout);
    setExpandRatio(rightLayout, 1);

    if (flow.getFlowSteps().size() > 0) {
        selected = new ArrayList<AbstractObject>();
        selected.add(flow.getFlowSteps().get(0));
        propertySheet.setSource(selected);
    }

    redrawFlow();
}

From source file:org.jumpmind.metl.ui.views.design.EditXsltPanel.java

License:Open Source License

protected void buildUI() {

    ButtonBar buttonBar = new ButtonBar();
    addComponent(buttonBar);/*  w  w w . java  2  s .  com*/

    if (!readOnly) {
        Button testButton = buttonBar.addButton("Test", FontAwesome.FILE_CODE_O);
        testButton.addClickListener(new TestClickListener());
    }

    filterField = buttonBar.addFilter();
    filterField.addTextChangeListener(this);

    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setSplitPosition(50, Unit.PERCENTAGE);

    VerticalLayout leftLayout = new VerticalLayout();
    editor = new AceEditor();
    editor.setMode(AceMode.xml);
    editor.setSizeFull();
    editor.setHighlightActiveLine(true);
    editor.setShowPrintMargin(false);
    editor.addTextChangeListener(new StylesheetChangeListener());
    editor.setValue(component.findSetting(XsltProcessor.XSLT_PROCESSOR_STYLESHEET).getValue());
    leftLayout.addComponent(new Label("XSLT Stylesheet"));
    leftLayout.addComponent(editor);
    leftLayout.setExpandRatio(editor, 1.0f);
    leftLayout.setSizeFull();
    splitPanel.setFirstComponent(leftLayout);

    VerticalLayout rightLayout = new VerticalLayout();
    rightLayout.setSizeFull();
    rightLayout.addComponent(new Label("Sample Input XML"));
    textArea = new TextArea();
    textArea.setEnabled(false);
    textArea.setSizeFull();
    textArea.setValue(getSampleXml());
    rightLayout.addComponent(textArea);
    rightLayout.setExpandRatio(textArea, 1.0f);
    splitPanel.setSecondComponent(rightLayout);

    addComponent(splitPanel);
    setExpandRatio(splitPanel, 1.0f);

    textArea.setReadOnly(readOnly);
    editor.setReadOnly(readOnly);

}

From source file:org.jumpmind.metl.ui.views.design.ImportXmlTemplateWindow.java

License:Open Source License

public ImportXmlTemplateWindow(ImportXmlListener listener) {
    this.listener = listener;
    setCaption("Import XML Template");
    setModal(true);/*from   w ww .  j av a  2s  . co  m*/
    setWidth(600.0f, Unit.PIXELS);
    setHeight(500.0f, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    setContent(layout);

    layout.addComponent(new Label("Import XML from either an XSD or WSDL source."));

    optionGroup = new OptionGroup("Select the location of the XSD or WSDL.");
    optionGroup.addItem(OPTION_TEXT);
    optionGroup.addItem(OPTION_FILE);
    optionGroup.addItem(OPTION_URL);
    optionGroup.setNullSelectionAllowed(false);
    optionGroup.setImmediate(true);
    optionGroup.select(OPTION_TEXT);
    optionGroup.addValueChangeListener(this);
    layout.addComponent(optionGroup);

    optionLayout = new VerticalLayout();
    editor = new AceEditor();
    editor.setCaption("Enter the XML text:");
    editor.setMode(AceMode.xml);
    editor.setWidth(100f, Unit.PERCENTAGE);
    editor.setHighlightActiveLine(true);
    editor.setShowPrintMargin(false);

    upload = new Upload(null, this);
    upload.addSucceededListener(this);
    upload.setButtonCaption(null);
    urlTextField = new TextField("Enter the URL:");
    urlTextField.setWidth(100.0f, Unit.PERCENTAGE);
    layout.addComponent(optionLayout);
    layout.setExpandRatio(optionLayout, 1.0f);
    rebuildOptionLayout();

    Button importButton = new Button("Import");
    importButton.addClickListener(this);
    layout.addComponent(importButton);
}

From source file:org.jumpmind.metl.ui.views.design.ManageProjectsPanel.java

License:Open Source License

protected Component buildVersionGrid(Project project) {
    context.getConfigurationService().refresh(project);
    List<ProjectVersion> versions = project.getProjectVersions();
    BeanItemContainer<ProjectVersion> versionGridContainer = new BeanItemContainer<>(ProjectVersion.class);
    Grid versionGrid = new Grid();

    VerticalLayout layout = new VerticalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(true);//from   www.j av  a  2s .c om
    layout.setSpacing(true);
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button openButton = new Button("Open", (event) -> {
        Collection<Object> selected = versionGrid.getSelectedRows();
        for (Object object : selected) {
            projectNavigator.addProjectVersion(((ProjectVersion) object));
        }
    });
    buttons.addComponent(openButton);
    Button newButton = new Button("New Version", (event) -> newVersion(versionGrid));
    buttons.addComponent(newButton);
    Button editButton = new Button("Edit Version", (event) -> edit(versionGrid));
    buttons.addComponent(editButton);
    Button removeButton = new Button("Remove Version", (event) -> removeVersion(versionGrid));
    buttons.addComponent(removeButton);

    openButton.setEnabled(false);
    newButton.setEnabled(false);
    removeButton.setEnabled(false);
    editButton.setEnabled(false);

    layout.addComponent(buttons);

    versionGrid.setWidth(100, Unit.PERCENTAGE);
    versionGrid.setHeight(3 + (versions.size() * ROW_EM), Unit.EM);
    versionGrid.setEditorEnabled(true);
    versionGrid.setSelectionMode(SelectionMode.MULTI);

    versionGrid.addColumn("versionLabel", String.class).setHeaderCaption("Version").setExpandRatio(2);
    versionGrid.addColumn("description", String.class).setHeaderCaption("Description").setExpandRatio(1);
    versionGrid.addColumn("readOnly", Boolean.class).setHeaderCaption("Read Only").setMaximumWidth(100)
            .setRenderer(new HtmlRenderer(), new StringToBooleanConverter() {
                private static final long serialVersionUID = 1L;

                protected String getTrueString() {
                    return FontAwesome.CHECK.getHtml();
                };

                protected String getFalseString() {
                    return "";
                };
            });
    versionGrid.addColumn("createTime", Date.class).setHeaderCaption("Create Time").setWidth(185)
            .setMaximumWidth(200).setRenderer(new DateRenderer(UiConstants.DATETIME_FORMAT)).setEditable(false);

    versionGrid.setContainerDataSource(versionGridContainer);
    versionGrid.setEditorFieldFactory(new FieldFactory());

    versionGrid.getEditorFieldGroup().addCommitHandler(new FieldGroup.CommitHandler() {

        private static final long serialVersionUID = 1L;

        @Override
        public void preCommit(CommitEvent commitEvent) throws CommitException {
        }

        @Override
        public void postCommit(CommitEvent commitEvent) throws CommitException {
            ProjectVersion item = (ProjectVersion) versionGrid.getEditedItemId();
            IConfigurationService configurationService = context.getConfigurationService();
            configurationService.save(item);
            projectGrid.markAsDirty();
        }
    });

    versionGrid.addSelectionListener((event) -> {
        int numberSelected = versionGrid.getSelectedRows().size();
        boolean currentlyEditing = projectGrid.getEditedItemId() != null;
        boolean selected = numberSelected > 0 && !currentlyEditing;
        openButton.setEnabled(selected);
        newButton.setEnabled(selected);
        removeButton.setEnabled(selected);
        editButton.setEnabled(selected);
    });
    versionGrid.addItemClickListener(new GridClickListener(versionGrid));
    layout.addComponent(versionGrid);
    layout.setExpandRatio(versionGrid, 1);
    layout.addComponent(new Label(" "));
    versionGridContainer.addAll(versions);
    versionGrid.sort("versionLabel", SortDirection.DESCENDING);

    return layout;
}