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

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

Introduction

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

Prototype

public SafeHtmlBuilder appendEscapedLines(String text) 

Source Link

Document

Appends a string consisting of several newline-separated lines after HTML-escaping it.

Usage

From source file:com.dianaui.universal.core.client.ui.ButtonCell.java

License:Apache License

@Override
public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant("<button type=\"button\" class=\"btn " + (type != null ? type.getCssName() : "")
            + (size != null ? " " + size.getCssName() : "") + "\" tabindex=\"-1\">");
    if (data != null) {
        String iconHtml = "";

        if (fontAwesomeIcon != null || glyphicon != null) {
            String iconClasses = fontAwesomeIcon != null
                    ? Styles.FONT_AWESOME_BASE + " " + fontAwesomeIcon.getCssName()
                    : Styles.GLYPHICON_BASE + " " + glyphicon.getCssName();

            if (fontAwesomeIcon != null) {
                if (iconSize != null)
                    iconClasses += iconSize.getCssName() + " ";
                if (iconFlip != null)
                    iconClasses += iconFlip.getCssName() + " ";
                if (iconRotate != null)
                    iconClasses += iconRotate.getCssName() + " ";
                if (iconBordered)
                    iconClasses += Styles.ICON_BORDER + " ";
                if (iconMuted)
                    iconClasses += Styles.ICON_MUTED + " ";
                if (iconLight)
                    iconClasses += Styles.ICON_LIGHT + " ";
                if (iconSpin)
                    iconClasses += Styles.ICON_SPIN + " ";
                if (iconFixedWidth)
                    iconClasses += Styles.ICON_FIXED_WIDTH;
            }/* w w w.ja  v  a 2s .  c om*/

            iconHtml = "<i class=\"" + iconClasses + "\"></i> ";
        }

        if (iconPosition == IconPosition.LEFT) {
            sb.appendHtmlConstant(iconHtml);
            sb.appendEscapedLines(separator);
        }

        sb.append(data);

        if (iconPosition == IconPosition.RIGHT) {
            sb.appendEscapedLines(separator);
            sb.appendHtmlConstant(iconHtml);
        }
    }
    sb.appendHtmlConstant("</button>");
}

From source file:com.google.gwt.sample.validation.server.GreetingServiceImpl.java

License:Apache License

public SafeHtml greetServer(Person person) throws IllegalArgumentException, ConstraintViolationException {
    // Verify that the input is valid.
    Set<ConstraintViolation<Person>> violations = validator.validate(person, Default.class, ServerGroup.class);
    if (!violations.isEmpty()) {
        Set<ConstraintViolation<?>> temp = new HashSet<ConstraintViolation<?>>(violations);
        throw new ConstraintViolationException(temp);
    }/* w  ww . j  a  v a2  s  . c o m*/

    String serverInfo = getServletContext().getServerInfo();
    String userAgent = getThreadLocalRequest().getHeader("User-Agent");

    // Escape data from the client to avoid cross-site script vulnerabilities.
    SafeHtmlBuilder builder = new SafeHtmlBuilder();

    SafeHtml safeHtml = builder//
            .appendEscapedLines("Hello, " + person.getName() + "!")//
            .appendHtmlConstant("<br>")//
            .appendEscaped("I am running " + serverInfo + ".")//
            .appendHtmlConstant("<br><br>")//
            .appendEscaped("It looks like you are using: ")//
            .appendEscaped(userAgent)//
            .toSafeHtml();
    return safeHtml;
}

From source file:com.kk_electronic.kkportal.core.security.IdentityProvider.java

License:Open Source License

private SafeHtml getDialogText() {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    if (motd != null) {
        sb.appendEscapedLines(motd);
        sb.appendHtmlConstant("<br /><br />");
    }/*from  www  .j a  va  2  s  . com*/
    if (errortext != null) {
        sb.appendHtmlConstant("<span style=\"color:#C4151B;\"><br />");
        sb.appendEscapedLines(errortext);
        sb.appendHtmlConstant("<br /><br /></span>");
    }
    sb.appendEscapedLines(dialogtext);
    return sb.toSafeHtml();
}

From source file:com.kk_electronic.kkportal.core.ui.InputDialog.java

License:Open Source License

public void setText(String string) {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    sb.appendEscapedLines(string);
    text.setInnerHTML(sb.toSafeHtml().asString());
}

From source file:com.kk_electronic.kkportal.examples.modules.MotD.java

License:Open Source License

@Override
public void onSuccess(String result) {
    if (result != null) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        sb.appendEscapedLines(result);
        widget.setHTML(sb.toSafeHtml());
    } else {/*from  w  ww  .  j  a va  2s  . co m*/
        widget.setHTML("No message of the day");
    }
}

From source file:org.activityinfo.ui.client.page.entry.form.SiteRenderer.java

License:Open Source License

protected String formatValue(IndicatorDTO indicator, Object value) {
    if (indicator.getType() == FieldTypeClass.QUANTITY) {
        if (value instanceof Double) {
            return indicatorValueFormatter.format((Double) value);
        }//from w  ww  .jav a 2 s  . com
    } else if (indicator.getType() == FieldTypeClass.FREE_TEXT) {
        if (value instanceof String) {
            return htmlEscape((String) value);
        }
    } else if (indicator.getType() == FieldTypeClass.NARRATIVE) {
        if (value instanceof String) {
            SafeHtmlBuilder html = new SafeHtmlBuilder();
            html.appendEscapedLines((String) value);
            return html.toSafeHtml().asString();
        }
    }
    return "-";
}

From source file:org.jbpm.console.ng.ht.client.editors.tasklogs.TaskLogsPresenter.java

License:Apache License

public void refreshLogs() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("taskId", currentTaskId);
    QueryFilter filter = new PortableQueryFilter(0, 0, false, "", "", false, "", params);
    taskAuditService.call(new RemoteCallback<PageResponse<TaskEventSummary>>() {
        @Override/*from  w  ww .java 2  s  .  c om*/
        public void callback(PageResponse<TaskEventSummary> events) {
            SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
            DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy HH:mm");
            for (TaskEventSummary tes : events.getPageRowList()) {
                String timeStamp = format.format(tes.getLogTime());
                if (tes.getType().equals("UPDATED")) {
                    safeHtmlBuilder.appendEscapedLines(
                            timeStamp + ": Task " + tes.getType() + " (" + tes.getMessage() + ") \n");
                } else {
                    safeHtmlBuilder.appendEscapedLines(
                            timeStamp + ": Task - " + tes.getType() + " (" + tes.getUserId() + ") \n");
                }
            }
            view.setLogTextAreaText(safeHtmlBuilder.toSafeHtml().asString());
        }

    }, new ErrorCallback<Message>() {
        @Override
        public boolean error(Message message, Throwable throwable) {
            ErrorPopup.showMessage("Unexpected error encountered : " + throwable.getMessage());
            return true;
        }
    }).getData(filter);

}

From source file:org.jbpm.console.ng.pr.client.editors.definition.details.advance.AdvancedViewProcessDefDetailsPresenter.java

License:Apache License

private void refreshServiceTasks(final String deploymentId, final String processId) {
    dataServices.call(new RemoteCallback<Map<String, String>>() {

        @Override/*w w w.  j  av a2 s  .c  om*/
        public void callback(Map<String, String> services) {
            view.getProcessServicesListBox().setText("");
            SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
            if (services.keySet().isEmpty()) {
                safeHtmlBuilder.appendEscaped("No services required for this process");
                view.getProcessServicesListBox().setStyleName("muted");
                view.getProcessServicesListBox().setHTML(safeHtmlBuilder.toSafeHtml());
            } else {
                for (String key : services.keySet()) {
                    safeHtmlBuilder.appendEscapedLines(key + " - " + services.get(key) + "\n");
                }
                view.getProcessServicesListBox().setHTML(safeHtmlBuilder.toSafeHtml());
            }
        }
    }, new ErrorCallback<Message>() {

        @Override
        public boolean error(Message message, Throwable throwable) {
            ErrorPopup.showMessage("Unexpected error encountered : " + throwable.getMessage());
            return true;
        }
    }).getServiceTasks(deploymentId, processId);
}

From source file:org.jbpm.console.ng.pr.client.editors.definition.details.advance.AdvancedViewProcessDefDetailsPresenter.java

License:Apache License

private void refreshReusableSubProcesses(final String deploymentId, final String processId) {
    dataServices.call(new RemoteCallback<Collection<String>>() {

        @Override/*from   www.j av  a  2 s .  co  m*/
        public void callback(Collection<String> subprocesses) {
            view.getSubprocessListBox().setText("");
            SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
            if (subprocesses.isEmpty()) {
                safeHtmlBuilder.appendEscapedLines("No subproceses required by this process");
                view.getSubprocessListBox().setStyleName("muted");
                view.getSubprocessListBox().setHTML(safeHtmlBuilder.toSafeHtml());
            } else {
                for (String key : subprocesses) {
                    safeHtmlBuilder.appendEscapedLines(key + "\n");
                }
                view.getSubprocessListBox().setHTML(safeHtmlBuilder.toSafeHtml());
            }
        }
    }, new ErrorCallback<Message>() {

        @Override
        public boolean error(Message message, Throwable throwable) {
            ErrorPopup.showMessage("Unexpected error encountered : " + throwable.getMessage());
            return true;
        }
    }).getReusableSubProcesses(deploymentId, processId);
}

From source file:org.jbpm.console.ng.pr.client.editors.definition.details.advance.AdvancedViewProcessDefDetailsPresenter.java

License:Apache License

private void refreshRequiredInputData(final String deploymentId, final String processId) {
    dataServices.call(new RemoteCallback<Map<String, String>>() {

        @Override//from www.  j av  a2 s . c o m
        public void callback(Map<String, String> inputs) {
            view.getProcessDataListBox().setText("");
            SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
            if (inputs.keySet().isEmpty()) {
                safeHtmlBuilder.appendEscapedLines("No process variables defined for this process");
                view.getProcessDataListBox().setStyleName("muted");
                view.getProcessDataListBox().setHTML(safeHtmlBuilder.toSafeHtml());
            } else {
                for (String key : inputs.keySet()) {
                    safeHtmlBuilder.appendEscapedLines(key + " - " + inputs.get(key) + "\n");
                }
                view.getProcessDataListBox().setHTML(safeHtmlBuilder.toSafeHtml());
            }
        }
    }, new ErrorCallback<Message>() {

        @Override
        public boolean error(Message message, Throwable throwable) {
            ErrorPopup.showMessage("Unexpected error encountered : " + throwable.getMessage());
            return true;
        }
    }).getRequiredInputData(deploymentId, processId);
}