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

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

Introduction

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

Prototype

public SafeHtmlBuilder() 

Source Link

Document

Constructs an empty SafeHtmlBuilder.

Usage

From source file:org.gwt.dynamic.module.foo.client.FooContentView.java

License:MIT License

void setFooData(FooData fooData) {
    LOG.info("FooContentView.setFooData: fooData=" + fooData);
    SafeHtmlBuilder shb = new SafeHtmlBuilder();
    shb.appendHtmlConstant("<h1>").appendEscaped(fooData.getHeader()).appendHtmlConstant("</h1>");
    shb.appendHtmlConstant(fooData.getHtml());
    content.setHTML(shb.toSafeHtml());//from   w  ww  .  ja  v a 2 s  .  co m
    content.removeStyleName(style.loading());
}

From source file:org.gwtbootstrap3.client.ui.PageHeader.java

License:Apache License

private void render() {
    final SafeHtmlBuilder builder = new SafeHtmlBuilder();

    builder.appendHtmlConstant("<h1>");
    builder.appendEscaped(heading == null ? "" : heading);

    if (subText != null && !subText.isEmpty()) {
        builder.appendEscaped(" ");
        builder.appendHtmlConstant("<small>");
        builder.appendEscaped(subText);/*  w  w w  .  j a va2  s.co m*/
        builder.appendHtmlConstant("</small>");
    }

    builder.appendHtmlConstant("</h1>");

    getElement().setInnerSafeHtml(builder.toSafeHtml());
}

From source file:org.jadice.web.gwt.fontawesome.client.FontAwesome.java

License:Apache License

public SafeHtml toSafeHtml() {
    return new SafeHtmlBuilder().appendHtmlConstant("<i class=\"fa fa-" + styleClass + "\"></i>").toSafeHtml();
}

From source file:org.jboss.as.console.client.administration.accesscontrol.ui.AccessControlProviderDialog.java

License:Open Source License

@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);/*w  w w .j  a  v  a2 s.c o m*/
    return new WindowContentBuilder(new ScrollPanel(layout), options).build();
}

From source file:org.jboss.as.console.client.administration.accesscontrol.ui.AssignmentColumn.java

License:Open Source License

@SuppressWarnings({ "unchecked", "Convert2MethodRef" })
public AssignmentColumn(final Dispatcher circuit, final AccessControlFinder presenter,
        final PreviewContentFactory contentFactory, final ColumnManager columnManager,
        final Supplier<Principal> selectedPrincipal, final Supplier<Boolean> include, final String token) {

    super(FinderId.ACCESS_CONTROL, Console.CONSTANTS.common_label_role(), new Display<Assignment>() {
        @Override//from   w ww  . j  av a2  s.  c  om
        public boolean isFolder(final Assignment data) {
            return false;
        }

        @Override
        public SafeHtml render(final String baseCss, final Assignment data) {
            return Templates.assignmentItem(baseCss, data);
        }

        @Override
        public String rowCss(final Assignment data) {
            return "";
        }
    }, new ProvidesKey<Assignment>() {
        @Override
        public Object getKey(final Assignment item) {
            return item.getId();
        }
    }, token);

    setShowSize(true);
    setPreviewFactory((data, callback) -> {
        if (data.getRole().isStandard()) {
            ExternalTextResource resource = (ExternalTextResource) PREVIEW_CONTENT
                    .getResource(data.getRole().getName().toLowerCase());

            contentFactory.createAndModifyContent(resource,
                    input -> new SafeHtmlBuilder().appendHtmlConstant("<div class='preview-content'>")
                            .append(input).appendHtmlConstant("</div>").toSafeHtml(),
                    callback);
        } else {
            callback.onSuccess(Templates.scopedRolePreview(data.getRole()));
        }
    });

    setTopMenuItems(new MenuDelegate<>(Console.CONSTANTS.common_label_add(),
            item -> presenter.launchAddAssignmentDialog(selectedPrincipal.get(), include.get()),
            MenuDelegate.Role.Operation));

    setMenuItems(new MenuDelegate<>(Console.CONSTANTS.common_label_delete(),
            item -> Feedback.confirm(Console.CONSTANTS.common_label_areYouSure(),
                    Console.MESSAGES.deleteTitle(item.getRole().getName()), isConfirmed -> {
                        if (isConfirmed) {
                            circuit.dispatch(new RemoveAssignment(item, PRINCIPAL_TO_ROLE));
                        }
                    }),
            MenuDelegate.Role.Operation));

    addSelectionChangeHandler(event -> {
        columnManager.reduceColumnsTo(4);
        if (hasSelectedItem()) {
            columnManager.updateActiveSelection(asWidget());
        }
    });
}

From source file:org.jboss.as.console.client.administration.accesscontrol.ui.RoleColumn.java

License:Open Source License

@SuppressWarnings({ "unchecked", "Convert2MethodRef" })
public RoleColumn(final BootstrapContext bootstrapContext, final AccessControlStore accessControlStore,
        final Dispatcher circuit, final AccessControlFinder presenter,
        final PreviewContentFactory contentFactory, final ColumnManager columnManager,
        final Scheduler.ScheduledCommand onSelect, final String token) {

    super(FinderId.ACCESS_CONTROL, "Role", new Display<Role>() {
        @Override/*from  ww  w  . j av a  2 s  .c om*/
        public boolean isFolder(final Role data) {
            return true;
        }

        @Override
        public SafeHtml render(final String baseCss, final Role data) {
            return Templates.roleItem(baseCss, data);
        }

        @Override
        public String rowCss(final Role data) {
            return data.isStandard() ? "standard-role-item" : "scoped-role-item";
        }
    }, new ProvidesKey<Role>() {
        @Override
        public Object getKey(final Role item) {
            return item.getId();
        }
    }, token);

    setShowSize(true);
    setPreviewFactory((data, callback) -> {
        if (data.isStandard()) {
            ExternalTextResource resource = (ExternalTextResource) PREVIEW_CONTENT
                    .getResource(data.getName().toLowerCase());

            contentFactory.createAndModifyContent(resource,
                    input -> new SafeHtmlBuilder().appendHtmlConstant("<div class='preview-content'>")
                            .append(input)
                            .append(Templates.roleMembers(data, accessControlStore.getPrincipals(data, false),
                                    accessControlStore.getPrincipals(data, true)))
                            .appendHtmlConstant("</div>").toSafeHtml(),
                    callback);
        } else {
            callback.onSuccess(Templates.scopedRolePreview(data, accessControlStore.getPrincipals(data, false),
                    accessControlStore.getPrincipals(data, true)));
        }
    });

    if (!bootstrapContext.isStandalone()) {
        setTopMenuItems(new MenuDelegate<>(Console.CONSTANTS.common_label_add(),
                item -> presenter.launchAddScopedRoleDialog(), MenuDelegate.Role.Operation));
    }
    setMenuItems(
            new MenuDelegate<>(Console.CONSTANTS.common_label_edit(), item -> presenter.editRole(item),
                    MenuDelegate.Role.Operation),
            new MenuDelegate<>(Console.CONSTANTS.common_label_delete(), item -> {
                if (item.isScoped()) {
                    Feedback.confirm(Console.CONSTANTS.common_label_areYouSure(),
                            Console.MESSAGES.deleteTitle(item.getName()), isConfirmed -> {
                                if (isConfirmed) {
                                    circuit.dispatch(new RemoveScopedRole(item));
                                }
                            });
                } else {
                    Console.warning(Console.CONSTANTS.standardRolesCannotBeRemoved());
                }
            }, MenuDelegate.Role.Operation));

    addSelectionChangeHandler(event -> {
        columnManager.reduceColumnsTo(2);
        if (hasSelectedItem()) {
            columnManager.updateActiveSelection(asWidget());
            onSelect.execute();
        }
    });
}

From source file:org.jboss.as.console.client.administration.accesscontrol.ui.Templates.java

License:Open Source License

static SafeHtml principalPreview(final Principal principal, Iterable<Assignment> includes,
        Iterable<Assignment> excludes) {
    SafeHtmlBuilder details = new SafeHtmlBuilder();
    details.appendHtmlConstant("<p>");
    if (!Iterables.isEmpty(excludes)) {
        List<Role> excludedRoles = Roles.orderedByName().immutableSortedCopy(distinctRoles(excludes));
        details.appendEscaped("Excluded from ");
        details.appendEscaped(Joiner.on(", ").join(Lists.transform(excludedRoles, Role::getName)));
        details.appendEscaped(".");
        details.appendHtmlConstant("<br/>");
    }/*from  w ww  . j  ava  2  s. com*/
    if (!Iterables.isEmpty(includes)) {
        List<Role> assignedRoles = Roles.orderedByName().immutableSortedCopy(distinctRoles(includes));
        details.appendEscaped("Assigned to ");
        details.appendEscaped(Joiner.on(", ").join(Lists.transform(assignedRoles, Role::getName)));
        details.appendEscaped(".");
    }
    if (Iterables.isEmpty(excludes) && Iterables.isEmpty(includes)) {
        details.appendEscaped("No roles are assigned to this ");
        details.appendEscaped(principal.getType() == Principal.Type.USER ? "user" : "group");
        details.append('.');
    }
    details.appendHtmlConstant("</p>");
    return principal.getType() == Principal.Type.USER ? PREVIEWS.user(principal.getName(), details.toSafeHtml())
            : PREVIEWS.group(principal.getName(), details.toSafeHtml());
}

From source file:org.jboss.as.console.client.administration.accesscontrol.ui.Templates.java

License:Open Source License

static SafeHtml roleMembers(final Role role, final Iterable<Principal> excludes,
        final Iterable<Principal> includes) {
    SafeHtmlBuilder members = new SafeHtmlBuilder();
    if (role.isIncludeAll()) {
        members.appendHtmlConstant("<p>")
                .appendEscaped("All authenticated users are automatically assigned to this role.")
                .appendHtmlConstant("</p>");

    } else if (Iterables.isEmpty(excludes) && Iterables.isEmpty(includes)) {
        members.appendHtmlConstant("<p>").appendEscaped("No users or groups are assigned to this role.")
                .appendHtmlConstant("</p>");

    } else {//from  ww  w  .  j  a  v  a2 s .c o m
        if (!Iterables.isEmpty(excludes)) {
            String names = Joiner.on(", ").join(Iterables.transform(excludes, Principal::getNameAndRealm));
            members.appendHtmlConstant("<p><b>").appendEscaped("Excludes").appendHtmlConstant("</b><br/>")
                    .appendEscaped(names).appendHtmlConstant("</p>");
        }

        if (!Iterables.isEmpty(includes)) {
            String names = Joiner.on(", ").join(Iterables.transform(includes, Principal::getNameAndRealm));
            members.appendHtmlConstant("<p><b>").appendEscaped("Includes").appendHtmlConstant("</b><br/>")
                    .appendEscaped(names).appendHtmlConstant("</p>");
        }
    }
    return members.toSafeHtml();
}

From source file:org.jboss.as.console.client.administration.accesscontrol.ui.Templates.java

License:Open Source License

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(". ");
    }/*from   www.j ava  2s  . c o m*/
    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());
}

From source file:org.jboss.as.console.client.administration.audit.AuditHelpPanel.java

License:Open Source License

public AuditHelpPanel() {
    super(new SafeHtmlBuilder().appendHtmlConstant(RESOURCES.help().getText()).toSafeHtml());
}