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

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

Introduction

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

Prototype

public static SafeHtml fromString(String s) 

Source Link

Document

Returns a SafeHtml containing the escaped string.

Usage

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();/*from  w ww.  j  a v  a 2  s  .co  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;//from   ww  w.  ja  v  a2s  .c om
    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;
}

From source file:org.roda.wui.client.management.ShowLogEntry.java

/**
 * Create a new panel to view a log entry
 *
 *//*  w  ww  .ja  va  2s . c  o  m*/
public ShowLogEntry(LogEntry logEntry) {
    initWidget(uiBinder.createAndBindUi(this));

    logIdValue.setText(logEntry.getId());
    logIdLabel.setVisible(StringUtils.isNotBlank(logEntry.getId()));
    logIdValue.setVisible(StringUtils.isNotBlank(logEntry.getId()));

    logComponentValue.setText(logEntry.getActionComponent());
    logComponentLabel.setVisible(StringUtils.isNotBlank(logEntry.getActionComponent()));
    logComponentValue.setVisible(StringUtils.isNotBlank(logEntry.getActionComponent()));

    logMethodValue.setText(logEntry.getActionMethod());
    logMethodLabel.setVisible(StringUtils.isNotBlank(logEntry.getActionMethod()));
    logMethodValue.setVisible(StringUtils.isNotBlank(logEntry.getActionMethod()));

    logAddressValue.setText(logEntry.getAddress());
    logAddressLabel.setVisible(StringUtils.isNotBlank(logEntry.getAddress()));
    logAddressValue.setVisible(StringUtils.isNotBlank(logEntry.getAddress()));

    logDatetimeValue
            .setText(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(logEntry.getDatetime()));
    logDatetimeLabel.setVisible(logEntry.getDatetime() != null);
    logDatetimeValue.setVisible(logEntry.getDatetime() != null);

    logRelatedObjectValue.setText(logEntry.getRelatedObjectID());
    logRelatedObjectLabel.setVisible(StringUtils.isNotBlank(logEntry.getRelatedObjectID()));
    logRelatedObjectValue.setVisible(StringUtils.isNotBlank(logEntry.getRelatedObjectID()));

    logUsernameValue.setText(logEntry.getUsername());
    logUsernameLabel.setVisible(StringUtils.isNotBlank(logEntry.getUsername()));
    logUsernameValue.setVisible(StringUtils.isNotBlank(logEntry.getUsername()));

    List<LogEntryParameter> parameters = logEntry.getParameters();

    if (parameters != null && !parameters.isEmpty()) {
        for (LogEntryParameter par : parameters) {
            HTML parPanel = new HTML();
            parPanel.setHTML(SafeHtmlUtils.fromString(messages.logParameter(par.getName(), par.getValue())));
            logParametersValue.add(parPanel);
        }
        logParametersLabel.setVisible(true);
        logParametersValue.setVisible(true);
    } else {
        logParametersLabel.setVisible(false);
        logParametersValue.setVisible(false);
    }

    logStateValue.setHTML(HtmlSnippetUtils.getLogEntryStateHtml(logEntry.getState()));
    logStateLabel.setVisible(logEntry.getState() != null);
    logStateValue.setVisible(logEntry.getState() != null);

}

From source file:org.rstudio.studio.client.workbench.exportplot.clipboard.CopyPlotToClipboardDesktopMetafileDialog.java

License:Open Source License

public CopyPlotToClipboardDesktopMetafileDialog(ExportPlotPreviewer previewer, ExportPlotClipboard clipboard,
        ExportPlotOptions options, OperationWithInput<ExportPlotOptions> onClose) {
    super(previewer, clipboard, options, onClose);

    ExportPlotResources.Styles styles = ExportPlotResources.INSTANCE.styles();

    Label label = new Label();
    label.setStylePrimaryName(styles.copyFormatLabel());
    label.setText("Copy as:");
    addLeftWidget(label);/*from   w  w w. j  a  v  a 2  s.  co m*/

    copyAsBitmapRadioButton_ = new RadioButton("Format", SafeHtmlUtils.fromString("Bitmap"));
    copyAsBitmapRadioButton_.setStylePrimaryName(styles.copyFormatBitmap());
    addLeftWidget(copyAsBitmapRadioButton_);

    copyAsMetafileRadioButton_ = new RadioButton("Format", SafeHtmlUtils.fromString("Metafile"));
    copyAsMetafileRadioButton_.setStylePrimaryName(styles.copyFormatMetafile());
    addLeftWidget(copyAsMetafileRadioButton_);

    if (options.getCopyAsMetafile())
        copyAsMetafileRadioButton_.setValue(true);
    else
        copyAsBitmapRadioButton_.setValue(true);
}

From source file:org.rstudio.studio.client.workbench.views.plots.ui.export.impl.CopyPlotToClipboardDesktopMetafileDialog.java

License:Open Source License

public CopyPlotToClipboardDesktopMetafileDialog(PlotsServerOperations server, ExportPlotOptions options,
        OperationWithInput<ExportPlotOptions> onClose) {
    super(server, options, onClose);

    ExportPlotResources.Styles styles = ExportPlotResources.INSTANCE.styles();

    Label label = new Label();
    label.setStylePrimaryName(styles.copyFormatLabel());
    label.setText("Copy as:");
    addLeftWidget(label);//from w  w  w . j ava  2 s. c o m

    copyAsBitmapRadioButton_ = new RadioButton("Format", SafeHtmlUtils.fromString("Bitmap"));
    copyAsBitmapRadioButton_.setStylePrimaryName(styles.copyFormatBitmap());
    addLeftWidget(copyAsBitmapRadioButton_);

    copyAsMetafileRadioButton_ = new RadioButton("Format", SafeHtmlUtils.fromString("Metafile"));
    copyAsMetafileRadioButton_.setStylePrimaryName(styles.copyFormatMetafile());
    addLeftWidget(copyAsMetafileRadioButton_);

    if (options.getCopyAsMetafile())
        copyAsMetafileRadioButton_.setValue(true);
    else
        copyAsBitmapRadioButton_.setValue(true);
}

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.senchalabs.gwt.gwtdriver.gxt.models.client.App.java

License:Apache License

private void appendTabPanel(TabPanel panel, String text) {
    panel.setCloseContextMenu(true);/*from ww  w.j  ava 2s .  co m*/
    SelectHandler error = new SelectHandler() {
        @Override
        public void onSelect(SelectEvent event) {
            com.google.gwt.user.client.Window.alert("Button was clicked, shouldn't have been");
        }
    };
    panel.add(new TextButton(text, error), new TabItemConfig(text + " plain", true));
    TabItemConfig config1 = new TabItemConfig();
    config1.setClosable(true);

    // Bug in GXT 3.0.1
    //config1.setHTML(new SafeHtmlBuilder().appendHtmlConstant("<b>").appendEscaped(text + " bold").appendHtmlConstant("</b>").toSafeHtml());
    config1.setHTML(SafeHtmlUtils.fromString(text + " bold"));
    panel.add(new TextButton("bold", error), config1);
    TabItemConfig config2 = new TabItemConfig();
    config2.setClosable(true);
    //      config2.setHTML(new SafeHtmlBuilder().appendHtmlConstant("<i><span><span>").appendEscaped(text + " italic").appendHtmlConstant("</span></span></i>").toSafeHtml());
    config2.setHTML(SafeHtmlUtils.fromString(text + " italic"));
    panel.add(new TextButton("italic", error), config2);
    panel.setPixelSize(400, 200);
    RootPanel.get().add(panel);
}

From source file:org.spiffyui.client.MessageUtil.java

License:Apache License

/**
 * <p>/* w w w . j  a va 2s  .c  om*/
 * Show a warning message.
 * </p>
 * 
 * <p> 
 * This message has a default style of black text with a yellow background.
 * </p>
 * 
 * <h3>CSS Style Ryles</h3>
 * 
 * <ul>
 * <li>.humanMsgWarn</li>
 * </ul>
 * 
 * @param msg the message to show in HTML
 * @param shouldLog indicates if this warning should be sent to the in-browser error log
 * @param isSafe if this field is true then this just calls showMessage, otherwise it
 *               runs the specified message through the GWT SaveHtmlUtils
 */
public static void showWarning(String msg, boolean shouldLog, boolean isSafe) {
    if (isSafe) {
        showWarning(msg, shouldLog);
    } else {
        showWarning(SafeHtmlUtils.fromString(msg).asString(), shouldLog);
    }
}

From source file:org.spiffyui.client.MessageUtil.java

License:Apache License

/**
 * <p>//from w w  w  .  ja v  a 2  s. c o m
 * Show an information message.
 * </p>
 * 
 * <p> 
 * This message has a default style of white text with a black background.
 * </p>
 * 
 * <h3>CSS Style Ryles</h3>
 * 
 * <ul>
 * <li>.humanMsgInfo</li>
 * </ul>
 * 
 * @param msg the message to show in HTML
 * @param isSafe if this field is true then this just calls showMessage, otherwise it
 *               runs the specified message through the GWT SaveHtmlUtils
 */
public static void showMessage(String msg, boolean isSafe) {
    if (isSafe) {
        showMessage(msg);
    } else {
        showMessage(SafeHtmlUtils.fromString(msg).asString());
    }
}