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.jumpmind.metl.ui.views.design.TableColumnSelectWindow.java

License:Open Source License

public TableColumnSelectWindow(ApplicationContext context, Model model) {
    super("Import from Database into Model");
    this.context = context;
    this.model = model;

    setWidth(600.0f, Unit.PIXELS);/* w w  w .j  a  v  a2s .c o m*/
    setHeight(600.0f, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();
    layout.addComponent(new Label("Select tables and columns to import into the model."));

    Panel scrollable = new Panel();
    scrollable.addStyleName(ValoTheme.PANEL_BORDERLESS);
    scrollable.addStyleName(ValoTheme.PANEL_SCROLL_INDICATOR);
    scrollable.setSizeFull();

    provider = new DbProvider(context);
    dbTree = new DbTree(provider, new DefaultSettingsProvider(context.getConfigDir()));
    scrollable.setContent(dbTree);

    layout.addComponent(scrollable);
    layout.setExpandRatio(scrollable, 1.0f);
    addComponent(layout, 1);

    Button refreshButton = new Button("Refresh");
    Button cancelButton = new Button("Cancel");
    Button selectButton = new Button("Import");
    addComponent(buildButtonFooter(refreshButton, cancelButton, selectButton));

    cancelButton.addClickListener(event -> close());
    selectButton.addClickListener(event -> select());
    refreshButton.addClickListener(event -> refresh());
}

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

License:Open Source License

public ManageNavigator(FolderType folderType, ApplicationContext context) {
    this.context = context;

    setSizeFull();/*from  w  ww.  j  a v  a  2s. c  o  m*/

    addStyleName(ValoTheme.MENU_ROOT);

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();
    setContent(content);

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

    treeTable = buildTreeTable();
    content.addComponent(treeTable);
    content.setExpandRatio(treeTable, 1);

    agentsFolder = new Folder();
    agentsFolder.setName("Agents");

    flowsFolder = new Folder();
    flowsFolder.setName("Flows");
}

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

License:Open Source License

@SuppressWarnings("serial")
@PostConstruct//from   w  w w .  ja va  2 s .  co m
protected void init() {
    viewButton = new Button("View Log");
    viewButton.setEnabled(false);
    viewButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            viewLog(table.getValue());
        }
    });

    VerticalLayout mainTab = new VerticalLayout();
    mainTab.setSizeFull();
    HorizontalLayout header = new HorizontalLayout();
    header.addComponent(viewButton);
    header.setComponentAlignment(viewButton, Alignment.BOTTOM_RIGHT);

    statusSelect = new ComboBox("Status");
    statusSelect.setNewItemsAllowed(false);
    statusSelect.setNullSelectionAllowed(false);
    statusSelect.addItem(ANY);
    statusSelect.setValue(ANY);
    for (ExecutionStatus status : ExecutionStatus.values()) {
        statusSelect.addItem(status.toString());
    }
    ;
    statusSelect.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            refreshUI(getBackgroundData());
        }
    });
    header.addComponent(statusSelect);
    header.setComponentAlignment(statusSelect, Alignment.BOTTOM_RIGHT);

    HorizontalLayout limitLayout = new HorizontalLayout();
    limitLayout.setSpacing(true);
    Label limitLabel = new Label("Limit:");
    limitLayout.addComponent(limitLabel);
    limitLayout.setComponentAlignment(limitLabel, Alignment.MIDDLE_CENTER);
    TextField limitField = new TextField(null, String.valueOf(DEFAULT_LIMIT));
    limitField.setWidth("5em");
    limitField.setImmediate(true);
    limitField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    limitField.setTextChangeTimeout(200);
    limitField.addTextChangeListener(new TextChangeListener() {
        public void textChange(TextChangeEvent event) {
            try {
                limit = Integer.parseInt(event.getText());
            } catch (Exception e) {
            }
            refreshUI(getBackgroundData());
        }
    });
    limitLayout.addComponent(limitField);
    limitLayout.setComponentAlignment(limitField, Alignment.BOTTOM_RIGHT);
    header.addComponent(limitLayout);
    header.setComponentAlignment(limitLayout, Alignment.BOTTOM_RIGHT);
    header.setExpandRatio(limitLayout, 1.0f);

    TextField filterField = new TextField();
    filterField.setInputPrompt("Filter");
    filterField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    filterField.setIcon(FontAwesome.SEARCH);
    filterField.setImmediate(true);
    filterField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    filterField.setTextChangeTimeout(200);
    filterField.addTextChangeListener(new TextChangeListener() {
        public void textChange(TextChangeEvent event) {
            executionContainer.removeAllContainerFilters();
            if (!StringUtils.isBlank(event.getText())) {
                executionContainer.addContainerFilter(new MultiPropertyFilter(event.getText(), new String[] {
                        "agentName", "hostName", "flowName", "status", "startTime", "endTime" }));
            }
        }
    });
    header.addComponent(filterField);
    header.setComponentAlignment(filterField, Alignment.BOTTOM_RIGHT);

    header.setSpacing(true);
    header.setMargin(true);
    header.setWidth("100%");
    mainTab.addComponent(header);

    table = new Table();
    table.setContainerDataSource(executionContainer);
    table.setSelectable(true);
    table.setMultiSelect(false);
    table.setSizeFull();
    table.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                viewLog(event.getItemId());
            }
        }
    });
    table.setVisibleColumns(
            new Object[] { "agentName", "deploymentName", "hostName", "status", "startTime", "endTime" });
    table.setColumnHeaders(new String[] { "Agent", "Deployment", "Host", "Status", "Start", "End" });
    table.setSortContainerPropertyId("startTime");
    table.setSortAscending(false);
    table.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            viewButton.setEnabled(table.getValue() != null);
        }
    });
    mainTab.addComponent(table);
    mainTab.setExpandRatio(table, 1.0f);

    tabs = new TabbedPanel();
    tabs.setMainTab("Executions", Icons.EXECUTION, mainTab);

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

    manageNavigator = new ManageNavigator(FolderType.AGENT, context);
    manageNavigator.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            refreshUI(getBackgroundData());
        }
    });
    split.setFirstComponent(manageNavigator);

    VerticalLayout container = new VerticalLayout();
    container.setSizeFull();
    container.addComponent(tabs);
    split.setSecondComponent(container);

    addComponent(split);
    setSizeFull();
    context.getBackgroundRefresherService().register(this);
}

From source file:org.jumpmind.vaadin.ui.common.ConfirmDialog.java

License:Open Source License

public ConfirmDialog(String caption, String text, final IConfirmListener confirmListener) {
    setCaption(caption);//from  www  .  j a v  a 2s. c  o  m
    setModal(true);
    setResizable(true);
    setWidth(300, Unit.PIXELS);
    setHeight(200, Unit.PIXELS);
    setClosable(false);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);

    if (isNotBlank(text)) {
        Label textLabel = new Label(text);
        layout.addComponent(textLabel);
        layout.setExpandRatio(textLabel, 1);
    }

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(100, Unit.PERCENTAGE);

    Label spacer = new Label(" ");
    buttonLayout.addComponent(spacer);
    buttonLayout.setExpandRatio(spacer, 1);

    Button cancelButton = new Button("Cancel");
    cancelButton.setClickShortcut(KeyCode.ESCAPE);
    cancelButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(ConfirmDialog.this);
        }
    });
    buttonLayout.addComponent(cancelButton);

    Button okButton = new Button("Ok");
    okButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    okButton.setClickShortcut(KeyCode.ENTER);
    okButton.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (confirmListener.onOk()) {
                UI.getCurrent().removeWindow(ConfirmDialog.this);
            }
        }
    });
    buttonLayout.addComponent(okButton);

    layout.addComponent(buttonLayout);

    okButton.focus();

}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java

License:Open Source License

public QueryPanel(IDb db, ISettingsProvider settingsProvider, IButtonBar buttonBar, String user) {
    this.settingsProvider = settingsProvider;
    this.db = db;
    this.user = user;
    this.buttonBar = buttonBar;
    this.sqlArea = buildSqlEditor();
    this.shortCutListeners.add(createExecuteSqlShortcutListener());

    VerticalLayout resultsLayout = new VerticalLayout();
    resultsLayout.setSizeFull();/*w ww  .j a  va2  s. c om*/

    resultsTabs = CommonUiUtils.createTabSheet();
    resultStatuses = new HashMap<Component, String>();

    HorizontalLayout statusBar = new HorizontalLayout();
    statusBar.addStyleName(ValoTheme.PANEL_WELL);
    statusBar.setMargin(new MarginInfo(true, true, true, true));
    statusBar.setWidth(100, Unit.PERCENTAGE);

    status = new Label("No Results");
    statusBar.addComponent(status);

    setSelectedTabChangeListener();

    resultsLayout.addComponents(resultsTabs, statusBar);
    resultsLayout.setExpandRatio(resultsTabs, 1);

    addComponents(sqlArea, resultsLayout);

    setSplitPosition(400, Unit.PIXELS);

    emptyResults = new VerticalLayout();
    emptyResults.setSizeFull();
    Label label = new Label("New results will appear here");
    label.setWidthUndefined();
    emptyResults.addComponent(label);
    emptyResults.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    resultStatuses.put(emptyResults, "No Results");

    if (!settingsProvider.get().getProperties().is(SQL_EXPLORER_SHOW_RESULTS_IN_NEW_TABS)) {
        createGeneralResultsTab();
    }
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.SqlExplorer.java

License:Open Source License

public SqlExplorer(String configDir, IDbProvider databaseProvider, ISettingsProvider settingsProvider,
        String user, float leftSplitSize, IDbMenuItem... additionalMenuItems) {
    this.databaseProvider = databaseProvider;
    this.settingsProvider = settingsProvider;
    this.savedSplitPosition = leftSplitSize;
    this.additionalMenuItems = additionalMenuItems;

    setSizeFull();//from w w  w . j a va 2s  .  c o m
    addStyleName("sqlexplorer");

    VerticalLayout leftLayout = new VerticalLayout();
    leftLayout.setSizeFull();
    leftLayout.addStyleName(ValoTheme.MENU_ROOT);

    leftLayout.addComponent(buildLeftMenu());

    Panel scrollable = new Panel();
    scrollable.setSizeFull();

    dbTree = buildDbTree();
    scrollable.setContent(dbTree);

    leftLayout.addComponent(scrollable);
    leftLayout.setExpandRatio(scrollable, 1);

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

    VerticalLayout rightMenuWrapper = new VerticalLayout();
    rightMenuWrapper.setWidth(100, Unit.PERCENTAGE);
    rightMenuWrapper.addStyleName(ValoTheme.MENU_ROOT);
    contentMenuBar = new MenuBar();
    contentMenuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
    contentMenuBar.setWidth(100, Unit.PERCENTAGE);
    addShowButton(contentMenuBar);

    rightMenuWrapper.addComponent(contentMenuBar);
    rightLayout.addComponent(rightMenuWrapper);

    contentTabs = new SqlExplorerTabPanel();
    contentTabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            selectContentTab((IContentTab) contentTabs.getSelectedTab());
        }
    });
    rightLayout.addComponent(contentTabs);
    rightLayout.setExpandRatio(contentTabs, 1);

    addComponents(leftLayout, rightLayout);

    setSplitPosition(savedSplitPosition, Unit.PIXELS);
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.SqlHistoryDialog.java

License:Open Source License

public SqlHistoryDialog(ISettingsProvider settingsProvider, QueryPanel queryPanel) {
    super("Sql History");
    this.settingsProvider = settingsProvider;
    this.queryPanel = queryPanel;

    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();//w  w  w  .  j  av a  2  s. c  om
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    addComponent(mainLayout, 1);

    final Set<SqlHistory> sqlHistories = new TreeSet<SqlHistory>(settingsProvider.get().getSqlHistory());

    table = new Grid();
    table.setImmediate(true);

    table.addColumn("sqlStatement", String.class).setHeaderCaption("SQL")
            .setConverter(new AbbreviatorConverter(50));

    table.addColumn("lastExecuteTime", Date.class).setHeaderCaption("Time").setWidth(150).setMaximumWidth(200)
            .setRenderer(new DateRenderer("%1$tk:%1$tM:%1$tS:%1$tL"));

    table.addColumn("lastExecuteDuration", Long.class).setHeaderCaption("Duration").setWidth(120)
            .setConverter(new DurationConverter());

    table.addColumn("executeCount", Long.class).setHeaderCaption("Count").setWidth(120);
    table.setEditorEnabled(false);
    table.setSelectionMode(SelectionMode.MULTI);
    table.setRowDescriptionGenerator(new RowDescriptionGenerator() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDescription(RowReference row) {
            return (String) row.getItemId();
        }
    });
    final BeanContainer<String, SqlHistory> container = new BeanContainer<String, SqlHistory>(SqlHistory.class);
    container.setBeanIdProperty("sqlStatement");

    HeaderRow filteringHeader = table.appendHeaderRow();
    HeaderCell logTextFilterCell = filteringHeader.getCell("sqlStatement");
    TextField filterField = new TextField();
    filterField.setInputPrompt("Filter");
    filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
    filterField.setWidth("100%");

    // Update filter When the filter input is changed
    filterField.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            // Can't modify filters so need to replace
            container.removeContainerFilters("sqlStatement");

            // (Re)create the filter if necessary
            if (!event.getText().isEmpty()) {
                container.addContainerFilter(
                        new SimpleStringFilter("sqlStatement", event.getText(), true, false));
            }

        }
    });
    logTextFilterCell.setComponent(filterField);

    table.setContainerDataSource(container);

    table.addItemClickListener(new ItemClickEvent.ItemClickListener() {

        private static final long serialVersionUID = 1L;

        public void itemClick(ItemClickEvent event) {
            Object object = event.getPropertyId();
            if (object != null && !object.toString().equals("")) {
                if (event.isDoubleClick()) {
                    table.select(event.getItemId());
                    select();
                } else {
                    Object row = event.getItemId();
                    if (!table.getSelectedRows().contains(row)) {
                        table.select(row);
                    } else {
                        table.deselect(row);
                    }
                }
            }
        }
    });

    table.setSizeFull();

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

    container.addAll(sqlHistories);

    Button cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    Button applyButton = CommonUiUtils.createPrimaryButton("Select");
    applyButton.setClickShortcut(KeyCode.ENTER);
    applyButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            select();
        }
    });

    addComponent(buildButtonFooter(cancelButton, applyButton));

}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableInfoPanel.java

License:Open Source License

protected void populate(VerticalLayout layout) {
    AbstractMetaDataTableCreator creator = (AbstractMetaDataTableCreator) layout.getData();
    Table table = creator.create();//w w  w. j  a v  a  2 s  .  c  om
    layout.addComponent(table);
    layout.setExpandRatio(table, 1);
    layout.setData(null);
}

From source file:org.lunifera.christmastree.control.DesktopControlComponent.java

License:Creative Commons License

protected AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);/*  w  ww .  java2  s  .  c o  m*/
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // title area
    ThemeResource resource = new ThemeResource("images/Title.png");
    Image title = new Image(" ", resource);
    title.setHeight("108px");
    title.setWidth("827px");
    mainLayout.addComponent(title, "top:22.0px;left:120.0px");

    VerticalLayout vl = new VerticalLayout();
    vl.setHeight("500px");
    vl.setWidth("400px");
    vl.setSpacing(true);
    mainLayout.addComponent(vl, "top:140.0px;left:100.0px;");

    contentLayout = buildContent();
    vl.addComponent(contentLayout);
    vl.setExpandRatio(contentLayout, 1.0f);

    // licenses
    PopupView licenseLink = new PopupView("Attributions",
            new Label("<div><i>Monitor/tablet/smartphone</i> and <i>tree</i> icons </br> made by "
                    + "<a href=\"http://www.freepik.com\" title=\"Freepik\">Freepik</a> "
                    + "from <a href=\"http://www.flaticon.com\" title=\"Flaticon\">www.flaticon.com</a> </br>"
                    + "is licensed under <a href=\"http://creativecommons.org/licenses/by/3.0/\" "
                    + "title=\"Creative Commons BY 3.0\">CC BY 3.0</a></div>", ContentMode.HTML));
    licenseLink.setPrimaryStyleName("attributions");
    vl.addComponent(licenseLink);

    Label image = new Label();
    image.setHeight("400px");
    image.setWidth("100%");
    // image.setValue("<div style=\"overflow:hidden; width: 400px;
    // margin-left: -60px;\">"
    // + "<img src=\"http://77.119.240.22:8081\"/>" + "</div>");
    image.setValue("<div style=\"overflow:hidden; width: 370px; margin-left: -60px;\">"
            + "<img src=\"http://192.168.0.108:8081\"/>" + "</div>");
    image.setContentMode(ContentMode.HTML);
    mainLayout.addComponent(image, "top:140.0px;left:600.0px;");

    return mainLayout;
}

From source file:org.lunifera.christmastree.control.MobileControlComponent.java

License:Creative Commons License

protected AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setImmediate(false);/*from   w ww.j  a  va 2  s.  c  om*/
    mainLayout.setWidth("1280px");
    mainLayout.setHeight("720px");

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // title area
    ThemeResource resource = new ThemeResource("images/Title.png");
    Image title = new Image(" ", resource);
    title.setHeight("54px");
    title.setWidth("413px");
    mainLayout.addComponent(title, "top:11.0px;left:60.0px");

    Label image = new Label();
    image.setHeight("340px");
    image.setWidth("600px");
    image.setValue("<div style=\"overflow:hidden; width: 320px; height: 600px; margin-left: -60px;\">"
            + "<img src=\"http://192.168.0.108:8081\"/>" + "</div>");
    image.setContentMode(ContentMode.HTML);
    mainLayout.addComponent(image, "top:70.0px;left:125px;");

    // Image image = new Image();
    // image.setHeight("240px");
    // image.setWidth("320px");
    // image.setSource(new
    // ExternalResource("http://192.168.0.108:8081/stream",
    // "video/x-motion-jpeg"));
    // mainLayout.addComponent(image, "top:70.0px;left:50.0px;");

    VerticalLayout vl = new VerticalLayout();
    //      vl.setHeight("250px");
    vl.setWidth("200px");
    vl.setSpacing(true);

    mainLayout.addComponent(vl, "top:180.0px;left:535.0px;");
    contentLayout = buildContent();
    vl.addComponent(contentLayout);
    vl.setExpandRatio(contentLayout, 1.0f);

    // licenses
    PopupView licenseLink = new PopupView("Attributions",
            new Label("<div><i>Monitor/tablet/smartphone</i> and <i>tree</i> icons </br> made by "
                    + "<a href=\"http://www.freepik.com\" title=\"Freepik\">Freepik</a> "
                    + "from <a href=\"http://www.flaticon.com\" title=\"Flaticon\">www.flaticon.com</a> </br>"
                    + "is licensed under <a href=\"http://creativecommons.org/licenses/by/3.0/\" "
                    + "title=\"Creative Commons BY 3.0\">CC BY 3.0</a></div>", ContentMode.HTML));
    licenseLink.setPrimaryStyleName("attributions");
    vl.addComponent(licenseLink);

    return mainLayout;
}