Ejemplo n.º 1
0
  public String getInnerHTML() {
    // if this canvas is being redrawn, detach underlying gwt widget so that onDraw()
    // can correctly reassociate it with container div
    if (widget.isAttached()) widget.removeFromParent();

    return "<DIV STYLE='width:100%;height:100%' ID=" + this.getID() + "_widget></DIV>";
  }
Ejemplo n.º 2
0
  @Override
  public void setWidget(final Widget w) {
    // Validate
    if (w == widget) {
      return;
    }

    // Detach new child
    if (w != null) {
      w.removeFromParent();
    }

    // Remove old child
    if (widget != null) {
      remove(widget);
    }

    // Logical attach, but don't physical attach; done by jquery.
    widget = w;
    if (widget == null) {
      return;
    }

    // Bind jquery events
    bindJavaScriptEvents(widget.getElement());

    // When we attach it, configure the tooltip
    widget.addAttachHandler(
        new AttachEvent.Handler() {
          @Override
          public void onAttachOrDetach(final AttachEvent event) {
            reconfigure();
          }
        });
  }
Ejemplo n.º 3
0
 public void setSecondWidget(Widget aSecondWidget) {
   if (secondWidget != aSecondWidget) {
     if (secondWidget != null) secondWidget.removeFromParent();
     secondWidget = aSecondWidget;
     if (secondWidget != null) {
       add(secondWidget);
     }
   }
 }
 @Override
 public void reset() {
   Preconditions.checkState(this.listener != null);
   this.listener = null;
   avatar.setSrc(null);
   name.setInnerText(null);
   address.setInnerText(null);
   for (Widget child : self.getChildren()) {
     child.removeFromParent();
   }
 }
Ejemplo n.º 5
0
 public void setFirstWidget(Widget aFirstWidget) {
   if (firstWidget != aFirstWidget) {
     if (firstWidget != null) firstWidget.removeFromParent();
     firstWidget = aFirstWidget;
     if (firstWidget != null) {
       if (orientation == HORIZONTAL_SPLIT) {
         addWest(firstWidget, dividerLocation);
       } else addNorth(firstWidget, dividerLocation);
     }
   }
 }
Ejemplo n.º 6
0
 public void setOrientation(int aValue) {
   if (orientation != aValue) {
     orientation = aValue;
     if (firstWidget != null) {
       firstWidget.removeFromParent();
       if (orientation == HORIZONTAL_SPLIT) {
         addWest(firstWidget, dividerLocation);
       } else {
         addNorth(firstWidget, dividerLocation);
       }
     }
   }
 }
  /** Clear the chip items on the autocomplete box */
  public void clear() {
    itemBox.setValue("");

    Collection<MaterialChip> values = suggestionMap.values();
    for (MaterialChip chip : values) {
      Widget parent = chip.getParent();
      if (parent instanceof ListItem) {
        parent.removeFromParent();
      }
    }
    suggestionMap.clear();

    clearErrorOrSuccess();
  }
Ejemplo n.º 8
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);
  }