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

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

Introduction

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

Prototype

@Override
    public void setScrollTop(int scrollTop) 

Source Link

Usage

From source file:org.primordion.xholon.base.Xholon.java

License:Open Source License

/**
 * Print to a console.//from  ww  w  . ja  v  a2  s.  com
 * This can be very slow, so limit the number of calls,
 * for example by consolidating text using a StringBuilder before calling.
 * @param str A String to append to the end of the console.
 * @param scroll Whether or not to scroll to the bottom of the text area.
 */
protected void print2Console(String str, boolean scroll) {
    if (str.startsWith(PRINT2CONSOLE_IGNORE_ME)) {
        return;
    }
    Element element = HtmlElementCache.xhout;
    if (element != null) {
        element = element.getFirstChildElement();
    }
    if (element != null) {
        TextAreaElement textfield = element.cast();
        textfield.setValue(textfield.getValue() + str);
        // optionally scroll to the bottom of the text area
        if (scroll) {
            textfield.setScrollTop(textfield.getScrollHeight());
        }
    }
}

From source file:org.primordion.xholon.io.console.XholonConsole.java

License:Open Source License

/**
 * Set the result of the query into the XholonConsole GUI,
 * and make it visible to the user./* ww w .  j a  v a 2  s  .  c  o  m*/
 * For now, the resultPane and commandPane are the same.
 * @param result
 * @param replace whether to replace current text (true), or append to end of current text (false)
 */
public void setResult(String result, boolean replace) {
    //Window.alert(result);

    // get the element
    Element ele = commandPane.getElement().getFirstChildElement();

    // <pre>
    //ele.setInnerText(ele.getInnerText() + result);

    // these leave the escaped chars in the text
    //ele.setInnerHTML(ele.getInnerHTML() + result);
    //ele.setInnerText(ele.getInnerText() + SafeHtmlUtils.htmlEscape(result));

    // textarea
    TextAreaElement ta = TextAreaElement.as(ele);
    if (replace) {
        ta.setValue(result);
    } else {
        ta.setValue(ta.getValue() + result);
    }
    // optionally scroll to the bottom of the text area
    if (isTerminalEnabled()) {
        ta.setScrollTop(ta.getScrollHeight());
    }
}