List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromString
public static SafeHtml fromString(String s)
From source file:org.roda.wui.client.browse.ShowPreservationEvent.java
private void getEventDetailsHTML(final AsyncCallback<SafeHtml> callback) { IndexedPreservationEvent event = bundle.getEvent(); SafeUri uri = RestUtils.createPreservationEventDetailsHTMLUri(eventId, event.getAipID(), event.getRepresentationUUID(), event.getFileUUID()); RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, uri.asString()); requestBuilder.setHeader("Authorization", "Custom"); try {/*from w w w .j a v a 2 s . c om*/ requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { String html = response.getText(); SafeHtmlBuilder b = new SafeHtmlBuilder(); b.append(SafeHtmlUtils.fromSafeConstant("<div class='eventHTML'>")); 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(); // error message b.append(SafeHtmlUtils.fromSafeConstant("<div class='error'>")); b.append(messages.preservationEventDetailsTransformToHTMLError()); 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.roda.wui.client.common.lists.SearchFileList.java
@Override protected void configureDisplay(CellTable<IndexedFile> display) { iconColumn = new Column<IndexedFile, SafeHtml>(new SafeHtmlCell()) { @Override/* ww w . j a va 2s.c om*/ public SafeHtml getValue(IndexedFile file) { if (file != null) { if (file.isDirectory()) { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-folder-open'></i>"); } else { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-file-o'></i>"); } } else { logger.error("Trying to display a NULL item"); } return null; } }; pathColumn = new Column<IndexedFile, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(IndexedFile file) { SafeHtmlBuilder b = new SafeHtmlBuilder(); if (file != null) { List<String> filePath = file.getPath(); String fileName = file.getOriginalName() != null ? file.getOriginalName() : file.getId(); List<String> fullpath = new ArrayList<>(filePath); fullpath.add(fileName); b.append(SafeHtmlUtils.fromSafeConstant("<div title='")); b.append(SafeHtmlUtils.fromString(StringUtils.join(fullpath, "/"))); b.append(SafeHtmlUtils.fromSafeConstant("'>")); if (showFilePath && filePath != null && !filePath.isEmpty()) { String path = StringUtils.join(filePath, "/"); b.append(SafeHtmlUtils.fromSafeConstant("<span class='file-path'>")); b.append(SafeHtmlUtils.fromString(path)); b.append(SafeHtmlUtils.fromSafeConstant("/")); b.append(SafeHtmlUtils.fromSafeConstant("</span>")); } b.append(SafeHtmlUtils.fromString(fileName)); b.append(SafeHtmlUtils.fromSafeConstant("</div>")); } return b.toSafeHtml(); } }; formatColumn = new TextColumn<IndexedFile>() { @Override public String getValue(IndexedFile file) { if (file != null && file.getFileFormat() != null) { FileFormat format = file.getFileFormat(); String ret; if (StringUtils.isNotBlank(format.getFormatDesignationName())) { ret = format.getFormatDesignationName(); if (StringUtils.isNotBlank(format.getFormatDesignationVersion())) { ret = ret + " " + format.getFormatDesignationVersion(); } } else if (StringUtils.isNotBlank(format.getPronom())) { ret = format.getPronom(); } else if (StringUtils.isNotBlank(format.getMimeType())) { ret = format.getMimeType(); } else { ret = null; } return ret; } else { return null; } } }; sizeColumn = new TextColumn<IndexedFile>() { @Override public String getValue(IndexedFile file) { return (file != null && file.getSize() > 0) ? Humanize.readableFileSize(file.getSize()) : ""; } }; /* add sortable */ iconColumn.setSortable(true); pathColumn.setSortable(true); formatColumn.setSortable(true); sizeColumn.setSortable(true); addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<i class='fa fa-files-o'></i>"), false, false, 3); addColumn(pathColumn, messages.filePath(), true, false); addColumn(formatColumn, messages.fileFormat(), true, false); addColumn(sizeColumn, messages.fileSize(), true, false, 7); // define column width priority display.setColumnWidth(iconColumn, 3.0, Unit.EM); display.setColumnWidth(sizeColumn, 6.0, Unit.EM); pathColumn.setCellStyleNames("text-align-left"); formatColumn.setCellStyleNames("text-align-left"); sizeColumn.setCellStyleNames("text-align-right"); // define default sorting display.getColumnSortList().push(new ColumnSortInfo(pathColumn, true)); addStyleName("my-files-table"); }
From source file:org.roda.wui.client.common.search.SearchPanel.java
private void drawSearchPreFilters() { searchPreFilters.clear();// w w w.ja v a2s . c om searchPreFilters.setVisible(defaultFilter != null && !defaultFilter.getParameters().isEmpty()); if (defaultFilter != null) { for (FilterParameter parameter : defaultFilter.getParameters()) { HTML html = null; if (parameter instanceof SimpleFilterParameter) { SimpleFilterParameter p = (SimpleFilterParameter) parameter; html = new HTML( messages.searchPreFilterSimpleFilterParameter(messages.searchPreFilterName(p.getName()), messages.searchPreFilterValue(p.getValue()))); } else if (parameter instanceof BasicSearchFilterParameter) { BasicSearchFilterParameter p = (BasicSearchFilterParameter) parameter; // TODO put '*' in some constant, see Search if (!"*".equals(p.getValue())) { html = new HTML(messages.searchPreFilterBasicSearchFilterParameter( messages.searchPreFilterName(p.getName()), messages.searchPreFilterValue(p.getValue()))); } } else if (parameter instanceof NotSimpleFilterParameter) { NotSimpleFilterParameter p = (NotSimpleFilterParameter) parameter; html = new HTML(messages.searchPreFilterNotSimpleFilterParameter( messages.searchPreFilterName(p.getName()), messages.searchPreFilterValue(p.getValue()))); } else if (parameter instanceof EmptyKeyFilterParameter) { EmptyKeyFilterParameter p = (EmptyKeyFilterParameter) parameter; html = new HTML(messages .searchPreFilterEmptyKeyFilterParameter(messages.searchPreFilterName(p.getName()))); } else { html = new HTML(SafeHtmlUtils.fromString(parameter.getClass().getSimpleName())); } if (html != null) { HTML header = new HTML(SafeHtmlUtils.fromSafeConstant(FILTER_ICON)); header.addStyleName("inline gray"); searchPreFilters.add(header); html.addStyleName("xsmall gray inline nowrap"); searchPreFilters.add(html); } } } }
From source file:org.roda.wui.client.common.slider.InfoSliderHelper.java
private static void updateInfoSliderPanel(IndexedAIP aip, SliderPanel infoSliderPanel) { HashMap<String, SafeHtml> values = new HashMap<>(); infoSliderPanel.clear();//from www .j av a 2s . c o m infoSliderPanel.addTitle(new Label(messages.viewRepresentationInfoTitle())); if (aip != null) { if (StringUtils.isNotBlank(aip.getLevel())) { values.put(messages.aipLevel(), DescriptionLevelUtils.getElementLevelIconSafeHtml(aip.getLevel(), true)); } if (StringUtils.isNotBlank(aip.getTitle())) { values.put(messages.aipGenericTitle(), SafeHtmlUtils.fromString(aip.getTitle())); } if (aip.getDateInitial() != null || aip.getDateFinal() != null) { values.put(messages.aipDates(), SafeHtmlUtils .fromString(Humanize.getDatesText(aip.getDateInitial(), aip.getDateFinal(), true))); } } populate(infoSliderPanel, values); }
From source file:org.roda.wui.client.common.slider.InfoSliderHelper.java
private static void updateInfoSliderPanel(IndexedRepresentation representation, SliderPanel infoSliderPanel) { HashMap<String, SafeHtml> values = new HashMap<>(); infoSliderPanel.clear();//www . ja va 2 s .com infoSliderPanel.addTitle(new Label(messages.viewRepresentationInfoTitle())); if (representation != null) { if (StringUtils.isNotBlank(messages.representationType())) { values.put(messages.representationType(), DescriptionLevelUtils.getRepresentationTypeIcon(representation.getType(), true)); } if (StringUtils.isNotBlank(messages.representationFiles())) { values.put(messages.representationFiles(), SafeHtmlUtils.fromString(messages.numberOfFiles(representation.getNumberOfDataFiles()))); } if (representation.getNumberOfDataFiles() > 0) { values.put(messages.representationFiles(), SafeHtmlUtils.fromString(messages.numberOfFiles(representation.getNumberOfDataFiles()))); } values.put(messages.representationOriginal(), SafeHtmlUtils.fromString(representation.isOriginal() ? messages.originalRepresentation() : messages.alternativeRepresentation())); } populate(infoSliderPanel, values); }
From source file:org.roda.wui.client.common.slider.InfoSliderHelper.java
private static void updateInfoSliderPanel(IndexedFile file, SliderPanel infoSliderPanel) { HashMap<String, SafeHtml> values = new HashMap<>(); infoSliderPanel.clear();/*from w w w . j av a2s .c o m*/ infoSliderPanel.addTitle(new Label(messages.viewRepresentationInfoTitle())); if (file != null) { String fileName = file.getOriginalName() != null ? file.getOriginalName() : file.getId(); values.put(messages.viewRepresentationInfoFilename(), SafeHtmlUtils.fromString(fileName)); if (file.getSize() > 0) { values.put(messages.viewRepresentationInfoSize(), SafeHtmlUtils.fromString(Humanize.readableFileSize(file.getSize()))); } if (file.getFileFormat() != null) { FileFormat fileFormat = file.getFileFormat(); if (StringUtils.isNotBlank(fileFormat.getMimeType())) { values.put(messages.viewRepresentationInfoMimetype(), SafeHtmlUtils.fromString(fileFormat.getMimeType())); } if (StringUtils.isNotBlank(fileFormat.getFormatDesignationName())) { values.put(messages.viewRepresentationInfoFormat(), SafeHtmlUtils.fromString(fileFormat.getFormatDesignationName())); } if (StringUtils.isNotBlank(fileFormat.getFormatDesignationVersion())) { values.put(messages.viewRepresentationInfoFormatVersion(), SafeHtmlUtils.fromString(fileFormat.getFormatDesignationVersion())); } if (StringUtils.isNotBlank(fileFormat.getPronom())) { values.put(messages.viewRepresentationInfoPronom(), SafeHtmlUtils.fromString(fileFormat.getPronom())); } } if (StringUtils.isNotBlank(file.getCreatingApplicationName())) { values.put(messages.viewRepresentationInfoCreatingApplicationName(), SafeHtmlUtils.fromString(file.getCreatingApplicationName())); } if (StringUtils.isNotBlank(file.getCreatingApplicationVersion())) { values.put(messages.viewRepresentationInfoCreatingApplicationVersion(), SafeHtmlUtils.fromString(file.getCreatingApplicationVersion())); } if (StringUtils.isNotBlank(file.getDateCreatedByApplication())) { values.put(messages.viewRepresentationInfoDateCreatedByApplication(), SafeHtmlUtils.fromString(file.getDateCreatedByApplication())); } if (file.getHash() != null && !file.getHash().isEmpty()) { SafeHtmlBuilder b = new SafeHtmlBuilder(); boolean first = true; for (String hash : file.getHash()) { if (first) { first = false; } else { b.append(SafeHtmlUtils.fromSafeConstant("<br/>")); } b.append(SafeHtmlUtils.fromSafeConstant("<small>")); b.append(SafeHtmlUtils.fromString(hash)); b.append(SafeHtmlUtils.fromSafeConstant("</small>")); } values.put(messages.viewRepresentationInfoHash(), b.toSafeHtml()); } if (file.getStoragePath() != null) { SafeHtmlBuilder b = new SafeHtmlBuilder(); b.append(SafeHtmlUtils.fromSafeConstant("<small>")); b.append(SafeHtmlUtils.fromString(file.getStoragePath())); b.append(SafeHtmlUtils.fromSafeConstant("</small>")); values.put(messages.viewRepresentationInfoStoragePath(), b.toSafeHtml()); } } populate(infoSliderPanel, values); }
From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java
public static SafeHtml getAIPStateHTML(AIPState aipState) { SafeHtmlBuilder b = new SafeHtmlBuilder(); switch (aipState) { case ACTIVE: b.append(SafeHtmlUtils.fromSafeConstant(OPEN_SPAN_CLASS_LABEL_SUCCESS)); break;/*w w w .j a va2 s.c o m*/ case UNDER_APPRAISAL: b.append(SafeHtmlUtils.fromSafeConstant(OPEN_SPAN_CLASS_LABEL_WARNING)); break; default: b.append(SafeHtmlUtils.fromSafeConstant(OPEN_SPAN_CLASS_LABEL_DANGER)); break; } b.append(SafeHtmlUtils.fromString(messages.aipState(aipState))); b.append(SafeHtmlUtils.fromSafeConstant(CLOSE_SPAN)); return b.toSafeHtml(); }
From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java
public static SafeHtml getRepresentationTypeHTML(String type, boolean isOriginal) { SafeHtmlBuilder b = new SafeHtmlBuilder(); b.append(SafeHtmlUtils.fromSafeConstant(OPEN_H4_CLASS_LABEL_SUCCESS)); b.append(SafeHtmlUtils.fromString(type)); b.append(SafeHtmlUtils.fromSafeConstant(CLOSE_SPAN)); b.append(SafeHtmlUtils.fromSafeConstant(OPEN_SPAN_ORIGINAL_LABEL_SUCCESS)); if (isOriginal) { b.append(SafeHtmlUtils.fromString(messages.originalRepresentation())); } else {/*from ww w .j a v a2 s . c om*/ b.append(SafeHtmlUtils.fromString(messages.alternativeRepresentation())); } b.append(SafeHtmlUtils.fromSafeConstant(CLOSE_SPAN)); return b.toSafeHtml(); }
From source file:org.roda.wui.client.main.BreadcrumbUtils.java
public static List<BreadcrumbItem> getTransferredResourceBreadcrumbs(TransferredResource r) { List<BreadcrumbItem> ret = new ArrayList<>(); ret.add(new BreadcrumbItem(DescriptionLevelUtils.getTopIconSafeHtml(), "", IngestTransfer.RESOLVER.getHistoryPath())); if (r != null) { // add parent if (r.getParentUUID() != null) { List<String> path = new ArrayList<>(); path.addAll(IngestTransfer.RESOLVER.getHistoryPath()); path.add(r.getParentUUID()); SafeHtml breadcrumbLabel = SafeHtmlUtils.fromString(r.getParentId()); ret.add(new BreadcrumbItem(breadcrumbLabel, r.getParentId(), path)); }//from w ww. ja v a 2s .co m // add self List<String> path = new ArrayList<>(); path.addAll(IngestTransfer.RESOLVER.getHistoryPath()); path.add(r.getUUID()); SafeHtml breadcrumbLabel = SafeHtmlUtils.fromString(r.getName()); ret.add(new BreadcrumbItem(breadcrumbLabel, r.getName(), path)); } return ret; }
From source file:org.roda.wui.client.main.BreadcrumbUtils.java
private static BreadcrumbItem getBreadcrumbItem(final IndexedDIP dip) { SafeHtmlBuilder b = new SafeHtmlBuilder(); // TODO get icon from config b.append(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-play-circle-o'></i>")); b.append(SafeHtmlUtils.fromString(dip.getTitle())); SafeHtml label = b.toSafeHtml();/* www . ja v a 2s . c o m*/ return new BreadcrumbItem(label, dip.getTitle(), new Command() { @Override public void execute() { HistoryUtils.openBrowse(dip); } }); }