Example usage for com.vaadin.ui CustomComponent CustomComponent

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

Introduction

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

Prototype

public CustomComponent(Component compositionRoot) 

Source Link

Document

Constructs a new custom component.

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 {/*from   w  ww.j a  v  a2 s .  co 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  www.ja va  2 s.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);
}

From source file:com.mymita.vaadlets.VaadletsBuilder.java

License:Apache License

private void create(final com.mymita.vaadlets.core.Component aComponent) {
    component = aComponent;/*  w  w w  .j a va  2 s  .c om*/
    if (!(aComponent instanceof com.mymita.vaadlets.core.ComponentContainer)) {
        // XXX create a dummy component container
        final VerticalLayout dummy = new VerticalLayout();
        dummy.setSizeFull();
        root = new CustomComponent(dummy);
        dummy.addComponent(createVaadinComponent(aComponent));
    } else {
        root = createVaadinComponent(aComponent);
        createChildComponents(root, (com.mymita.vaadlets.core.ComponentContainer) aComponent);
    }
    for (final Entry<String, ClickListener> cl : clickListener.entrySet()) {
        final Component component = getComponent(cl.getKey());
        if (component instanceof Button) {
            ((Button) component).addListener(cl.getValue());
        }
    }
    for (final Entry<String, Listener> cl : componentListener.entrySet()) {
        final Component component = getComponent(cl.getKey());
        if (component != null) {
            component.addListener(cl.getValue());
        }
    }
}