Java源码示例:com.google.gwt.safehtml.shared.SafeHtmlBuilder
示例1
@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>");
}
示例2
@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());
}
示例3
/*************************************************************
** 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());
}
示例4
/*************************************************************
** 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());
}
示例5
/*************************************************************
** 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());
}
示例6
@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());
}
示例7
@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());
}
示例8
@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);
}
示例9
@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();
}
示例10
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());
}
示例11
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());
}
示例12
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());
}
}
}
示例13
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();
}
示例14
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);
}
}
示例15
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());
}
示例16
@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()));
}
}
示例17
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> ");
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);
}
示例18
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();
}
示例19
private ColumnModel<LayerDef> createColumnList(LayerDefProperties props,
RowExpander<LayerDef> rowExpander) {
rowExpander.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
rowExpander.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<LayerDef, String> nameColumn = new ColumnConfig<LayerDef, String>(
props.name(), 200, SafeHtmlUtils.fromTrustedString("<b>"
+ UIMessages.INSTANCE.layerManagerToolText() + "</b>"));
nameColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<LayerDef, String> typeColumn = new ColumnConfig<LayerDef, String>(
props.type(), 75, UICatalogMessages.INSTANCE.type());
typeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
typeColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
ColumnConfig<LayerDef, ImageResource> iconColumn = new ColumnConfig<LayerDef, ImageResource>(
props.icon(), 32, "");
iconColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
iconColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
iconColumn.setCell(new ImageResourceCell() {
@Override
public void render(Context context, ImageResource value, SafeHtmlBuilder sb) {
super.render(context, value, sb);
}
});
List<ColumnConfig<LayerDef, ?>> columns = new ArrayList<ColumnConfig<LayerDef, ?>>();
columns.add(rowExpander);
columns.add(iconColumn);
columns.add(nameColumn);
columns.add(typeColumn);
return new ColumnModel<LayerDef>(columns);
}
示例20
private RowExpander<LayerDef> createRowExpander() {
return new RowExpander<LayerDef>(new AbstractCell<LayerDef>() {
@Override
public void render(Context context, LayerDef value,
SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>"
+ UICatalogMessages.INSTANCE.description() + ":</b> "
+ value.getDescription() + "</p>");
}
});
}
示例21
private ImageListEditor<ColumnType>.Entry buildEntry(final ColumnType type) {
final String name = type.name();
final String descr = getColumnTypeDescription(type);
final SafeUri uri = getImageUri(type);
return columnType.newEntry(type,
uri,
new SafeHtmlBuilder().appendEscaped(name).toSafeHtml(),
new SafeHtmlBuilder().appendEscaped(descr).toSafeHtml());
}
示例22
protected void showError(final ClientRuntimeError error) {
loadingBox.hide();
final String message = error.getCause() != null ? error.getCause() : error.getMessage();
view.showErrorNotification(new SafeHtmlBuilder().appendEscaped(message).toSafeHtml());
errorEvent.fire(new ErrorEvent(this,
error));
if (afterPreviewCommand != null) {
this.afterPreviewCommand.execute();
}
}
示例23
protected Collection<ImageListEditor<DataSetProviderType>.Entry> getDefaultEntries() {
final DataSetProviderType[] providerTypes = CORE_TYPES;
final Collection<ImageListEditor<DataSetProviderType>.Entry> entries = new ArrayList<>(providerTypes.length);
for (final DataSetProviderType type : providerTypes) {
final String title = getTypeSelectorTitle(type);
final String text = getTypeSelectorText(type);
final SafeUri uri = getTypeSelectorImageUri(type);
final ImageListEditor<DataSetProviderType>.Entry entry = provider.newEntry(type,
uri,
new SafeHtmlBuilder().appendEscaped(title).toSafeHtml(),
new SafeHtmlBuilder().appendEscaped(text).toSafeHtml());
entries.add(entry);
}
return entries;
}
示例24
@Override
public void render(Context context, TreeState.TreeNodeState value, SafeHtmlBuilder sb) {
GwtHorizontalLayoutImpl layout = GwtComboBoxImplConnector.buildItem(value);
SafeHtml safeValue = SafeHtmlUtils.fromSafeConstant(layout.toString());
sb.append(safeValue);
}
示例25
@Override
public void replaceAllChildren(List<C> values, SelectionModel<? super C> selectionModel, boolean stealFocus) {
// Render the children.
SafeHtmlBuilder sb = new SafeHtmlBuilder();
render(sb, values, 0, selectionModel);
// Hide the child container so we can animate it.
if (nodeView.tree.isAnimationEnabled()) {
nodeView.ensureAnimationFrame().getStyle().setDisplay(Display.NONE);
}
// Replace the child nodes.
nodeView.tree.isRefreshing = true;
Map<Object, CellTreeNodeView<?>> savedViews = saveChildState(values, 0);
AbstractHasData.replaceAllChildren(nodeView.tree, childContainer, sb.toSafeHtml());
nodeView.tree.isRefreshing = false;
// Trim the list of children.
int size = values.size();
int childCount = nodeView.children.size();
while (childCount > size) {
childCount--;
CellTreeNodeView<?> deleted = nodeView.children.remove(childCount);
deleted.cleanup(true);
}
// Reattach the open nodes.
loadChildState(values, 0, savedViews);
// If this is the root node, move keyboard focus to the first child.
if (nodeView.isRootNode() && nodeView.tree.getKeyboardSelectedNode() == nodeView && values.size() > 0) {
nodeView.tree.keyboardSelect(nodeView.children.get(0), false);
}
// Animate the child container open.
if (nodeView.tree.isAnimationEnabled()) {
nodeView.tree.maybeAnimateTreeNode(nodeView);
}
}
示例26
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/>");
}
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());
}
示例27
public StaticHelpPanel(String helpText) {
SafeHtmlBuilder builder = new SafeHtmlBuilder();
builder.appendHtmlConstant("<div class='help-attribute-descriptions' style='padding-left:10px;'>");
builder.appendHtmlConstant(helpText);
builder.appendHtmlConstant("</div>");
this.helpText = builder.toSafeHtml();
}
示例28
public static SafeHtml getEndpointDescription()
{
SafeHtmlBuilder html = new SafeHtmlBuilder();
html.appendHtmlConstant("<ul>");
html.appendHtmlConstant("<li>");
html.appendEscaped("context: Webservice endpoint context.") ;
html.appendHtmlConstant("<li>");
html.appendEscaped("class: Webservice implementation class.") ;
html.appendHtmlConstant("<li>");
html.appendEscaped("type: Webservice endpoint type.") ;
html.appendHtmlConstant("<li>");
html.appendEscaped("wsdl-url:Webservice endpoint WSDL URL.") ;
html.appendHtmlConstant("</ul>");
return html.toSafeHtml();
}
示例29
@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);
}
}
示例30
@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>");
}