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

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

Introduction

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

Prototype

public void add(Widget w) 

Source Link

Document

Adds a widget to the end of this collection.

Usage

From source file:geogebra.web.gui.app.docklayout.MyDockLayoutPanel.java

License:Apache License

/**
 * Adds a widget to the specified edge of the dock. If the widget is already
 * a child of this panel, this method behaves as though
 * {@link #remove(Widget)} had already been called.
 * /*w  w w .j  a  v  a 2s. c  om*/
 * @param widget
 *            the widget to be added
 * @param direction
 *            the widget's direction in the dock
 * @param before
 *            the widget before which to insert the new child, or
 *            <code>null</code> to append
 */
protected void insert(Widget widget, Direction direction, double size, Widget before) {
    assertIsChild(before);

    // Validation.
    if (before == null) {
        assert center == null : "No widget may be added after the CENTER widget";
    } else {
        assert direction != Direction.CENTER : "A CENTER widget must always be added last";
    }

    // Detach new child.
    widget.removeFromParent();

    // Logical attach.
    WidgetCollection children = getChildren();
    if (before == null) {
        children.add(widget);
    } else {
        int index = children.indexOf(before);
        children.insert(widget, index);
    }

    if (direction == Direction.CENTER) {
        center = widget;
    }

    // Physical attach.
    Layer layer = layout.attachChild(widget.getElement(), (before != null) ? before.getElement() : null,
            widget);
    LayoutData data = new LayoutData(direction, size, layer);
    widget.setLayoutData(data);

    // Adopt.
    adopt(widget);

    // Update the layout.
    animate(0);
}

From source file:org.kaaproject.kaa.server.admin.client.layout.CustomDeckLayoutPanel.java

License:Apache License

/**
 * Insert a widget before the specified widget. If the widget is already a
 * child of this panel, this method behaves as though {@link #remove(Widget)}
 * had already been called./*from   w w  w.j  a v a 2s .c  o m*/
 *
 * @param widget the widget to be added
 * @param before the widget before which to insert the new child, or
 *          <code>null</code> to append
 */
public void insert(Widget widget, Widget before) {
    assertIsChild(before);

    // Detach new child.
    widget.removeFromParent();

    // Logical attach.
    WidgetCollection children = getChildren();
    if (before == null) {
        children.add(widget);
    } else {
        int index = children.indexOf(before);
        children.insert(widget, index);
    }

    // Physical attach.
    Layer layer = layout.attachChild(widget.getElement(), (before != null) ? before.getElement() : null,
            widget);
    setWidgetVisible(widget, layer, false);
    widget.setLayoutData(layer);

    // Adopt.
    adopt(widget);

    // Update the layout.
    animate(0);
}