Example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder append

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder append

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder append.

Prototype

public SafeHtmlBuilder append(SafeHtml html) 

Source Link

Document

Appends the contents of another SafeHtml object, without applying HTML-escaping to it.

Usage

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//from w w  w.  ja  va2 s  .  c o m
        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.lists.utils.TooltipTextCell.java

@Override
public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {

    sb.append(TEMPLATES.startToolTip(value.asString()));
    super.render(context, value, sb);
    sb.append(TEMPLATES.endToolTip());/* w w  w  . jav a 2s .c o  m*/

}

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 ava2 s.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;//from  w w  w  .  ja v  a2  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   w  ww. j  av a2  s.  com*/
        b.append(SafeHtmlUtils.fromString(messages.alternativeRepresentation()));
    }

    b.append(SafeHtmlUtils.fromSafeConstant(CLOSE_SPAN));
    return b.toSafeHtml();
}

From source file:org.roda.wui.client.ingest.process.ShowJob.java

private void update() {
    // set end date
    dateEndedLabel.setVisible(job.getEndDate() != null);
    dateEnded.setVisible(job.getEndDate() != null);
    if (job.getEndDate() != null) {
        dateEnded.setText(dateTimeFormat.format(job.getEndDate()));
    }//from   ww w  .ja  v  a  2  s .  c o  m

    // set duration
    duration.setText(Humanize.durationInDHMS(job.getStartDate(), job.getEndDate(), DHMSFormat.LONG));

    // set state
    status.setHTML(HtmlSnippetUtils.getJobStateHtml(job));

    // set state details
    boolean hasStateDetails = StringUtils.isNotBlank(job.getStateDetails());
    stateDetailsLabel.setVisible(hasStateDetails);
    stateDetailsValue.setVisible(hasStateDetails);
    if (hasStateDetails) {
        stateDetailsValue.setText(job.getStateDetails());
    }

    // set counters
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    b.append(SafeHtmlUtils.fromSafeConstant("<span class='label-default'>"));
    b.append(messages.showJobProgressCompletionPercentage(job.getJobStats().getCompletionPercentage()));
    b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    if (job.getJobStats().getSourceObjectsCount() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-default'>"));
        b.append(messages.showJobProgressTotalCount(job.getJobStats().getSourceObjectsCount()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsProcessedWithSuccess() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-success'>"));
        b.append(messages
                .showJobProgressSuccessfulCount(job.getJobStats().getSourceObjectsProcessedWithSuccess()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsProcessedWithFailure() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-danger'>"));
        b.append(messages.showJobProgressFailedCount(job.getJobStats().getSourceObjectsProcessedWithFailure()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsBeingProcessed() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-info'>"));
        b.append(messages.showJobProgressProcessingCount(job.getJobStats().getSourceObjectsBeingProcessed()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsWaitingToBeProcessed() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-warning'>"));
        b.append(
                messages.showJobProgressWaitingCount(job.getJobStats().getSourceObjectsWaitingToBeProcessed()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }

    progress.setHTML(b.toSafeHtml());

    buttonStop.setText(messages.stopButton());
    buttonStop.setVisible(!job.isInFinalState());
    buttonStop.setEnabled(!job.isStopping());

    buttonAppraisal.setText(messages.appraisalTitle() + " ("
            + job.getJobStats().getOutcomeObjectsWithManualIntervention() + ")");
    buttonAppraisal.setVisible(job.getJobStats().getOutcomeObjectsWithManualIntervention() > 0);

    scheduleUpdateStatus();
}

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();/* w ww  .  ja v a 2s .c o  m*/

    return new BreadcrumbItem(label, dip.getTitle(), new Command() {

        @Override
        public void execute() {
            HistoryUtils.openBrowse(dip);
        }
    });
}

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static BreadcrumbItem getBreadcrumbItem(final DIPFile dipFile) {
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    // TODO get icon from config
    b.append(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-play-circle'></i>"));
    b.append(SafeHtmlUtils.fromString(dipFile.getId()));
    SafeHtml label = b.toSafeHtml();/*  www. j  av a 2s  .  c  o m*/

    return new BreadcrumbItem(label, dipFile.getId(), new Command() {

        @Override
        public void execute() {
            HistoryUtils.openBrowse(dipFile);
        }
    });
}

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static SafeHtml getBreadcrumbLabel(String label, String level) {
    SafeHtml elementLevelIconSafeHtml = DescriptionLevelUtils.getElementLevelIconSafeHtml(level, false);
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(elementLevelIconSafeHtml).append(SafeHtmlUtils.fromString(label));
    return builder.toSafeHtml();
}

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static SafeHtml getBreadcrumbLabel(IndexedAIP aip) {
    SafeHtml breadcrumbLabel;//www. j a  v  a  2s. c  o m
    SafeHtml elementLevelIconSafeHtml;
    if (aip.getGhost()) {
        elementLevelIconSafeHtml = DescriptionLevelUtils.getElementLevelIconSafeHtml(RodaConstants.AIP_GHOST,
                true);
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        builder.append(elementLevelIconSafeHtml);
        breadcrumbLabel = builder.toSafeHtml();
    } else {
        elementLevelIconSafeHtml = DescriptionLevelUtils.getElementLevelIconSafeHtml(aip.getLevel(), false);
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        String label = aip.getTitle() != null ? aip.getTitle() : aip.getId();
        builder.append(elementLevelIconSafeHtml).append(SafeHtmlUtils.fromString(label));
        breadcrumbLabel = builder.toSafeHtml();
    }

    return breadcrumbLabel;
}