Example usage for com.google.gwt.user.client.ui ComplexPanel getWidgetIndex

List of usage examples for com.google.gwt.user.client.ui ComplexPanel getWidgetIndex

Introduction

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

Prototype

public int getWidgetIndex(Widget child) 

Source Link

Usage

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void replace(Widget current, Widget newWidget, Panel parent) {
    if (parent == null) {
        parent = (Panel) current.getParent();
    }/*  w ww.  ja v a  2 s.com*/
    if (current == null || current.getParent() != parent) {
        parent.add(newWidget);
        return;
    }
    if (parent instanceof SimplePanel) {
        ((SimplePanel) parent).setWidget(newWidget);
        return;
    }
    ComplexPanel cp = (ComplexPanel) parent;
    int index = cp.getWidgetIndex(current);
    cp.remove(index);
    if (cp instanceof FlowPanel) {
        FlowPanel fp = (FlowPanel) cp;
        fp.insert(newWidget, index);
    }
}

From source file:com.goodow.web.ui.client.shell.one.ActivityPanel.java

License:Apache License

@Override
public void setWidget(final IsWidget w) {
    if (w == null) {
        setVisible(false);/*from ww w  .j a  v  a 2s.  c  o  m*/
    } else {
        if (!shell.get().isAttached()) {
            // RootLayoutPanel.get().clear();
            RootPanel.get().clear();
            RootPanel.get().add(shell.get());
        }
        setVisible(true);
    }
    super.setWidget(w);

    if (side != null && getParent() instanceof ComplexPanel) {
        ComplexPanel parent = (ComplexPanel) getParent();
        int index = parent.getWidgetIndex(this);

        if (parent.getWidgetCount() > index + 1) {
            Widget centerWidget = parent.getWidget(index + 1);

            int margin = w == null ? 10 : getOffsetWidth();

            if ("left".equals(side)) {
                centerWidget.getElement().getStyle().setMarginLeft(margin, Unit.PX);
            } else if ("right".equals(side)) {
                centerWidget.getElement().getStyle().setMarginRight(margin, Unit.PX);
            }
        }
    }
}

From source file:org.uberfire.client.views.pfly.menu.WorkbenchMenuStandardNavBarView.java

License:Apache License

private void addContextMenusToContainer(final String menuItemId, final ComplexPanel menuItemWidget) {
    final ComplexPanel contextContainer = getContextContainerWidgetMap().get(menuItemId);
    final ComplexPanel container = menuItemWidget.getParent().getParent() instanceof ListDropDown
            ? (ListDropDown) menuItemWidget.getParent().getParent()
            : menuItemWidget;/*from ww  w.j  a v a  2  s  .  c  o  m*/
    if (contextContainer != null && container.getWidgetIndex(contextContainer) == -1) {
        container.add(contextContainer);
    }
}