List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils htmlEscape
public static String htmlEscape(String s)
From source file:org.roda.wui.client.browse.BrowseAIP.java
private void getDescriptiveMetadataHTML(final String aipId, final String descId, final DescriptiveMetadataViewBundle bundle, final AsyncCallback<SafeHtml> callback) { SafeUri uri = RestUtils.createDescriptiveMetadataHTMLUri(aipId, descId); RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, uri.asString()); requestBuilder.setHeader("Authorization", "Custom"); try {/* w ww . j a v a 2 s .c o m*/ requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { String escapedDescId = SafeHtmlUtils.htmlEscape(descId); if (200 == response.getStatusCode()) { String html = response.getText(); SafeHtmlBuilder b = new SafeHtmlBuilder(); b.append(SafeHtmlUtils.fromSafeConstant("<div class='descriptiveMetadataLinks'>")); if (bundle.hasHistory()) { // History link String historyLink = HistoryUtils.createHistoryHashLink( DescriptiveMetadataHistory.RESOLVER, aipId, escapedDescId); String historyLinkHtml = "<a href='" + historyLink + "' class='toolbarLink'><i class='fa fa-history'></i></a>"; b.append(SafeHtmlUtils.fromSafeConstant(historyLinkHtml)); } // Edit link String editLink = HistoryUtils.createHistoryHashLink(EditDescriptiveMetadata.RESOLVER, aipId, escapedDescId); String editLinkHtml = "<a href='" + editLink + "' class='toolbarLink'><i class='fa fa-edit'></i></a>"; b.append(SafeHtmlUtils.fromSafeConstant(editLinkHtml)); // Download link SafeUri downloadUri = RestUtils.createDescriptiveMetadataDownloadUri(aipId, escapedDescId); String downloadLinkHtml = "<a href='" + downloadUri.asString() + "' class='toolbarLink'><i class='fa fa-download'></i></a>"; b.append(SafeHtmlUtils.fromSafeConstant(downloadLinkHtml)); b.append(SafeHtmlUtils.fromSafeConstant("</div>")); b.append(SafeHtmlUtils.fromSafeConstant("<div class='descriptiveMetadataHTML'>")); b.append(SafeHtmlUtils.fromTrustedString(html)); b.append(SafeHtmlUtils.fromSafeConstant("</div>")); SafeHtml safeHtml = b.toSafeHtml(); callback.onSuccess(safeHtml); } else { String text = response.getText(); String message; try { RestErrorOverlayType error = (RestErrorOverlayType) JsonUtils.safeEval(text); message = error.getMessage(); } catch (IllegalArgumentException e) { message = text; } SafeHtmlBuilder b = new SafeHtmlBuilder(); b.append(SafeHtmlUtils.fromSafeConstant("<div class='descriptiveMetadataLinks'>")); if (bundle.hasHistory()) { // History link String historyLink = HistoryUtils.createHistoryHashLink( DescriptiveMetadataHistory.RESOLVER, aipId, escapedDescId); String historyLinkHtml = "<a href='" + historyLink + "' class='toolbarLink'><i class='fa fa-history'></i></a>"; b.append(SafeHtmlUtils.fromSafeConstant(historyLinkHtml)); } // Edit link String editLink = HistoryUtils.createHistoryHashLink(EditDescriptiveMetadata.RESOLVER, aipId, escapedDescId); String editLinkHtml = "<a href='" + editLink + "' class='toolbarLink'><i class='fa fa-edit'></i></a>"; b.append(SafeHtmlUtils.fromSafeConstant(editLinkHtml)); b.append(SafeHtmlUtils.fromSafeConstant("</div>")); // error message b.append(SafeHtmlUtils.fromSafeConstant("<div class='error'>")); b.append(messages.descriptiveMetadataTransformToHTMLError()); b.append(SafeHtmlUtils.fromSafeConstant("<pre><code>")); b.append(SafeHtmlUtils.fromString(message)); b.append(SafeHtmlUtils.fromSafeConstant("</core></pre>")); b.append(SafeHtmlUtils.fromSafeConstant("</div>")); callback.onSuccess(b.toSafeHtml()); } } @Override public void onError(Request request, Throwable exception) { callback.onFailure(exception); } }); } catch (RequestException e) { callback.onFailure(e); } }
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static SafeHtml createOpenTag(String tagName, String... attribs) { StringBuilder builder = new StringBuilder(); builder.append("<").append(tagName); for (int i = 0; i < attribs.length; i += 2) { builder.append(' ').append(SafeHtmlUtils.htmlEscape(attribs[i])).append("=\"") .append(SafeHtmlUtils.htmlEscape(attribs[i + 1])).append("\""); }//from w w w . j a v a2 s. c om builder.append(">"); return SafeHtmlUtils.fromTrustedString(builder.toString()); }
From source file:org.rstudio.studio.client.notebook.CompileNotebookOptionsDialog.java
License:Open Source License
private String createPrefix() { StringBuilder builder = new StringBuilder(); String title = txtTitle_.getValue().trim(); if (title.length() > 0) { builder.append("### ").append(SafeHtmlUtils.htmlEscape(title)).append("\n"); }/* w ww .j a va2s . com*/ String author = txtAuthor_.getValue().trim(); if (author.length() > 0) { builder.append(SafeHtmlUtils.htmlEscape(author)).append(" --- "); } builder.append("*"); builder.append(StringUtil.formatDate(new Date())); builder.append("*"); return builder.toString(); }
From source file:org.rstudio.studio.client.workbench.views.vcs.git.GitStatusRenderer.java
License:Open Source License
@Override public SafeHtml render(String str) { if (str.length() != 2) return null; ImageResource indexImg = imgForStatus(str.charAt(0)); ImageResource treeImg = imgForStatus(str.charAt(1)); SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status() + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">")); builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(indexImg).getHTML())); builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(treeImg).getHTML())); builder.appendHtmlConstant("</span>"); return builder.toSafeHtml(); }
From source file:org.rstudio.studio.client.workbench.views.vcs.svn.SVNStatusRenderer.java
License:Open Source License
@Override public SafeHtml render(String str) { if (str.length() != 1) return SafeHtmlUtils.fromString(str); ImageResource img = imgForStatus(str.charAt(0)); if (img == null) return SafeHtmlUtils.fromString(str); SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status() + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">")); builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(img).getHTML())); builder.appendHtmlConstant("</span>"); return builder.toSafeHtml(); }
From source file:org.sakaiproject.gradebook.gwt.sakai.GradebookImportController.java
License:Educational Community License
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; String gradebookUid = multipartRequest.getParameter(AppConstants.REQUEST_FORM_FIELD_GBUID); String justStructureCheckBox = multipartRequest.getParameter(AppConstants.IMPORT_PARAM_STRUCTURE); Boolean importJustStructure = justStructureCheckBox != null; String fileTypeNameFromClient = multipartRequest .getParameter(AppConstants.IMPORT_PARAM_FILETYPE + "-hidden"); String fileFormatChosen = multipartRequest.getParameter(AppConstants.IMPORT_PARAM_FILEFORMAT + "-hidden"); FileFormat fileFormatFromClient = FileFormat.getFormatByName(fileFormatChosen); ImportSettings importSettings = new ImportSettingsImpl(); importSettings.setJustStructure(importJustStructure); importSettings.setGradebookUid(gradebookUid); for (Iterator<String> fileNameIterator = multipartRequest.getFileNames(); fileNameIterator.hasNext();) { String fileName = fileNameIterator.next(); MultipartFile file = multipartRequest.getFile(fileName); String origName = file.getOriginalFilename(); Upload importFile = null;/*from w w w . j a v a2s . c o m*/ // first check for sane choices on the client side FileType fileTypeFromFileExt = null; if (fileFormatFromClient == null) { importFile = new UploadImpl(); importFile.setNotes(i18n.getString("unknownFormatSelected")); importFile.setErrors(true); } else { int theLastDot = origName.lastIndexOf("."); if (theLastDot > 0) { fileTypeFromFileExt = FileType.getTypeFromExtension(origName.substring(theLastDot)); if (!fileTypeFromFileExt.equals(FileType.valueOf(fileTypeNameFromClient))) { importFile = new UploadImpl(); importFile.setNotes(i18n.getString("filetypeExtensionMismatch") + fileTypeNameFromClient); importFile.setErrors(true); } } else {//client should be preventing this as of SAK-1221 importFile = new UploadImpl(); importFile.setNotes(i18n.getString("noFileExtensionFound")); importFile.setErrors(true); } } log.debug("Original Name: " + origName + "; type: " + fileTypeFromFileExt); if ((importFile == null || !importFile.hasErrors()) && fileTypeFromFileExt != null) { importSettings.setExportTypeName((ExportType.valueOf(fileTypeNameFromClient)).name()); importSettings.setFileFormatName(fileFormatFromClient.name()); importFile = importExportUtility.getImportFile(file, importSettings); } PrintWriter writer = response.getWriter(); response.setContentType(CONTENT_TYPE_TEXT_HTML); // NOTE: Only use this during DEV phase //saveJsonToFile(importFile, "/tmp/data.json"); if (null == importFile) { importFile = new UploadImpl(); importFile.setErrors(true); importFile.setNotes(i18n.getString("unknownFileType")); } else if (!importJustStructure) { /// to save a few cycles //GRBK-1194 List<Learner> rows = importFile.getRows(); List<String> studentIds = new ArrayList<String>(); StringBuffer msg = null; boolean dupsFound = false; if (rows != null) { for (Learner student : rows) { String id = student.getIdentifier(); if (null == id) continue; if (studentIds.contains(id) && !student.getUserNotFound()) { dupsFound = true; if (null == msg) { msg = new StringBuffer(i18n.getString("importDuplicateStudentsFound", "Duplicate rows found in the table. The following Student Id's where duplicated: ")) .append("'").append(student.getStudentName()).append("'"); } else { msg.append(",").append("'").append(student.getStudentName()).append("'"); } } else { studentIds.add(id); } } if (dupsFound) { importFile.setErrors(true); importFile.setNotes(msg.toString()); } } } writer.write(SafeHtmlUtils.htmlEscape(toJson(importFile))); writer.flush(); writer.close(); } return null; }
From source file:org.spiffyui.client.widgets.dialog.Dialog.java
License:Apache License
private void init(String title, String titleStyle) { final String captionDiv = "<div class=\"spiffy-dialog-caption-close\"><a href=\"#\" id=\"" + m_id + "_close\" title=\"" + STRINGS.close() + "\">" + "<div class=\"spiffy-dialog-caption-close-icon\"></div></a></div>" + "<div id=\"" + m_id + "_title\" class=\"spiffy-dialog-caption " + titleStyle + "\">" + SafeHtmlUtils.htmlEscape(title) + "</div>"; setHTML(captionDiv);/*from w ww . ja va 2 s .c o m*/ FlowPanel main = new FlowPanel(); m_dialogBody = new HTMLPanel("<div><div id=\"" + m_id + "_mainDlgBody\"></div><div>"); main.add(m_dialogBody); add(main); m_buttonBar = new FlowPanel(); m_buttonBar.setStyleName("spiffy-dialog-button-bar"); main.add(m_buttonBar); }
From source file:org.uberfire.client.views.pfly.modal.Bs3Modal.java
License:Apache License
public void setModalTitle(final String title) { this.setTitle(SafeHtmlUtils.htmlEscape(title)); }
From source file:org.uberfire.ext.security.management.client.screens.home.EntitiesManagementHomeView.java
License:Apache License
public void show(final String welcomeText, final List<String> items) { // Main text. homeText.setText(SafeHtmlUtils.htmlEscape(welcomeText)); // List items. removeChildrenElements(itemsPanel.getElement()); if (items != null && !items.isEmpty()) { final Element listElement = DOM.createElement("UL"); for (final String item : items) { final Element itemElement = DOM.createElement("LI"); final Element spanElement = DOM.createElement("SPAN"); spanElement.setInnerText(SafeHtmlUtils.htmlEscape(item)); DOM.appendChild(listElement, itemElement); DOM.appendChild(itemElement, spanElement); }// w w w . j av a 2 s .c o m DOM.appendChild(itemsPanel.getElement(), listElement); } }
From source file:org.uberfire.ext.security.management.client.widgets.management.explorer.EntitiesExplorerViewImpl.java
License:Apache License
void doSearch(final String pattern) { final String pEsc = SafeHtmlUtils.htmlEscape(pattern); heading.setText(UsersManagementWidgetsConstants.INSTANCE.searchResultsFor() + " " + pEsc); clearSearchButton.setEnabled(true);/*from ww w .ja va 2 s. c om*/ if (callback != null) { callback.onSearch(pattern); } }