/**
   * Binds the tool tip to the target widget. Allows a tool tip to switch the target widget.
   *
   * @param target the target widget
   */
  public void initTarget(final Widget target) {
    if (this.target != null) {
      handlerRegistration.removeHandler();
    }

    this.target = target;

    if (target != null) {
      Handler handler = new Handler();
      handlerRegistration = new GroupingHandlerRegistration();
      handlerRegistration.add(target.addDomHandler(handler, MouseOverEvent.getType()));
      handlerRegistration.add(target.addDomHandler(handler, MouseOutEvent.getType()));
      handlerRegistration.add(target.addDomHandler(handler, MouseMoveEvent.getType()));
      handlerRegistration.add(target.addHandler(handler, HideEvent.getType()));
      handlerRegistration.add(target.addHandler(handler, AttachEvent.getType()));
    }
  }
 @Override
 public void onAttachOrDetach(AttachEvent event) {
   if (event.isAttached()) {
     textField
         .getElement()
         .getParentElement()
         .insertAfter(resetButtonElement, textField.getElement());
     updateResetButtonVisibility();
     addResetButtonClickListener(resetButtonElement);
   } else {
     Element parentElement = resetButtonElement.getParentElement();
     if (parentElement != null) {
       parentElement.removeChild(resetButtonElement);
     }
     removeResetButtonClickListener(resetButtonElement);
   }
 }
 @Override
 public void onAttachOrDetach(AttachEvent event) {
   if (!event.isAttached()) {
     hide();
   }
 }