Search in sources :

Example 71 with SafeHtmlBuilder

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);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Date(java.util.Date) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Revision(org.eclipse.che.api.git.shared.Revision) Column(com.google.gwt.user.cellview.client.Column)

Example 72 with SafeHtmlBuilder

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();
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 73 with SafeHtmlBuilder

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();
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 74 with SafeHtmlBuilder

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);
        }
    });
}
Also used : AbstractSafeHtmlRenderer(com.google.gwt.text.shared.AbstractSafeHtmlRenderer) ImageResource(com.google.gwt.resources.client.ImageResource) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) JsArrayString(com.google.gwt.core.client.JsArrayString) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell)

Example 75 with SafeHtmlBuilder

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;
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) LinkColumn(org.rstudio.core.client.cellview.LinkColumn) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Aggregations

SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)143 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)26 Test (org.junit.Test)18 Column (com.google.gwt.user.cellview.client.Column)17 Cell (com.google.gwt.cell.client.Cell)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)12 Context (com.google.gwt.cell.client.Cell.Context)7 MenuItem (com.google.gwt.user.client.ui.MenuItem)7 NativeEvent (com.google.gwt.dom.client.NativeEvent)6 Command (com.google.gwt.user.client.Command)6 ArrayList (java.util.ArrayList)6 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)5 GWT (com.google.gwt.core.client.GWT)5 Element (com.google.gwt.dom.client.Element)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)4 TextCell (com.google.gwt.cell.client.TextCell)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 ImageResource (com.google.gwt.resources.client.ImageResource)4 Map (java.util.Map)4