Example usage for com.google.gwt.dom.client TextAreaElement getRows

List of usage examples for com.google.gwt.dom.client TextAreaElement getRows

Introduction

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

Prototype

public int getRows() 

Source Link

Document

Number of text rows.

Usage

From source file:com.cgxlib.xq.client.plugins.widgets.TextAreaWidgetFactory.java

License:Apache License

@Override
protected void copyAttributes(Element src, Element dest) {
    TextAreaElement source = src.cast();
    TextAreaElement destination = dest.cast();

    destination.setAccessKey(source.getAccessKey());
    destination.setCols(source.getCols());
    destination.setDefaultValue(source.getDefaultValue());
    destination.setDisabled(source.isDisabled());
    destination.setName(source.getName());
    destination.setReadOnly(source.isReadOnly());
    destination.setRows(source.getRows());
    destination.setValue(source.getValue());
}

From source file:org.opencms.ui.client.CmsAutoGrowingTextAreaConnector.java

License:Open Source License

/**
 * Resize the text area.<p>//w  w w . j  a va  2s  .  c o m
 */
protected void handle() {

    Element e = m_widget.getElement();
    if (e instanceof TextAreaElement) {
        TextAreaElement elem = (TextAreaElement) e;
        int scrollHeight = elem.getScrollHeight();
        // allow text area to shrink
        if (m_lastValue.length() > elem.getValue().length()) {
            elem.setRows(getState().getMinRows());
        }
        int currentRows = elem.getRows();
        if (m_lineHeight == 0) {
            elem.setRows(2);
            int heightTwo = elem.getClientHeight();
            elem.setRows(1);
            int heightOne = elem.getClientHeight();
            m_lineHeight = heightTwo - heightOne;
            m_paddingHeight = heightOne - m_lineHeight;
            elem.setRows(currentRows);
        }
        if (m_lineHeight > 0) {
            int totalHeight = scrollHeight - m_paddingHeight;
            int requiredRows = ((scrollHeight - m_paddingHeight) / m_lineHeight);
            if ((totalHeight % m_lineHeight) > 0) {
                requiredRows++;
            }
            int minRows = getState().getMinRows();
            int maxRows = getState().getMaxRows();
            if ((requiredRows <= minRows) && (currentRows != minRows)) {
                elem.setRows(minRows);
            } else if ((requiredRows >= maxRows) && (currentRows != maxRows)) {
                elem.setRows(maxRows);
            } else if (requiredRows != currentRows) {
                elem.setRows(requiredRows);
            }
        }
    }
}