Example usage for com.google.gwt.user.client.ui Widget getParent

List of usage examples for com.google.gwt.user.client.ui Widget getParent

Introduction

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

Prototype

public Widget getParent() 

Source Link

Document

Gets this widget's parent panel.

Usage

From source file:com.qualogy.qafe.mgwt.client.ui.component.ComponentHelper.java

License:Apache License

public static HandlerRegistration registerScroll(Widget widget) {
    if (widget == null) {
        return null;
    }/*from  w  w  w.j a  v  a2s  .  com*/
    final Widget source = widget;
    HandlerRegistration handlerRegistration = null;
    while (widget.getParent() != null) {
        widget = widget.getParent();
        if (widget instanceof ScrollPanel) {
            ScrollPanel scrollPanel = (ScrollPanel) widget;
            handlerRegistration = (HandlerRegistration) scrollPanel
                    .addScrollEndHandler(new ScrollEndEvent.Handler() {
                        @Override
                        public void onScrollEnd(ScrollEndEvent event) {
                            if (isScrolledToBottom(source)) {
                                fireScrollBottom(source);
                            }
                        }
                    });
            break;
        }
    }
    return handlerRegistration;
}

From source file:com.qualogy.qafe.mgwt.client.ui.component.ComponentHelper.java

License:Apache License

public static void refreshScroll(Widget widget) {
    // After setting data which results in a long list, 
    // the ScrollPanel needs to be refreshed for recalculating the size of the child to scroll,
    // otherwise the scrolling will not work properly, this is a workaround
    // see https://groups.google.com/group/mgwt/tree/browse_frm/month/2012-5/b47fc71b23b2b40e?rnum=201&_done=/group/mgwt/browse_frm/month/2012-5?scoring%3Dd%26start%3D0%26sa%3DN%26fwc%3D1%26&scoring=d&pli=1
    if (widget == null) {
        return;/*w w w  .  j  av a2  s .co  m*/
    }
    while (widget.getParent() != null) {
        widget = widget.getParent();
        if (widget instanceof ScrollPanel) {
            ScrollPanel scrollPanel = (ScrollPanel) widget;
            scrollPanel.refresh();
            return;
        }
    }
}

From source file:com.qualogy.qafe.mgwt.client.ui.component.QTileList.java

License:Apache License

private void updateSelectedIndex(Widget source) {
    if (cellWidgetModels.containsKey(source)) {
        Object model = cellWidgetModels.get(source);
        selectedIndex = models.indexOf(model);
    } else {/*from  ww w .  ja  v a 2s  .c o  m*/
        Widget tile = source;
        while ((tile != null) && (tile.getParent() != this)) {
            tile = tile.getParent();
        }
        if (tile != source) {
            updateSelectedIndex(tile);
        }
    }
}

From source file:com.qualogy.qafe.mgwt.client.vo.functions.execute.FocusExecute.java

License:Apache License

private void handleParentVisibility(Widget widget) {
    if (widget instanceof IsStackable) {
        IsStackable stackable = (IsStackable) widget;
        stackable.setSelected();//from   w  ww.  j  a  v a  2  s .co  m
    } else if (widget != null) {
        handleParentVisibility(widget.getParent());
    }
}

From source file:com.qualogy.qafe.mgwt.client.vo.functions.execute.SetPanelExecute.java

License:Apache License

private void setPanel(SetPanelGVO setPanelGVO, WindowActivity activity) {
    WindowPlace windowPlace = activity.getPlace();
    String context = windowPlace.getContext();
    String windowId = windowPlace.getId();
    String panelRefId = setPanelGVO.getTarget();
    String panelRefKey = activity.getClientFactory().generateComponentKey(panelRefId, windowId, context);
    List<UIObject> widgets = activity.getClientFactory().getComponentById(panelRefKey);
    if ((widgets == null) || (widgets.size() == 0)) {
        return;/* w w  w .  j  av a  2 s .c  om*/
    }
    UIObject widget = widgets.get(0);
    if (!(widget instanceof HasWidgets)) {
        return;
    }
    HasWidgets panelRef = (HasWidgets) widget;

    ComponentGVO definitionComponentGVO = setPanelGVO.getSrc();
    String viewKey = activity.getClientFactory().generateViewKey(windowId, context);
    activity.getClientFactory().removeComponents(viewKey, panelRefId);
    UIObject definitionComponent = AnyComponentRenderer.getInstance().render(definitionComponentGVO, panelRefId,
            context, windowId, context, activity);
    if (definitionComponent instanceof Widget) {
        panelRef.clear();
        panelRef.add((Widget) definitionComponent);

        if (panelRef instanceof Widget) {
            Widget parentWidget = ((Widget) panelRef).getParent();
            while (parentWidget != null) {
                if (parentWidget instanceof ScrollPanel) {
                    ScrollPanel scrollPanel = (ScrollPanel) parentWidget;
                    scrollPanel.refresh();
                    break;
                }
                parentWidget = parentWidget.getParent();
            }
        }

        // Register the events if it is not coming from the rendering process (PanelRefRenderer),
        // because the events will be registered when the rendering process is done
        if (setPanelGVO.getSenderId() != null) {
            Map<UIObject, ComponentGVO> ownerComponents = activity.getClientFactory().getComponents(viewKey,
                    panelRefId);
            registerEvents(ownerComponents, windowId, context, activity);
        }
    }
}

From source file:com.risevision.ui.client.presentation.PresentationLayoutWidget.java

License:Open Source License

private void setWidgetPixelPosition(Widget placeholderWidget, PlaceholderInfo placeholder, int offset) {
    //      if (placeholderWidget.getParent() != null) {
    //         DOM.setStyleAttribute(placeholderWidget.getElement(), "position", "absolute");
    //         DOM.setStyleAttribute(placeholderWidget.getElement(), "left", (placeholder.getLeft() + offset) + placeholder.getLeftUnits());
    //         DOM.setStyleAttribute(placeholderWidget.getElement(), "top", (placeholder.getTop() + offset) + placeholder.getTopUnits());
    //      }/*ww w. j a  va 2 s.  co m*/

    int top = getPixelSize(placeholder.getTop(), height, placeholder.getTopUnits());
    int left = getPixelSize(placeholder.getLeft(), width, placeholder.getLeftUnits());

    if (placeholderWidget.getParent() != null) {
        AbsolutePanel parent = (AbsolutePanel) placeholderWidget.getParent();

        parent.setWidgetPosition(placeholderWidget, left + offset, top + offset);
    }
}

From source file:com.ritchey.client.view.CellPanel.java

License:Apache License

Element getWidgetTd(Widget w) {
    if (w.getParent() != this) {
        return null;
    }/* w w w .  ja  v a2 s.c o m*/
    return DOM.getParent(w.getElement());
}

From source file:com.ritchey.client.view.DockPanel.java

License:Apache License

/**
 * Gets the layout direction of the given child widget.
 *
 * @param w the widget to be queried/* ww  w . j ava  2 s . co  m*/
 * @return the widget's layout direction, or <code>null</code> if it is not
 *         a child of this panel
 */
public DockLayoutConstant getWidgetDirection(Widget w) {
    if (w.getParent() != this) {
        return null;
    }
    return ((LayoutData) w.getLayoutData()).direction;
}

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

License:sencha.com license

@Override
public boolean remove(Widget child) {
    // Validate./*w  w  w. j a  va  2 s.  com*/
    if (child.getParent() != this) {
        return false;
    }
    if (!fireCancellableEvent(new BeforeRemoveEvent(child))) {
        return false;
    }
    // Orphan.
    try {
        orphan(child);
    } finally {
        // Physical detach.
        doPhysicalDetach(child);

        // Logical detach.
        getChildren().remove(child);

        widgetMap.remove(child).removeHandler();

        onRemove(child);
    }

    fireEvent(new RemoveEvent(child));
    return true;
}

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

License:sencha.com license

protected int adjustIndex(Widget child, int beforeIndex) {
    checkIndexBoundsForInsertion(beforeIndex);

    // Check to see if this widget is already a direct child.
    if (child.getParent() == this) {
        // If the Widget's previous position was left of the desired new
        // position
        // shift the desired position left to reflect the removal
        int idx = getWidgetIndex(child);
        if (idx < beforeIndex) {
            beforeIndex--;/*from   w  w  w.  j ava2 s  .c om*/
        }
    }

    return beforeIndex;
}