private int getMarginSize() {
    if (marginSize != -101) {
      return marginSize;
    }

    if (widget.getParent().getOffsetHeight() != 0) {
      int previousSize = widget.getOffsetHeight();
      widget.setHeight(previousSize + "px");
      marginSize = widget.getOffsetHeight() - previousSize;
      GWT.log("set to " + marginSize);
      return marginSize;
    } else {
      return 0;
    }
  }
  @Override
  protected Widget newPositioner(DragContext context) {
    // Use two widgets so that setPixelSize() consistently affects dimensions
    // excluding positioner border in quirks and strict modes
    SimplePanel outer = new SimplePanel();
    outer.addStyleName(DragClientBundle.INSTANCE.css().positioner());

    // place off screen for border calculation
    RootPanel.get().add(outer, -500, -500);

    // Ensure IE quirks mode returns valid outer.offsetHeight, and thus valid
    // DOMUtil.getVerticalBorders(outer)
    outer.setWidget(DUMMY_LABEL_IE_QUIRKS_MODE_OFFSET_HEIGHT);

    int width = 0;
    int height = 0;
    for (Widget widget : context.selectedWidgets) {
      width = Math.max(width, widget.getOffsetWidth());
      height += widget.getOffsetHeight();
    }

    SimplePanel inner = new SimplePanel();
    inner.setPixelSize(
        width - DOMUtil.getHorizontalBorders(outer), height - DOMUtil.getVerticalBorders(outer));

    outer.setWidget(inner);

    return outer;
  }
  @Override
  public void setErrors(Set<ErrorDisplay> errors) {
    HashSet<ErrorDisplay> errorsToRemove = new HashSet<ErrorDisplay>(containedErrros);
    errorsToRemove.removeAll(errors);
    for (ErrorDisplay errorDisplay : errorsToRemove) {
      Widget widget = widgets.get(errorDisplay);
      errorsList.remove(widget);
      widgets.remove(widget);
    }

    HashSet<ErrorDisplay> errorsToAdd = new HashSet<ErrorView.ErrorDisplay>(errors);
    errorsToAdd.removeAll(containedErrros);
    String errorViewItemClass = ApplicationResources.INSTANCE.css().errorViewItemClass();
    String errorViewImageClass = ApplicationResources.INSTANCE.css().errorViewImageClass();
    for (ErrorDisplay errorDisplay : errorsToAdd) {
      SafeHtml html =
          template.errorDisplayTemplate(
              errorImageSafeUri, errorDisplay.getErrorInfo(), errorViewImageClass);
      HTML widget = new HTML(html);
      widget.setStyleName(errorViewItemClass);
      widgets.put(errorDisplay, widget);
      errorsList.add(widget);
    }
    containedErrros = new HashSet<ErrorView.ErrorDisplay>(errors);
    int height = 0;
    for (int i = 0; i < errorsList.getWidgetCount(); ++i) {
      Widget widget = errorsList.getWidget(i);
      widget.getElement().getStyle().setTop(height, Unit.PX);
      height += widget.getOffsetHeight() + 5;
    }
  }
 @Override
 public void onResize() {
   // It is possible that the SplitterPanel is removed from the DOM before the resize is called
   if (isAttached()) {
     final Widget parent = getParent();
     setPixelSize(parent.getOffsetWidth(), parent.getOffsetHeight());
     super.onResize();
   }
 }
Example #5
0
 /**
  * Show on the left of the provided widget
  *
  * @param widget
  */
 public void showWestOf(Widget widget, String text) {
   init(text);
   clearStyleDependentName();
   addStyleDependentName(EAST);
   show();
   int top = widget.getAbsoluteTop() - ((this.getOffsetHeight() - widget.getOffsetHeight()) / 2);
   int left = widget.getAbsoluteLeft() - 1;
   moveTo(top, left);
 }
 @Override
 public void onResize() {
   final Widget parent = getParent();
   if (parent != null) {
     final int width = parent.getOffsetWidth();
     final int height = parent.getOffsetHeight();
     setPixelSize(width, height);
     presenter.onResize(width, height);
     panel.setPixelSize(width, height);
     super.onResize();
   }
 }
Example #7
0
 /**
  * Show on the right of the provided widget
  *
  * @param widget
  */
 public void showEastOf(Widget widget, String text) {
   init(text);
   clearStyleDependentName();
   addStyleDependentName(WEST);
   show();
   if (this.getOffsetWidth() + widget.getOffsetWidth() + widget.getAbsoluteLeft()
       > Window.getClientWidth()) {
     showNorthOf(widget, text);
     return;
   }
   int top = widget.getAbsoluteTop() - ((this.getOffsetHeight() - widget.getOffsetHeight()) / 2);
   int left = widget.getAbsoluteLeft() + widget.getOffsetWidth() + 1;
   moveTo(top, left);
 }
Example #8
0
  /**
   * Determine if the given click was inside the boundaries of the given widget.
   *
   * @param pWidget the widget
   * @param pClickEvent the click
   * @return <code>true</code> if yes
   */
  public static boolean isInside(final Widget pWidget, final ClickEvent pClickEvent) {
    LOG.enter("isInside"); // $NON-NLS-1$

    boolean result = false;
    final int cx = pClickEvent.getClientX();
    final int cy = pClickEvent.getClientY();
    final int wleft = pWidget.getAbsoluteLeft();
    final int wtop = pWidget.getAbsoluteTop();

    if (LOG.isDetailEnabled()) {
      LOG.detail(
          "isInside", //$NON-NLS-1$
          "Click at ("
              + cx
              + ','
              + cy //$NON-NLS-1$
              + "), widget pos ("
              + wleft
              + ','
              + wtop //$NON-NLS-1$
              + "), widget dims ["
              + pWidget.getOffsetWidth()
              + ',' //$NON-NLS-1$
              + pWidget.getOffsetHeight()
              + ']');
    }
    if (cx >= wleft
        && cy >= wtop
        && cx < wleft + pWidget.getOffsetWidth()
        && cy < wtop + pWidget.getOffsetHeight()) {
      result = true;
    }

    LOG.exit("isInside", Boolean.valueOf(result)); // $NON-NLS-1$
    return result;
  }
Example #9
0
 @Override
 public void onResize(ResizeEvent event) {
   if (receptor != null) {
     Element elem = simplePanel.getElement();
     DOM.setStyleAttribute(
         elem, "left", receptor.getAbsoluteLeft() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(
         elem, "top", receptor.getAbsoluteTop() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(
         elem, "width", receptor.getOffsetWidth() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(
         elem, "height", receptor.getOffsetHeight() + "px"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(elem, "position", "absolute"); // $NON-NLS-1$ //$NON-NLS-2$
     DOM.setStyleAttribute(elem, "zIndex", "1005"); // $NON-NLS-1$ //$NON-NLS-2$
   }
 }
  @Override
  public void forceResize() {
    if (!widget.isAttached()) {
      return;
    }
    if (widget.getOffsetHeight() != getHeight()) {
      DeferredCommand.addCommand(
          new Command() {

            @Override
            public void execute() {

              widget.setHeight(getHeight() + "px");
            }
          });
    }
  }
  public FirstPersonControls(Object3D object, Widget widget) {
    super(object, widget);

    this.viewHalfX = widget.getOffsetWidth() / 2;
    this.viewHalfY = widget.getOffsetHeight() / 2;

    if (getWidget().getClass() != RootPanel.class)
      getWidget().getElement().setAttribute("tabindex", "-1");

    this.target = new Vector3();

    getWidget().addDomHandler(this, ContextMenuEvent.getType());

    getWidget().addDomHandler(this, MouseMoveEvent.getType());
    getWidget().addDomHandler(this, MouseDownEvent.getType());
    getWidget().addDomHandler(this, MouseUpEvent.getType());
    RootPanel.get().addDomHandler(this, KeyDownEvent.getType());
    RootPanel.get().addDomHandler(this, KeyUpEvent.getType());
  }
  public void dragMove() {

    Widget appointment = context.draggable.getParent();

    // calculates difference between elements position on screen
    // and how many pixels the user is trying to drag it
    int delta = context.draggable.getAbsoluteTop() - context.desiredDraggableY;

    // get the height of the widget
    int contentHeight = appointment.getOffsetHeight();

    // make sure the height of the widget is not < the minimum size
    int newHeight = Math.max(contentHeight - delta, snapSize);

    // get the 'snapped' height. basically it gets the rounded
    // intervals spanned, then multiples it by the snapSize
    int snapHeight = Math.round((float) newHeight / snapSize) * snapSize;

    appointment.setHeight(snapHeight + "px");
  }
Example #13
0
  public WidgetArea(Widget widget, Widget reference) {
    setLeft(widget.getAbsoluteLeft());
    setTop(widget.getAbsoluteTop());

    if (reference != null) {
      setLeft(
          getLeft() - reference.getAbsoluteLeft() - DOMUtil.getBorderLeft(reference.getElement()));
      setTop(getTop() - reference.getAbsoluteTop() - DOMUtil.getBorderTop(reference.getElement()));
    }
    setRight(getLeft() + widget.getOffsetWidth());
    setBottom(getTop() + widget.getOffsetHeight());

    Element elem = widget.getElement().getOffsetParent();
    Element p;

    while (elem != null && (p = elem.getOffsetParent()) != null) {
      int left = elem.getAbsoluteLeft();

      if (getLeft() < left) {
        setLeft(left);
      }

      int top = elem.getAbsoluteTop();
      if (getTop() < top) {
        setTop(top);
      }

      int bottom = top + elem.getOffsetHeight();
      if (getBottom() > bottom) {
        setBottom(bottom);
      }

      int right = left + elem.getOffsetWidth();
      if (getRight() > right) {
        setRight(right);
      }

      elem = p;
    }
  }
Example #14
0
  public void attachWidgetToMouse(
      MouseDownEvent event,
      Widget w,
      MouseMoveHandler mouseMoveHandler,
      MouseUpHandler mouseUpHandler) {
    this.mouseMoveHandler = mouseMoveHandler;
    this.mouseUpHandler = mouseUpHandler;
    if (widget == w) return;

    clearWidgetFromMouse();
    widget = w;

    if (widget != null) {
      height = w.getOffsetHeight();
      width = w.getOffsetWidth();
      offsetX = event.getRelativeX(w.getElement());
      offsetY = event.getRelativeY(w.getElement());
      parent.add(widget);
      parent.setWidgetTopHeight(widget, event.getClientY() - offsetY, Unit.PX, height, Unit.PX);
      parent.setWidgetLeftWidth(widget, event.getClientX() - offsetX, Unit.PX, width, Unit.PX);
      attachHandlers();
    }
  }
Example #15
0
 public void showAndAdapt(Widget w) {
   receptor = w;
   show(w.getAbsoluteLeft(), w.getAbsoluteTop(), w.getOffsetWidth(), w.getOffsetHeight());
 }
Example #16
0
 public void show(Widget w) {
   show(w.getAbsoluteLeft(), w.getAbsoluteTop(), w.getOffsetWidth(), w.getOffsetHeight());
 }