use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project che by eclipse.
the class ResetToCommitViewImpl method createCommitsTable.
/** Creates table what contains list of available commits. */
private void createCommitsTable() {
commits = new CellTable<Revision>(15, tableRes);
Column<Revision, String> dateColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
return DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM).format(new Date((long) revision.getCommitTime()));
}
@Override
public void render(Cell.Context context, Revision revision, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-reset-cellTable-" + context.getIndex() + "\">");
super.render(context, revision, sb);
}
};
Column<Revision, String> commiterColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
if (revision.getCommitter() == null) {
return "";
}
return revision.getCommitter().getName();
}
};
Column<Revision, String> commentColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
return revision.getMessage();
}
};
commits.addColumn(dateColumn, locale.commitGridDate());
commits.setColumnWidth(dateColumn, "20%");
commits.addColumn(commiterColumn, locale.commitGridCommiter());
commits.setColumnWidth(commiterColumn, "20%");
commits.addColumn(commentColumn, locale.commitGridComment());
commits.setColumnWidth(commentColumn, "60%");
final SingleSelectionModel<Revision> selectionModel = new SingleSelectionModel<Revision>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
Revision selectedObject = selectionModel.getSelectedObject();
delegate.onRevisionSelected(selectedObject);
}
});
commits.setSelectionModel(selectionModel);
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class ImageResource2x method getSafeHtml.
public SafeHtml getSafeHtml() {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
sb.appendHtmlConstant("<img src=\"");
sb.appendHtmlConstant(getSafeUri().asString());
sb.appendHtmlConstant("\" width=\"");
sb.appendHtmlConstant(new Integer(getWidth()).toString());
sb.appendHtmlConstant("\" height=\"");
sb.appendHtmlConstant(new Integer(getHeight()).toString());
sb.appendHtmlConstant("\">");
return sb.toSafeHtml();
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class CodeSearchSuggestion method createDisplayString.
private String createDisplayString(ImageResource image, String imageStyle, String name, String extraInfo, String context) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
SafeHtmlUtil.appendImage(sb, imageStyle, image);
SafeHtmlUtil.appendSpan(sb, RES.styles().itemName(), name);
// check for extra info
if (!StringUtil.isNullOrEmpty(extraInfo)) {
SafeHtmlUtil.appendSpan(sb, RES.styles().itemName(), extraInfo);
}
// check for context
if (context != null) {
SafeHtmlUtil.appendSpan(sb, RES.styles().itemContext(), "(" + context + ")");
}
return sb.toSafeHtml().asString();
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class EnvironmentObjectList method createExpandColumn.
private void createExpandColumn() {
// the column containing the expand command; available only on objects
// with contents (such as lists and data frames).
SafeHtmlRenderer<String> expanderRenderer = new AbstractSafeHtmlRenderer<String>() {
@Override
public SafeHtml render(String object) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
sb.appendHtmlConstant(object);
return sb.toSafeHtml();
}
};
objectExpandColumn_ = new Column<RObjectEntry, String>(new ClickableTextCell(expanderRenderer)) {
@Override
public String getValue(RObjectEntry object) {
String imageUri = "";
String imageStyle = style_.expandIcon();
if (object.canExpand()) {
imageStyle = imageStyle + " " + ThemeStyles.INSTANCE.handCursor();
ImageResource expandImage = object.isExpanding ? CoreResources.INSTANCE.progress() : object.expanded ? new ImageResource2x(EnvironmentResources.INSTANCE.collapseIcon2x()) : new ImageResource2x(EnvironmentResources.INSTANCE.expandIcon2x());
imageUri = expandImage.getSafeUri().asString();
} else if (object.hasTraceInfo()) {
imageUri = new ImageResource2x(EnvironmentResources.INSTANCE.tracedFunction2x()).getSafeUri().asString();
imageStyle += (" " + style_.unclickableIcon());
}
if (imageUri.length() > 0) {
return "<input type=\"image\" src=\"" + imageUri + "\" " + "class=\"" + imageStyle + "\" />";
}
return "";
}
};
objectExpandColumn_.setFieldUpdater(new FieldUpdater<RObjectEntry, String>() {
@Override
public void update(int index, RObjectEntry object, String value) {
if (!object.canExpand())
return;
expandObject(index, object);
}
});
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project rstudio by rstudio.
the class FilesList method addSelectionColumn.
private Column<FileSystemItem, Boolean> addSelectionColumn() {
Column<FileSystemItem, Boolean> checkColumn = new Column<FileSystemItem, Boolean>(new CheckboxCell(true, false) {
@Override
public void render(Context context, Boolean value, SafeHtmlBuilder sb) {
// don't render the check box if its for the parent path
if (parentPath_ == null || context.getIndex() > 0)
super.render(context, value, sb);
}
}) {
@Override
public Boolean getValue(FileSystemItem item) {
return selectionModel_.isSelected(item);
}
};
checkColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
filesDataGrid_.addColumn(checkColumn);
filesDataGrid_.setColumnWidth(checkColumn, CHECK_COLUMN_WIDTH_PIXELS, Unit.PX);
return checkColumn;
}
Aggregations