Example usage for com.google.gwt.dom.client Element getPropertyInt

List of usage examples for com.google.gwt.dom.client Element getPropertyInt

Introduction

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

Prototype

@Override
    public int getPropertyInt(String name) 

Source Link

Usage

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

License:Apache License

private static int getBestOffsetHeight(Element e, boolean parentPass, boolean allowParentPass) {
    int h = e.getPropertyInt("offsetHeight");
    if (h != 0 || e.getParentElement() == null) {
        return h;
    }//w w w  . j a v  a  2 s  .  c om
    if (e.getFirstChildElement() == null && !parentPass) {
        return getBestOffsetHeight(e, true);
    }
    if (!allowParentPass) {
        return 0;
    }
    return getBestOffsetHeight(parentPass ? e.getParentElement() : e.getFirstChildElement(), parentPass);
}

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

License:Apache License

private static int getBestOffsetWidth(Element e, boolean parentPass) {
    int h = e.getPropertyInt("offsetWidth");
    if (h != 0 || e.getParentElement() == null) {
        return h;
    }/*w w w .j  a  v a 2  s .c  o m*/
    if (e.getFirstChildElement() == null && !parentPass) {
        return getBestOffsetWidth(e, true);
    }
    return getBestOffsetWidth(parentPass ? e.getParentElement() : e.getFirstChildElement(), parentPass);
}

From source file:com.extjs.gxt.ui.client.widget.grid.GridView.java

License:sencha.com license

/**
 * Returns the row index./*from   ww  w .  j  a va  2s . c  o m*/
 * 
 * @param elem the row or child of the row element
 * @return the index
 */
public int findRowIndex(Element elem) {
    Element r = findRow(elem);
    return r != null ? r.getPropertyInt("rowIndex") : -1;
}

From source file:com.google.gerrit.client.diff.SideBySideChunkManager.java

License:Apache License

void adjustPadding() {
    if (paddingDivs != null) {
        double h = cmB.extras().lineHeightPx();
        for (Element div : paddingDivs) {
            int lines = div.getPropertyInt(DATA_LINES);
            div.getStyle().setHeight(lines * h, Unit.PX);
        }//from w w w. j  a va2  s .  c  o m
        for (LineWidget w : padding) {
            w.changed();
        }
        paddingDivs = null;
        guessedLineHeightPx = h;
    }
}

From source file:com.sencha.gxt.widget.core.client.DatePicker.java

License:sencha.com license

protected void updateMPMonth(int month) {
    for (int i = 0; i < mpMonths.getCount(); i++) {
        Element elem = mpMonths.item(i);
        int xmonth = elem.getPropertyInt("xmonth");
        appearance.onMonthSelected(elem, xmonth == month);
    }//from  ww w  .  java 2  s .  c  om
}

From source file:com.sencha.gxt.widget.core.client.grid.GridView.java

License:sencha.com license

/**
 * Returns the row index./*  w ww. j  av  a  2s  .  co  m*/
 *
 * @param elem the row or child of the row element
 * @return the index
 */
public int findRowIndex(Element elem) {
    Element r = findRow(elem);
    if (r != null) {
        return r.getPropertyInt("rowindex");
    }
    return -1;
}

From source file:com.vaadin.client.ui.VSlider.java

License:Apache License

/** For internal use only. May be removed or replaced in the future. */
public void buildBase() {
    final String styleAttribute = isVertical() ? "height" : "width";
    final String oppositeStyleAttribute = isVertical() ? "width" : "height";
    final String domProperty = isVertical() ? "offsetHeight" : "offsetWidth";

    // clear unnecessary opposite style attribute
    base.getStyle().clearProperty(oppositeStyleAttribute);

    /*//from   ww  w. j  a  v a2 s  . c  o  m
     * To resolve defect #13681 we should not return from method buildBase()
     * if slider has no parentElement, because such operations as
     * buildHandle() and setValues(), which are needed for Slider, are
     * called at the end of method buildBase(). And these methods will not
     * be called if there is no parentElement. So, instead of returning from
     * method buildBase() if there is no parentElement "if condition" is
     * applied to call code for parentElement only in case it exists.
     */
    if (getElement().hasParentElement()) {
        final Element p = getElement();
        if (p.getPropertyInt(domProperty) > MIN_SIZE) {
            if (isVertical()) {
                setHeight();
            } else {
                base.getStyle().clearProperty(styleAttribute);
            }
        } else {
            // Set minimum size and adjust after all components have
            // (supposedly) been drawn completely.
            base.getStyle().setPropertyPx(styleAttribute, MIN_SIZE);
            Scheduler.get().scheduleDeferred(new Command() {

                @Override
                public void execute() {
                    final Element p = getElement();
                    if (p.getPropertyInt(domProperty) > (MIN_SIZE + 5)
                            || propertyNotNullOrEmpty(styleAttribute, p)) {
                        if (isVertical()) {
                            setHeight();
                        } else {
                            base.getStyle().clearProperty(styleAttribute);
                        }
                        // Ensure correct position
                        setValue(value, false);
                    }
                }

                // Style has non empty property
                private boolean propertyNotNullOrEmpty(final String styleAttribute, final Element p) {
                    return p.getStyle().getProperty(styleAttribute) != null
                            && !p.getStyle().getProperty(styleAttribute).isEmpty();
                }
            });
        }
    }

    if (!isVertical()) {
        // Draw handle with a delay to allow base to gain maximum width
        Scheduler.get().scheduleDeferred(new Command() {
            @Override
            public void execute() {
                buildHandle();
                setValue(value, false);
            }
        });
    } else {
        buildHandle();
        setValue(value, false);
    }

    // TODO attach listeners for focusing and arrow keys
}

From source file:com.vaadin.client.widget.grid.selection.MultiSelectionRenderer.java

License:Apache License

private int getLogicalRowIndex(final Element target) {
    if (target == null) {
        return -1;
    }//from   w  w  w . j  av a2 s  . c  o m

    /*
     * We can't simply go backwards until we find a <tr> first element,
     * because of the table-in-table scenario. We need to, unfortunately, go
     * up from our known root.
     */
    final Element tbody = getTbodyElement();
    Element tr = tbody.getFirstChildElement();
    while (tr != null) {
        if (tr.isOrHasChild(target)) {
            final Element td = tr.getFirstChildElement();
            assert td != null : "Cell has disappeared";

            final Element checkbox = td.getFirstChildElement();
            assert checkbox != null : "Checkbox has disappeared";

            return checkbox.getPropertyInt(LOGICAL_ROW_PROPERTY_INT);
        }
        tr = tr.getNextSiblingElement();
    }
    return -1;
}

From source file:com.vaadin.client.WidgetUtil.java

License:Apache License

public static int measureHorizontalBorder(Element element) {
    int borders;/*from w  w  w  .  j a v a2s . com*/

    if (BrowserInfo.get().isIE()) {
        String width = element.getStyle().getProperty("width");
        String height = element.getStyle().getProperty("height");

        int offsetWidth = element.getOffsetWidth();
        int offsetHeight = element.getOffsetHeight();
        if (offsetHeight < 1) {
            offsetHeight = 1;
        }
        if (offsetWidth < 1) {
            offsetWidth = 10;
        }
        element.getStyle().setPropertyPx("height", offsetHeight);
        element.getStyle().setPropertyPx("width", offsetWidth);

        borders = element.getOffsetWidth() - element.getClientWidth();

        element.getStyle().setProperty("width", width);
        element.getStyle().setProperty("height", height);
    } else {
        borders = element.getOffsetWidth() - element.getPropertyInt("clientWidth");
    }
    assert borders >= 0;

    return borders;
}

From source file:com.vaadin.client.WidgetUtil.java

License:Apache License

public static int measureVerticalBorder(Element element) {
    int borders;//from w  w w . ja v  a 2 s  .c o  m
    if (BrowserInfo.get().isIE()) {
        String width = element.getStyle().getProperty("width");
        String height = element.getStyle().getProperty("height");

        int offsetWidth = element.getOffsetWidth();
        int offsetHeight = element.getOffsetHeight();
        if (offsetHeight < 1) {
            offsetHeight = 1;
        }
        if (offsetWidth < 1) {
            offsetWidth = 10;
        }
        element.getStyle().setPropertyPx("width", offsetWidth);

        element.getStyle().setPropertyPx("height", offsetHeight);

        borders = element.getOffsetHeight() - element.getPropertyInt("clientHeight");

        element.getStyle().setProperty("height", height);
        element.getStyle().setProperty("width", width);
    } else {
        borders = element.getOffsetHeight() - element.getPropertyInt("clientHeight");
    }
    assert borders >= 0;

    return borders;
}