List of usage examples for com.google.gwt.user.client.ui TextArea wrap
public static TextArea wrap(Element element)
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.MPProxyBody.java
License:Apache License
/** * @param e//w w w.j a v a 2 s .c o m * @return a textbox or textarea widget if the element is one of those, otherwise null */ private TextBoxBase getTextBoxBase(Element e) { if (e.getTagName().equalsIgnoreCase("input") && (e.getAttribute("type") == null || e.getAttribute("type").isEmpty() || e.getAttribute("type").equalsIgnoreCase("text"))) return TextBox.wrap(e); else if (e.getTagName().equalsIgnoreCase("textarea")) return TextArea.wrap(e); return null; }
From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java
License:Apache License
/** preserves event handlers on element to be wrapped */ public static Widget elementToWidget(Element e, String typ) { Widget result = null;/* w w w . j av a 2s . co m*/ if (e != null) { int eventsSunk = DOM.getEventsSunk(e); EventListener el = DOM.getEventListener(e); if (typ == TEXT) result = TextBox.wrap(e); else if (typ == TEXT_AREA) result = TextArea.wrap(e); else if (typ == PASSWORD) result = PasswordTextBox.wrap(e); else if (typ == LABEL) result = Label.wrap(e); else if (typ == A) result = Anchor.wrap(e); else if (typ == IMAGE) result = Image.wrap(e); else if (typ == SELECT) result = ListBox.wrap(e); else if (typ == HIDDEN) result = Hidden.wrap(e); else if (typ == FILE) result = FileUpload.wrap(e); else if (typ == FORM) result = FormPanel.wrap(e, true); else if (typ == FRAME) result = Frame.wrap(e); else if (typ == SUBMIT) result = SubmitButton.wrap(e); else if (typ == BUTTON) result = Button.wrap(e); else if (typ == CHECK_BOX) result = SimpleCheckBox.wrap(e); DOM.sinkEvents(e, eventsSunk); DOM.setEventListener(e, el); } else { if (typ == TEXT) result = new TextBox(); else if (typ == TEXT_AREA) result = new TextArea(); else if (typ == PASSWORD) result = new PasswordTextBox(); else if (typ == LABEL) result = new Label(); else if (typ == A) result = new Anchor(); else if (typ == SELECT) result = new ListBox(); else if (typ == IMAGE) result = new Image(); else if (typ == HIDDEN) result = new Hidden(); else if (typ == FILE) result = new FileUpload(); else if (typ == FORM) result = new FormPanel(); else if (typ == FRAME) result = new Frame(); else if (typ == SUBMIT) result = new SubmitButton(); else if (typ == BUTTON) result = new Button(); else if (typ == CHECK_BOX) result = SimpleCheckBox.wrap(e); } return result; }
From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java
License:Apache License
/** preserves event handlers on element to be wrapped */ public static Widget elementToWidget(String elementName, String typ) { Widget result = null;// ww w. j a va2 s . co m Element e = DOM.getElementById(elementName); if (e != null) { int eventsSunk = DOM.getEventsSunk(e); EventListener el = DOM.getEventListener(e); if (typ == TEXT) result = TextBox.wrap(e); else if (typ == TEXT_AREA) result = TextArea.wrap(e); else if (typ == PASSWORD) result = PasswordTextBox.wrap(e); else if (typ == LABEL) result = Label.wrap(e); else if (typ == A) result = Anchor.wrap(e); else if (typ == SELECT) result = ListBox.wrap(e); else if (typ == IMAGE) result = Image.wrap(e); else if (typ == HIDDEN) result = Hidden.wrap(e); else if (typ == FILE) result = FileUpload.wrap(e); else if (typ == FORM) result = FormPanel.wrap(e, true); else if (typ == FRAME) result = Frame.wrap(e); else if (typ == SUBMIT) result = SubmitButton.wrap(e); else if (typ == BUTTON) result = Button.wrap(e); else if (typ == CHECK_BOX) result = SimpleCheckBox.wrap(e); DOM.sinkEvents(e, eventsSunk); DOM.setEventListener(e, el); } else { if (typ == TEXT) result = new TextBox(); else if (typ == TEXT_AREA) result = new TextArea(); else if (typ == PASSWORD) result = new PasswordTextBox(); else if (typ == LABEL) result = new Label(); else if (typ == A) result = new Anchor(); else if (typ == IMAGE) result = new Image(); else if (typ == SELECT) result = new ListBox(); else if (typ == HIDDEN) result = new Hidden(); else if (typ == FILE) result = new FileUpload(); else if (typ == FORM) result = new FormPanel(); else if (typ == FRAME) result = new Frame(); else if (typ == SUBMIT) result = new SubmitButton(); else if (typ == BUTTON) result = new Button(); else if (typ == CHECK_BOX) result = SimpleCheckBox.wrap(e); } return result; }
From source file:fr.gael.dhus.gwt.client.page.management.ManagementCollectionsPage.java
License:Open Source License
private static void init() { showCollectionManagement();/*ww w. j av a 2 s . c o m*/ name = TextBox.wrap(RootPanel.get("managementCollection_name").getElement()); description = TextArea.wrap(RootPanel.get("managementCollection_description").getElement()); parent = TextBox.wrap(RootPanel.get("managementCollection_parent").getElement()); createButton = RootPanel.get("managementCollection_buttonCreate"); createSubButton = RootPanel.get("managementCollection_buttonCreateSub"); resetButton = RootPanel.get("managementCollection_buttonReset"); saveButton = RootPanel.get("managementCollection_buttonSave"); updateButton = RootPanel.get("managementCollection_buttonUpdate"); deleteButton = RootPanel.get("managementCollection_buttonDelete"); cancelButton = RootPanel.get("managementCollection_buttonCancel"); createButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (createButton.getElement().getClassName().contains("disabled")) { return; } deselect(); CollectionData parent = selectedCollection; selectedCollection = new CollectionData(); selectedCollection.setParent(parent); setState(State.CREATE, true); } }, ClickEvent.getType()); createSubButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (createSubButton.getElement().getClassName().contains("disabled")) { return; } CollectionData parent = selectedCollection; selectedCollection = new CollectionData(); selectedCollection.setParent(parent); setState(State.CREATESUB, true); } }, ClickEvent.getType()); resetButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (resetButton.getElement().getClassName().contains("disabled")) { return; } setState(state, true); } }, ClickEvent.getType()); saveButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (saveButton.getElement().getClassName().contains("disabled")) { return; } save(true); } }, ClickEvent.getType()); updateButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (updateButton.getElement().getClassName().contains("disabled")) { return; } save(false); } }, ClickEvent.getType()); deleteButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (deleteButton.getElement().getClassName().contains("disabled")) { return; } Long selectedId = selectedCollection.getId(); List<CollectionData> selectedDisplayedChildren = selectedCollection.getDisplayedChildren(); disableAll(); displayedCollections.remove(selectedId); if (selectedDisplayedChildren != null && selectedDisplayedChildren.size() > 0) { removeFromDisplayedCollections(selectedDisplayedChildren); } collectionService.deleteCollection(selectedId, new AccessDeniedRedirectionCallback<Void>() { @Override public void _onFailure(Throwable caught) { Window.alert("Cannot delete collection.\n" + caught.getMessage()); setNothingState(); refreshCollections(); } @Override public void onSuccess(Void result) { setNothingState(); refreshCollections(); } }); } }, ClickEvent.getType()); cancelButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (cancelButton.getElement().getClassName().contains("disabled")) { return; } setNothingState(); } }, ClickEvent.getType()); setNothingState(); }
From source file:fr.loria.score.client.RtApi.java
License:Open Source License
public RtApi(JavaScriptObject jsConfig) { // and set the caret at pos 0 Config config = new DefaultConfig(jsConfig); // Get the text area element Element htmlTextAreaElement = DOM.getElementById(config.getParameter("textAreaId")); if (htmlTextAreaElement == null) { return;/*w w w. j a v a 2s . c o m*/ } Element toReplace = DOM.getElementById(config.getParameter("toReplaceId")); if (toReplace == null) { toReplace = htmlTextAreaElement; } if (htmlTextAreaElement.getTagName().equalsIgnoreCase("textarea")) { int width = 500; int height = 210; TextArea tArea = TextArea.wrap(htmlTextAreaElement); height = tArea.getOffsetHeight(); width = tArea.getOffsetWidth(); Element canvasEl = DOM.createElement("canvas"); canvasEl.setId("editor"); canvasEl.setPropertyInt("width", width); canvasEl.setPropertyInt("height", height); com.google.gwt.dom.client.Element parentElem = toReplace.getParentElement(); parentElem.insertFirst(canvasEl); parentElem.removeChild(toReplace); injectJSFilesForRTEditor(parentElem); editor = Editor.getEditor(); editor.addHooksToEventListeners(new EditorApi()); clientJupiter.setCommunicationService(comService); clientJupiter.setDocument(new PlainDocument(tArea.getText())); clientJupiter.setEditingSessionId(config.getParameter(DOCUMENT_ID).hashCode()); clientJupiter.setCallback(new ClientCallback.PlainClientCallback(editor)); clientJupiter.connect(); } }
From source file:org.primordion.xholon.io.console.XholonConsole.java
License:Open Source License
public void postConfigure() { // set various Xholon attributes for XholonConsole IXholonClass ixc = app.getClassNode("XholonConsole"); if (ixc != null) { setXhc(ixc);//from w ww. j a v a 2 s. c om } setId(app.getNextId()); setRoleName(context.getName()); if ((context.getXhc() != null) && context.getXhc().hasAncestor("Avatar")) { setTerminalEnabled(true); sendMsgAsyncOrSync = SENDMESSAGE_SYNC; } historyQ = new Queue(historyQSize); // append this new node to the View /* IXholon view = app.getAppRoot().getFirstChild(); while (view != null) { if ("View".equals(view.getRoleName())) { break; } view = view.getNextSibling(); } if (view != null) { IXholon viewXholonConsole = view.getFirstChild(); while (viewXholonConsole != null) { if ("XholonConsoles".equals(viewXholonConsole.getRoleName())) { break; } viewXholonConsole = viewXholonConsole.getNextSibling(); } if (viewXholonConsole == null) { // create a container XholonConsole node viewXholonConsole = ((IControl)view).setControlNode("XholonConsoles", (Control)view, view.getXhc()); } appendChild(viewXholonConsole); } */ readGuiFromXml(); // Special menu String specialXml = app.rcConfig("special", app.findGwtClientBundle()); if (specialXml != null) { //node.consoleLog("special.xml"); //node.consoleLog(specialXml); final Specials specials = new Specials(); specials.xmlString2Items(specialXml, this); String[] moreSpecialItems = specials.getActionList(); if (moreSpecialItems != null) { MenuBar specialSubMenu = new MenuBar(true); for (int i = 0; i < moreSpecialItems.length; i++) { final String actionName = moreSpecialItems[i]; specialSubMenu.addItem(actionName, new Command() { @Override public void execute() { //context.consoleLog("execute() " + actionName); specials.doAction(actionName); } }); } special.setSubMenu(specialSubMenu); } } else { //special.setEnabled(false); special.getParentMenu().removeItem(special); } // History menu // TODO History menu is only updated if I click on "History" // TODO don't add duplicates to the historyQ history.setScheduledCommand(new Command() { @Override public void execute() { if (historyQ.getSize() > 0) { MenuBar historySubMenu = new MenuBar(true); List<String> hitems = (List<String>) historyQ.getItems(); for (int i = 0; i < hitems.size(); i++) { final String hitem = hitems.get(i); historySubMenu.addItem(limitLength(hitem, 80), new Command() { @Override public void execute() { if (isTerminalEnabled()) { // replace the content of the last line with hitem String taval = getCommand(); int lastNewlinePos = taval.lastIndexOf("\n"); if (lastNewlinePos == -1) { setResult(hitem, true); } else { setResult(taval.substring(0, lastNewlinePos + 1) + hitem, true); } } else { // replace entire console contents with hitem setResult(hitem, true); } } }); } history.setSubMenu(historySubMenu); } } }); // File menu fileopen.setEnabled(false); filesave.setEnabled(false); filesaveas.setEnabled(false); closeguiMI.setEnabled(false); // Edit menu clearcommand.setScheduledCommand(new Command() { @Override public void execute() { clearCommand(); } }); increasefontsize.setScheduledCommand(new Command() { @Override public void execute() { changeFontSize(2.0); } }); decreasefontsize.setScheduledCommand(new Command() { @Override public void execute() { changeFontSize(-2.0); } }); // Mode menu //modedefault.setEnabled(true); //modexpath.setEnabled(true); //modejs.setEnabled(true); modeattr.setEnabled(false); modedefault.setScheduledCommand(new Command() { @Override public void execute() { setMode("default:"); } }); modexpath.setScheduledCommand(new Command() { @Override public void execute() { setMode("xpath:"); } }); modejs.setScheduledCommand(new Command() { @Override public void execute() { setMode("js:"); } }); modeattr.setScheduledCommand(new Command() { @Override public void execute() { setMode("attr:"); } }); terminal.setScheduledCommand(new Command() { @Override public void execute() { terminalEnabled = !terminalEnabled; } }); // Help menu help.setScheduledCommand(new Command() { @Override public void execute() { help(); } }); xpath.setScheduledCommand(new Command() { @Override public void execute() { xpathExamples(); } }); jsscript.setScheduledCommand(new Command() { @Override public void execute() { jsScript(); } }); behaviorScript.setScheduledCommand(new Command() { @Override public void execute() { behaviorScript(); } }); behaviorScriptProto.setScheduledCommand(new Command() { @Override public void execute() { behaviorScriptProto(); } }); behaviorScriptInstance.setScheduledCommand(new Command() { @Override public void execute() { behaviorScriptInstance(); } }); // handle the submit MenuItem submit.setScheduledCommand(new Command() { @Override public void execute() { submit(); } }); // TextArea handle ENTER key // TODO bug - TextArea.wrap(commandPaneTAE), in devmode, fails on assertion that the element is attached TextArea ta = null; try { ta = TextArea.wrap(commandPaneTAE); } catch (AssertionError ae) { // execute the lines of code that are in TextArea.wrap(); it won't compile //ta = new TextArea(commandPaneTAE); // Mark it attached and remember it for cleanup. //ta.onAttach(); //RootPanel.detachOnWindowClose(ta); this.consoleLog("XholonConsole " + ae.toString()); } finally { if (ta != null) { ta.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { if (isTerminalEnabled()) { submit(); } } } }); } } }