Example usage for com.vaadin.ui AbstractLayout removeAllComponents

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

Introduction

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

Prototype

@Override
public void removeAllComponents() 

Source Link

Document

Removes all components from the container.

Usage

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void fillTagEditor(final Database database, final AbstractLayout layout, final List<String> tags,
        final boolean allowRemove) {

    layout.removeAllComponents();

    for (int i = 0; i < tags.size(); i++) {

        String tag = tags.get(i);

        HorizontalLayout hl = new HorizontalLayout();

        if (allowRemove) {
            final int index = i;
            Button b = new Button();
            b.addStyleName(ValoTheme.BUTTON_BORDERLESS);
            b.setIcon(FontAwesome.TIMES_CIRCLE);
            b.addClickListener(new ClickListener() {

                private static final long serialVersionUID = -4473258383318654850L;

                @Override//from w ww  .  ja va  2s. c o  m
                public void buttonClick(ClickEvent event) {
                    tags.remove(index);
                    fillTagEditor(database, layout, tags, allowRemove);
                }
            });
            hl.addComponent(b);
        }

        Button tagButton = tagButton(database, "dialog", tag, i);
        hl.addComponent(tagButton);
        hl.setComponentAlignment(tagButton, Alignment.MIDDLE_LEFT);

        layout.addComponent(hl);

    }

}

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//www.  j a  v a  2s. c o m
        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);
}