Example usage for com.google.gwt.user.client.ui Widget getOffsetWidth

List of usage examples for com.google.gwt.user.client.ui Widget getOffsetWidth

Introduction

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

Prototype

@Override
    public int getOffsetWidth() 

Source Link

Usage

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void copySize(Widget from, Widget to) {
    to.setSize(from.getOffsetWidth() + "px", from.getOffsetHeight() + "px");
}

From source file:cc.alcina.framework.gwt.client.widget.RelativePopupValidationFeedback.java

License:Apache License

@Override
public void handleException(Object source, ValidationException exception) {
    final Widget w = (Widget) source;
    resolve(source);// w  w  w .j a v a 2s . c o m
    if (!DomUtils.isVisibleAncestorChain(w.getElement())) {
        return;
    }
    Widget suppressValidationFeedbackFor = RenderContext.get().getSuppressValidationFeedbackFor();
    if (suppressValidationFeedbackFor != null
            && suppressValidationFeedbackFor.getElement().isOrHasChild(w.getElement())) {
        return;
    }
    final RelativePopup p = new RelativePopup();
    p.setVisible(false);
    popups.put(source, p);
    WidgetByElementTracker.get().register(p);
    p.setStyleName("gwittir-ValidationPopup");
    if (getCss() != null) {
        p.addStyleName(getCss());
    }
    if (exception instanceof ProcessingServerValidationException) {
        ProcessingServerValidationException psve = (ProcessingServerValidationException) exception;
        FlowPanel fp = new FlowPanel();
        fp.setStyleName("gwittir-ServerValidation");
        fp.add(new InlineLabel(this.getMessage(exception)));
        p.add(fp);
        psve.setSourceWidget(source);
        psve.setFeedback(this);
    } else {
        p.add(renderExceptionWidget(exception));
    }
    int x = w.getAbsoluteLeft();
    int y = w.getAbsoluteTop();
    Widget pw = WidgetUtils.getPositioningParent(w);
    ComplexPanel cp = WidgetUtils.complexChildOrSelf(pw);
    if (!(pw instanceof RootPanel)) {
        x -= pw.getAbsoluteLeft();
        y -= pw.getAbsoluteTop();
    }
    cp.add(p);
    if (this.position == BOTTOM) {
        y += w.getOffsetHeight();
    } else if (this.position == RIGHT) {
        x += w.getOffsetWidth();
    } else if (this.position == LEFT) {
        x -= p.getOffsetWidth();
    } else if (this.position == TOP) {
        y -= p.getOffsetHeight();
    }
    Element h = p.getElement();
    Style style = h.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(x, Unit.PX);
    style.setTop(y, Unit.PX);
    if (this.position == BOTTOM) {
        style.setWidth(w.getOffsetWidth(), Unit.PX);
    }
    p.setVisible(true);
    if (w instanceof SourcesPropertyChangeEvents) {
        // GWT.log("is PCE", null);
        PropertyChangeListener attachListener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                if (((Boolean) propertyChangeEvent.getNewValue()).booleanValue()) {
                    p.setVisible(true);
                } else {
                    p.setVisible(false);
                }
            }
        };
        listeners.put(w, attachListener);
        ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("attached", attachListener);
        ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("visible", attachListener);
    }
}

From source file:cc.kune.common.client.tooltip.Tooltip.java

License:GNU Affero Public License

/**
 * Calculate position.// w  w  w . j a va2  s  . c  o  m
 *
 * @return the tooltip position
 */
private TooltipPosition calculatePosition(final Widget forWidget) {
    return TooltipPositionCalculator.calculate(Window.getClientWidth(), Window.getClientHeight(),
            forWidget.getAbsoluteLeft(), forWidget.getAbsoluteTop(), forWidget.getOffsetWidth(),
            forWidget.getOffsetHeight(), getTip().getWidth(), getTip().getHeight());
}

From source file:cc.kune.common.client.ui.MaskWidget.java

License:GNU Affero Public License

@Override
public void mask(final IsWidget widget, final String message) {
    label.setText(message);/*from  w ww. j  ava2 s.  c  om*/
    setPopupPositionAndShow(new PositionCallback() {
        @Override
        public void setPosition(final int offsetWidth, final int offsetHeight) {
            final Widget asWidget = widget.asWidget();
            final int w = asWidget.getOffsetWidth();
            final int h = asWidget.getOffsetHeight();
            MaskWidget.this.setPopupPosition(asWidget.getAbsoluteLeft(), asWidget.getAbsoluteTop());
            getElement().getStyle().setWidth(w, Unit.PX);
            getElement().getStyle().setHeight(h, Unit.PX);
            flow.getElement().getStyle().setTop((h - flow.getOffsetHeight()) / 2d, Unit.PX);
            flow.getElement().getStyle().setLeft((w - flow.getOffsetWidth()) / 2d, Unit.PX);
        }
    });
}

From source file:ch.unifr.pai.twice.dragndrop.client.MPDragNDrop.java

License:Apache License

@Override
public void initialize(Widget w, int offsetX, int offsetY, DragConfiguration conf) {
    this.w = w;/*from w w  w .  ja v  a2 s.  co  m*/
    this.percOffsetX = (int) (100.0 / w.getOffsetWidth() * offsetX);
    this.percOffsetY = (int) (100.0 / w.getOffsetHeight() * offsetY);
    this.originDisplay = w.getElement().getStyle().getDisplay();
    this.conf = conf;
}

From source file:ch.unifr.pai.twice.dragndrop.client.MPDragNDrop.java

License:Apache License

/**
 * This method looks up all the drop targets which are intersecting with the given element. If the drop targets differ in their priorities ({@link Priority}
 * ), only widgets of the highest priority are returned.
 * /*from   w ww. j av a  2  s . c  om*/
 * @param e
 *            - a HTML element (typically the HTML element of the dragged widget)
 * @return the drop target widgets which are intersecting with the given element and do have the highest priority
 */
protected Set<Widget> getAffectedDropTargets(Element e) {
    int w1X = e.getAbsoluteLeft();
    int w1Y = e.getAbsoluteTop();
    int w1Width = e.getOffsetWidth();
    int w1Height = e.getOffsetHeight();
    Map<Integer, HashSet<Widget>> targets = new HashMap<Integer, HashSet<Widget>>();
    for (Widget w2 : dropTargetRegistry.keySet()) {
        int w2X = w2.getAbsoluteLeft();
        int w2Y = w2.getAbsoluteTop();
        boolean xCollision = w1X < w2X ? w2X - w1X < w1Width : w1X - w2X < w2.getOffsetWidth();
        boolean yCollision = w1Y < w2Y ? w2Y - w1Y < w1Height : w1Y - w2Y < w2.getOffsetHeight();
        String idStyle = w2.getElement().getId() != null && !w2.getElement().getId().equals("")
                ? "hover-" + w2.getElement().getId()
                : null;
        if (xCollision && yCollision) {
            if (idStyle != null) {
                e.addClassName(idStyle);
            }
            DropTargetHandler h = dropTargetRegistry.get(w2);
            if (h != null) {
                int prio = h.getPriority().getValue();
                HashSet<Widget> widgetsForPrio = targets.get(prio);
                if (widgetsForPrio == null) {
                    widgetsForPrio = new HashSet<Widget>();
                    targets.put(prio, widgetsForPrio);
                }
                widgetsForPrio.add(w2);
            }
        } else if (idStyle != null) {
            e.removeClassName(idStyle);
        }
    }
    if (targets.isEmpty())
        return null;
    int maxprio = 0;
    for (Integer i : targets.keySet()) {
        if (i > maxprio) {
            maxprio = i;
        }
    }
    return targets.get(maxprio);
}

From source file:ch.unifr.pai.twice.layout.client.eclipseLayout.MiceSplitLayoutPanel.java

License:Apache License

/**
 * @param w// ww  w. j  ava  2s .  c  o  m
 * @return the size of the widget in pixels. Depending on the layouting position, this is either the widget's width (for horizontal orientation) or height
 *         (for vertical orientation).
 */
private Integer getSizeForWidget(Widget w) {
    switch (this.getWidgetDirection(w)) {
    case EAST:
    case WEST:
        return w.getOffsetWidth();
    }
    return w.getOffsetHeight();
}

From source file:com.allen_sauer.gwt.dnd.client.drop.AbsolutePositionDropController.java

License:Apache License

/**
 * Programmatically drop a widget on our drop target while obeying the constraints of this
 * controller./*from w ww.  j  a  v a2  s. c om*/
 * 
 * @param widget the widget to be dropped
 * @param left the desired absolute horizontal location relative to our drop target
 * @param top the desired absolute vertical location relative to our drop target
 */
public void drop(Widget widget, int left, int top) {
    left = Math.max(0, Math.min(left, dropTarget.getOffsetWidth() - widget.getOffsetWidth()));
    top = Math.max(0, Math.min(top, dropTarget.getOffsetHeight() - widget.getOffsetHeight()));
    dropTarget.add(widget, left, top);
}

From source file:com.allen_sauer.gwt.dnd.client.drop.AbsolutePositionDropController.java

License:Apache License

Widget makePositioner(Widget reference) {
    // 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());
    outer.getElement().getStyle().setProperty("margin", "0px");

    // 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);

    SimplePanel inner = new SimplePanel();
    inner.getElement().getStyle().setProperty("margin", "0px");
    inner.getElement().getStyle().setProperty("border", "none");
    int offsetWidth = reference.getOffsetWidth() - DOMUtil.getHorizontalBorders(outer);
    int offsetHeight = reference.getOffsetHeight() - DOMUtil.getVerticalBorders(outer);
    inner.setPixelSize(offsetWidth, offsetHeight);

    outer.setWidget(inner);/* w w  w  .  j ava 2s.co m*/

    return outer;
}

From source file:com.allen_sauer.gwt.dnd.client.drop.GridConstrainedDropController.java

License:Apache License

@Override
public void drop(Widget widget, int left, int top) {
    left = Math.max(0, Math.min(left, dropTarget.getOffsetWidth() - widget.getOffsetWidth()));
    top = Math.max(0, Math.min(top, dropTarget.getOffsetHeight() - widget.getOffsetHeight()));
    left = Math.round((float) left / gridX) * gridX;
    top = Math.round((float) top / gridY) * gridY;
    dropTarget.add(widget, left, top);//from www. j  a v a  2  s . c o  m
}