Example usage for com.google.gwt.dom.client Style setPosition

List of usage examples for com.google.gwt.dom.client Style setPosition

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style setPosition.

Prototype

public void setPosition(Position value) 

Source Link

Usage

From source file:burrito.client.widgets.form.EditForm.java

License:Apache License

public void makeButtonsStick(boolean stick) {
    getElement().getStyle().setPropertyPx("minHeight", getOffsetHeight());
    Style style = buttonWrapper.getElement().getStyle();
    buttonWrapper.addStyleName("k5-EditForm-fixedButtons");
    if (stick) {/*from ww  w  .  j a  v  a 2s.  com*/
        style.setPosition(Position.FIXED);
        style.setBottom(0, Unit.PX);
        style.setLeft(getAbsoluteLeft(), Unit.PX);
        style.setWidth(getOffsetWidth(), Unit.PX);
    } else {
        style.clearPosition();
        style.clearBottom();
        style.clearLeft();
        style.clearWidth();
    }

}

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

License:Apache License

public static String trimToWidth(String s, String style, int pxWidth, String ellipsis) {
    if (pxWidth <= 20) {
        return s;
    }//from   w w  w  .  j  a v  a2s .  c  o  m
    ellipsis = ellipsis == null ? "\u2026" : ellipsis;
    int r0 = 0;
    int r1 = s.length();
    Label l = new Label();
    setElementStyle(l.getElement(), style);
    Style cStyle = l.getElement().getStyle();
    cStyle.setPosition(Position.ABSOLUTE);
    cStyle.setLeft(0, Unit.PX);
    cStyle.setTop(0, Unit.PX);
    cStyle.setDisplay(Display.INLINE_BLOCK);
    cStyle.setProperty("whitespace", "nowrap");
    cStyle.setProperty("visibility", "hidden");
    RootPanel.get().add(l);
    boolean tried = false;
    while (true) {
        int mid = (r1 - r0) / 2 + r0;
        String t = tried ? s.substring(0, mid) + ellipsis : s;
        l.setText(t);
        if (l.getOffsetWidth() <= pxWidth) {
            if (!tried || (r1 - r0) <= 1) {
                RootPanel.get().remove(l);
                return t;
            }
            r0 = mid;
        } else {
            if (!tried) {
                tried = true;
            } else {
                r1 = mid;
            }
        }
    }
}

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  ww .  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:com.ait.lienzo.client.widget.panel.mediators.PanelPreviewMediator.java

License:Apache License

@Override
protected void onEnable() {
    final LienzoBoundsPanel panel = getPanel();
    final int panelWidthPx = panel.getWidthPx();
    final int panelHeightPx = panel.getHeightPx();
    final Style style = previewPanel.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);
    style.setTop(0, Style.Unit.PX);
    style.setLeft(0, Style.Unit.PX);
    style.setBorderStyle(Style.BorderStyle.NONE);
    style.setBackgroundColor(PREVIEW_BG_COLOR);
    previewPanel.setPixelSize(panelWidthPx, panelHeightPx);
    previewPanel.setVisible(true);//from  w ww .jav a2s .c o  m

    final BoundingBox areaBox = area.get();
    final double fitLevel = PanelTransformUtils.computeZoomLevelFitToWidth(areaBox.getWidth(),
            areaBox.getHeight(), panel);

    final Viewport viewport = previewLayer.getViewport();
    final Transform transform = new Transform();
    transform.translate(areaBox.getX(), areaBox.getY());
    transform.scale(fitLevel, fitLevel);
    viewport.setTransform(transform);

    getLayer().drawWithTransforms(previewLayer.getContext(), 1,
            new BoundingBox(0, 0, panelWidthPx, panelHeightPx), new Supplier<Transform>() {
                @Override
                public Transform get() {
                    return transform;
                }
            });

    mediator.setMaxScale(maxScale);
    mediator.setEnabled(true);
    getLayer().setVisible(false);
}

From source file:com.alkacon.geranium.client.util.DebugLog.java

License:Open Source License

/**
 * Constructor.<p>/*from ww  w . ja  v a2  s.  com*/
 */
@SuppressWarnings("unused")
private DebugLog() {

    if (!DEBUG) {
        return;
    }
    m_html = new HTML();
    initWidget(m_html);
    Style style = getElement().getStyle();
    style.setWidth(200, Unit.PX);
    style.setHeight(500, Unit.PX);
    style.setPadding(10, Unit.PX);
    style.setOverflow(Overflow.AUTO);
    style.setBorderStyle(BorderStyle.SOLID);
    style.setBorderColor(I_LayoutBundle.INSTANCE.constants().css().borderColor());
    style.setBorderWidth(1, Unit.PX);
    style.setPosition(Position.FIXED);
    style.setTop(50, Unit.PX);
    style.setRight(50, Unit.PX);
    style.setBackgroundColor(I_LayoutBundle.INSTANCE.constants().css().backgroundColorDialog());
    style.setZIndex(10);
}

From source file:com.alkacon.geranium.client.util.TextMetrics.java

License:Open Source License

/**
 * Binds this text metrics instance to an element from which to copy existing
 * CSS styles that can affect the size of the rendered text.<p>
 * //  w  ww . ja  v a2  s. c  o m
 * @param element the element
 * @param attributes the attributes to bind
 */
protected void bind(Element element, DomUtil.Style... attributes) {

    if (m_elem == null) {
        // create playground
        m_elem = DOM.createDiv();
        Style style = m_elem.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setPosition(Style.Position.ABSOLUTE);
        style.setLeft(-5000, Style.Unit.PX);
        style.setTop(-5000, Style.Unit.PX);
    }
    // copy all relevant CSS properties
    Style style = m_elem.getStyle();
    for (DomUtil.Style attr : attributes) {
        String attrName = attr.toString();
        style.setProperty(attrName, DomUtil.getCurrentStyle(element, attr));
    }
    // append playground
    RootPanel.getBodyElement().appendChild(m_elem);
}

From source file:com.bearsoft.gwt.ui.widgets.DecoratorBox.java

public void setWidget(HasValue<T> w) {
    if (decorated != w) {
        if (changeValueHandler != null) {
            changeValueHandler.removeHandler();
        }//from ww w  .  j  a  v a 2s.c o  m
        if (keyDownHandler != null)
            keyDownHandler.removeHandler();
        if (keyUpHandler != null)
            keyUpHandler.removeHandler();
        if (keyPressHandler != null)
            keyPressHandler.removeHandler();
        if (focusHandler != null)
            focusHandler.removeHandler();
        if (blurHandler != null)
            blurHandler.removeHandler();
        if (decorated instanceof Widget) {
            ((Widget) decorated).removeFromParent();
        }
        decorated = w;
        if (decorated != null) {
            changeValueHandler = decorated.addValueChangeHandler(new ValueChangeHandler<T>() {

                @Override
                public void onValueChange(ValueChangeEvent<T> event) {
                    fireValueChangeEvent();
                }
            });
            if (decorated instanceof Widget) {
                CommonResources.INSTANCE.commons().ensureInjected();
                ((Widget) decorated).getElement()
                        .addClassName(CommonResources.INSTANCE.commons().borderSized());
                Style style = ((Widget) decorated).getElement().getStyle();
                style.setBorderWidth(0, Style.Unit.PX);
                style.setPadding(0, Style.Unit.PX);
                style.setMargin(0, Style.Unit.PX);
                style.setPosition(Style.Position.ABSOLUTE);
                style.setDisplay(Style.Display.INLINE_BLOCK);
                style.setLeft(0, Style.Unit.PX);
                style.setTop(0, Style.Unit.PX);
                style.setHeight(100, Style.Unit.PCT);
                style.setWidth(100, Style.Unit.PCT);
                style.setOutlineStyle(Style.OutlineStyle.NONE);
                style.setBackgroundColor("inherit");
                style.setColor("inherit");
                contentWrapper.setWidget((Widget) decorated);
            }
            if (decorated instanceof HasKeyDownHandlers) {
                keyDownHandler = ((HasKeyDownHandlers) decorated).addKeyDownHandler(new KeyDownHandler() {

                    @Override
                    public void onKeyDown(KeyDownEvent event) {
                        KeyDownEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
                    }
                });
            }
            if (decorated instanceof HasKeyUpHandlers) {
                keyUpHandler = ((HasKeyUpHandlers) decorated).addKeyUpHandler(new KeyUpHandler() {

                    @Override
                    public void onKeyUp(KeyUpEvent event) {
                        KeyUpEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
                    }
                });
            }
            if (decorated instanceof HasKeyPressHandlers) {
                keyPressHandler = ((HasKeyPressHandlers) decorated).addKeyPressHandler(new KeyPressHandler() {

                    @Override
                    public void onKeyPress(KeyPressEvent event) {
                        KeyPressEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
                    }
                });
            }
            if (decorated instanceof HasFocusHandlers) {
                focusHandler = ((HasFocusHandlers) decorated).addFocusHandler(new FocusHandler() {

                    @Override
                    public void onFocus(FocusEvent event) {
                        DecoratorBox.this.getElement().addClassName(DECORATOR_FOCUSED_CLASS_NAME);
                        FocusEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
                    }

                });
            }
            if (decorated instanceof HasBlurHandlers) {
                blurHandler = ((HasBlurHandlers) decorated).addBlurHandler(new BlurHandler() {

                    @Override
                    public void onBlur(BlurEvent event) {
                        DecoratorBox.this.getElement().removeClassName(DECORATOR_FOCUSED_CLASS_NAME);
                        BlurEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
                    }

                });
            }
        }
    }
}

From source file:com.codenvy.ide.client.elements.widgets.element.ElementViewImpl.java

License:Open Source License

@Nonnull
private Label createHeaderTitle() {
    Label title = createTitle();//  w  w  w  .  j a va2s . co m

    Style style = title.getElement().getStyle();
    style.setPosition(RELATIVE);
    style.setTop(2, PX);

    return title;
}

From source file:com.codenvy.ide.client.elements.widgets.element.ElementViewImpl.java

License:Open Source License

/** {@inheritDoc} */
@Override/*from   w ww .  j a  va  2 s .  c om*/
public void setWidth(@Nonnegative int width) {
    this.width = width - MARGIN;
    getElement().getStyle().setWidth(width, PX);

    Style rightPanelStyle = rightPanel.getElement().getStyle();

    if (element.isHorizontalOrientation()) {
        int rightPanelLeft = element.isRoot() ? 0 : DEFAULT_SIZE;
        rightPanelStyle.setLeft(rightPanelLeft, PX);
        rightPanelStyle.setTop(0, PX);
    } else {
        int rightPanelTop = element.isRoot() ? 0 : DEFAULT_SIZE;
        rightPanelStyle.setTop(rightPanelTop, PX);
        rightPanelStyle.setLeft(0, PX);
    }

    Position position = element.isRoot() ? RELATIVE : ABSOLUTE;
    rightPanelStyle.setPosition(position);
}

From source file:com.dianaui.universal.core.client.ui.DateTimePicker.java

License:Apache License

@Override
public void setVisible(final boolean visible) {
    Style style = container.getElement().getStyle();

    if (visible) {
        style.setDisplay(Style.Display.BLOCK);
        style.setZIndex(9999);/*from w  w w .  ja  v a2s. co  m*/
        style.setPosition(Style.Position.ABSOLUTE);
        style.setProperty("right", "auto");
    } else {
        super.setVisible(false);

        style.clearDisplay();
        style.clearZIndex();
        style.clearPosition();
        style.clearTop();
        style.clearLeft();
    }
}