コード例 #1
0
 @Override
 public void forceLayout() {
   layoutCmd.cancel();
   doLayout();
   layout.layout(500);
   onResize();
 }
コード例 #2
0
 @Override
 public boolean remove(Widget w) {
   boolean removed = super.remove(w);
   if (removed) {
     layout.removeChild((Layer) w.getLayoutData());
   }
   return removed;
 }
コード例 #3
0
  @Override
  public boolean remove(Widget w) {
    boolean removed = super.remove(w);
    if (removed) {
      // Clear the center widget.
      if (w == center) {
        center = null;
      }

      LayoutData data = (LayoutData) w.getLayoutData();
      layout.removeChild(data.layer);
    }

    return removed;
  }
コード例 #4
0
  /**
   * Inserts a widget before the specified index.
   *
   * <p>By default, each child will fill the panel. To build more interesting layouts, set child
   * widgets' layout constraints using {@link #setWidgetLeftRight(Widget, double, Style.Unit,
   * double, Style.Unit)} and related methods.
   *
   * <p>Inserting a widget in this way has no effect on the DOM structure, but can be useful for
   * other panels that wrap LayoutPanel to maintain insertion order.
   *
   * @param widget the widget to be inserted
   * @param beforeIndex the index before which it will be inserted
   * @throws IndexOutOfBoundsException if <code>beforeIndex</code> is out of range
   */
  public void insert(Widget widget, int beforeIndex) {
    // Detach new child.
    widget.removeFromParent();

    // Logical attach.
    getChildren().insert(widget, beforeIndex);

    // Physical attach.
    Layer layer = layout.attachChild(widget.getElement(), widget);
    widget.setLayoutData(layer);

    // Adopt.
    adopt(widget);

    animate(0);
  }
コード例 #5
0
  /**
   * 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.
   *
   * @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);
  }
コード例 #6
0
 @Override
 protected void onUnload() {
   layout.onDetach();
 }
コード例 #7
0
 @Override
 protected void onLoad() {
   layout.onAttach();
 }
コード例 #8
0
 public void forceLayout() {
   layoutCmd.cancel();
   layout.layout();
   onResize();
 }
コード例 #9
0
 @Override
 protected void onDetach() {
   super.onDetach();
   layout.onDetach();
 }
コード例 #10
0
 protected double getCenterWidth() {
   return getElement().getClientWidth() / layout.getUnitSize(unit, false) - filledWidth;
 }
コード例 #11
0
 protected double getCenterHeight() {
   return getElement().getClientHeight() / layout.getUnitSize(unit, true) - filledHeight;
 }