Example usage for com.vaadin.ui AbstractLayout addComponent

List of usage examples for com.vaadin.ui AbstractLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

This only implements the events and component parent calls.

Usage

From source file:org.semanticsoft.vaaclipse.presentation.renderers.TrimBarRenderer.java

License:Open Source License

@Override
public void processContents(MElementContainer<MUIElement> container) {
    final MTrimBar trimBar = (MTrimBar) ((MElementContainer<?>) container);
    int orientation = trimBar.getSide().getValue();
    AbstractLayout trimBarWidget = (AbstractLayout) container.getWidget();
    if (orientation == SideValue.TOP_VALUE || orientation == SideValue.BOTTOM_VALUE)
        trimBarWidget.setHeight(-1, Unit.PIXELS);
    else/*from   w w w  .j  av a2 s. c om*/
        trimBarWidget.setWidth(-1, Unit.PIXELS);

    boolean isFirst = true;
    trimBarWidget.removeAllComponents();
    for (MUIElement element : container.getChildren()) {
        if (element.isToBeRendered()) {
            ComponentContainer subToolbar = (ComponentContainer) element.getWidget();
            subToolbar.setVisible(element.isVisible());
            if (subToolbar != null) {
                if (orientation == SideValue.TOP_VALUE || orientation == SideValue.BOTTOM_VALUE)
                    subToolbar.addStyleName("horizontaltrimelement");
                else
                    subToolbar.addStyleName("verticaltrimelement");

                subToolbar.setSizeUndefined();

                trimBarWidget.addComponent(subToolbar);
                isFirst = false;
            }
        }
    }

    //---
    IEclipseContext ctx = getContext(container);
    final ExpressionContext eContext = new ExpressionContext(ctx);

    //visible when support for original trimbar elements (without contributed)
    for (final MTrimElement child : trimBar.getChildren()) {
        if (child.getVisibleWhen() != null) {
            ctx.runAndTrack(new RunAndTrack() {
                @Override
                public boolean changed(IEclipseContext context) {

                    if (!trimBar.isToBeRendered() || !trimBar.isVisible() || trimBar.getWidget() == null) {
                        return false;
                    }

                    final boolean rc = ContributionsAnalyzer.isVisible((MCoreExpression) child.getVisibleWhen(),
                            eContext);
                    execService.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            child.setToBeRendered(rc);
                        }
                    });

                    return true;
                }
            });
        }
    }

    //contributions
    ArrayList<MTrimContribution> toContribute = new ArrayList<MTrimContribution>();
    ContributionsAnalyzer.gatherTrimContributions(trimBar, app.getTrimContributions(), trimBar.getElementId(),
            toContribute, eContext);
    addTrimContributions(trimBar, toContribute, ctx, eContext);

    refreshVisibility(trimBar);
}