com.google.gwt.safehtml.shared.SafeHtmlBuilder Java Examples

The following examples show how to use com.google.gwt.safehtml.shared.SafeHtmlBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccessControlProviderDialog.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Widget asWidget() {
    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("window-content");
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(Console.MESSAGES.access_control_provider());
    layout.add(new HTML(builder.toSafeHtml()));

    DialogueOptions options = new DialogueOptions(
            Console.CONSTANTS.common_label_done(),
            event -> presenter.closeWindow(),
            Console.CONSTANTS.common_label_cancel(),
            event -> presenter.closeWindow()
    );
    options.showCancel(false);
    return new WindowContentBuilder(new ScrollPanel(layout), options).build();
}
 
Example #2
Source File: AccessLogView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void updateTreee() {
    tree.removeItems();

    Iterator<String> keys = log.getKeys();

    while(keys.hasNext())
    {
        String token = keys.next();
        Set<String> addresses = log.getAddresses(token);

        SafeHtmlBuilder sh = new SafeHtmlBuilder();
        TreeItem parent = tree.addItem(sh.appendEscaped(token+" ("+addresses.size()+")").toSafeHtml());

        for(String address : addresses)
        {
            SafeHtmlBuilder sh2 = new SafeHtmlBuilder();
            parent.addItem(sh2.appendEscaped(address).toSafeHtml());
        }
    }
}
 
Example #3
Source File: ModelBrowserView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void addChildrenTypes(ModelTreeItem rootItem, List<ModelNode> modelNodes) {

        rootItem.removeItems();

        final ChildInformation childInformation = parseChildrenTypes(modelNodes);

        for(String child : childInformation.getNames())
        {
            final ModelNode address = getNodeAddress(rootItem, child);

            SafeHtmlBuilder html = new SafeHtmlBuilder();
            html.appendHtmlConstant("<i class='icon-folder-close-alt'></i>&nbsp;");
            html.appendEscaped(child);
            TreeItem childItem = new ModelTreeItem(html.toSafeHtml(), child, address, childInformation.isSingleton(child));
            childItem.addItem(new PlaceholderItem());
            rootItem.addItem(childItem);
            rootItem.updateChildInfo(childInformation);
        }

        rootItem.setState(true);
    }
 
Example #4
Source File: StackedBar.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void setRatio(double total, double actual)
{
    Element inner = panel.getElementById(innerId);
    double percentage = percentage(total, actual);
    if(percentage>0)
    {
        inner.setAttribute("style", "width:" + percentage + "%");
        inner.setAttribute("cssText", "width:" + percentage + "%");
    }
    else
    {
        inner.setAttribute("style", "background:none");
        inner.setAttribute("cssText", "background:none");
    }
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<span style='padding-right:5px;'>").appendEscaped(percentage + "%").appendHtmlConstant("</span>");
    inner.setInnerHTML(html.toSafeHtml().asString());
}
 
Example #5
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void replaceChildren(List<C> values, int start, SelectionModel<? super C> selectionModel, boolean stealFocus) {
  // Render the children.
  SafeHtmlBuilder sb = new SafeHtmlBuilder();
  render(sb, values, 0, selectionModel);

  Map<Object, CellTreeNodeView<?>> savedViews = saveChildState(values, start);

  nodeView.tree.isRefreshing = true;
  SafeHtml html = sb.toSafeHtml();
  Element newChildren = AbstractHasData.convertToElements(nodeView.tree, getTmpElem(), html);
  AbstractHasData.replaceChildren(nodeView.tree, childContainer, newChildren, start, html);
  nodeView.tree.isRefreshing = false;

  loadChildState(values, start, savedViews);
}
 
Example #6
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml unmanaged() {
    // TODO I18n or take from DMR
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
    addHelpTextRow(builder, "Path:",
            Console.CONSTANTS.unmanagedDeploymentPathDescription());
    addHelpTextRow(builder, "Relative To:",
            Console.CONSTANTS.unmanagedDeploymentRelativeToDescription());
    addHelpTextRow(builder, "Is Archive?:",
            Console.CONSTANTS.unmanagedDeploymentArchiveDescription());
    addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
    addHelpTextRow(builder, "Runtime Name:",
            Console.CONSTANTS.deploymentRuntimeNameDescription());
    if (Console.getBootstrapContext().isStandalone()) {
        addHelpTextRow(builder, "Enable:",
                Console.CONSTANTS.deploymentEnabledDescription());
    }
    return builder.toSafeHtml();
}
 
Example #7
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml memberPreview(final Assignment assignment, int memberAssignments) {
    int otherAssignments = max(0, memberAssignments - 1);
    Principal member = assignment.getPrincipal();
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<p>");
    if (!assignment.isInclude()) {
        builder.appendEscaped("Excluded from role ").appendEscaped(assignment.getRole().getName())
                .appendEscaped(". ");
    }
    if (otherAssignments == 0) {
        builder.appendEscaped("Not used in other assignments. ");
    } else if (otherAssignments == 1) {
        builder.appendEscaped("Used in one other assignment. ");
    } else {
        builder.appendEscaped("Used in ").append(otherAssignments).appendEscaped(" other assignments. ");
    }
    if (member.getRealm() != null) {
        builder.appendEscaped("Bound to realm '").appendEscaped(member.getRealm()).appendEscaped("'.");
    }
    builder.appendHtmlConstant("</p>");
    return PREVIEWS.member(member.getName(), builder.toSafeHtml());
}
 
Example #8
Source File: TemplateUploadWizard.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
  public void render(Context context, TemplateInfo template, SafeHtmlBuilder sb) {
  if (template == null)
    return;
  sb.appendHtmlConstant("<table style='margin: 4pt 0;'>");

  // Add the thumbnail image, if available, or a default image.
  sb.appendHtmlConstant("<tr><td rowspan='3' width=\"32px\">");
  if ( !template.thumbStr.equals("") )   {
    String src = hostUrl + TEMPLATES_ROOT_DIRECTORY +   template.name + "/" + template.thumbStr;
    sb.appendHtmlConstant("<img style='width:32px' src='" + src + "'>");
  } else {
    ImageResource imgResource = Ode.getImageBundle().appInventorLogo();
    Image img = new Image(imgResource);
    String url = img.getUrl();
    sb.appendHtmlConstant("<img style='width:32px' src='" + url + "'>");
  }
  sb.appendHtmlConstant("</td>");

  // Add the name and description.
  sb.appendHtmlConstant("<td style='font-size:95%;'><b>");
  sb.appendEscaped(template.name);
  sb.appendHtmlConstant("</b></td></tr><tr><td>");
  sb.appendEscaped(template.subtitle);
  sb.appendHtmlConstant("</td></tr></table>");
}
 
Example #9
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml contentPreview(final Content content) {
    String managed = "No";
    String archive = "Yes";
    
    if (content.get("managed").asBoolean()) 
        managed = "Yes";
    
    if (content.get("content").get(0).hasDefined("archive") && !content.get("content").get(0).get("archive").asBoolean()) {
        archive = "No";
    }
    if (content.getAssignments().isEmpty()) {
        return PREVIEWS.unassignedContent(content.getName(), managed, archive);
    } else {
        SafeHtmlBuilder details = new SafeHtmlBuilder();
        details.appendHtmlConstant("<ul>");
        for (Assignment assignment : content.getAssignments()) {
            details.appendHtmlConstant("<li>")
                    .appendEscaped(assignment.getServerGroup())
                    .appendHtmlConstant("</li>");
        }
        details.appendHtmlConstant("</ul>");
        return PREVIEWS.content(content.getName(), details.toSafeHtml(), managed, archive);
    }
}
 
Example #10
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml serverGroupPreview(final ServerGroupRecord serverGroup, int deployments) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<p>");
    if (deployments == -1) {
        builder.appendEscaped("Deployments for server group ")
                .appendEscaped(serverGroup.getName())
                .appendEscaped(" cannot be read.");
    } else if (deployments == 0) {
        builder.appendEscaped("Server group ")
                .appendEscaped(serverGroup.getName())
                .appendEscaped(" does not contain deployments.");
    } else {
        builder.appendEscaped("Server group ")
                .appendEscaped(serverGroup.getName())
                .appendEscaped(" contains ")
                .append(deployments)
                .appendEscaped(" deployment(s).");
    }
    builder.appendHtmlConstant("</p>");
    return PREVIEWS.serverGroup(builder.toSafeHtml());
}
 
Example #11
Source File: ValueBoxEditor.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (final EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example #12
Source File: FileUploadEditor.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example #13
Source File: ImageListEditor.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
/*************************************************************
 ** GWT EDITOR CONTRACT METHODS **
 *************************************************************/

@Override
public void showErrors(final List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        if (error.getEditor().equals(this)) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example #14
Source File: DropDownEditor.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
/*************************************************************
 ** GWT EDITOR CONTRACT METHODS **
 *************************************************************/

@Override
public void showErrors(final List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        if (error.getEditor().equals(this)) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example #15
Source File: MapEditor.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
/*************************************************************
 ** GWT EDITOR CONTRACT METHODS **
 *************************************************************/

@Override
public void showErrors(final List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example #16
Source File: ToggleSwitchEditor.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example #17
Source File: SearchPopup.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void render(Context context, TokenGroup tokenGroup, SafeHtmlBuilder safeHtmlBuilder) {
    SafeHtmlBuilder descriptions = new SafeHtmlBuilder();
    for (String description : tokenGroup.getDescriptions()) {
        descriptions.append(TEMPLATE.description(description));
    }
    String token = tokenGroup.getToken();
    try {
        // try to find a description for this token
        token = Console.TOKENS.getString(token.replace('-', '_'));
    } catch (MissingResourceException e) {
        System.err.println("No description found for token " + token + ": " + e.getMessage());
    }
    if (tokenGroup.getKeywords().isEmpty()) {
        safeHtmlBuilder.append(TEMPLATE.tokenGroup(token, descriptions.toSafeHtml()));
    } else {
        SafeHtmlBuilder keywords = new SafeHtmlBuilder();
        for (String keyword : tokenGroup.getKeywords()) {
            keywords.append(TEMPLATE.keyword(keyword));
        }
        safeHtmlBuilder.append(TEMPLATE.tokenGroup(token, descriptions.toSafeHtml(), keywords.toSafeHtml()));
    }
}
 
Example #18
Source File: LinkBar.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void addLink(String text, ClickHandler handler) {

        InlineLink html = new InlineLink(text);
        //html.setHTML("<a href='javascript:void(0)' tabindex='0'>"+text+"</a>");

        html.addClickHandler(handler);
        html.addStyleName("link-bar");

        SafeHtmlBuilder builder = new SafeHtmlBuilder();

        if(numLinks==0)
        {
            if(!navOnFirstPage)
            {
                html.addStyleName("link-bar-first");
                builder.appendHtmlConstant("<i class='icon-list-ul'></i>");
                builder.appendHtmlConstant("&nbsp;");
            }
        }

        builder.appendHtmlConstant("<a href='javascript:void(0)' tabindex='0'>"+text+"</a>");
        html.setHTML(builder.toSafeHtml());
        links.add(html);

        bar.add(html);

        numLinks++;

    }
 
Example #19
Source File: TextLinkCell.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void render(Context context, T value, SafeHtmlBuilder sb) {


    String css = !visible ? "textlink-cell rbac-suppressed" : "textlink-cell";
    SafeHtml html = new SafeHtmlBuilder()
            .appendHtmlConstant("<a href='javascript:void(0)' tabindex=\"-1\" class='"+css+"'>")
            .appendHtmlConstant(title)
            .appendHtmlConstant("</a>")
            .toSafeHtml();


    sb.append(html);
}
 
Example #20
Source File: SecurityContextImpl.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public SafeHtml asHtml() {
    try {
        return RBACUtil.dump(this);
    } catch (Throwable e) {
        e.printStackTrace();
        return new SafeHtmlBuilder().appendEscaped(e.getMessage()).toSafeHtml();
    }
}
 
Example #21
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static SafeHtml assignmentPreview(final Assignment assignment) {
    Deployment deployment = assignment.getDeployment();
    if (deployment == null) {
        SafeHtmlBuilder status = new SafeHtmlBuilder();
        PreviewState.error(status, "No running server");
        return PREVIEWS.noReferenceServer(assignment.getName(), assignment.getServerGroup(), status.toSafeHtml());
    } else {
        return deploymentPreview(deployment);
    }
}
 
Example #22
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static SafeHtml replace() {
    // TODO I18n or take from DMR
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
    addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
    addHelpTextRow(builder, "Runtime Name:",
            Console.CONSTANTS.deploymentRuntimeNameDescription());
    return builder.toSafeHtml();
}
 
Example #23
Source File: RBACUtil.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static SafeHtml dump(SecurityContext sc) {
    SafeHtmlBuilder html = new SafeHtmlBuilder();

    SecurityContextImpl context = (SecurityContextImpl)sc; // parent context

    html.appendHtmlConstant("<hr/><b>Child Contexts:</b> <br/>");
    html.appendHtmlConstant("<ul>");
    for (AddressTemplate address : context.getResourceAddresses()) {
        html.appendHtmlConstant("<li><i>").appendEscaped(address.toString()).appendHtmlConstant("</i></li>");
        String activeKey = context.getActiveKey(address);

        html.appendHtmlConstant("<ul>");
        for (String key : context.getConstraintsKeys(address)) {
            if(key.equals(activeKey))
                html.appendHtmlConstant("<li><b>").appendEscaped(key).appendHtmlConstant("</b></li>");
            else
                html.appendHtmlConstant("<li>").appendEscaped(key).appendHtmlConstant("</li>");
        }
        html.appendHtmlConstant("</ul>");

    }

    html.appendHtmlConstant("</ul>");

    writeContext(html, context);

    return html.toSafeHtml();
}
 
Example #24
Source File: ConfigAdminEditor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void onCreateProperty(String reference, PropertyRecord prop) {
    dialog.hide();
    ConfigAdminData data = findData(reference);
    if (data == null) {
        Feedback.alert(Console.CONSTANTS.subsys_configadmin_add(),
            new SafeHtmlBuilder().appendEscaped(Console.MESSAGES.subsys_configadmin_addNoPIDselected()).toSafeHtml());
    } else {
        data.getProperties().add(prop);
        presenter.onUpdateConfigurationAdminData(data);
    }
}
 
Example #25
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void addHelpTextRow(SafeHtmlBuilder builder, String name, String desc) {
    builder.appendHtmlConstant("<tr class='help-field-row'>");
    builder.appendHtmlConstant("<td class='help-field-name'>");
    builder.appendEscaped(name);
    builder.appendHtmlConstant("</td>");
    builder.appendHtmlConstant("<td class='help-field-desc'>");
    builder.appendEscaped(desc);
    builder.appendHtmlConstant("</td>");
    builder.appendHtmlConstant("</tr>");
}
 
Example #26
Source File: ViewLinkCell.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void render(Context context, T value, SafeHtmlBuilder sb) {
    SafeHtml html = new SafeHtmlBuilder()
            .appendHtmlConstant("<a href='javascript:void(0)' tabindex=\"-1\" class='viewlink-cell'>")
            .appendHtmlConstant(title)
            .appendHtmlConstant("&nbsp;")
            .appendHtmlConstant("<i class='icon-chevron-right'></i>")
            .appendHtmlConstant("</a>")
            .toSafeHtml();

    sb.append(html);
}
 
Example #27
Source File: ParticipantsPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void render(Context context, TXParticipant txParticipant, SafeHtmlBuilder html) {
    html.appendHtmlConstant("<ul style='font-size:9px; list-style-type:none'>");
    if(txParticipant.getJndiName()!=null)
        html.appendHtmlConstant("<li>JNDI: ").appendEscaped(txParticipant.getJndiName());

    if(txParticipant.getEisName()!=null)
        html.appendHtmlConstant("<li>EIS: ").appendEscaped(txParticipant.getEisName());

    if(txParticipant.getJmxName()!=null)
        html.appendHtmlConstant("<li>JMX: ").appendEscaped(txParticipant.getJmxName());

    html.appendHtmlConstant("</ul>");
}
 
Example #28
Source File: ModelBrowserView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
PlaceholderItem(String title) {
    super(new SafeHtmlBuilder()
            .appendHtmlConstant("<span style='color:#cccccc'>")
            .appendEscaped(title)
            .appendHtmlConstant("</span>")
            .toSafeHtml());
}
 
Example #29
Source File: ServerGroupCell.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void render(
        Context context,
        ServerGroupRecord groupRecord,
        SafeHtmlBuilder safeHtmlBuilder)
{

    safeHtmlBuilder.append(
                TEMPLATE.message("cross-reference",
                    groupRecord.getName(),
                    groupRecord.getProfileName()
            )
    );

}
 
Example #30
Source File: CodeHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public static SafeHtml parseCode(String code) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?");
    String[] arr$ = splitted;
    int len$ = splitted.length;

    for (int i$ = 0; i$ < len$; ++i$) {
        String s = arr$[i$];
        builder.append(SafeHtmlUtils.fromTrustedString(SafeHtmlUtils.htmlEscapeAllowEntities(s)));
        builder.appendHtmlConstant("<br>");
    }

    return builder.toSafeHtml();
}