Example usage for com.google.gwt.user.client.ui IndexedPanel getWidget

List of usage examples for com.google.gwt.user.client.ui IndexedPanel getWidget

Introduction

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

Prototype

Widget getWidget(int index);

Source Link

Document

Gets the child widget at the specified index.

Usage

From source file:cc.alcina.framework.gwt.client.widget.SelectWithSearch.java

License:Apache License

@Override
public boolean filter(String filterText) {
    selectableNavigation.clear();//from   www  .  ja  va2 s. c  o m
    if (filterText == null) {
        filterText = lastFilterText;
    } else {
        lastFilterText = filterText;
    }
    if (isUseCellList()) {
        updateItemsCellList(filterText, (HasWidgets) itemHolder);
        return false;
    }
    filterText = filterText.toLowerCase();
    HashSet okChar = new HashSet<String>();
    boolean b = false;
    for (Label l : groupCaptions) {
        l.setVisible(filterText.length() == 0);
    }
    IndexedPanel itemHolder = itemHolderAsIndexedPanel();
    for (int i = 0; i < itemHolder.getWidgetCount(); i++) {
        Widget widget = itemHolder.getWidget(i);
        if (widget instanceof VisualFilterable) {
            VisualFilterable td = (VisualFilterable) widget;
            boolean r = td.filter(filterText);
            b |= td.filter(filterText);
        }
    }
    return b;
}

From source file:com.allen_sauer.gwt.dnd.client.util.DOMUtil.java

License:Apache License

/**
 * Find child widget intersection at the provided location using the provided comparator strategy.
 * //  w  w  w. j a v  a2  s  .c  o m
 * TODO Change IndexedPanel -> InsertPanel
 * 
 * @param parent the parent widget which contains the children to be compared
 * @param location the location of the intersection
 * @param comparator the comparator strategy
 * @return the index of the matching child
 */
public static int findIntersect(IndexedPanel parent, Location location, LocationWidgetComparator comparator) {
    int widgetCount = parent.getWidgetCount();

    // short circuit in case dropTarget has no children
    if (widgetCount == 0) {
        return 0;
    }

    // use the first widget as a proxy for parent's direction
    boolean rtl = isRtl(parent.getWidget(0));

    if (DEBUG) {
        for (int i = 0; i < widgetCount; i++) {
            debugWidgetWithColor(parent, i, "white");
        }
    }

    // binary search over range of widgets to find intersection
    int low = 0;
    int high = widgetCount;

    while (true) {
        int mid = (low + high) / 2;
        assert mid >= low;
        assert mid < high;
        Widget widget = parent.getWidget(mid);
        WidgetArea midArea = new WidgetArea(widget, null);
        if (mid == low) {
            if (mid == 0) {
                if (comparator.locationIndicatesIndexFollowingWidget(midArea, location)) {
                    debugWidgetWithColor(parent, high, "green");
                    return high;
                } else {
                    debugWidgetWithColor(parent, mid, "green");
                    return mid;
                }
            } else {
                debugWidgetWithColor(parent, high, "green");
                return high;
            }
        }
        if (midArea.getBottom() < location.getTop()) {
            debugWidgetWithColor(parent, mid, "blue");
            low = mid;
        } else if (midArea.getTop() > location.getTop()) {
            debugWidgetWithColor(parent, mid, "red");
            high = mid;
        } else if (midArea.getRight() < location.getLeft()) {
            debugWidgetWithColor(parent, mid, "blue");
            if (rtl) {
                high = mid;
            } else {
                low = mid;
            }
        } else if (midArea.getLeft() > location.getLeft()) {
            debugWidgetWithColor(parent, mid, "red");
            if (rtl) {
                low = mid;
            } else {
                high = mid;
            }
        } else {
            if (comparator.locationIndicatesIndexFollowingWidget(midArea, location)) {
                debugWidgetWithColor(parent, mid + 1, "green");
                return mid + 1;
            } else {
                debugWidgetWithColor(parent, mid, "green");
                return mid;
            }
        }
    }
}

From source file:com.allen_sauer.gwt.dnd.client.util.DOMUtil.java

License:Apache License

/**
 * TODO Change IndexedPanel -> InsertPanel
 *//*from   ww w.j  a v  a 2  s.com*/
private static void debugWidgetWithColor(IndexedPanel parent, int index, String color) {
    if (DEBUG) {
        if (index >= parent.getWidgetCount()) {
            debugWidgetWithColor(parent.getWidget(parent.getWidgetCount() - 1), color);
        } else {
            debugWidgetWithColor(parent.getWidget(index), color);
        }
    }
}

From source file:com.sencha.gxt.widget.core.client.container.ResizeContainer.java

License:sencha.com license

protected void forceLayoutOnChildren(IndexedPanel widgets) {
    for (int index = 0, len = widgets.getWidgetCount(); index < len; index++) {
        Widget w = widgets.getWidget(index);
        if (w instanceof HasLayout) {
            ((HasLayout) w).forceLayout();
        } else if (w instanceof HasWidgets && isWidgetVisible(w)) {
            forceLayoutOnChildren((HasWidgets) w);
        } else if (w instanceof IndexedPanel && isWidgetVisible(w)) {
            forceLayoutOnChildren((IndexedPanel) w);
        }//  w ww  . j  a v  a2s  . c  o m
    }
}

From source file:org.activityinfo.ui.client.component.formdesigner.FormSavedGuard.java

License:Open Source License

public static FormSavedGuard getGuard(Widget widget) {
    if (widget instanceof FormSavedGuard.HasSavedGuard) {
        return (FormSavedGuard) ((HasSavedGuard) widget).getSavedGuard();
    }// w  w w  .ja va 2s.  co m
    if (widget instanceof HasOneWidget) {
        return getGuard(((HasOneWidget) widget).getWidget());
    } else if (widget instanceof IndexedPanel) {
        IndexedPanel indexedPanel = (IndexedPanel) widget;
        for (int i = 0; i < indexedPanel.getWidgetCount(); i++) {
            Widget w = indexedPanel.getWidget(i);
            FormSavedGuard guard = getGuard(w);
            if (guard != null) {
                return guard;
            }
        }
    }
    return null;
}

From source file:org.activityinfo.ui.client.component.formdesigner.FormSavedGuard.java

License:Open Source License

/**
 * @return true HasNavigationCallback was found, otherwise false
 *///from www .  j a va2 s .co  m
public static boolean callNavigationCallback(Widget widget, NavigationCallback callback) {
    if (widget instanceof HasNavigationCallback) {
        ((HasNavigationCallback) widget).navigate(callback);
        return true;
    }
    if (widget instanceof HasOneWidget) {
        if (callNavigationCallback(((HasOneWidget) widget).getWidget(), callback)) {
            return true;
        }
    } else if (widget instanceof IndexedPanel) {
        IndexedPanel indexedPanel = (IndexedPanel) widget;
        for (int i = 0; i < indexedPanel.getWidgetCount(); i++) {
            Widget w = indexedPanel.getWidget(i);
            if (callNavigationCallback(w, callback)) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.obiba.opal.web.gwt.app.client.ui.CloseableList.java

License:Open Source License

private String getItemText(IndexedPanel item) {
    Widget label = item.getWidget(0);
    return ((HasText) label).getText();
}

From source file:org.obiba.opal.web.gwt.app.client.ui.PropertiesTable.java

License:Open Source License

@Override
public void add(Widget child) {
    if (child instanceof IndexedPanel) {
        IndexedPanel children = (IndexedPanel) child;
        int column = 0;
        int span = 1;
        if (child instanceof PropertyPanel) {
            column = ((PropertyPanel) child).getColumn();
            span = ((PropertyPanel) child).getSpan();
        }// w w  w  .ja  v  a  2  s. com
        if (children.getWidgetCount() != 2) {
            throw new IllegalArgumentException(
                    "PropertiesGrid expects a pair of key/value widgets at row " + innerTable.getRowCount());
        }
        addProperty(children.getWidget(0), children.getWidget(1), column, span);
    } else {
        throw new IllegalArgumentException("PropertiesGrid expects child widgets being IndexedPanels");
    }
}

From source file:org.vaadin.sasha.portallayout.client.dnd.util.DOMUtil.java

License:Apache License

/**
 * Find child widget intersection at the provided location using the
 * provided comparator strategy. TODO Handle LTR case for Bidi TODO Change
 * IndexedPanel -> InsertPanel// w  w w. j  ava 2s  .co m
 * 
 * @param parent
 *            the parent widget which contains the children to be compared
 * @param location
 *            the location of the intersection
 * @param comparator
 *            the comparator strategy
 * @return the index of the matching child
 */
public static int findIntersect(IndexedPanel parent, Location location, LocationWidgetComparator comparator) {
    int widgetCount = parent.getWidgetCount();

    // short circuit in case dropTarget has no children
    if (widgetCount == 0) {
        return 0;
    }

    // binary search over range of widgets to find intersection
    int low = 0;
    int high = widgetCount;

    while (true) {
        int mid = (low + high) / 2;
        assert mid >= low;
        assert mid < high;
        Widget widget = parent.getWidget(mid);
        WidgetArea midArea = new WidgetArea(widget, null);
        if (mid == low) {
            if (mid == 0) {
                return (comparator.locationIndicatesIndexFollowingWidget(midArea, location)) ? high : mid;
            } else {
                return high;
            }
        }
        if (midArea.getBottom() < location.getTop()) {
            low = mid;
        } else if (midArea.getTop() > location.getTop()) {
            high = mid;
        } else if (midArea.getRight() < location.getLeft()) {
            low = mid;
        } else if (midArea.getLeft() > location.getLeft()) {
            high = mid;
        } else {
            return (comparator.locationIndicatesIndexFollowingWidget(midArea, location)) ? mid + 1 : mid;
        }
    }
}

From source file:org.vaadin.sasha.portallayout.client.dnd.util.DOMUtil.java

License:Apache License

/**
 * TODO Change IndexedPanel -> InsertPanel
 *///from   ww w .j  ava2 s .c  o  m
@SuppressWarnings("unused")
private static void debugWidgetWithColor(IndexedPanel parent, int index, String color) {
    if (DEBUG) {
        if (index >= parent.getWidgetCount()) {
            debugWidgetWithColor(parent.getWidget(parent.getWidgetCount() - 1), color);
        } else {
            debugWidgetWithColor(parent.getWidget(index), color);
        }
    }
}