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:eu.livotov.labs.webskel.app.MainUI.java

License:Apache License

protected void init(final VaadinRequest vaadinRequest) {
    Label hello = new Label("Hello Web Skeleton WebApp User !");
    hello.setStyleName(ValoTheme.LABEL_H1);

    Button b = new Button("Log me now !");
    b.setStyleName(ValoTheme.BUTTON_DANGER);
    b.addClickListener(new Button.ClickListener() {
        public void buttonClick(final Button.ClickEvent event) {
            logsDao.addLogEntry("Hello, it is me you looking for...");
        }// w  ww. ja  va2  s.c om
    });

    VerticalLayout root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(true);
    root.setSpacing(true);
    root.addComponent(hello);
    root.addComponent(b);
    root.setExpandRatio(hello, 1.0f);

    setContent(root);
}

From source file:eu.lod2.stat.dsdrepo.DSDRepoComponent.java

public DSDRepoComponent(Repository repository, String dataGraph, String repoGraph) {
    this.repository = repository;
    this.dataGraph = dataGraph;
    this.repoGraph = repoGraph;

    initializeRepoGraph();/*from  w  w  w  .  ja v a2s  . c om*/

    dcRepo = new SparqlDCRepository(repository);
    graph = new SparqlDCGraph(repository, dataGraph);

    setSizeFull();
    VerticalLayout rootLayout = new VerticalLayout();
    rootLayout.setSizeFull();
    rootLayout.setSpacing(true);
    setDebugId("dsd-repo");

    mainLayout = new VerticalLayout();
    mainLayout.setSizeUndefined();
    mainLayout.setWidth("100%");
    //        mainLayout.setHeight("800px");
    mainLayout.setSpacing(true);

    HorizontalLayout menuLayout = new HorizontalLayout();
    menuLayout.setSpacing(true);
    menuLayout.setWidth("100%");
    rootLayout.addComponent(menuLayout);
    rootLayout.setExpandRatio(menuLayout, 0.0f);

    final MenuBar menu = new MenuBar();
    menu.addStyleName("dsd");
    cmdFindDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        findDSDs();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Find Suitable DSDs", cmdFindDSD).setStyleName("bleja");
    cmdCreateDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        createDSD();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Create DSD", cmdCreateDSD).setStyleName("bleja");
    cmdStoreDSD = new MenuBar.Command() {
        public void menuSelected(MenuBar.MenuItem selectedItem) {
            for (MenuBar.MenuItem item : menu.getItems()) {
                if (item == selectedItem) {
                    if (!item.getStyleName().contains("selected")) {
                        if (ds != null)
                            item.setStyleName("selected");
                        storeDSD();
                    }
                } else
                    item.setStyleName("bleja");
            }
        }
    };
    menu.addItem("Store DSD", cmdStoreDSD).setStyleName("bleja");

    menuLayout.addComponent(menu);
    Label spaceLbl = new Label("");
    menuLayout.addComponent(spaceLbl);
    menuLayout.setExpandRatio(spaceLbl, 2.0f);
    Label lbl = new Label("Choose dataset: ");
    lbl.setSizeUndefined();
    menuLayout.addComponent(lbl);

    Collection<DataSet> colDataSets = graph.getDataSets();
    if (colDataSets == null)
        colDataSets = new LinkedList<DataSet>();
    selectDataSet = new ComboBox(null, colDataSets);
    selectDataSet.setImmediate(true);
    selectDataSet.setNewItemsAllowed(false);
    selectDataSet.setNullSelectionAllowed(false);
    selectDataSet.setWidth("300px");
    selectDataSet.addListener(new Property.ValueChangeListener() {
        public void valueChange(Property.ValueChangeEvent event) {
            ds = (DataSet) event.getProperty().getValue();
        }
    });
    menuLayout.addComponent(selectDataSet);

    Panel mainPanel = new Panel(mainLayout);
    mainPanel.setSizeFull();
    mainPanel.setScrollable(true);
    mainPanel.setStyleName(Reindeer.PANEL_LIGHT);

    Label hrLabel = new Label("<hr/>", Label.CONTENT_XHTML);
    rootLayout.addComponent(hrLabel);
    rootLayout.setExpandRatio(hrLabel, 0.0f);
    rootLayout.addComponent(mainPanel);
    rootLayout.setExpandRatio(mainPanel, 2.0f);
    rootLayout.setMargin(true, false, true, false);

    setCompositionRoot(rootLayout);
}

From source file:eu.lod2.stat.dsdrepo.DSDRepoComponent.java

private void refreshContentFindDSDs(DataSet ds) {
    if (ds == null) {
        getWindow().showNotification("No dataset selected", Window.Notification.TYPE_ERROR_MESSAGE);
        return;//  w  ww.  ja v  a2  s  . c o m
    }
    Structure struct = ds.getStructure();
    if (struct != null) {
        contentLayout.addComponent(new Label("The dataset already has a DSD!"));
        return;
    }

    dataset = ds.getUri();
    contentLayout.removeAllComponents();
    ;
    dataTree = new Tree("Dataset");
    dataTree.setWidth("500px");
    dataTree.setNullSelectionAllowed(true);
    dataTree.setImmediate(true);
    populateDataTree();
    addDataTreeListenersFind();
    contentLayout.addComponent(dataTree);
    contentLayout.setExpandRatio(dataTree, 0.0f);
    repoTree = new Tree("Matching Structures");
    repoTree.setNullSelectionAllowed(true);
    repoTree.setImmediate(true);
    repoTreeItems = new LinkedList<Structure>();
    populateRepoTree();
    VerticalLayout v = new VerticalLayout();
    contentLayout.addComponent(v);
    contentLayout.setExpandRatio(v, 2.0f);
    v.addComponent(repoTree);
    v.setExpandRatio(repoTree, 2.0f);
}

From source file:eu.lod2.stat.dsdrepo.DSDRepoComponentWrapper.java

private void refresh() {
    mainContainer.removeAllComponents();
    String currentGraph = state.getCurrentGraph();
    if (currentGraph == null || currentGraph.isEmpty()) {
        VerticalLayout l = new VerticalLayout();
        l.setSizeFull();/*from   www.  j  a v a 2 s  . co  m*/
        mainContainer.addComponent(l);
        Label message = new Label("No graph is currently selected. You can select one below:");
        l.addComponent(message);
        l.setExpandRatio(message, 0.0f);
        ConfigurationTab config = new ConfigurationTab(this.state);
        l.addComponent(config);
        l.setExpandRatio(config, 2.0f);
        l.setComponentAlignment(message, Alignment.TOP_LEFT);
        l.setComponentAlignment(config, Alignment.TOP_LEFT);

        return;
    }

    mainContainer.addComponent(new DSDRepoComponent(state.getRdfStore(), currentGraph));
}

From source file:eu.maxschuster.vaadin.localstorage.test.LocalStorageUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    final LocalStorageItemCallback callback = new LocalStorageItemCallback() {

        /*//from  w w w.  j  a va2s .co m
         * (non-Javadoc)
         * @see eu.maxschuster.vaadin.localstorage.shared.LocalStorageItemCallback#onSussess(java.lang.String, java.lang.String, java.lang.String)
         */
        @Override
        public void onSuccess(LocalStorageItem item) {
            appendToLog("Success:\n" + item);
        }

        /*
         * (non-Javadoc)
         * @see eu.maxschuster.vaadin.localstorage.shared.LocalStorageItemCallback#onError()
         */
        @Override
        public void onError(String key) {
            appendToLog("ERROR for item \"" + key + "\" (simulateNotSupported="
                    + LocalStorage.getCurrent().isSimulateNotSupported() + ")");
        }

    };

    final ItemUpdateListener itemUpdateListener = new ItemUpdateListener() {

        @Override
        public void onUpdate(ItemUpdateEvent event) {
            appendToLog("Update (type=" + event.getType() + "):\n" + event.getItem());
        }

    };

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

    final HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    layout.addComponent(topLayout);
    layout.setExpandRatio(topLayout, 0);

    Button button = new Button("Start", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            appendToLog("Start localStorage test:");

            LocalStorage localStorage = LocalStorage.getCurrent();

            localStorage.setItem("remove", "REMOVE ME!");

            localStorage.setItem("test", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", callback);

            localStorage.removeItem("remove");

            localStorage.setItem("test", "Duis commodo.", callback);

            localStorage.getItem("test", callback);

            localStorage.getItem("remove", callback);

        }
    });
    topLayout.addComponent(button);

    Button clearButton = new Button("Clear localStorage", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            LocalStorage.getCurrent().clear(callback);
        }

    });

    CheckBox fireUpdateCheckBox = new CheckBox("Fire update events");
    fireUpdateCheckBox.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            if (value)
                LocalStorage.getCurrent().addItemUpdateListener(itemUpdateListener);
            else
                LocalStorage.getCurrent().removeItemUpdateListener(itemUpdateListener);
        }

    });

    CheckBox simulateNotSupportedCheckbox = new CheckBox("Simulate not supported");
    simulateNotSupportedCheckbox.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            LocalStorage.getCurrent().setSimulateNotSupported((Boolean) event.getProperty().getValue());
        }
    });

    topLayout.addComponents(clearButton, fireUpdateCheckBox, simulateNotSupportedCheckbox);

    log.setSizeFull();
    log.setReadOnly(true);
    layout.addComponent(log);
    layout.setExpandRatio(log, 1);

}

From source file:fi.jasoft.draganddrop.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    Panel showcase = new Panel();
    showcase.setSizeUndefined();/*from w w  w . j  av a2  s  . c o  m*/

    navigator = new Navigator(this, showcase);

    for (DemoView view : views) {
        navigator.addView(view.getViewPath(), view);
    }

    // default
    openView(views.get(0));

    MenuBar demos = new MenuBar();
    demos.setStyleName(ValoTheme.MENUBAR_BORDERLESS);

    for (final DemoView view : views) {
        demos.addItem(view.getViewCaption(), new Command() {

            @Override
            public void menuSelected(MenuItem selectedItem) {
                openView(view);
            }
        });
    }

    VerticalLayout root = new VerticalLayout(demos, showcase);
    root.setSizeFull();
    root.setExpandRatio(showcase, 1);
    root.setComponentAlignment(showcase, Alignment.MIDDLE_CENTER);
    setContent(root);

    HorizontalLayout sourceWrapperLayout = new HorizontalLayout();
    Label caption = new Label("Source code for example");
    caption.setStyleName("source-caption");
    sourceWrapperLayout.addComponent(caption);

    Panel sourceWrapper = new Panel(codeLabel);
    sourceWrapper.setStyleName(ValoTheme.PANEL_BORDERLESS);
    sourceWrapper.setHeight(getPage().getBrowserWindowHeight() + "px");
    sourceWrapperLayout.addComponent(sourceWrapper);
    sourceWrapperLayout.setExpandRatio(sourceWrapper, 1);

    Toolbox sourceBox = new Toolbox();
    sourceBox.setOrientation(ORIENTATION.RIGHT_CENTER);
    sourceBox.setContent(sourceWrapperLayout);
    sourceBox.setOverflowSize(30);
    root.addComponent(sourceBox);
}

From source file:fi.jasoft.dragdroplayouts.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//from   w  w  w. j  a v a  2s .co  m
    setContent(content);

    Label header = new Label("DragDropLayouts for Vaadin 8");
    header.setStyleName(ValoTheme.LABEL_H1);
    content.addComponent(header);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeFull();
    content.addComponent(hl);
    content.setExpandRatio(hl, 1);

    VerticalSplitPanel split = new VerticalSplitPanel();
    hl.addComponent(split);
    hl.setExpandRatio(split, 1);

    CssLayout placeHolder = new CssLayout(new Label("No view selected."));
    placeHolder.setSizeFull();
    split.setFirstComponent(placeHolder);

    Panel codePanel = new Panel(codeLabel);
    codePanel.setSizeFull();
    split.setSecondComponent(codePanel);

    navigator = new Navigator(this, placeHolder);

    navigator.addViewChangeListener(new ViewChangeListener() {

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
            DemoView view = (DemoView) event.getNewView();
            selection.getSelectionModel().select(view);
            codeLabel.setValue(getFormattedSourceCode(view.getSource()));
            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
            // TODO Auto-generated method stub

        }
    });

    try {
        addView(new DragdropAbsoluteLayoutDemo(navigator));
        addView(new DragdropVerticalLayoutDemo(navigator));
        addView(new DragdropHorizontalLayoutDemo(navigator));
        addView(new DragdropGridLayoutDemo(navigator));
        addView(new DragdropCssLayoutDemo(navigator));
        addView(new DragdropFormLayoutDemo(navigator));
        addView(new DragdropPanelDemo(navigator));

        addView(new DragdropLayoutDraggingDemo(navigator));
        addView(new DragdropHorizontalSplitPanelDemo(navigator));
        addView(new DragdropVerticalSplitPanelDemo(navigator));
        addView(new DragdropTabsheetDemo(navigator));
        addView(new DragdropAccordionDemo(navigator));

        addView(new DragdropDragFilterDemo(navigator));
        addView(new DragdropCaptionModeDemo(navigator));

        addView(new DragdropV7VerticalLayoutDemo(navigator));
        addView(new DragdropV7HorizontalLayoutDemo(navigator));

        // addView(new DragdropIframeDragging(navigator));

    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    hl.addComponent(selection = createViewSelection(), 0);

    String fragment = Page.getCurrent().getUriFragment();
    if (fragment == null || fragment.equals("")) {
        navigator.navigateTo(DragdropAbsoluteLayoutDemo.NAME);
    }
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropAccordionDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();//w  w  w .j  ava2  s  .co  m
    v.setSpacing(true);

    Label lb = new Label(
            "This demo shows you how you can drag components into a Accordion and reorder the tabs. "
                    + "Try dragging some Buttons on to the accordion to add them as tabs. You can "
                    + "reorder the tabs by dragging on them");
    v.addComponent(lb);

    // Add some buttons to a vertical layout with dragging enabled
    final DDHorizontalLayout btns = new DDHorizontalLayout();
    btns.setSpacing(true);
    btns.setDragMode(LayoutDragMode.CLONE);
    btns.addComponent(new Button("One Button"));
    btns.addComponent(new Button("Second Button"));
    btns.addComponent(new Button("Third Button"));
    btns.addComponent(new Button("Fourth Button"));
    btns.addComponent(new Button("Fifth Button"));
    v.addComponent(btns);

    // Create an Accordion
    final DDAccordion acc = new DDAccordion();
    acc.setSizeFull();

    acc.setDragMode(LayoutDragMode.CLONE);

    acc.setComponentVerticalDropRatio(EQUAL_DROP_RATIO);

    acc.setDropHandler(new DefaultAccordionDropHandler());

    // Add a tab to the accordion
    VerticalLayout layout = new VerticalLayout();
    layout.setCaption("Tab 1");
    layout.addComponent(new Label("This is an example tab already in the accordion."));
    acc.addComponent(layout);

    layout = new VerticalLayout();
    layout.setCaption("Tab 2");
    layout.addComponent(new Label("This is an example tab already in the accordion."));
    acc.addComponent(layout);

    layout = new VerticalLayout();
    layout.setCaption("Tab 3");
    layout.addComponent(new Label("This is an example tab already in the accordion."));
    acc.addComponent(layout);

    v.addComponent(acc);
    v.setExpandRatio(acc, 1);

    // end-source
    return v;
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropTabsheetDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();//from   w  ww.  ja v  a2  s  .c o  m
    v.setSpacing(true);

    Label lb = new Label(
            "This demo shows you how you can drag components into a tabsheet and reorder the tabs. "
                    + "Try dragging some Buttons into the tab area to add them as tabs. You can then "
                    + "reorder the tabs by dragging on them");
    v.addComponent(lb);

    // Add some buttons to a vertical layout with dragging enabled
    final DDHorizontalLayout btns = new DDHorizontalLayout();
    btns.setSpacing(true);
    btns.setDragMode(LayoutDragMode.CLONE);
    btns.addComponent(new Button("One Button"));
    btns.addComponent(new Button("Second Button"));
    btns.addComponent(new Button("Third Button"));
    btns.addComponent(new Button("Fourth Button"));
    btns.addComponent(new Button("Fifth Button"));
    v.addComponent(btns);

    // Create a tabsheet
    final DDTabSheet tabSheet = new DDTabSheet();
    tabSheet.setSizeFull();

    // Add a tab
    VerticalLayout layout = new VerticalLayout();
    layout.setCaption("Example");
    layout.addComponent(new Label("This is an example tab already in the tabsheet."));
    tabSheet.addComponent(layout);

    // Enable dragging
    tabSheet.setDragMode(LayoutDragMode.CLONE);

    // Enable dropping
    tabSheet.setDropHandler(new DefaultTabSheetDropHandler());

    v.addComponent(tabSheet);
    v.setExpandRatio(tabSheet, 1);
    // end-source
    return v;
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropVerticalSplitPanelDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    VerticalLayout root = new VerticalLayout();
    root.setSpacing(true);//from  w ww .  j av a 2  s .c  o m
    root.setSizeFull();

    Label lbl = new Label("On top are some buttons, and below them is a vertical split panel. "
            + "Try dragging the buttons on to the splitpanel. If a component already exists in the SplitPanel it is replaced with the dragged one.");
    root.addComponent(lbl);

    // Add some buttons to a vertical layout with dragging enabled
    final DDHorizontalLayout btns = new DDHorizontalLayout();
    btns.setSpacing(true);
    btns.setDragMode(LayoutDragMode.CLONE);
    String caption = "Button ";
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    root.addComponent(btns);

    // Create a drag & drop horizontal split panel
    final DDVerticalSplitPanel panel = new DDVerticalSplitPanel();
    panel.setSizeFull();

    root.addComponent(panel);
    root.setExpandRatio(panel, 1);

    // Enable dragging
    panel.setDragMode(LayoutDragMode.CLONE);

    // Enable dropping
    panel.setDropHandler(new DefaultVerticalSplitPanelDropHandler());
    // end-source
    return root;
}