List of usage examples for com.google.gwt.dom.client Document createTextNode
public Text createTextNode(String data)
From source file:com.google.maps.gwt.samples.layers.client.LayerPanoramio.java
License:Apache License
@Override public void onModuleLoad() { LatLng fremont = LatLng.create(47.651743, -122.349243); MapOptions mapOpts = MapOptions.create(); mapOpts.setZoom(16);/* w w w . ja va2 s . c o m*/ mapOpts.setCenter(fremont); mapOpts.setMapTypeId(MapTypeId.ROADMAP); final GoogleMap map = GoogleMap.create(Document.get().getElementById("map_canvas"), mapOpts); PanoramioLayer panoramioLayer = PanoramioLayer.create(); panoramioLayer.setMap(map); panoramioLayer.addClickListener(new ClickHandler() { @Override public void handle(PanoramioMouseEvent event) { Document document = Document.get(); Element photoDiv = document.getElementById("photo_panel"); Text attribution = document.createTextNode( event.getFeatureDetails().getTitle() + ": " + event.getFeatureDetails().getAuthor()); Element br = document.createElement("br"); Element link = document.createElement("a"); link.setAttribute("href", event.getFeatureDetails().getUrl()); link.appendChild(attribution); photoDiv.appendChild(br); photoDiv.appendChild(link); } }); }
From source file:com.google.speedtracer.client.SourceViewer.java
License:Apache License
/** * Places a marker in the source for the specified line number at the * specified character offset.//from ww w . ja v a 2s. co m * * @param lineNumber the line which we will use for marking the column. * @param columnNumber the offset from the start of the line to mark. */ public void markColumn(int lineNumber, int columnNumber) { if (columnNumber <= 0) { return; } TableCellElement contentCell = getRowContentCell(getTableRowElement(lineNumber)); columnMarker.removeFromParent(); int zeroIndexCol = columnNumber - 1; String textBeforeMark = contentCell.getInnerText().substring(0, zeroIndexCol); String textAfterMark = contentCell.getInnerText().substring(zeroIndexCol); Document document = contentCell.getOwnerDocument(); contentCell.setInnerText(""); contentCell.appendChild(document.createTextNode(textBeforeMark)); contentCell.appendChild(columnMarker); contentCell.appendChild(document.createTextNode(textAfterMark)); columnMarker.setClassName(styles.columnMarker()); }
From source file:com.google.speedtracer.client.visualizations.view.RequestDetails.java
License:Apache License
private static void maybeAddSpringInsightLinks(ServerEvent event, Css css, Element parent) { final ServerEvent.Data data = event.getServerEventData(); final String applicationUrl = data.getApplicationUrl(); final String endPointUrl = data.getEndPointUrl(); final String traceViewUrl = data.getTraceViewUrl(); if (applicationUrl == null && endPointUrl == null && traceViewUrl == null) { return;/*from w w w .j a va 2 s . c o m*/ } final Document document = parent.getOwnerDocument(); final DivElement element = document.createDivElement(); element.setClassName(css.springInsightViews()); element.setInnerText("Spring Insight Views: "); element.appendChild(document.createTextNode("(")); // Add Trace URL if (traceViewUrl != null) { element.appendChild(createNewTabLink(document, css.springInsightLink(), traceViewUrl, "Trace")); } // Add EndPoint URL if (endPointUrl != null) { // Is there a previous item? if (traceViewUrl != null) { element.appendChild(document.createTextNode(", ")); } element.appendChild(createNewTabLink(document, css.springInsightLink(), endPointUrl, "EndPoint")); } // Add Application URL if (applicationUrl != null) { // Is there a previous item? if (traceViewUrl != null || endPointUrl != null) { element.appendChild(document.createTextNode(", ")); } element.appendChild(createNewTabLink(document, css.springInsightLink(), applicationUrl, "Application")); } element.appendChild(document.createTextNode(") ")); parent.appendChild(element); }
From source file:com.google.speedtracer.client.visualizations.view.StackFrameRenderer.java
License:Apache License
public void render(Element parentElem, boolean attemptResymbolization) { assert (myElem == null) : "Render called twice for StackFrameRenderer!"; myElem = parentElem.getOwnerDocument().createDivElement(); Document document = myElem.getOwnerDocument(); final Url resource = new Url(stackFrame.getUrl()); String resourceName = resource.getLastPathComponent(); resourceName = ("".equals(resourceName)) ? resource.getPath() : resourceName; // If we still don't have anything, replace with [unknown] String symbolName = (stackFrame.getFunctionName().equals("")) ? "[anonymous] " : stackFrame.getFunctionName() + "() "; myElem.appendChild(document.createTextNode(resourceName + "::")); myElem.appendChild(document.createTextNode(symbolName)); // We make a link out of the line number which should pop open // the Source Viewer when clicked. AnchorElement lineLink = document.createAnchorElement(); lineLink.getStyle().setProperty("whiteSpace", "nowrap"); String columnStr = (stackFrame.getColumnOffset() > 0) ? " Col " + stackFrame.getColumnOffset() : ""; lineLink.setInnerText("Line " + stackFrame.getLineNumber() + columnStr); lineLink.setHref("javascript:;"); myElem.appendChild(lineLink);/*from w w w . jav a 2 s.c om*/ myElem.appendChild(document.createBRElement()); stackTraceRenderer.getListenerManager() .manageEventListener(ClickEvent.addClickListener(lineLink, lineLink, new ClickListener() { public void onClick(ClickEvent event) { stackTraceRenderer.getSourceClickListener().onSymbolClicked(resource.getUrl(), null, stackFrame.getLineNumber(), stackFrame.getColumnOffset(), null); } })); myElem.setClassName(stackTraceRenderer.getResources().stackFrameRendererCss().stackFrame()); parentElem.appendChild(myElem); if (attemptResymbolization) { // Add resymbolized data to frame/profile if it is available. SymbolServerController ssController = SymbolServerService .getSymbolServerController(new Url(stackTraceRenderer.getCurrentAppUrl())); if (ssController != null) { ssController.attemptResymbolization(resource.getUrl(), stackFrame.getFunctionName(), this, stackTraceRenderer.getSourcePresenter()); } } }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
private LIElement showGroup(List<Record> recordsToShow, UListElement ul) { final Document document = Document.get(); final String primaryKeyField = getPrimaryKeyFieldName(), iconField = getIconField(), titleField = getTitleField(), infoField = getInfoField(), descriptionField = getDescriptionField(); LIElement lastLI = null;//from w w w . j a v a 2s . c o m for (final Record record : recordsToShow) { final Canvas recordComponent; if (getShowRecordComponents()) { recordComponent = createRecordComponent(record); if (recordComponent == null) { continue; } else recordComponents.add(recordComponent); } else recordComponent = null; final LIElement li = document.createLIElement(); li.addClassName(ROW_CLASS_NAME); com.google.gwt.user.client.Element element = li.cast(); final Object recordID = record.getAttributeAsObject(primaryKeyField); elementMap.put(recordID, element); final Integer recordIndex = record.getAttributeAsInt(recordIndexProperty); li.setAttribute(RECORD_INDEX_ATTRIBUTE_NAME, recordIndex.toString()); if (lastLI == null) { li.addClassName(_CSS.firstTableViewRowClass()); } if (showSelectedIcon && selectedIcon == null && getSelectionType() == SelectionStyle.MULTIPLE) { DivElement selectionDisclosure = document.createDivElement(); selectionDisclosure.setClassName(_CSS.recordSelectionDisclosureClass()); if (!_canSelectRecord(record)) { selectionDisclosure.addClassName(_CSS.nonselectableSelectionDisclosureClass()); } SpanElement span = document.createSpanElement(); selectionDisclosure.appendChild(span); li.appendChild(selectionDisclosure); } if (canRemoveRecords) { Boolean deletable = record.getAttributeAsBoolean(canRemoveProperty); if (deletable == null || (deletable != null && deletable.booleanValue())) { DivElement div = document.createDivElement(); div.addClassName(_CSS.recordDeleteDisclosureClass()); SpanElement span = document.createSpanElement(); div.appendChild(span); li.appendChild(div); if (markedForRemoval != null && markedForRemoval.contains(record)) { _markRecordRemoved(record, div, true); } } } if (canReorderRecords) { MoveIndicator draggableRow = new MoveIndicator(element); add(draggableRow, element); } if (!getShowRecordComponents()) { if (recordFormatter != null) { DivElement div = document.createDivElement(); div.setClassName("content"); div.setInnerHTML(recordFormatter.format(record)); li.appendChild(div); } else { if (getShowNavigation(record)) { final ImageResource navIcon = getNavigationIcon(record); if (navigationMode == NavigationMode.NAVICON_ONLY) { Boolean navigate = record.getAttributeAsBoolean(getRecordNavigationProperty()); if (navigate == null || (navigate != null && navigate.booleanValue())) { final DetailsRow detailsRow = new DetailsRow(navIcon); add(detailsRow, element); } } else if (navIcon != null) { final Image image = new Image(navIcon); image.getElement().addClassName(TableView._CSS.recordDetailDisclosureNavIconClass()); add(image, element); } else { li.addClassName(_CSS.tableViewRowHasNavigationDisclosureClass()); } } if (showIcons) { Object icon = record.get(iconField); if (!(icon instanceof ImageResource) && !(icon instanceof Image)) { icon = formatCellValue(record, recordIndex.intValue(), iconField); } if (icon != null) { SpanElement span = document.createSpanElement(); span.addClassName(RECORD_ICON_CLASS_NAME); li.appendChild(span); li.addClassName(_CSS.tableViewRowHasIconClass()); ImageElement img = document.createImageElement(); if (icon instanceof ImageResource) { img.setSrc(((ImageResource) icon).getSafeUri().asString()); } else if (icon instanceof Image) { img.setSrc(((Image) icon).getUrl()); } else { img.setSrc(icon.toString()); } span.appendChild(img); } } if (showDetailCount) { String count = formatCellValue(record, recordIndex.intValue(), detailCountProperty); if (count != null) { SpanElement span = document.createSpanElement(); span.addClassName(RECORD_COUNTER_CLASS_NAME); span.setInnerHTML(count); li.appendChild(span); } } String title = formatCellValue(record, recordIndex.intValue(), titleField); if (title != null) { SpanElement span = document.createSpanElement(); final String baseStyle = getBaseStyle(record, recordIndex.intValue(), getFieldNum(titleField)); if (baseStyle != null) span.setClassName(baseStyle); span.addClassName(RECORD_TITLE_CLASS_NAME); span.setInnerHTML(title); li.appendChild(span); } if (recordLayout == RecordLayout.AUTOMATIC || recordLayout == RecordLayout.SUMMARY_FULL || recordLayout == RecordLayout.SUMMARY_INFO) { String info = formatCellValue(record, recordIndex.intValue(), infoField); if (info != null) { ul.addClassName(_CSS.stackedTableViewClass()); li.addClassName(_CSS.tableViewRowHasRecordInfoClass()); SpanElement span = document.createSpanElement(); final String baseStyle = getBaseStyle(record, recordIndex.intValue(), getFieldNum(infoField)); if (baseStyle != null) span.setClassName(baseStyle); span.addClassName(RECORD_INFO_CLASS_NAME); span.appendChild(document.createTextNode(info)); li.appendChild(span); } } if (recordLayout == RecordLayout.AUTOMATIC || recordLayout == RecordLayout.TITLE_DESCRIPTION || recordLayout == RecordLayout.SUMMARY_DATA || recordLayout == RecordLayout.SUMMARY_FULL || recordLayout == RecordLayout.SUMMARY_INFO) { String description = formatCellValue(record, recordIndex.intValue(), descriptionField); if (description != null) { SpanElement span = document.createSpanElement(); final String baseStyle = getBaseStyle(record, recordIndex.intValue(), getFieldNum(descriptionField)); if (baseStyle != null) span.setClassName(baseStyle); span.addClassName(RECORD_DESCRIPTION_CLASS_NAME); span.appendChild(document.createTextNode(description)); li.appendChild(span); } } } } else { assert recordComponent != null; recordComponent.getElement().addClassName(RECORD_COMPONENT_CLASS_NAME); add(recordComponent, element); } ul.appendChild(li); lastLI = li; } return lastLI; }
From source file:org.cruxframework.crux.core.client.screen.ViewPortHandlerIEMobileImpl.java
License:Apache License
@Override public void createViewport(String content, JavaScriptObject wnd) { if (!DeviceAdaptiveUtils.isInternetExplorerMobile()) { new ViewPortHandlerImpl().createViewport(content, wnd); return;/*www . ja va2 s.c o m*/ } Document document = getWindowDocument(wnd); Element header = document.getElementsByTagName("head").getItem(0); StyleElement viewPortStyleElement = document.createStyleElement(); String newProperties = handlePropertiesToCSS(content); viewPortStyleElement.appendChild(document.createTextNode("@-ms-viewport{" + newProperties + "}")); header.appendChild(viewPortStyleElement); JavaScriptObject parentWindow = getParentWindow(wnd); if (parentWindow != null && isCruxWindow(parentWindow)) { createViewport(content, parentWindow); } }
From source file:org.eurekastreams.web.client.ui.common.stream.renderers.content.ParsedContentRenderer.java
License:Apache License
/** * Renders a single segment into the supplied container element (appending to existing content). * * @param segment//from w w w .j av a2 s . co m * The segment. * @param parent * The container element. * @param streamSearchLinkBuilder * For building links for hashtags. */ public void renderSegment(final ContentSegment segment, final ComplexPanel parent, final StreamSearchLinkBuilder streamSearchLinkBuilder) { // Notes: // * The element and widget setters automatically HTML encode content, hence it is not explicitly done. // * Using plain elements instead of widgets to keep markup cleaner, except for internal links. Although the // internal links will go to the right place when implemented as plain anchors, IE will lose all its history. // (So really this is working around another IE bug.) final Element parentElement = parent.getElement(); final Document doc = parentElement.getOwnerDocument(); if (segment.isText()) { parentElement.appendChild(doc.createTextNode(segment.getContent())); } else if (segment.isLink()) { String url; if (segment.getContent().charAt(0) == '#' && (segment.getUrl() == null || segment.getUrl().isEmpty())) { // hashtag - determine URL to link to url = streamSearchLinkBuilder.buildHashtagSearchLink(segment.getContent(), null); } else { // "normal" link - target is known. url = segment.getUrl(); } // May be internal or external; open in new window unless internal. if (url.charAt(0) == '#') { parent.add(new InlineHyperlink(segment.getContent(), url.substring(1))); } else { AnchorElement anchor = doc.createAnchorElement(); anchor.setHref(url); anchor.appendChild(doc.createTextNode(segment.getContent())); anchor.setTarget("_blank"); parentElement.appendChild(anchor); } } else if (segment.isTag() && "br/".equals(segment.getContent())) { parentElement.appendChild(doc.createBRElement()); } }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.decorator.AnnoteaDecoratorVisitor.java
License:Apache License
private void processDecoratedNode(Node node, String data, Node parent) { String[] selectedText = getSelectedText(data, textToAnnotate); if (selectedText[1].trim().length() == 0 && selectedText[2].trim().length() == 0 && node.getParentNode().getNodeName().equalsIgnoreCase("tr")) { // don't add nodes to tr textToAnnotate -= selectedText[0].length(); return;//ww w.j a v a2 s . co m } Document document = node.getOwnerDocument(); SpanElement spanElement = getSpanElement(document); spanElement.setInnerText(selectedText[1]); insertBefore(parent, node.getNextSibling(), spanElement); if (selectedText[2].length() > 0) { insertBefore(parent, spanElement.getNextSibling(), document.createTextNode(selectedText[2])); } textToAnnotate -= selectedText[0].length(); }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.decorator.NuxeoDecoratorVisitor.java
License:Apache License
protected void decorateText(String textToDecorate) { checkEndNodeFound();/* w ww. j av a 2 s .co m*/ String afterText = getAfterText(); Log.debug("Decorator -- afterText: " + afterText); if (afterText.length() > 0) { textToDecorate = textToDecorate.substring(0, textToDecorate.length() - afterText.length()); } if (currentNode.getParentNode().getNodeName().equalsIgnoreCase("tr")) { // don't add nodes to tr return; } com.google.gwt.dom.client.Element spanElement = decorateTextWithSpan(textToDecorate); if (spanElement == null) { if (afterText.length() > 0) { Document document = currentNode.getOwnerDocument(); Node parent = currentNode.getParentNode(); insertBefore(parent, currentNode, document.createTextNode(afterText)); } } else { Log.debug("Decorator -- span element: " + spanElement.getInnerHTML()); if (afterText.length() > 0) { Document document = currentNode.getOwnerDocument(); Node parent = currentNode.getParentNode(); insertBefore(parent, spanElement.getNextSibling(), document.createTextNode(afterText)); } } }
From source file:org.openxdata.sharedlib.client.view.FormRunnerView.java
/** * Reloads the form runner view//from w w w. j a va 2s .c om * * @param formDef the form definition to load. * @param layoutXml the form widget layout xml. * @param externalSourceWidgets a list of widgets which get their data from sources * external to the xform. */ public void loadForm(FormDef formDef, String layoutXml, String javaScriptSrc, List<RuntimeWidgetWrapper> externalSourceWidgets, boolean previewMode) { FormUtil.initialize(); if (previewMode) { //Here we must be in preview mode where we need to create a new copy of the formdef //such that we don't set preview values as default formdef values. if (formDef == null) this.formDef = null; else //set the document xml which we shall need for updating the model with question answers this.formDef = XformParser.copyFormDef(formDef); } else this.formDef = formDef; tabs.clear(); if (formDef == null || layoutXml == null || layoutXml.trim().length() == 0) { addNewTab(constants.page() + "1"); return; } loadLayout(layoutXml, externalSourceWidgets, getCalcQtnMappings(this.formDef)); isValid(true); moveToFirstWidget(); com.google.gwt.dom.client.Element script = DOM.getElementById("formtools_javascript"); if (script != null) script.removeFromParent(); if (javaScriptSrc != null) { Document document = Document.get(); script = document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("id", "formtools_javascript"); script.appendChild(document.createTextNode(javaScriptSrc)); document.getElementsByTagName("head").getItem(0).appendChild(script); } this.externalSourceWidgets = externalSourceWidgets; externalSourceWidgetIndex = 0; if (externalSourceWidgets != null && externalSourceWidgets.size() > 0 && FormUtil.getExternalSourceUrlSuffix() != null) fillExternalSourceWidget(externalSourceWidgets.get(externalSourceWidgetIndex++), null); }