Example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

Introduction

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

Prototype

public static SafeHtml fromSafeConstant(String s) 

Source Link

Document

Returns a SafeHtml constructed from a safe string, i.e., without escaping the string.

Usage

From source file:org.roda.wui.client.common.slider.DisseminationsSliderHelper.java

private static FlowPanel createDisseminationPanel(final IndexedDIP dip) {
    FlowPanel layout = new FlowPanel();

    // open layout
    FlowPanel leftLayout = new FlowPanel();
    Label titleLabel = new Label(dip.getTitle());
    Label descriptionLabel = new Label(dip.getDescription());

    leftLayout.add(titleLabel);/*w  w  w  . j ava2 s  . c o m*/
    leftLayout.add(descriptionLabel);

    FocusPanel openFocus = new FocusPanel(leftLayout);
    layout.add(openFocus);

    // options
    HTML optionsIcon = new HTML(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-ellipsis-v'></i>"));
    final FocusPanel optionsButton = new FocusPanel(optionsIcon);

    optionsButton.addStyleName("lightbtn");
    optionsIcon.addStyleName("lightbtn-icon");
    optionsButton.setTitle(messages.browseFileDipDelete());

    optionsButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showActions(dip, optionsButton);
        }
    });

    layout.add(optionsButton);

    titleLabel.addStyleName("dipTitle");
    descriptionLabel.addStyleName("dipDescription");
    layout.addStyleName("dip");
    leftLayout.addStyleName("dip-left");
    openFocus.addStyleName("dip-focus");
    optionsButton.addStyleName("dip-options");

    openFocus.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            BrowserService.Util.getInstance().showDIPEmbedded(new AsyncCallback<Boolean>() {
                @Override
                public void onFailure(Throwable caught) {
                    AsyncCallbackUtils.defaultFailureTreatment(caught);
                }

                @Override
                public void onSuccess(Boolean showEmbedded) {
                    if (StringUtils.isNotBlank(dip.getOpenExternalURL()) && !showEmbedded) {
                        Window.open(dip.getOpenExternalURL(), "_blank", "");
                        Toast.showInfo(messages.browseFileDipOpenedExternalURL(), dip.getOpenExternalURL());
                    } else {
                        HistoryUtils.openBrowse(dip);
                    }
                }
            });
        }

    });

    return layout;
}

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  . ja v  a  2  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 getJobStateHtml(Job job) {
    SafeHtml ret = null;//from  w  ww.  j av a2  s  .com
    if (job != null) {
        JOB_STATE state = job.getState();
        if (JOB_STATE.COMPLETED.equals(state)) {
            if (job.getJobStats().getSourceObjectsCount() == job.getJobStats()
                    .getSourceObjectsProcessedWithSuccess()) {
                ret = SafeHtmlUtils.fromSafeConstant(
                        OPEN_SPAN_CLASS_LABEL_SUCCESS + messages.showJobStatusCompleted() + CLOSE_SPAN);
            } else if (job.getJobStats().getSourceObjectsProcessedWithSuccess() > 0) {
                ret = SafeHtmlUtils.fromSafeConstant(
                        OPEN_SPAN_CLASS_LABEL_WARNING + messages.showJobStatusCompleted() + CLOSE_SPAN);
            } else {
                ret = SafeHtmlUtils.fromSafeConstant(
                        OPEN_SPAN_CLASS_LABEL_DANGER + messages.showJobStatusCompleted() + CLOSE_SPAN);
            }
        } else if (JOB_STATE.FAILED_DURING_CREATION.equals(state)) {
            ret = SafeHtmlUtils.fromSafeConstant(
                    OPEN_SPAN_CLASS_LABEL_DEFAULT + messages.showJobStatusFailedDuringCreation() + CLOSE_SPAN);
        } else if (JOB_STATE.FAILED_TO_COMPLETE.equals(state)) {
            ret = SafeHtmlUtils.fromSafeConstant(
                    OPEN_SPAN_CLASS_LABEL_DEFAULT + messages.showJobStatusFailedToComplete() + CLOSE_SPAN);
        } else if (JOB_STATE.STOPPING.equals(state)) {
            ret = SafeHtmlUtils.fromSafeConstant(
                    OPEN_SPAN_CLASS_LABEL_DEFAULT + messages.showJobStatusStopping() + CLOSE_SPAN);
        } else if (JOB_STATE.STOPPED.equals(state)) {
            ret = SafeHtmlUtils.fromSafeConstant(
                    OPEN_SPAN_CLASS_LABEL_DEFAULT + messages.showJobStatusStopped() + CLOSE_SPAN);
        } else if (JOB_STATE.CREATED.equals(state)) {
            ret = SafeHtmlUtils.fromSafeConstant(
                    OPEN_SPAN_CLASS_LABEL_INFO + messages.showJobStatusCreated() + CLOSE_SPAN);
        } else if (JOB_STATE.STARTED.equals(state)) {
            ret = SafeHtmlUtils.fromSafeConstant(
                    OPEN_SPAN_CLASS_LABEL_INFO + messages.showJobStatusStarted() + CLOSE_SPAN);
        } else {
            ret = SafeHtmlUtils.fromSafeConstant(OPEN_SPAN_CLASS_LABEL_WARNING + state + CLOSE_SPAN);
        }
    }
    return ret;
}

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  ww .  ja v  a2s . 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 a  v a 2  s. c o  m
        b.append(SafeHtmlUtils.fromString(messages.alternativeRepresentation()));
    }

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

From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java

public static SafeHtml getPluginStateHTML(PluginState pluginState) {
    SafeHtml pluginStateHTML;//from   ww  w .  java  2 s  . co m
    switch (pluginState) {
    case SUCCESS:
        pluginStateHTML = SafeHtmlUtils.fromSafeConstant(
                OPEN_SPAN_CLASS_LABEL_SUCCESS + messages.pluginStateMessage(pluginState) + CLOSE_SPAN);
        break;
    case RUNNING:
        pluginStateHTML = SafeHtmlUtils.fromSafeConstant(
                OPEN_SPAN_CLASS_LABEL_DEFAULT + messages.pluginStateMessage(pluginState) + CLOSE_SPAN);
        break;
    case FAILURE:
    default:
        pluginStateHTML = SafeHtmlUtils.fromSafeConstant(
                OPEN_SPAN_CLASS_LABEL_DANGER + messages.pluginStateMessage(pluginState) + CLOSE_SPAN);
        break;
    }
    return pluginStateHTML;
}

From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java

public static SafeHtml getNotificationStateHTML(NOTIFICATION_STATE state, String label) {
    SafeHtml notificationStateHTML;//  w w w .  ja  v  a  2  s .  com
    switch (state) {
    case COMPLETED:
        notificationStateHTML = SafeHtmlUtils
                .fromSafeConstant(OPEN_SPAN_CLASS_LABEL_SUCCESS + label + CLOSE_SPAN);
        break;
    case FAILED:
        notificationStateHTML = SafeHtmlUtils
                .fromSafeConstant(OPEN_SPAN_CLASS_LABEL_DANGER + label + CLOSE_SPAN);
        break;
    case CREATED:
    default:
        notificationStateHTML = SafeHtmlUtils
                .fromSafeConstant(OPEN_SPAN_CLASS_LABEL_DEFAULT + label + CLOSE_SPAN);
        break;
    }
    return notificationStateHTML;
}

From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java

public static SafeHtml getSeverityDefinition(SEVERITY_LEVEL level) {
    SafeHtml ret;//from w w  w . j a  va  2s  . co  m
    switch (level) {
    case LOW:
        ret = SafeHtmlUtils
                .fromSafeConstant(OPEN_SPAN_CLASS_LABEL_SUCCESS + messages.severityLevel(level) + CLOSE_SPAN);
        break;
    case MODERATE:
        ret = SafeHtmlUtils
                .fromSafeConstant(OPEN_SPAN_CLASS_LABEL_WARNING + messages.severityLevel(level) + CLOSE_SPAN);
        break;
    case HIGH:
    default:
        ret = SafeHtmlUtils
                .fromSafeConstant(OPEN_SPAN_CLASS_LABEL_DANGER + messages.severityLevel(level) + CLOSE_SPAN);
        break;
    }
    return ret;
}

From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java

public static SafeHtml getStatusDefinition(INCIDENCE_STATUS status) {
    if (status.equals(INCIDENCE_STATUS.UNMITIGATED)) {
        return SafeHtmlUtils.fromSafeConstant(
                OPEN_SPAN_CLASS_LABEL_DANGER + messages.riskIncidenceStatusValue(status) + CLOSE_SPAN);
    } else {//from   w  w  w. j  av  a  2  s .c o  m
        return SafeHtmlUtils.fromSafeConstant(
                OPEN_SPAN_CLASS_LABEL_SUCCESS + messages.riskIncidenceStatusValue(status) + CLOSE_SPAN);
    }
}

From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java

public static SafeHtml getLogEntryStateHtml(LOG_ENTRY_STATE state) {
    String labelClass;/*from  w  w w. ja  v a2s .c o m*/

    switch (state) {
    case SUCCESS:
        labelClass = "label-success";
        break;

    case FAILURE:
        labelClass = "label-danger";
        break;

    case UNAUTHORIZED:
        labelClass = "label-warning";
        break;

    default:
        labelClass = "label-default";
        break;
    }

    return SafeHtmlUtils.fromSafeConstant(
            "<span class='" + labelClass + "'>" + messages.logEntryStateValue(state) + CLOSE_SPAN);
}