Example usage for com.vaadin.ui GridLayout setMargin

List of usage examples for com.vaadin.ui GridLayout setMargin

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setMargin.

Prototype

@Override
    public void setMargin(MarginInfo marginInfo) 

Source Link

Usage

From source file:probe.com.view.body.welcomelayout.PublicationsInformationWindow.java

public PublicationsInformationWindow(List<Object[]> publicationList) {

    int height = Page.getCurrent().getBrowserWindowHeight() - 100;
    int width = Page.getCurrent().getBrowserWindowWidth() - 100;
    int columnNum = width / 250;
    width = columnNum * 250;/*from   w  w  w .  ja v  a 2  s .  c o  m*/
    VerticalLayout popupBodyWrapper = new VerticalLayout();
    popupBodyWrapper.setWidth("100%");
    popupBodyWrapper.setHeight("100%");
    VerticalLayout popupBody = new VerticalLayout();
    popupBody.setWidth((width) + "px");
    popupBody.setHeightUndefined();
    popupBody.setStyleName(Reindeer.LAYOUT_WHITE);
    popupBody.setMargin(true);
    popupBody.setSpacing(true);
    popupBodyWrapper.addComponent(popupBody);
    popupBodyWrapper.setComponentAlignment(popupBody, Alignment.TOP_CENTER);

    popupWindow = new Window() {

        @Override
        public void close() {
            popupWindow.setVisible(false);

        }

    };

    popupWindow.setContent(popupBodyWrapper);
    popupWindow.setWindowMode(WindowMode.NORMAL);

    popupWindow.setWidth((width + 22) + "px");

    popupWindow.setVisible(false);
    popupWindow.setResizable(false);
    popupWindow.setClosable(false);
    popupWindow.setStyleName(Reindeer.WINDOW_LIGHT);
    popupWindow.setModal(true);
    popupWindow.setDraggable(false);
    popupWindow.setCaption(
            "<font color='gray' style='font-weight: bold;!important'>&nbsp;&nbsp;Publication Information</font>");

    UI.getCurrent().addWindow(popupWindow);
    popupWindow.center();

    popupWindow.setCaptionAsHtml(true);
    popupWindow.setClosable(true);

    GridLayout publicationContainer = new GridLayout();
    publicationContainer.setWidth("100%");
    publicationContainer.setSpacing(true);
    publicationContainer.setMargin(true);
    popupBody.addComponent(publicationContainer);

    publicationContainer.setColumns(columnNum);
    publicationContainer.setRows(publicationList.size());

    this.addLayoutClickListener(PublicationsInformationWindow.this);
    int row = 0;
    int col = 0;

    for (Object[] obj : publicationList) {
        VerticalLayout publicationLayout = initPublicationLayout(obj);
        String btnName = "<font size=1 >" + obj[0].toString() + "</font><br/>" + obj[1].toString()
                + "<br/><font size=1 >" + obj[2].toString() + "</font><br/><font size=1 >#Proteins: "
                + obj[5].toString() /*+ "/" + obj[5].toString() + */ + "   #Peptides: "
                + obj[7].toString() /*+ "/" + obj[7].toString() +*/ + "</font>";

        PopupInfoBtn publicationBtn = new PopupInfoBtn(publicationLayout, btnName, obj[1].toString());
        publicationContainer.addComponent(publicationBtn, col++, row);
        publicationContainer.setComponentAlignment(publicationBtn, Alignment.TOP_CENTER);
        if (col >= columnNum) {
            row++;
            col = 0;

        }
    }
    height = Math.min((++row * 85) + 200, height);
    popupWindow.setHeight((height) + "px");

}