List of usage examples for com.google.gwt.dom.client TextAreaElement getValue
public String getValue()
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>/*from w ww . j av a 2 s . c om*/ */ 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); } } } }
From source file:org.primordion.xholon.base.Xholon.java
License:Open Source License
/** * Print to a console./*from www . j a va 2s . co m*/ * 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
/** * Get the contents of the command, as typed in by the user into the XholonConsole GUI. * @return The String typed in by the user, or only the selected part of the String. *//*from w ww . ja va2 s . co m*/ protected String getCommand() { /*JTextPane jTextPane = (JTextPane)commandPane.getVal_Object(); String contents = jTextPane.getSelectedText(); if (contents == null) { contents = jTextPane.getText(); }*/ Element ele = commandPane.getElement().getFirstChildElement(); //consoleLog(ele); // pre //String contents = ele.getInnerText(); // textarea TextAreaElement ta = TextAreaElement.as(ele); String contents = ta.getValue(); //consoleLog(contents); return contents; }
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 .ja v a 2 s .co 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()); } }
From source file:org.primordion.xholon.io.ngui.AqlWebInterface.java
License:BSD License
/** * Get the contents of the command.// w ww . java2 s . c o m * @return The String typed in by the user. */ protected String getCommand() { Element ele = commandPane.getElement().getFirstChildElement(); TextAreaElement ta = TextAreaElement.as(ele); String contents = ta.getValue(); return contents; }
From source file:org.primordion.xholon.io.ngui.AqlWebInterface.java
License:BSD License
/** * Set the result of the query into a text area, * and make it visible to the user./*from w ww.ja va2s . co 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) { // get the element Element ele = commandPane.getElement().getFirstChildElement(); // textarea TextAreaElement ta = TextAreaElement.as(ele); if (replace) { ta.setValue(result); } else { ta.setValue(ta.getValue() + result); } }
From source file:org.primordion.xholon.service.xholonhelper.XholonClipboard.java
License:Open Source License
public String readStringFromClipboard() { String str = null;// ww w.j av a 2 s . co m Element element = Document.get().getElementById("xhclipboard").getFirstChildElement(); if (element != null) { TextAreaElement textfield = element.cast(); str = textfield.getValue(); /* the following fails at runtime TextArea ta = TextArea.wrap(element); if (ta.getSelectionLength() == 0) { str = ta.getText(); } else { str = ta.getSelectedText(); } */ } /* GWT Clipboard clipboard = null; try { clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); } catch (AccessControlException e) { return "<Null/>"; } Transferable contents = clipboard.getContents(null); if (contents == null) {return null;} try { if (contents.isDataFlavorSupported(DataFlavor.stringFlavor)) { str = (String)contents.getTransferData(DataFlavor.stringFlavor); } else {str = "<Null/>";} } catch (UnsupportedFlavorException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }*/ return str; }