Example usage for com.vaadin.ui CustomComponent setWidth

List of usage examples for com.vaadin.ui CustomComponent setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui CustomComponent setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.esofthead.mycollab.vaadin.ui.Depot.java

License:Open Source License

public Depot(final Label titleLbl, final AbstractOrderedLayout headerElement,
        final ComponentContainer component, final String headerWidth, final String headerLeftWidth) {
    this.setStyleName("depotComp");
    this.setMargin(new MarginInfo(true, false, false, false));
    this.header = new HorizontalLayout();
    this.header.setStyleName("depotHeader");
    this.header.setWidth(headerWidth);
    this.bodyContent = component;
    if (headerElement != null) {
        this.headerContent = headerElement;
    } else {/* w ww  .j  a  v a 2  s  . c  o m*/
        this.headerContent = new HorizontalLayout();
        this.headerContent.setSpacing(true);
        this.headerContent.setMargin(true);
        this.headerContent.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
        this.headerContent.setVisible(false);
    }

    this.headerContent.setStyleName("header-elements");
    this.headerContent.setWidthUndefined();
    this.headerContent.setSizeUndefined();

    this.addComponent(this.header);

    final HorizontalLayout headerLeft = new HorizontalLayout();
    headerLeft.setMargin(false);
    this.headerLbl = titleLbl;
    this.headerLbl.setStyleName("h2");
    this.headerLbl.setWidth("100%");
    headerLeft.addComponent(this.headerLbl);
    headerLeft.setStyleName("depot-title");
    headerLeft.addLayoutClickListener(new LayoutClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void layoutClick(final LayoutClickEvent event) {
            Depot.this.isOpenned = !Depot.this.isOpenned;
            if (Depot.this.isOpenned) {
                Depot.this.bodyContent.setVisible(true);
                Depot.this.removeStyleName("collapsed");
            } else {
                Depot.this.bodyContent.setVisible(false);
                Depot.this.addStyleName("collapsed");
            }
        }
    });
    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.addComponent(headerLeft);
    headerWrapper.setStyleName("header-wrapper");
    headerWrapper.setWidth(headerLeftWidth);
    this.header.addComponent(headerWrapper);
    this.header.setComponentAlignment(headerWrapper, Alignment.MIDDLE_LEFT);
    this.header.addComponent(this.headerContent);
    this.header.setComponentAlignment(this.headerContent, Alignment.TOP_RIGHT);
    this.header.setExpandRatio(headerWrapper, 1.0f);

    final CustomComponent customComp = new CustomComponent(this.bodyContent);
    customComp.setWidth("100%");
    this.bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.Depot.java

License:Open Source License

public Depot(String title, ComponentContainer content) {
    this.addStyleName("depotComp");
    this.setMargin(false);
    header = new MHorizontalLayout().withHeight("40px").withStyleName("depotHeader");
    bodyContent = content;/*from   w w  w.j av  a2s  .  co m*/
    bodyContent.setWidth("100%");
    headerContent = new MHorizontalLayout().withMargin(true).withFullHeight();
    headerContent.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    headerContent.setVisible(false);
    headerContent.setStyleName("header-elements");
    headerContent.setWidthUndefined();
    this.addComponent(header);

    headerLbl = new Label(title);
    final MHorizontalLayout headerLeft = new MHorizontalLayout(headerLbl).withStyleName("depot-title")
            .withAlign(headerLbl, Alignment.MIDDLE_LEFT).withFullWidth();
    headerLeft.addLayoutClickListener(new LayoutClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void layoutClick(final LayoutClickEvent event) {
            isOpened = !isOpened;
            if (isOpened) {
                bodyContent.setVisible(true);
                removeStyleName("collapsed");
            } else {
                bodyContent.setVisible(false);
                addStyleName("collapsed");
            }
        }
    });
    header.with(headerLeft, headerContent).withAlign(headerLeft, Alignment.MIDDLE_LEFT)
            .withAlign(headerContent, Alignment.MIDDLE_RIGHT).expand(headerLeft);

    final CustomComponent customComp = new CustomComponent(bodyContent);
    customComp.setWidth("100%");
    bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
}