List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder toSafeHtml
public SafeHtml 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);/*from ww w . j a va 2 s . c om*/ return new WindowContentBuilder(new ScrollPanel(layout), options).build(); }
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/>"); }/* www. j ava 2 s.c o m*/ 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 w w w .j av a 2s.co 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 w ww . j a va 2 s .c om 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.role.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(), new ClickHandler() { @Override//www . ja v a 2s . c om public void onClick(ClickEvent event) { presenter.closeWindow(); } }, Console.CONSTANTS.common_label_cancel(), new ClickHandler() { @Override public void onClick(final ClickEvent event) { presenter.closeWindow(); } }); options.showCancel(false); return new WindowContentBuilder(new ScrollPanel(layout), options).build(); }
From source file:org.jboss.as.console.client.administration.role.ui.MembersDialog.java
License:Open Source License
@Override public Widget asWidget() { VerticalPanel layout = new VerticalPanel(); layout.setStyleName("window-content"); SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (internal.isEmpty()) { builder.append(TEMPLATES.noMembers(internal.getRole().getName())); } else {/*from w w w. j a va 2 s . c o m*/ builder.append(TEMPLATES.title(internal.getRole().getName())); builder.appendHtmlConstant("<ol class=\"outer-list\">"); boolean includeAll = internal.getRole().isIncludeAll(); List<RoleAssignment.PrincipalRealmTupel> includes = internal.getIncludes(); if (includeAll || !includes.isEmpty()) { builder.appendHtmlConstant( "<li class=\"header\">Included principals</li><ul class=\"inner-list icons-ul\">"); if (includeAll) { builder.append(TEMPLATES.includeAll("User")); } if (!includes.isEmpty()) { for (RoleAssignment.PrincipalRealmTupel include : includes) { if (include.principal.getType() == USER) { builder.append(TEMPLATES.principal("user", "User", UIHelper.principalAsSafeHtml(include.principal, include.realm))); } else { builder.append(TEMPLATES.principal("group", "Group", UIHelper.principalAsSafeHtml(include.principal, include.realm))); } } } builder.appendHtmlConstant("</ul>"); } else { builder.appendHtmlConstant("<li class=\"header\">No principals are included</li>"); } List<RoleAssignment.PrincipalRealmTupel> excludes = internal.getExcludes(); if (!excludes.isEmpty()) { builder.appendHtmlConstant( "<li class=\"header\">Excluded principals</li><ul class=\"inner-list icons-ul\">"); for (RoleAssignment.PrincipalRealmTupel exclude : excludes) { if (exclude.principal.getType() == USER) { builder.append(TEMPLATES.principal("user", "User", UIHelper.principalAsSafeHtml(exclude.principal, exclude.realm))); } else { builder.append(TEMPLATES.principal("group", "Group", UIHelper.principalAsSafeHtml(exclude.principal, exclude.realm))); } } builder.appendHtmlConstant("</ul>"); } else { builder.appendHtmlConstant("<li class=\"header\">No principals are excluded</li>"); } builder.appendHtmlConstant("</ol>"); } HTML html = new HTML(builder.toSafeHtml()); html.addStyleName("members-dialog"); layout.add(html); DialogueOptions options = new DialogueOptions(Console.CONSTANTS.common_label_done(), new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.closeWindow(); } }, Console.CONSTANTS.common_label_cancel(), new ClickHandler() { @Override public void onClick(final ClickEvent event) { presenter.closeWindow(); } }); options.showCancel(false); return new WindowContentBuilder(new ScrollPanel(layout), options).build(); }
From source file:org.jboss.as.console.client.core.Header.java
License:Open Source License
private Widget getLinksSection() { linksPane = new HTMLPanel(createLinks()); linksPane.getElement().setId("header-links-section"); linksPane.getElement().setAttribute("role", "menubar"); linksPane.getElement().setAttribute("aria-controls", "main-content-area"); String[][] sections = bootstrap.isStandalone() ? SECTIONS_STANADLONE : SECTIONS; for (String[] section : sections) { final String name = section[0]; final String id = "header-" + name; SafeHtmlBuilder html = new SafeHtmlBuilder(); html.appendHtmlConstant("<div class='header-link-label'>"); html.appendHtmlConstant("<span role='menuitem'>"); html.appendHtmlConstant(section[1]); html.appendHtmlConstant("</span>"); html.appendHtmlConstant("</div>"); HTML widget = new HTML(html.toSafeHtml()); widget.setStyleName("fill-layout"); widget.addClickHandler(new ClickHandler() { @Override//from w ww .ja v a2s. co m public void onClick(ClickEvent event) { placeManager.revealPlace(new PlaceRequest(name)); } }); linksPane.add(widget, id); } //subnavigation = createSubnavigation(); //linksPane.add(subnavigation, "subnavigation"); return linksPane; }
From source file:org.jboss.as.console.client.core.Header.java
License:Open Source License
private String createLinks() { String[][] sections = bootstrap.getProperty(BootstrapContext.STANDALONE).equals("true") ? SECTIONS_STANADLONE// w w w . j ava2 s. co m : SECTIONS; SafeHtmlBuilder headerString = new SafeHtmlBuilder(); if (sections.length > 0) { headerString.appendHtmlConstant( "<table border=0 class='header-links' cellpadding=0 cellspacing=0 border=0>"); headerString.appendHtmlConstant("<tr id='header-links-ref'>"); headerString.appendHtmlConstant("<td><img src=\"images/blank.png\" width=1/></td>"); for (String[] section : sections) { final String name = section[0]; final String id = "header-" + name; String styleClass = "header-link"; String styleAtt = "vertical-align:middle; text-align:center"; String td = "<td style='" + styleAtt + "' id='" + id + "' class='" + styleClass + "'></td>"; headerString.appendHtmlConstant(td); //headerString.append(title); //headerString.appendHtmlConstant("<td ><img src=\"images/blank.png\" width=1 height=32/></td>"); } headerString.appendHtmlConstant("</tr>"); headerString.appendHtmlConstant("</table>"); headerString.appendHtmlConstant("<div id='subnavigation' style='float:right;clear:right;'/>"); } return headerString.toSafeHtml().asString(); }
From source file:org.jboss.as.console.client.core.message.MessageCenterView.java
License:Open Source License
private void showDetail(final Message msg) { msg.setNew(false);//from www .ja v a 2 s.co m final DefaultWindow window = new DefaultWindow(Console.CONSTANTS.common_label_messageDetailTitle()); window.setWidth(480); window.setHeight(360); window.setGlassEnabled(true); //ImageResource icon = MessageCenterView.getSeverityIcon(msg.getSeverity()); //AbstractImagePrototype prototype = AbstractImagePrototype.create(icon); SafeHtmlBuilder html = new SafeHtmlBuilder(); // TODO: XSS prevention? html.appendHtmlConstant(msg.getSeverity().getTag()); html.appendHtmlConstant(" "); html.appendHtmlConstant(msg.getFired().toString()); html.appendHtmlConstant("<h3 id='consise-message'>"); html.appendHtmlConstant(msg.getConciseMessage()); html.appendHtmlConstant("</h3>"); html.appendHtmlConstant("<p/>"); String detail = msg.getDetailedMessage() != null ? msg.getDetailedMessage() : ""; html.appendHtmlConstant("<pre style='font-family:tahoma, verdana, sans-serif;' id='detail-message'>"); html.appendHtmlConstant(detail); html.appendHtmlConstant("</pre>"); final HTML widget = new HTML(html.toSafeHtml()); widget.getElement().setAttribute("style", "margin:5px"); DialogueOptions options = new DialogueOptions("OK", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { window.hide(); } }, Console.CONSTANTS.common_label_cancel(), new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { window.hide(); } }); options.getSubmit().setAttribute("aria-describedby", "consise-message detail-message"); Widget windowContent = new WindowContentBuilder(widget, options).build(); TrappedFocusPanel trap = new TrappedFocusPanel(windowContent) { @Override protected void onAttach() { super.onAttach(); Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { getFocus().onFirstButton(); } }); } }; window.setWidget(trap); window.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { messagePopup.getMessageList().getSelectionModel().setSelected(msg, false); messagePopup.hide(); } }); messagePopup.hide(); window.center(); }
From source file:org.jboss.as.console.client.core.settings.SettingsView.java
License:Open Source License
@Inject public SettingsView(EventBus eventBus) { super(eventBus); window = new DefaultWindow(Console.CONSTANTS.common_label_settings()); VerticalPanel layout = new VerticalPanel(); layout.setStyleName("window-content"); form = new Form<CommonSettings>(CommonSettings.class); ComboBoxItem localeItem = new ComboBoxItem(Preferences.Key.LOCALE.getToken(), Preferences.Key.LOCALE.getTitle()); localeItem.setDefaultToFirstOption(true); localeItem.setValueMap(new String[] { "en", "de", "zh_Hans", "pt_BR", "fr", "es", "ja" }); //CheckBoxItem useCache = new CheckBoxItem(Preferences.Key.USE_CACHE.getToken(), Preferences.Key.USE_CACHE.getTitle()); CheckBoxItem enableAnalytics = new CheckBoxItem(Preferences.Key.ANALYTICS.getToken(), Preferences.Key.ANALYTICS.getTitle()); form.setFields(localeItem, enableAnalytics); Widget formWidget = form.asWidget(); formWidget.getElement().setAttribute("style", "margin:15px"); DialogueOptions options = new DialogueOptions(Console.CONSTANTS.common_label_save(), new ClickHandler() { @Override/* w w w. j a va 2s . com*/ public void onClick(ClickEvent event) { presenter.onSaveDialogue(form.getUpdatedEntity()); presenter.hideView(); Feedback.confirm(Console.MESSAGES.restartRequired(), Console.MESSAGES.restartRequiredConfirm(), new Feedback.ConfirmationHandler() { @Override public void onConfirmation(boolean isConfirmed) { // Ignore: it crashes the browser.. /*if(isConfirmed){ Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { reload(); } }); } */ } }); } }, Console.CONSTANTS.common_label_cancel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.onCancelDialogue(); } }); options.getElement().setAttribute("style", "padding:10px"); SafeHtmlBuilder html = new SafeHtmlBuilder(); html.appendHtmlConstant("<ul>"); html.appendHtmlConstant("<li>").appendEscaped("Locale: The user interface language."); html.appendHtmlConstant("<li>").appendEscaped( "Analytics: We track browser and operating system information in order to improve the user interface. "); html.appendEscaped("You can disable the analytics feature at anytime."); html.appendHtmlConstant("</ul>"); StaticHelpPanel help = new StaticHelpPanel(html.toSafeHtml()); layout.add(help.asWidget()); layout.add(form.asWidget()); window.setWidth(480); window.setHeight(360); window.trapWidget(new WindowContentBuilder(layout, options).build()); window.setGlassEnabled(true); window.center(); }