Example usage for com.vaadin.ui ComponentContainer getComponentIterator

List of usage examples for com.vaadin.ui ComponentContainer getComponentIterator

Introduction

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

Prototype

@Deprecated
public Iterator<Component> getComponentIterator();

Source Link

Document

Gets an iterator to the collection of contained components.

Usage

From source file:com.expressui.core.view.page.DashboardPage.java

License:Open Source License

private Set<ViewBean> findViewBeanComponents() {
    Set<ViewBean> viewBeans = new HashSet<ViewBean>();

    Iterator<Component> iterator = rootLayout.getComponentIterator();
    while (iterator.hasNext()) {
        Component dashboardComponent = iterator.next();
        if (dashboardComponent instanceof Panel) {
            Panel panel = (Panel) dashboardComponent;
            ComponentContainer layout = panel.getContent();
            Component component = layout.getComponentIterator().next();
            if (component instanceof ViewBean) {
                viewBeans.add((ViewBean) component);
            }/* www .  ja  va  2s  .c om*/
        }
    }

    return viewBeans;
}

From source file:nz.co.senanque.vaadinsupport.I18n.I18nCaptionHelper.java

License:Apache License

private static void switchCaption(ComponentContainer componentContainer,
        MessageSourceAccessor messageSourceAccessor) {
    String newCaption = getTranslatedCaption(componentContainer.getCaption(), messageSourceAccessor);
    if (newCaption != null) {
        componentContainer.setCaption(newCaption);
    }/*w  ww .  j a v a  2 s  . c  om*/
    Iterator<Component> it = componentContainer.getComponentIterator();
    while (it.hasNext()) {
        Component subcomponent = it.next();
        switchCaptions(subcomponent, messageSourceAccessor);
    }
}

From source file:org.abstractform.binding.vaadin.VaadinBindingFormToolkit.java

License:Apache License

@Override
public VaadinBindingFormInstance buildForm(Form form, Map<String, Object> extraObjects) {
    VaadinFormInstance delegate = (VaadinFormInstance) delegateToolKit.buildForm(form, extraObjects);
    ComponentContainer c = addValidationSummaryField(delegate.getImplementation(), false);
    VaadinBindingFormInstance<?> formInstance = new VaadinBindingFormInstanceImpl<Object>(c,
            (ComponentContainer) c.getComponentIterator().next(), delegate);
    replaceFormInstanceReferences(delegate, formInstance);
    return formInstance;
}

From source file:org.abstractform.binding.vaadin.VaadinBindingFormToolkit.java

License:Apache License

@Override
public <S> VaadinBindingFormInstance<S> buildForm(BForm<S> form, BindingToolkit bindingToolkit,
        Map<String, Object> extraObjects, boolean immediate) {
    VaadinFormInstance delegate = (VaadinFormInstance) delegateToolKit.buildForm(form, extraObjects);
    ComponentContainer c = addValidationSummaryField(delegate.getImplementation(),
            form.isValidationSummaryVisible());
    VaadinBindingFormInstanceImpl<S> instance = new VaadinBindingFormInstanceImpl<S>(c,
            (ComponentContainer) c.getComponentIterator().next(), delegate);
    bindingToolkit.bindFields(instance, form);
    replaceFormInstanceReferences(delegate, instance);
    return instance;
}

From source file:org.metawidget.vaadin.ui.layout.FormLayout.java

License:LGPL

public void layoutWidget(Component component, String elementName, Map<String, String> attributes,
        ComponentContainer container, VaadinMetawidget metawidget) {

    // Do not render empty stubs

    if (component instanceof Stub && !((Stub) component).getComponentIterator().hasNext()) {
        return;/*w  w w. ja  va  2  s  .c  o  m*/
    }

    // Fix caption

    if (component.getCaption() != null && component.getCaption().length() != 0 && mLabelSuffix != null
            && mLabelSuffix.length() != 0) {
        if (!(component instanceof Button) || component instanceof CheckBox) {
            component.setCaption(component.getCaption() + mLabelSuffix);
        }
    }

    // Add it

    com.vaadin.ui.FormLayout layout = (com.vaadin.ui.FormLayout) container.getComponentIterator().next();
    component.setWidth("100%");
    layout.addComponent(component);
}

From source file:org.metawidget.vaadin.ui.layout.HorizontalLayout.java

License:LGPL

public void layoutWidget(Component component, String elementName, Map<String, String> attributes,
        ComponentContainer container, VaadinMetawidget metawidget) {

    // Do not render empty stubs

    if (component instanceof Stub && !((Stub) component).getComponentIterator().hasNext()) {
        return;//from w  w w  . j  a  v a 2 s .c  om
    }

    // Add it

    com.vaadin.ui.HorizontalLayout layout = (com.vaadin.ui.HorizontalLayout) container.getComponentIterator()
            .next();
    layout.addComponent(component);
}

From source file:org.metawidget.vaadin.ui.layout.VerticalLayout.java

License:LGPL

public void layoutWidget(Component component, String elementName, Map<String, String> attributes,
        ComponentContainer container, VaadinMetawidget metawidget) {

    // Do not render empty stubs

    if (component instanceof Stub && !((Stub) component).getComponentIterator().hasNext()) {
        return;//from  w w  w .jav a 2 s  .c o  m
    }

    // Add it

    com.vaadin.ui.VerticalLayout layout = (com.vaadin.ui.VerticalLayout) container.getComponentIterator()
            .next();
    component.setWidth("100%");
    layout.addComponent(component);
}

From source file:org.metawidget.vaadin.ui.VaadinMetawidget.java

License:LGPL

private Component getComponent(ComponentContainer container, String name) {

    Iterator<Component> iterator = container.getComponentIterator();

    while (iterator.hasNext()) {

        AbstractComponent childComponent = (AbstractComponent) iterator.next();

        // Drill into unnamed containers

        if (childComponent.getData() == null && childComponent instanceof ComponentContainer) {
            childComponent = (AbstractComponent) getComponent((ComponentContainer) childComponent, name);

            if (childComponent != null) {
                return childComponent;
            }/*from   w  w w.  j a v  a 2  s. c o  m*/

            continue;
        }

        // Match by name

        if (name.equals(childComponent.getData())) {
            return childComponent;
        }
    }

    // Not found

    return null;
}

From source file:org.semanticsoft.vaaclipse.widgets.WorkbenchWindow.java

License:Open Source License

private void updateBounds(ComponentContainer container, Bounds currentBounds) {
    if (container instanceof BoundsinfoVerticalLayout) {
        BoundsinfoVerticalLayout bvl = (BoundsinfoVerticalLayout) container;
        bvl.setBounds(currentBounds);/*from ww  w .  jav a 2  s .  c  o m*/
    } else if (container instanceof StackWidget) {
        StackWidget bvl = (StackWidget) container;
        bvl.setBounds(currentBounds);
    }

    if (container instanceof SashWidget) {
        AbstractSplitPanel splitPanel = (AbstractSplitPanel) container;
        float splitPos = splitPanel.getSplitPosition() / 100;
        if (splitPanel instanceof HorizontalSplitPanel) {
            int firstBoundsWidth = (int) (splitPos * currentBounds.w);
            if (splitPanel.getFirstComponent() instanceof ComponentContainer) {
                Bounds leftBounds = new Bounds(currentBounds.x, currentBounds.y, firstBoundsWidth,
                        currentBounds.h);
                updateBounds((ComponentContainer) splitPanel.getFirstComponent(), leftBounds);
            }

            if (splitPanel.getSecondComponent() instanceof ComponentContainer) {
                Bounds rightBounds = new Bounds(currentBounds.x + firstBoundsWidth, currentBounds.y,
                        (int) (currentBounds.w - firstBoundsWidth), currentBounds.h);
                updateBounds((ComponentContainer) splitPanel.getSecondComponent(), rightBounds);
            }
        } else if (splitPanel instanceof VerticalSplitPanel) {
            int firstBoundsHeight = (int) (splitPos * currentBounds.h);
            if (splitPanel.getFirstComponent() instanceof ComponentContainer) {
                Bounds leftBounds = new Bounds(currentBounds.x, currentBounds.y, currentBounds.w,
                        firstBoundsHeight);
                updateBounds((ComponentContainer) splitPanel.getFirstComponent(), leftBounds);
            }

            if (splitPanel.getSecondComponent() instanceof ComponentContainer) {
                Bounds rightBounds = new Bounds(currentBounds.x, currentBounds.y + firstBoundsHeight,
                        (int) (currentBounds.w), currentBounds.h - firstBoundsHeight);
                updateBounds((ComponentContainer) splitPanel.getSecondComponent(), rightBounds);
            }
        }
    } else if (container instanceof ComponentContainer) {
        Iterator<Component> it = container.getComponentIterator();
        while (it.hasNext()) {
            Component c = it.next();
            if (c instanceof ComponentContainer) {
                updateBounds((ComponentContainer) c, currentBounds);
            }
        }
    }
}

From source file:v7cr.Review.java

License:Open Source License

public Review addVote(AccountInfo user, Date date, String comment, String vote, ComponentContainer files) {
    BSONObject v = new BasicBSONObject("c", comment).append("d", date).append("v", vote).append("by",
            user.getBSONObject());/*w  ww  . j  a  va 2s .c  o m*/
    if (files != null) {
        Iterator<Component> fi = files.getComponentIterator();
        List<BSONObject> fileData = new ArrayList<BSONObject>();
        while (fi.hasNext()) {
            TemporaryFile f = (TemporaryFile) fi.next();
            fileData.add(f.file.getBSONObject());
        }
        if (!fileData.isEmpty()) {
            v.put("files", fileData);
        }
    }
    Review r = new Review(push("v", BSONBackedObjectLoader.wrap(v, null))).updateStatus();
    return r;
}