Example usage for com.vaadin.ui VerticalLayout setHeight

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

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setHeight.

Prototype

@Override
    public void setHeight(float height, Unit unit) 

Source Link

Usage

From source file:org.esn.esobase.view.MainView.java

@PostConstruct
public void PostConstruct() {
    setSizeFull();/*from  www  .  j  a  v a  2s.  c o  m*/
    this.setHeight(100f, Unit.PERCENTAGE);
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-label {\n" + "    white-space: pre-line;\n" + "    overflow: hidden;\n" + "}"
            + ".v-caption-darkblue {\n" + "   font-weight:bold;margin-bottom:0.33em;margin-top:0.55em;\n" + "}"
            + ".my-grid .v-grid-body .v-grid-cell { height: 100px; }"
            + ".v-treegrid-cell.step_row {background-color: #d7e7d5 !important;}"
            + ".v-treegrid-cell.direction_row {background-color: #ffffff !important;}"
            + ".v-table, .v-table * { overflow-anchor: none; };");
    VerticalLayout layout = new VerticalLayout();
    layout.setHeight(100f, Unit.PERCENTAGE);
    layout.setSpacing(false);
    layout.setMargin(true);
    layout.addComponent(headerLayout);
    buildHeader();
    layout.addComponent(mainMenu);
    buildMenu();
    layout.addComponent(tabs);
    layout.setExpandRatio(tabs, 40f);
    buildTabs();

    setContent(layout);

}

From source file:org.jdal.vaadin.ui.Box.java

License:Apache License

/**
 * @return new VerticalLayout/*from   w  w  w . j  a v a  2s.c  o m*/
 */
public static VerticalLayout createVerticalBox() {
    VerticalLayout vl = new VerticalLayout();
    vl.setHeight(100, Unit.PERCENTAGE);

    return vl;
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.PropertiesWindow.java

License:Open Source License

/**
 * Constructor for instantiating a {@link PropertiesWindow} for a given {@link DashletSpec}.
 *
 * @param dashletSpec    the {@link DashletSpec} to edit
 * @param dashletFactory the {@link DashletFactory} for querying the property data
 *///from w w w.j  a v  a2s  .  c o  m
public PropertiesWindow(final DashletSpec dashletSpec, final DashletFactory dashletFactory) {
    /**
     * Using a vertical layout for content
     */
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    //verticalLayout.addStyleName("debug");
    verticalLayout.setSizeFull();
    verticalLayout.setHeight(100, Unit.PERCENTAGE);

    /**
     * Setting up the table object for displaying the parameters
     */
    final Table table = new Table();

    table.setTableFieldFactory(new DefaultFieldFactory() {
        @Override
        public Field<?> createField(Container container, Object itemId, Object propertyId,
                Component uiContext) {
            Field<?> field = super.createField(container, itemId, propertyId, uiContext);
            if (propertyId.equals("Key")) {
                field.setReadOnly(true);
            } else {
                field.setSizeFull();
            }
            return field;
        }
    });

    table.setEditable(true);
    table.setSizeFull();
    table.setImmediate(true);

    table.addContainerProperty("Key", String.class, "");
    table.addContainerProperty("Value", String.class, "");

    /**
     * Filling the date with parameter data
     */
    final Map<String, String> requiredParameters = dashletFactory.getRequiredParameters();

    for (Map.Entry<String, String> entry : requiredParameters.entrySet()) {
        table.addItem(new Object[] { entry.getKey(), dashletSpec.getParameters().get(entry.getKey()) },
                entry.getKey());
    }

    table.setColumnWidth("Key", 100);
    table.setColumnWidth("Value", -1);
    table.setSizeFull();
    verticalLayout.addComponent(table);

    /**
     * Using an additional {@link HorizontalLayout} for layouting the buttons
     */
    HorizontalLayout horizontalLayout = new HorizontalLayout();

    horizontalLayout.setMargin(true);
    horizontalLayout.setSpacing(true);
    horizontalLayout.setWidth(100, Unit.PERCENTAGE);

    /**
     * Adding the cancel button...
     */
    Button cancel = new Button("Cancel");
    cancel.setDescription("Cancel editing properties");
    cancel.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });

    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    horizontalLayout.addComponent(cancel);
    horizontalLayout.setExpandRatio(cancel, 1);
    horizontalLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT);

    /**
     * ...and the OK button
     */
    Button ok = new Button("Save");
    ok.setDescription("Save properties and close");

    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            for (Map.Entry<String, String> entry : requiredParameters.entrySet()) {
                String newValue = table.getItem(entry.getKey()).getItemProperty("Value").getValue().toString();
                dashletSpec.getParameters().put(entry.getKey(), newValue);
            }

            WallboardProvider.getInstance().save();
            ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties");

            close();
        }
    });

    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    horizontalLayout.addComponent(ok);
    //horizontalLayout.addStyleName("debug");

    /**
     * Adding the layout and setting the content
     */
    verticalLayout.addComponent(horizontalLayout);

    verticalLayout.setExpandRatio(table, 1.0f);

    setContent(verticalLayout);
}

From source file:org.opennms.features.vaadin.dashboard.dashlets.AlarmConfigurationWindow.java

License:Open Source License

/**
 * Constructor for instantiating new objects of this class.
 *
 * @param dashletSpec the {@link DashletSpec} to be edited
 *//*  www  .j a  va  2s .  com*/
public AlarmConfigurationWindow(DashletSpec dashletSpec) {
    /**
     * Setting the members
     */
    m_dashletSpec = dashletSpec;

    /**
     * Setting up the base layouts
     */
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setHeight(100, Unit.PERCENTAGE);
    verticalLayout.setSizeFull();
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    /**
     * Adding the selection box
     */
    m_boostedSeveritySelect = new NativeSelect();
    m_boostedSeveritySelect.setCaption("Boosted Severity");
    m_boostedSeveritySelect.setDescription("Select the boost severity");
    m_boostedSeveritySelect.setMultiSelect(false);
    m_boostedSeveritySelect.setNullSelectionAllowed(false);
    m_boostedSeveritySelect.setInvalidAllowed(false);
    m_boostedSeveritySelect.setNewItemsAllowed(false);

    for (OnmsSeverity onmsSeverity : OnmsSeverity.values()) {
        m_boostedSeveritySelect.addItem(onmsSeverity.name());
    }

    String boostSeverity = m_dashletSpec.getParameters().get("boostSeverity");

    if (boostSeverity == null || "".equals(boostSeverity)) {
        boostSeverity = OnmsSeverity.CLEARED.name();
    }

    m_boostedSeveritySelect.setValue(boostSeverity);

    verticalLayout.addComponent(m_boostedSeveritySelect);

    /**
     * Setting up the {@link CriteriaBuilderComponent} component
     */
    CriteriaBuilderHelper criteriaBuilderHelper = new CriteriaBuilderHelper(OnmsAlarm.class, OnmsNode.class,
            OnmsEvent.class, OnmsCategory.class);

    final CriteriaBuilderComponent criteriaBuilderComponent = new CriteriaBuilderComponent(
            criteriaBuilderHelper, m_dashletSpec.getParameters().get("criteria"));

    verticalLayout.addComponent(criteriaBuilderComponent);
    verticalLayout.setExpandRatio(criteriaBuilderComponent, 1.0f);

    /**
     * Using an additional {@link com.vaadin.ui.HorizontalLayout} for layouting the buttons
     */
    HorizontalLayout buttonLayout = new HorizontalLayout();

    buttonLayout.setMargin(true);
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth("100%");
    /**
     * Adding the cancel button...
     */
    Button cancel = new Button("Cancel");
    cancel.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    cancel.setDescription("Cancel editing");
    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    buttonLayout.addComponent(cancel);
    buttonLayout.setExpandRatio(cancel, 1.0f);
    buttonLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT);

    /**
     * ...and the OK button
     */
    Button ok = new Button("Save");
    ok.setDescription("Save properties and close");
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            m_dashletSpec.getParameters().put("criteria", criteriaBuilderComponent.getCriteria());
            m_dashletSpec.getParameters().put("boostSeverity",
                    String.valueOf(m_boostedSeveritySelect.getValue()));

            WallboardProvider.getInstance().save();
            ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties");

            close();
        }
    });

    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttonLayout.addComponent(ok);

    /**
     * Adding the layout and setting the content
     */
    verticalLayout.addComponent(buttonLayout);

    setContent(verticalLayout);
}

From source file:org.vaadin.addon.itemlayout.demo.client.ui.ItemLayoutDemoUI.java

License:Open Source License

private Component initItemVerticalExamples() {
    // Layout to show examples
    final VerticalLayout example = new VerticalLayout();
    example.setHeight(100, Unit.PERCENTAGE);
    example.addComponent(new Label("Demo for ItemVertical"));

    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setHeight(100, Unit.PERCENTAGE);
    horizontalLayout.setMargin(true);/*from   ww  w.jav a 2s  . c om*/
    example.addComponent(horizontalLayout);

    final ItemVertical itemVertical = buildDefaultItemVertical();
    itemVertical.addItemClickListener(buildClickListener());

    final OptionGroup sample = buildSelectableOption();
    sample.addValueChangeListener(buildValueChangeListener(itemVertical));
    horizontalLayout.addComponent(sample);
    horizontalLayout.addComponent(itemVertical);
    return example;
}

From source file:org.vaadin.addons.core.window.DialogWindow.java

License:Apache License

private VerticalLayout buildContent(String title, VaadinIcons type, Component content,
        ButtonType[] buttonTypes) {//from  w ww .j  av a2s .c  o  m
    VerticalLayout root = new VerticalLayout();
    root.setMargin(false);
    root.setSpacing(false);

    float width = -1;
    float height = 0;

    if (title != null) {
        HorizontalLayout header = new HorizontalLayout();
        header.setMargin(true);
        header.setHeightUndefined();
        header.setWidth("100%");
        header.addStyleName(ValoTheme.WINDOW_TOP_TOOLBAR);
        Label l = new Label("<font size=\"4\">" + title + "</font>", ContentMode.HTML);
        width = l.getWidth();
        header.addComponent(l);
        header.setComponentAlignment(l, Alignment.MIDDLE_LEFT);

        if (type != null) {
            Label i = new Label(type.getHtml(), ContentMode.HTML);
            header.addComponent(i);
            header.setComponentAlignment(i, Alignment.MIDDLE_RIGHT);
        }

        height = header.getHeight();
        root.addComponent(header);
    }

    if (content != null) {
        content.setSizeFull();
        HorizontalLayout contentRoot = new HorizontalLayout(content);
        contentRoot.setMargin(true);
        root.addComponent(contentRoot);
        height = height + contentRoot.getHeight();
    }

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

    HorizontalLayout buttons = new HorizontalLayout();
    if (buttonTypes != null) {
        Stream.of(buttonTypes).forEach(buttonType -> {
            Button b = new Button(buttonType.getCaption());
            if (buttonType.getIcon() != null) {
                b.setIcon(buttonType.getIcon());
            }
            if (buttonType.getDescription() != null) {
                b.setDescription(buttonType.getDescription());
            }
            if (buttonType.getStyle() != null) {
                b.addStyleName(buttonType.getStyle());
            }
            b.addClickListener(event -> buttonType.getActions().forEach(buttonAction -> {
                ButtonTypeClickEvent event1 = new ButtonTypeClickEvent(buttonType, DialogWindow.this);
                buttonAction.getListener().buttonClick(event1);
            }));
            buttons.addComponent(b);
        });
    }
    buttons.setSizeUndefined();
    buttons.setMargin(false);
    buttons.setSpacing(true);

    footer.addComponent(buttons);
    footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);

    if (buttons.getWidth() > width) {
        width = buttons.getWidth();
    }

    root.addComponent(footer);
    root.setComponentAlignment(footer, Alignment.BOTTOM_LEFT);
    height = height + footer.getHeight();

    root.setHeight(height, Unit.PIXELS);
    root.setWidth(width, Unit.PIXELS);
    return root;
}

From source file:pt.ist.vaadinframework.ui.ApplicationWindow.java

License:Open Source License

public ApplicationWindow(String theme, Property applicationTitle, Property applicationSubtitle,
        Property copyright) {/*  w w w.  ja  v a  2s . c o m*/
    setTheme(theme);
    this.applicationTitle = applicationTitle;
    this.applicationSubtitle = applicationSubtitle;
    this.copyright = copyright;
    VerticalLayout main = new VerticalLayout();
    main.setWidth(90, UNITS_PERCENTAGE);
    main.setHeight(98, UNITS_PERCENTAGE);
    main.addStyleName("application-container");

    VerticalLayout header = new VerticalLayout();
    header.setMargin(true, true, false, true);
    header.setSpacing(true);
    main.addComponent(header);
    HorizontalLayout iconAndTitle = new HorizontalLayout();
    iconAndTitle.setSizeFull();
    iconAndTitle.setSpacing(true);
    header.addComponent(iconAndTitle);
    Embedded logo = new Embedded(null, new ThemeResource("../runo/icons/64/globe.png"));
    iconAndTitle.addComponent(logo);
    iconAndTitle.setComponentAlignment(logo, Alignment.MIDDLE_LEFT);

    VerticalLayout titles = new VerticalLayout();
    titles.setSpacing(true);
    iconAndTitle.addComponent(titles);
    iconAndTitle.setExpandRatio(titles, 0.8f);
    Label title = new Label(applicationTitle);
    title.addStyleName("application-title");
    titles.addComponent(title);
    Label subtitle = new Label(applicationSubtitle);
    subtitle.addStyleName("application-subtitle");
    titles.addComponent(subtitle);

    HorizontalLayout controls = new HorizontalLayout();
    controls.setSpacing(true);
    iconAndTitle.addComponent(controls);
    iconAndTitle.setComponentAlignment(controls, Alignment.TOP_RIGHT);
    Label user = new Label("ist148357");
    controls.addComponent(user);
    Link logout = new Link("logout", new ExternalResource("#"));
    controls.addComponent(logout);

    MenuBar menu = new MenuBar();
    menu.addStyleName("application-menu");
    header.addComponent(menu);
    MenuItem hello = menu.addItem("hello", null);
    hello.addItem("sdgjk", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            getWindow().showNotification("skjhfgksjdfhglksdjh");
        }
    });
    MenuItem hello1 = menu.addItem("hello", null);
    hello1.addItem("sdgjk", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            getWindow().showNotification("skjhfgksjdfhglksdjh");
        }
    });
    MenuItem hello2 = menu.addItem("hello", null);
    hello2.addItem("sdgjk", new Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            getWindow().showNotification("skjhfgksjdfhglksdjh");
        }
    });

    body = new VerticalLayout();
    body.setSizeFull();
    body.setMargin(true);
    body.addStyleName("application-body");
    main.addComponent(body);
    main.setExpandRatio(body, 1f);
    body.addComponent(createDefaultPageBody());

    VerticalLayout footer = new VerticalLayout();
    main.addComponent(footer);
    main.setComponentAlignment(footer, Alignment.MIDDLE_CENTER);
    Label copyrightLabel = new Label(copyright);
    copyrightLabel.setSizeUndefined();
    copyrightLabel.addStyleName("application-footer");
    footer.addComponent(copyrightLabel);
    footer.setComponentAlignment(copyrightLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout outer = (VerticalLayout) getContent();
    outer.setSizeFull();
    outer.addComponent(main);
    outer.setComponentAlignment(main, Alignment.MIDDLE_CENTER);
}

From source file:ru.codeinside.gses.webui.components.ProcessDefinitionShowUi.java

License:Mozilla Public License

private Component buildMainLayout() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from w  w w  . java2 s.  c om
    layout.setSpacing(true);
    layout.setMargin(true);

    Label label = new Label();
    String name = getProcessDefinitionById(processDefinitionId).getName();
    label.setCaption(name);
    label.setStyleName(Reindeer.LABEL_H2);

    Button showScheme = new Button("");
    showScheme.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -5911713385519847639L;

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
            VerticalLayout imageLayout = new VerticalLayout();
            Button back = new Button("?");
            back.addListener(new Button.ClickListener() {
                private static final long serialVersionUID = 4154712522487297925L;

                @Override
                public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
                    changer.back();
                }
            });
            imageLayout.addComponent(back);
            imageLayout.setMargin(true);
            imageLayout.setSpacing(true);
            imageLayout.setWidth(1100, Sizeable.UNITS_PIXELS);
            imageLayout.setHeight(600, Sizeable.UNITS_PIXELS);
            final Panel panel = new Panel();
            panel.getContent().setSizeUndefined();
            TaskGraph tg = new TaskGraph(processDefinitionId, null);
            panel.addComponent(tg);
            panel.setSizeFull();
            panel.setScrollable(true);
            imageLayout.addComponent(panel);
            imageLayout.setExpandRatio(back, 0.01f);
            imageLayout.setExpandRatio(panel, 0.99f);
            changer.change(imageLayout);
        }
    });
    layout.addComponent(showScheme);

    Table table = new Table();
    table.setSizeFull();
    table.setImmediate(true);
    table.setSelectable(true);
    table.setSortDisabled(true);
    table.setPageLength(0);
    table.setSelectable(false);
    table.addContainerProperty("id", String.class, null);
    table.addContainerProperty("name", String.class, null);
    table.addContainerProperty("accessPermissions", Component.class, null);
    table.addContainerProperty("formProperties", Component.class, null);
    table.addContainerProperty("other", String.class, null);
    table.setColumnHeaders(new String[] { " ?", "?",
            /*" ?",*/ " ?", "? ",
            "? " });
    table.setColumnExpandRatio("id", 0.1f);
    table.setColumnExpandRatio("name", 0.1f);
    table.setColumnExpandRatio("accessPermissions", 0.1f);
    table.setColumnExpandRatio("formProperties", 0.4f);
    table.setColumnExpandRatio("other", 0.2f);
    fillTable(table);

    layout.addComponent(label);
    layout.setExpandRatio(label, 1);

    layout.addComponent(table);
    layout.setExpandRatio(table, 40);

    return layout;
}