Example usage for com.vaadin.ui HasComponents iterator

List of usage examples for com.vaadin.ui HasComponents iterator

Introduction

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

Prototype

@Override
public Iterator<Component> iterator();

Source Link

Document

Gets an iterator to the collection of contained components.

Usage

From source file:annis.libgui.IDGenerator.java

License:Apache License

public static void assignIDForEachField(HasComponents parent) {
    if (parent != null) {
        Iterator<Component> itComponents = parent.iterator();
        while (itComponents.hasNext()) {
            Component c = itComponents.next();
            assignIDForField(parent, c);
        }// w  w  w. j  av a  2s .c  om
    }
}

From source file:annis.libgui.IDGenerator.java

License:Apache License

private static boolean childHasID(HasComponents parent, String id) {
    if (parent != null && id != null) {
        Iterator<Component> itChildren = parent.iterator();
        while (itChildren.hasNext()) {
            Component child = itChildren.next();
            if (id.equals(child.getId())) {
                return true;
            }//  www.j  a va 2  s.c  o m
        }
    }
    return false;
}

From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDUtil.java

License:Apache License

public static void onBeforeClientResponse(HasComponents layout, DragAndDropAwareState state) {
    DDLayoutState dragAndDropState = state.getDragAndDropState();
    Iterator<Component> componentIterator = layout.iterator();

    dragAndDropState.draggable = new ArrayList<>();
    dragAndDropState.referenceImageComponents = new HashMap<>();
    dragAndDropState.nonGrabbable = new ArrayList<>();
    dragAndDropState.dragCaptions = new HashMap<>();

    if (layout instanceof AbstractClientConnector) {
        for (DragCaptionInfo dci : dragAndDropState.dragCaptions.values()) {
            if (dci.iconKey != null) {
                ((AbstractClientConnector) layout).setConnectorResource(dci.iconKey, null);
            }// ww w. j  a v  a2  s .  c o m
        }
    }

    KeyMapper<Resource> keyMapper = new KeyMapper<>();

    while (componentIterator.hasNext()) {
        Component c = componentIterator.next();

        if (layout instanceof DragFilterSupport
                && ((DragFilterSupport) layout).getDragFilter().isDraggable(c)) {
            dragAndDropState.draggable.add(c);
        }

        if (layout instanceof DragGrabFilterSupport) {
            DragGrabFilter dragGrabFilter = ((DragGrabFilterSupport) layout).getDragGrabFilter();
            if (dragGrabFilter != null) {
                addNonGrabbedComponents(dragAndDropState.nonGrabbable, c, dragGrabFilter);
            }
        }

        if (layout instanceof HasDragCaptionProvider) {
            DragCaptionProvider dragCaptionProvider = ((HasDragCaptionProvider) layout)
                    .getDragCaptionProvider();

            if (dragCaptionProvider != null) {
                DragCaption dragCaption = dragCaptionProvider.getDragCaption(c);

                if (dragCaption != null) {
                    String dragIconKey = null;
                    if (dragCaption.getIcon() != null && layout instanceof AbstractClientConnector) {
                        dragIconKey = keyMapper.key(dragCaption.getIcon());
                        ((AbstractClientConnector) layout).setConnectorResource(dragIconKey,
                                dragCaption.getIcon());
                    }

                    DragCaptionInfo dci = new DragCaptionInfo();
                    dci.caption = dragCaption.getCaption();
                    dci.contentMode = dragCaption.getContentMode();
                    dci.iconKey = dragIconKey;

                    dragAndDropState.dragCaptions.put(c, dci);
                }
            }
        }

        if (layout instanceof DragImageReferenceSupport) {
            DragImageProvider provider = ((DragImageReferenceSupport) layout).getDragImageProvider();
            if (provider != null) {
                Component dragImage = provider.getDragImage(c);
                if (dragImage != null) {
                    dragAndDropState.referenceImageComponents.put(c, dragImage);
                }
            }
        }
    }
}

From source file:com.profitsoftware.vaadin.query.matcher.MatchFirstChild.java

License:Apache License

public boolean match(Component component) {
    if (!matcher.match(component)) {
        return false;
    }/*from w  w  w. j  av a  2s  . co  m*/
    Component parent = component.getParent();
    if (parent == null) {
        return true;
    }
    if (parent instanceof HasComponents) {
        HasComponents parentComponents = (HasComponents) parent;
        Iterator<Component> i = parentComponents.iterator();
        if (i.hasNext() && i.next() == component) {
            return true;
        }
    }
    return false;
}

From source file:com.profitsoftware.vaadin.query.matcher.MatchSibling.java

License:Apache License

public boolean match(Component component) {
    Component parent = component.getParent();
    if (parent == null) {
        return false;
    }/* w w  w  .  j  a  v a  2 s.  co  m*/
    if (parent instanceof HasComponents) {
        HasComponents components = (HasComponents) parent;
        Iterator<Component> i = components.iterator();
        Component previous = null;
        while (i.hasNext()) {
            Component next = i.next();
            if (next == component) {
                return matcher.match(previous);
            }
            previous = next;
        }
    }
    return false;
}

From source file:edu.cornell.qatarmed.planrnaseq.AnnotateRNAseqSQL.java

public Component findById(HasComponents root, String id) {
    System.out.println("findById called on " + root);

    Iterator<Component> iterate = root.iterator();
    while (iterate.hasNext()) {
        Component c = iterate.next();
        if (id.equals(c.getId())) {
            return c;
        }/*from   w  w  w. j ava2 s .c om*/
        if (c instanceof HasComponents) {
            Component cc = findById((HasComponents) c, id);
            if (cc != null) {
                return cc;
            }
        }
    }

    return null;
}

From source file:edu.cornell.qatarmed.planrnaseq.BrowseAndAnnotate.java

public Component findById(HasComponents root, String id) {
    // System.out.println("findById called on " + root);

    Iterator<Component> iterate = root.iterator();
    while (iterate.hasNext()) {
        Component c = iterate.next();
        if (id.equals(c.getId())) {
            return c;
        }//w ww. j a  va 2 s  . c om
        if (c instanceof HasComponents) {
            Component cc = findById((HasComponents) c, id);
            if (cc != null) {
                return cc;
            }
        }
    }

    return null;
}

From source file:info.magnolia.ui.form.field.AbstractCustomMultiField.java

License:Open Source License

/**
 * Utility method that return a list of Fields embedded into a root custom field.
 *
 * @param root//from   w ww .ja  v  a  2 s.  c  o  m
 * @param onlyValid if set to true, return only the isValid() fields.
 */
@SuppressWarnings("unchecked")
protected List<AbstractField<T>> getFields(HasComponents root, boolean onlyValid) {
    Iterator<Component> it = root.iterator();
    List<AbstractField<T>> fields = new ArrayList<AbstractField<T>>();
    while (it.hasNext()) {
        Component c = it.next();
        if (c instanceof AbstractField) {
            if (!onlyValid || (onlyValid && ((AbstractField<T>) c).isValid())) {
                fields.add((AbstractField<T>) c);
            }
        } else if (c instanceof HasComponents) {
            fields.addAll(getFields((HasComponents) c, onlyValid));
        }
    }
    return fields;
}

From source file:info.magnolia.ui.mediaeditor.field.image.ImageMediaField.java

License:Open Source License

private void doScaleToActual(HasComponents hc) {
    Iterator<Component> it = hc.iterator();
    while (it.hasNext()) {
        Component c = it.next();//from   www  . j a  v  a2s . c  o m
        if (c instanceof Image) {
            c.removeStyleName("scale-to-fit");
        } else if (c instanceof HasComponents) {
            doScaleToActual((HasComponents) c);
        }
    }
}

From source file:info.magnolia.ui.mediaeditor.field.image.ImageMediaField.java

License:Open Source License

private void doScaleToFit(HasComponents hc) {
    Iterator<Component> it = hc.iterator();
    while (it.hasNext()) {
        Component c = it.next();//from  ww w .j a v a  2 s  .c  o  m
        if (c instanceof Image) {
            c.addStyleName("scale-to-fit");
        } else if (c instanceof HasComponents) {
            doScaleToFit((HasComponents) c);
        }
    }
}