Example usage for com.vaadin.ui Component getHeightUnits

List of usage examples for com.vaadin.ui Component getHeightUnits

Introduction

In this page you can find the example usage for com.vaadin.ui Component getHeightUnits.

Prototype

public Unit getHeightUnits();

Source Link

Document

Gets the height property units.

Usage

From source file:com.cms.utils.CommonUtils.java

public static String getHeight(Component co) {
    return (co.getHeight() + "" + co.getHeightUnits().getSymbol());
}

From source file:com.foc.vaadin.FocCentralPanel.java

License:Apache License

protected void afterChangeCentralPanelContent(ICentralPanel iCentralPanel) {
    Component central = (Component) iCentralPanel;
    if (central != null && central instanceof FocXMLLayout) {
        FocXMLLayout xmlLayout = (FocXMLLayout) central;
        if (xmlLayout != null && xmlLayout.getLayouts() != null && xmlLayout.getLayouts().size() > 0) {
            Component rootComp = (Component) xmlLayout.getLayouts().get(0);
            if (rootComp != null) {
                if (centralPanel != null) {
                    centralPanel.setWidth(rootComp.getWidth(), rootComp.getWidthUnits());
                    //                  centralPanel.setHeight("-1px");
                    //                  centralPanel.setHeight("100%");//NO_PANEL
                    //When the main layout is 100% this means that there will be no vertical srcoll
                    //When the main layout is -1px this means that there will be a  vertical srcoll
                    //    And then we can use expandRatio to the table or any other component inside
                    if (this instanceof FocWebVaadinWindow) {
                        centralPanel.setHeight(rootComp.getHeight(), rootComp.getHeightUnits());
                        setHeight("100%");//NO_PANEL
                    } else {
                        centralPanel.setHeight(rootComp.getHeight(), rootComp.getHeightUnits());
                        setHeight(rootComp.getHeight(), rootComp.getHeightUnits());
                        //This means we are in a Popup 
                        //                     centralPanel.setHeight("100%");
                        //                     setHeight("100%");//NO_PANEL
                    }/*from   w  w  w .  ja va 2s.co  m*/
                }
                //               setWidth(rootComp.getWidth(), rootComp.getWidthUnits());
                //setHeight(rootComp.getHeight(), rootComp.getHeightUnits());

                //               setHeight("-1px");
                //               setHeight("100%");//NO_PANEL               
                markAsDirty();
                //               requestRepaint();
            }
        }
    }
}

From source file:com.foc.vaadin.FocCentralPanel.java

License:Apache License

@Override
public void addUtilityPanel(IRightPanel utilityPanel) {
    if (utilityPanel != null) {
        try {// w  w  w .j a  v a 2 s.  c  om
            Component utilityPanelAsComponent = (Component) utilityPanel;
            //            Window window = getParent(Window.class);

            utilityWindow = new Window("Dictionary");
            utilityWindow.setSizeFull();
            utilityWindow.setWidth(utilityPanelAsComponent.getWidth(), utilityPanelAsComponent.getWidthUnits());
            utilityWindow.setHeight(utilityPanelAsComponent.getHeight(),
                    utilityPanelAsComponent.getHeightUnits());
            utilityWindow.setContent(utilityPanelAsComponent);

            getUI().addWindow(utilityWindow);
        } catch (Exception e) {
            Globals.logException(e);
        }
    }
}

From source file:com.lst.deploymentautomation.vaadin.core.AppFormConnector.java

License:Open Source License

@Override
public void setContent(Component content) {
    if (content == null) {
        //rendering failed; show a sad face to show how sorry we are
        VerticalLayout layout = new VerticalLayout();
        Label fail = new Label(":-(");
        fail.addStyleName("screen-failed-to-render");
        layout.addComponent(fail);/* w  w  w  .  j  a  va 2  s . c  om*/
        layout.setExpandRatio(fail, 1);
        layout.setComponentAlignment(fail, Alignment.MIDDLE_LEFT);
        layout.setSizeFull();

        view.setContent(layout);

    } else {
        //if the component has either natural or absolute size, wrap it
        //in a scrollable panel with full size and nice margin
        if (content.getHeightUnits() != Unit.PERCENTAGE) {
            final Panel panel = new Panel();
            panel.addStyleName("l-border-none");
            panel.setContent(content);
            panel.setSizeFull();
            content = panel;
        }

        view.setContent(content);
    }
}

From source file:info.magnolia.ui.vaadin.richtext.TextAreaStretcher.java

License:Open Source License

public TextAreaStretcher() {
    registerRpc(new TextAreaStretcherServerRpc() {
        @Override/*from ww w  .j  a va2 s.  c om*/
        public void toggle(int initialWidth, int initialHeight) {
            getState().isCollapsed = !getState().isCollapsed;
            final Component parent = (Component) getParent();
            if (getState().isCollapsed) {
                // Restore size info from the state.
                parent.setWidth(getState().collapsedStateWidth);
                parent.setHeight(getState().collapsedStateHeight);
            } else {

                // We save the initial dimensions and clear size info from the state.
                getState().collapsedStateHeight = parent.getHeight() + parent.getHeightUnits().toString();
                getState().collapsedStateWidth = parent.getWidth() + parent.getWidthUnits().toString();
                parent.setWidth("");
                parent.setHeight("");
            }
        }
    });
}

From source file:org.vaadin.addons.portallayout.portlet.Portlet.java

License:Apache License

private void delegateSizeManagement(boolean initial) {
    final Component c = getParent();
    String width = String.format("%d%s", (int) c.getWidth(), c.getWidthUnits().getSymbol());

    if (c.getWidth() >= 0 && !"100%".equals(width)) {
        c.setWidth("100%");
        getState().width = width;//w  ww .j a  va 2s  .  co m
    }

    String height = String.format("%d%s", (int) c.getHeight(), c.getHeightUnits().getSymbol());
    if (c.getHeight() >= 0 && !"100%".equals(height)) {
        c.setHeight("100%");
        getState().height = height;
    }
    getParent().beforeClientResponse(initial);
}

From source file:songstock.web.SongStockUI.java

License:Open Source License

/**
 * Shows a modal popup window with the given title and content.
 * @param title of the popup window/*from w  w w. j  a  v  a  2  s  .co  m*/
 * @param content of the popup window
 */
public void showPopupWindow(String title, Component content) {
    // Create a new popup window
    popupWindow = new Window(title);
    popupWindow.setModal(true);
    // Add content to the popup window
    popupWindow.setContent(content);
    // Set the height of the popup window
    popupWindow.setHeight(content.getHeight() + 50, content.getHeightUnits());
    // Set the width of the popup window
    popupWindow.setWidth(content.getWidth(), content.getWidthUnits());

    // Add popup window to the app's main window
    addWindow(popupWindow);
}