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

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

Introduction

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

Prototype

public Widget get(int index) 

Source Link

Document

Gets the widget at the given index.

Usage

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
 * //from w w  w . j  a  va2s . 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 ww.  j a v a 2  s .  co  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.// w  w  w.j a  v a2s.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_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.datacleaner.monitor.shared.widgets.WizardProgressBar.java

License:Open Source License

/**
 * Sets the current progress index (0-based)
 * /*from   w  ww  .  j a v a2 s.c  o m*/
 * @param stepIndex
 */
public void setProgress(final Integer stepIndex) {
    WidgetCollection children = getChildren();
    for (Widget child : children) {
        child.removeStyleName("current");
    }
    if (stepIndex != null) {
        children.get(stepIndex + 1).addStyleName("current");
    }
}

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

License:Educational Community License

/**
 * /*from  w ww  .ja v a2  s  . co  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 w  w  w.  ja  v  a2 s  .  co  m*/
        } 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;
}

From source file:rocket.widget.client.Panel.java

License:Apache License

/**
 * Removes the widget at the given slot.
 * //from   w  w w  .j a  v  a 2s .co m
 * @param index
 */
public boolean remove(final int index) {
    final WidgetCollection widgets = this.getWidgetCollection();

    final Widget widget = widgets.get(index);
    this.remove0(widget.getElement(), index);// cleanup opportunity
    this.orphan(widget);
    widgets.remove(index);

    return true;
}