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

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

Introduction

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

Prototype

public void setProperty(String name, String value) 

Source Link

Usage

From source file:org.thechiselgroup.biomixer.client.core.ui.popup.DefaultPopup.java

License:Apache License

@Override
public DefaultSizeInt getSize() {
    /*//  w  w w .  ja v  a2s.  c o m
     * If the popup panel is not attached --> attach in background, get
     * size, remove panel. Otherwise just report size.
     */
    NEffectPanel effectPanel = getEffectPanel();
    boolean attached = effectPanel.isAttached(); // do not inline

    if (!attached) {
        Style style = effectPanel.getElement().getStyle();
        style.setProperty(CSS.POSITION, CSS.FIXED);
        style.setProperty(CSS.Z_INDEX, Integer.toString(HIDDEN_Z_INDEX));
        rootPanel.add(effectPanel);
    }

    DefaultSizeInt size = new DefaultSizeInt(containerPanel.getOffsetWidth(), containerPanel.getOffsetHeight());

    if (!attached) {
        rootPanel.remove(effectPanel);
    }

    return size;
}

From source file:org.thechiselgroup.choosel.core.client.ui.popup.DefaultPopup.java

License:Apache License

@Override
public DefaultSize getSize() {
    /*/*w  w  w  .  ja va  2  s .  c o m*/
     * If the popup panel is not attached --> attach in background, get
     * size, remove panel. Otherwise just report size.
     */
    NEffectPanel effectPanel = getEffectPanel();
    boolean attached = effectPanel.isAttached(); // do not inline

    if (!attached) {
        Style style = effectPanel.getElement().getStyle();
        style.setProperty(CSS.POSITION, CSS.FIXED);
        style.setProperty(CSS.Z_INDEX, Integer.toString(HIDDEN_Z_INDEX));
        rootPanel.add(effectPanel);
    }

    DefaultSize size = new DefaultSize(containerPanel.getOffsetWidth(), containerPanel.getOffsetHeight());

    if (!attached) {
        rootPanel.remove(effectPanel);
    }

    return size;
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.BaseDOMElement.java

License:Apache License

/**
 * Transform the DOMElement based on the render context, such as scale and position.
 * @param context//w w w.  j  a  v a2s  .  com
 */
protected void transform(final GridBodyCellRenderContext context) {
    final Transform transform = context.getTransform();
    final double width = context.getCellWidth();
    final double height = context.getCellHeight();

    final Style style = widgetContainer.getElement().getStyle();

    //Copy across GridWidget's opacity to DOMElements
    style.setOpacity(gridWidget.getAlpha());

    //Reposition and transform the DOM Element
    style.setLeft((context.getAbsoluteCellX() * transform.getScaleX()) + transform.getTranslateX(),
            Style.Unit.PX);
    style.setTop((context.getAbsoluteCellY() * transform.getScaleY()) + transform.getTranslateY(),
            Style.Unit.PX);
    style.setWidth(width, Style.Unit.PX);
    style.setHeight(height, Style.Unit.PX);

    //If the DOMElement overlaps a fixed header clip content
    style.clearProperty("clip");
    final double top = context.getAbsoluteCellY() + transform.getTranslateY();
    final double left = context.getAbsoluteCellX() + transform.getTranslateX();
    final boolean isFloating = context.isFloating();
    boolean clip = false;
    double ct = 0.0;
    double cr = width;
    double cb = height;
    double cl = 0.0;

    final Group header = gridWidget.getHeader();
    final double clipMinY = context.getClipMinY() + transform.getTranslateY();
    final double clipMinX = context.getClipMinX() + transform.getTranslateX();
    if (header != null) {
        if (top < clipMinY) {
            ct = clipMinY - top;
            clip = true;
        }
    }
    if (!isFloating && left < clipMinX) {
        cl = clipMinX - left;
        clip = true;
    }
    if (clip) {
        style.setProperty("clip",
                "rect(" + (int) ct + "px," + (int) cr + "px," + (int) cb + "px," + (int) cl + "px)");
    }

    // --- Workaround for BS2 ---
    style.setProperty("WebkitBoxSizing", "border-box");
    style.setProperty("MozBoxSizing", "border-box");
    style.setProperty("boxSizing", "border-box");
    style.setProperty("lineHeight", "normal");
    // --- End workaround ---

    if (MathUtilities.isOne(transform.getScaleX()) && MathUtilities.isOne(transform.getScaleY())) {
        style.clearProperty("WebkitTransform");
        style.clearProperty("MozTransform");
        style.clearProperty("Transform");
        style.clearProperty("MsTransform");
        return;
    }

    final String scale = "scale(" + FORMAT.format(transform.getScaleX()) + ", "
            + FORMAT.format(transform.getScaleY()) + ")";
    final String translate = "translate(" + FORMAT.format(((width - width * transform.getScaleX()) / -2.0))
            + "px, " + FORMAT.format(((height - height * transform.getScaleY()) / -2.0)) + "px)";
    style.setProperty("WebkitTransform", translate + " " + scale);
    style.setProperty("MozTransform", translate + " " + scale);
    style.setProperty("Transform", translate + " " + scale);
    style.setProperty("MsTransform", translate + " " + scale);
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.BaseDOMElement.java

License:Apache License

/**
 * Attach the DOMElement to the GWT container, if not already attached.
 *///w  w  w.  j a  v a  2s .c  om
public void attach() {
    final Iterator<Widget> itr = domElementContainer.iterator();
    while (itr.hasNext()) {
        if (itr.next().equals(widgetContainer)) {
            return;
        }
    }
    //When an Element is detached it's Position configuration is cleared, so reset it
    final Style style = widgetContainer.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);
    style.setProperty("WebkitUserSelect", "none");
    style.setProperty("MozUserSelect", "none");
    style.setProperty("MsUserSelect", "none");

    domElementContainer.add(widgetContainer);
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.CheckBoxDOMElement.java

License:Apache License

public CheckBoxDOMElement(final CheckBox widget, final GridLayer gridLayer, final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setMarginTop(0, Style.Unit.PX);
    style.setMarginLeft(2, Style.Unit.PX);
    style.setWidth(SIZE, Style.Unit.PX);
    style.setHeight(SIZE, Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0, Style.Unit.PX);
    style.setPaddingBottom(0, Style.Unit.PX);
    style.setProperty("WebkitBoxSizing", "border-box");
    style.setProperty("MozBoxSizing", "border-box");
    style.setProperty("boxSizing", "border-box");
    style.setProperty("lineHeight", "normal");
    // --- End workaround ---

    getContainer().setWidget(widget);/* w  w w.  j ava 2 s.  co  m*/
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.ListBoxDOMElement.java

License:Apache License

public ListBoxDOMElement(final ListBox widget, final GridLayer gridLayer, final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(HEIGHT, Style.Unit.PX);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0, Style.Unit.PX);
    style.setPaddingBottom(0, Style.Unit.PX);
    style.setProperty("WebkitBoxSizing", "border-box");
    style.setProperty("MozBoxSizing", "border-box");
    style.setProperty("boxSizing", "border-box");
    style.setProperty("lineHeight", "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX);
    getContainer().setWidget(widget);//from w  w w  .  j a v a  2  s . c o  m
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.TextBoxDOMElement.java

License:Apache License

public TextBoxDOMElement(final TextBox widget, final GridLayer gridLayer, final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(HEIGHT, Style.Unit.PX);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0, Style.Unit.PX);
    style.setPaddingBottom(0, Style.Unit.PX);
    style.setProperty("WebkitBoxSizing", "border-box");
    style.setProperty("MozBoxSizing", "border-box");
    style.setProperty("boxSizing", "border-box");
    style.setProperty("lineHeight", "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX);
    getContainer().setWidget(widget);//  w  w  w  . java2 s  . co m
}

From source file:org.vaadin.addon.gwtgraphics.client.impl.SVGImpl.java

License:Apache License

protected int measureTextSize(Element element, boolean measureWidth) {
    String text = getText(element);
    if (text == null || "".equals(text)) {
        return 0;
    }//w w w . ja v  a2s  . c o  m

    DivElement measureElement = Document.get().createDivElement();
    Style style = measureElement.getStyle();
    style.setProperty("visibility", "hidden");
    style.setProperty("display", "inline");
    style.setProperty("whiteSpace", "nowrap");
    style.setProperty("fontFamily", getTextFontFamily(element));
    style.setPropertyPx("fontSize", getTextFontSize(element));
    measureElement.setInnerText(text);
    RootPanel.getBodyElement().appendChild(measureElement);
    int measurement;
    if (measureWidth) {
        measurement = measureElement.getOffsetWidth();
    } else {
        measurement = measureElement.getOffsetHeight();
    }
    RootPanel.getBodyElement().removeChild(measureElement);

    return measurement;
}

From source file:org.vaadin.alump.scaleimage.gwt.client.conn.ScaleImageConnector.java

License:Apache License

@Override
public void onStateChanged(StateChangeEvent event) {
    super.onStateChanged(event);

    clickEventHandler.handleEventHandlerRegistration();

    String url = getResourceUrl(AbstractEmbeddedState.SOURCE_RESOURCE);
    getWidget().setUrl(url);/*from  w w  w.  j ava  2s . c o  m*/

    for (String property : getState().styleValues.keySet()) {
        String value = getState().styleValues.get(property);
        Style elementStyle = getWidget().getElement().getStyle();
        if (value == null || value.isEmpty()) {
            elementStyle.clearProperty(property);
        } else {
            elementStyle.setProperty(property, value);
        }
    }
}

From source file:org.vaadin.sasha.portallayout.client.dnd.MouseDragHandler.java

License:Apache License

private void initCapturingWidget() {
    capturingWidget = new FocusPanel();
    capturingWidget.addMouseMoveHandler(this);
    capturingWidget.addMouseUpHandler(this);
    capturingWidget.addTouchMoveHandler(this);
    capturingWidget.addTouchEndHandler(this);
    capturingWidget.addTouchCancelHandler(this);
    Style style = capturingWidget.getElement().getStyle();
    // workaround for IE8 opacity
    // http://code.google.com/p/google-web-toolkit/issues/detail?id=5538
    style.setProperty("filter", "alpha(opacity=0)");
    style.setOpacity(0);/*  ww  w  .  java 2  s .  co  m*/
    style.setZIndex(1000);
    style.setMargin(0, Style.Unit.PX);
    style.setBorderStyle(BorderStyle.NONE);
    style.setBackgroundColor("blue");
}