Example usage for com.google.gwt.user.client.ui WidgetCollection size

List of usage examples for com.google.gwt.user.client.ui WidgetCollection size

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui WidgetCollection size.

Prototype

int size

To view the source code for com.google.gwt.user.client.ui WidgetCollection size.

Click Source Link

Usage

From source file:com.google.appengine.demos.sticky.client.SurfaceView.java

License:Apache License

private void removeAllNotes() {
    final WidgetCollection kids = getChildren();
    while (kids.size() > 0) {
        remove(kids.size() - 1);//from w  ww  . j a  v a 2s  .c o m
    }
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VDragDropUtil.java

License:Apache License

/**
 * Finds a slots index in a collection of slots and captions
 * //w w w. j  a v a2 s . c o  m
 * @param children
 *            the children.
 * @param slot
 *            the slot to find.
 * @return the index of the slot
 */
public static int findSlotIndex(WidgetCollection children, Slot slot) {
    int index = -1;
    for (int i = 0; i < children.size(); i++) {
        Widget w = children.get(i);
        if (w instanceof Slot) {
            index++;
            if (w == slot) {
                break;
            }
        }
    }
    return index;
}

From source file:fi.jasoft.dragdroplayouts.client.ui.horizontallayout.VDDHorizontalLayout.java

License:Apache License

/**
 * Updates the drop details while dragging. This is needed to ensure client side criterias can
 * validate the drop location./*from  w w  w.  jav a 2 s  .  c  o  m*/
 * 
 * @param widget The container which we are hovering over
 * @param event The drag event
 */
protected void updateDropDetails(Widget widget, VDragEvent event) {
    if (widget == null) {
        return;
    }

    /*
     * The horizontal position within the cell{
     */
    event.getDropDetails().put(Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION,
            getHorizontalDropLocation(widget, event));

    /*
     * The index over which the drag is. Can be used by a client side criteria to verify that a drag
     * is over a certain index.
     */
    int index = -1;
    if (widget instanceof Slot) {
        WidgetCollection captionsAndSlots = getChildren();
        int realIndex = 0;
        for (int i = 0; i < captionsAndSlots.size(); i++) {
            Widget w = captionsAndSlots.get(i);
            if (w == widget) {
                index = realIndex;
                break;
            } else if (w instanceof Slot) {
                realIndex++;
            }
        }
    }

    event.getDropDetails().put(Constants.DROP_DETAIL_TO, index);

    // Add mouse event details
    MouseEventDetails details = MouseEventDetailsBuilder.buildMouseEventDetails(event.getCurrentGwtEvent(),
            getElement());
    event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize());
}

From source file:fi.jasoft.dragdroplayouts.client.ui.verticallayout.VDDVerticalLayout.java

License:Apache License

/**
 * Updates the drop details while dragging. This is needed to ensure client side criterias can
 * validate the drop location./*from  w w w  . ja v  a  2  s.c om*/
 * 
 * @param widget The container which we are hovering over
 * @param event The drag event
 */
protected void updateDropDetails(Widget widget, VDragEvent event) {
    if (widget == null) {
        return;
    }

    /*
     * The horizontal position within the cell{
     */
    event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION,
            getVerticalDropLocation(widget, event));

    /*
     * The index over which the drag is. Can be used by a client side criteria to verify that a drag
     * is over a certain index.
     */
    int index = -1;
    if (widget instanceof Slot) {
        WidgetCollection captionsAndSlots = getChildren();
        int realIndex = 0;
        for (int i = 0; i < captionsAndSlots.size(); i++) {
            Widget w = captionsAndSlots.get(i);
            if (w == widget) {
                index = realIndex;
                break;
            } else if (w instanceof Slot) {
                realIndex++;
            }
        }
    }

    event.getDropDetails().put(Constants.DROP_DETAIL_TO, index);

    // Add mouse event details
    MouseEventDetails details = MouseEventDetailsBuilder.buildMouseEventDetails(event.getCurrentGwtEvent(),
            getElement());
    event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize());
}

From source file:org.kuali.student.common.ui.client.util.ExportUtils.java

License:Educational Community License

/**
 * /*ww w .  j a va 2 s  .c  o  m*/
 * Retrieves the sub elements from a container widget.
 * 
 * @param currentViewWidget
 * @param viewName
 * @param sectionName
 * @return
 */
public static List<ExportElement> getDetailsForWidget(Widget currentViewWidget, String viewName,
        String sectionName) {
    List<ExportElement> childElements = new ArrayList<ExportElement>();
    if (!currentViewWidget.getParent().getElement().getStyle().getDisplay().equals("none")) {
        if (currentViewWidget instanceof Section) {
            Section widgetHasFields = (Section) currentViewWidget;
            List<FieldDescriptor> widgetFields = widgetHasFields.getFields();
            for (FieldDescriptor field : widgetFields) {
                ExportElement exportItem = createExportElement(viewName, sectionName, childElements,
                        field.getFieldElement().getFieldWidget());
                exportItem.setFieldLabel(field.getFieldLabel());
            }
        } else if (currentViewWidget instanceof KSListPanel) {
            KSListPanel ksListPanelWidget = (KSListPanel) currentViewWidget;
            WidgetCollection children = ksListPanelWidget.getChildren();
            for (int i = 0; i < children.size(); i++) {
                createExportElement(viewName, sectionName, childElements, children.get(i));
            }

        } else if (currentViewWidget instanceof ULPanel) {
            ComplexPanel complexPanel = (ComplexPanel) currentViewWidget;
            if (complexPanel.isVisible()) {
                for (int i = 0; i < complexPanel.getWidgetCount(); i++) {
                    Widget child = complexPanel.getWidget(i);
                    if (child instanceof FlowPanel) {
                        List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName,
                                sectionName);
                        if (subset != null && subset.size() > 0) {
                            //Code Changed for JIRA-9075 - SONAR Critical issues - Use get(0) with caution - 5
                            int firstExportElement = 0;
                            subset.get(firstExportElement).setPrintType(ExportElement.LIST);
                            childElements.addAll(subset);
                        }

                    } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) {
                        ExportElement exportItem = createExportElement(viewName, sectionName, childElements,
                                child);
                        exportItem.setPrintType(ExportElement.LIST);
                    }
                }
            }

        } else if (currentViewWidget instanceof ComplexPanel) {
            ComplexPanel complexPanel = (ComplexPanel) currentViewWidget;
            if (complexPanel.isVisible()) {
                for (int i = 0; i < complexPanel.getWidgetCount(); i++) {
                    Widget child = complexPanel.getWidget(i);
                    if (child instanceof FlowPanel) {
                        List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName,
                                sectionName);
                        if (subset != null && subset.size() > 0) {
                            childElements.addAll(subset);
                        }

                    } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) {
                        createExportElement(viewName, sectionName, childElements, child);
                    }
                }
            }
        } else {

            System.out.println(
                    "ExportUtils does not cater for this type..." + currentViewWidget.getClass().getName());

        }
    }
    return childElements;
}

From source file:org.kuali.student.common.ui.client.util.ExportUtils.java

License:Educational Community License

public static List<ExportElement> getDetailsForWidget(ExportElement element, Widget currentViewWidget,
        boolean setFirstFieldValue, String viewName, String sectionName) {
    List<ExportElement> childElements = new ArrayList<ExportElement>();
    if (!currentViewWidget.getParent().getElement().getStyle().getDisplay().equals("none")) {
        if (currentViewWidget instanceof Section) {
            Section widgetHasFields = (Section) currentViewWidget;
            List<FieldDescriptor> widgetFields = widgetHasFields.getFields();
            for (FieldDescriptor field : widgetFields) {
                ExportElement exportItem = createExportElement(viewName, sectionName, childElements,
                        field.getFieldElement().getFieldWidget());
                exportItem.setFieldLabel(field.getFieldLabel());
            }//from ww w. j  av  a2  s .  com
        } else if (currentViewWidget instanceof KSListPanel) {
            KSListPanel ksListPanelWidget = (KSListPanel) currentViewWidget;
            WidgetCollection children = ksListPanelWidget.getChildren();
            for (int i = 0; i < children.size(); i++) {
                if (!element.getSubset().isEmpty() && i < element.getSubset().size())
                    createExportElementOld(element.getSubset().get(i), viewName, sectionName, childElements,
                            children.get(i));
                else
                    createExportElement2(viewName, sectionName, childElements, children.get(i));
            }
        } else if (currentViewWidget instanceof ULPanel) {
            ComplexPanel complexPanel = (ComplexPanel) currentViewWidget;
            if (complexPanel.isVisible()) {
                for (int i = 0; i < complexPanel.getWidgetCount(); i++) {
                    Widget child = complexPanel.getWidget(i);
                    if (child instanceof FlowPanel) {
                        List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName,
                                sectionName);
                        if (subset != null && subset.size() > 0) {
                            //Code Changed for JIRA-9075 - SONAR Critical issues - Use get(0) with caution - 5
                            int firstExportElement = 0;
                            subset.get(firstExportElement).setPrintType(ExportElement.LIST);
                            childElements.addAll(subset);
                        }

                    } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) {
                        ExportElement exportItem = createExportElement(viewName, sectionName, childElements,
                                child);
                        exportItem.setPrintType(ExportElement.LIST);
                    }
                }
            }

        } else if (currentViewWidget instanceof ComplexPanel) {
            ComplexPanel complexPanel = (ComplexPanel) currentViewWidget;
            if (complexPanel.isVisible()) {
                for (int i = 0; i < complexPanel.getWidgetCount(); i++) {
                    Widget child = complexPanel.getWidget(i);
                    if (child instanceof FlowPanel) {
                        List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName,
                                sectionName);
                        if (subset != null && subset.size() > 0) {
                            childElements.addAll(subset);
                        }

                    } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) {
                        createExportElement(viewName, sectionName, childElements, child);
                    }
                }
            }
        } else {

            System.out.println(
                    "ExportUtils does not cater for this type..." + currentViewWidget.getClass().getName());

        }
    }
    return childElements;
}