use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project che by eclipse.
the class SshKeyManagerViewImpl method initSshKeyTable.
/** Creates table what contains list of available ssh keys. */
private void initSshKeyTable(final CellTable.Resources res) {
keys = new CellTable<>(20, res);
Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) {
@Override
public String getValue(SshPairDto object) {
return object.getName();
}
@Override
public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-title-" + context.getIndex() + "\">");
super.render(context, object, sb);
}
};
hostColumn.setSortable(true);
Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
@Override
public String getValue(SshPairDto object) {
return "View";
}
@Override
public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-" + context.getIndex() + "\">");
if (object != null && object.getPublicKey() != null) {
super.render(context, object, sb);
}
}
};
// Creates handler on button clicked
publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
@Override
public void update(int index, SshPairDto object, String value) {
delegate.onViewClicked(object);
}
});
Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
@Override
public String getValue(SshPairDto object) {
return "Delete";
}
@Override
public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-" + context.getIndex() + "\">");
super.render(context, object, sb);
}
};
// Creates handler on button clicked
deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
@Override
public void update(int index, SshPairDto object, String value) {
delegate.onDeleteClicked(object);
}
});
keys.addColumn(hostColumn, "Title");
keys.addColumn(publicKeyColumn, "Public Key");
keys.addColumn(deleteKeyColumn, "Delete");
keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT);
keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX);
keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX);
// don't show loading indicator
keys.setLoadingIndicator(null);
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project che by eclipse.
the class GithubImporterPageViewImpl method createRepositoriesTable.
/**
* Creates table what contains list of available repositories.
*
* @param resources
*/
private void createRepositoriesTable(final Resources resources, GitHubLocalizationConstant locale) {
repositories = new CellTable<>(15, resources);
Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(ProjectData item) {
return null;
}
};
Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(final ProjectData item) {
return SafeHtmlUtils.fromString(item.getName());
}
};
Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(final ProjectData item) {
return new SafeHtmlBuilder().appendHtmlConstant("<span>").appendEscaped(item.getDescription() == null ? "" : item.getDescription()).appendHtmlConstant("</span>").toSafeHtml();
}
};
repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX);
repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn());
repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn());
// don't show loading indicator
repositories.setLoadingIndicator(null);
final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
ProjectData selectedObject = selectionModel.getSelectedObject();
delegate.onRepositorySelected(selectedObject);
}
});
repositories.setSelectionModel(selectionModel);
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project che by eclipse.
the class SshKeyManagerViewImpl method initSshKeyTable.
/** Creates table what contains list of available ssh keys. */
private void initSshKeyTable(final CellTable.Resources res) {
keys = new CellTable<>(15, res);
Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) {
@Override
public String getValue(SshPairDto object) {
return object.getName();
}
@Override
public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-host-" + context.getIndex() + "\">");
super.render(context, object, sb);
}
};
hostColumn.setSortable(true);
Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
@Override
public String getValue(SshPairDto object) {
return "View";
}
@Override
public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-" + context.getIndex() + "\">");
if (object != null && object.getPublicKey() != null) {
super.render(context, object, sb);
}
}
};
// Creates handler on button clicked
publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
@Override
public void update(int index, SshPairDto object, String value) {
delegate.onViewClicked(object);
}
});
Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
@Override
public String getValue(SshPairDto object) {
return "Delete";
}
@Override
public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-" + context.getIndex() + "\">");
super.render(context, object, sb);
}
};
// Creates handler on button clicked
deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
@Override
public void update(int index, SshPairDto object, String value) {
delegate.onDeleteClicked(object);
}
});
keys.addColumn(hostColumn, "Host");
keys.addColumn(publicKeyColumn, "Public Key");
keys.addColumn(deleteKeyColumn, "Delete");
keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT);
keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX);
keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX);
// don't show loading indicator
keys.setLoadingIndicator(null);
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project che by eclipse.
the class DiffViewerViewImpl method colorizeDiff.
private String colorizeDiff(String origin) {
StringBuilder html = new StringBuilder();
html.append("<pre>");
for (String line : Splitter.on("\n").splitToList(origin)) {
final String prefix = line.substring(0, 1);
final String sanitizedLine = new SafeHtmlBuilder().appendEscaped(line).toSafeHtml().asString();
html.append("<span style=\"color:").append(lineRules.containsKey(prefix) ? lineRules.get(prefix) : lineRules.get("default")).append(";\">").append(sanitizedLine).append("</span>").append("\n");
}
html.append("</pre>");
return html.toString();
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class AppCommand method createRightImageHtml.
private static SafeHtml createRightImageHtml(ImageResource image, String desc) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
sb.append(SafeHtmlUtil.createOpenTag("img", "class", ThemeStyles.INSTANCE.menuRightImage(), "title", StringUtil.notNull(desc), "width", Integer.toString(image.getWidth()), "height", Integer.toString(image.getHeight()), "src", image.getSafeUri().asString()));
sb.appendHtmlConstant("</img>");
return sb.toSafeHtml();
}
Aggregations