Search in sources :

Example 86 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project kie-wb-common by kiegroup.

the class PopupDropDownEditCellTest method testRender_SimpleDropDownData.

@Test
public void testRender_SimpleDropDownData() {
    final Cell.Context context = mock(Cell.Context.class);
    final SafeHtmlBuilder safeHtmlBuilder = mock(SafeHtmlBuilder.class);
    final String[] data = new String[] { "one", "two" };
    final DropDownData dd = DropDownData.create(data);
    when(dmo.getEnums(eq(FACT_TYPE), eq(FACT_FIELD), any(Map.class))).thenReturn(dd);
    when(listBox.getItemCount()).thenReturn(data.length);
    when(listBox.getValue(eq(0))).thenReturn("one");
    when(listBox.getValue(eq(1))).thenReturn("two");
    when(listBox.getItemText(eq(0))).thenReturn("one");
    when(listBox.getItemText(eq(1))).thenReturn("two");
    cell.render(context, "one", safeHtmlBuilder);
    final ArgumentCaptor<SafeHtml> captor = ArgumentCaptor.forClass(SafeHtml.class);
    verify(safeHtmlBuilder, times(1)).append(captor.capture());
    assertEquals("one", captor.getValue().asString());
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Cell(com.google.gwt.cell.client.Cell) Map(java.util.Map) Test(org.junit.Test)

Example 87 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project kie-wb-common by kiegroup.

the class AbstractProxyPopupDropDownListBoxRenderTest method appendIsCalled.

@Test
public void appendIsCalled() {
    final SafeHtmlBuilder sb = mock(SafeHtmlBuilder.class);
    final SafeHtmlRenderer renderer = mock(SafeHtmlRenderer.class);
    final SafeHtml safeHtml = mock(SafeHtml.class);
    doReturn(safeHtml).when(renderer).render(anyString());
    listBoxDropDown.render(mock(Cell.Context.class), "", sb, renderer);
    verify(sb).append(safeHtml);
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) SafeHtmlRenderer(com.google.gwt.text.shared.SafeHtmlRenderer) Test(org.junit.Test)

Example 88 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project blogwt by billy1380.

the class PostSummaryCell method render.

@Override
public void render(Context context, Post value, SafeHtmlBuilder builder) {
    SafeUri link = PageTypeHelper.asHref(PageType.PostDetailPageType, PostHelper.getSlug(value));
    SafeHtml published = Templates.INSTANCE.notPublished(DateTimeHelper.ago(value.created));
    if (value.published != null) {
        published = Templates.INSTANCE.publishedDate(DateTimeHelper.ago(value.published));
    }
    String body = "Empty... :imp:";
    if (value.summary != null && value.summary.length() > 0) {
        body = value.summary;
    } else if (value.content != null && value.content.body != null && value.content.body.length() > 0) {
        body = value.content.body;
    }
    SafeHtml author = SafeHtmlUtils.EMPTY_SAFE_HTML;
    if (PropertyController.get().booleanProperty(PropertyHelper.POST_SHOW_AUTHOR, false)) {
        author = Templates.INSTANCE.author(UriUtils.fromString(value.author.avatar + "?s=" + UserHelper.AVATAR_HEADER_SIZE + "&default=retro"), UserHelper.handle(value.author));
    }
    RENDERER.render(builder, link, SafeHtmlUtils.fromTrustedString(PostHelper.makeHeading2(value.title)), SafeHtmlUtils.fromTrustedString(PostHelper.makeMarkup(body)), author, published, value.listed.booleanValue() ? SafeHtmlUtils.EMPTY_SAFE_HTML : Templates.INSTANCE.notVisible());
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeUri(com.google.gwt.safehtml.shared.SafeUri)

Example 89 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project blogwt by billy1380.

the class PostDetailPage method show.

private void show(Post post) {
    elTitle.setInnerHTML(PostHelper.makeHeading(post.title));
    SafeHtml author = SafeHtmlUtils.EMPTY_SAFE_HTML;
    if (PropertyController.get().booleanProperty(PropertyHelper.POST_SHOW_AUTHOR, false)) {
        author = PostSummaryCell.Templates.INSTANCE.author(UriUtils.fromString(post.author.avatar + "?s=" + UserHelper.AVATAR_HEADER_SIZE + "&default=retro"), UserHelper.handle(post.author));
    }
    if (PropertyController.get().booleanProperty(PropertyHelper.POST_SHOW_AUTHOR_SUMMARY, false)) {
        pnlUserSummary.setUser(post.author);
        pnlUserSummaryRow.setVisible(true);
    }
    elAuthor.setInnerSafeHtml(author);
    if (post.published != null) {
        elDate.setInnerSafeHtml(PostSummaryCell.Templates.INSTANCE.publishedDate(DateTimeHelper.ago(post.published)));
    } else {
        elDate.setInnerSafeHtml(PostSummaryCell.Templates.INSTANCE.notPublished(DateTimeHelper.ago(post.created)));
    }
    lnkEditPost.setTargetHistoryToken(PageType.EditPostPageType.asTargetHistoryToken(post.slug));
    tagList.getList().clear();
    coRelated.setVisible(Boolean.TRUE.equals(post.listed));
    if (post.tags != null) {
        for (String tag : post.tags) {
            tagList.getList().add(new Tag().name(tag));
        }
    }
    final String url = GWT.getHostPageBaseURL() + PageTypeHelper.asHref(PageType.PostDetailPageType, post.slug).asString();
    final String title = post.title;
    ataShare.setUrl(url);
    ataShare.setTitle(title);
    ataShare.setVisible(true);
    if (post.content != null) {
        String markup = PostHelper.makeMarkup(post.content.body);
        pnlContent.getElement().setInnerHTML(markup);
        String comments = PropertyController.get().stringProperty(PropertyHelper.POST_COMMENTS_ENABLED);
        if (comments == null || comments.equals(PropertyHelper.NONE_VALUE)) {
            dsqComments.removeFromParent();
        } else if (Boolean.TRUE.equals(post.commentsEnabled)) {
            final String identifier = "post" + post.id.toString();
            final String tag = post.tags == null || post.tags.size() == 0 ? "none" : post.tags.get(0);
            dsqComments.setUrl(url);
            dsqComments.setTitle(title);
            dsqComments.setIdentifier(identifier);
            dsqComments.setTag(tag);
            dsqComments.setVisible(true);
        } else {
            dsqComments.setVisible(false);
        }
    }
    pnlPostNav.setSlugs(post.previousSlug, post.nextSlug);
    pnlLoading.setVisible(false);
    FooterPart.get().scrollToTop();
    refreshTitle();
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Tag(com.willshex.blogwt.shared.api.datatype.Tag)

Example 90 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project blogwt by billy1380.

the class DownloadsPage method createColumns.

/**
 */
private void createColumns() {
    Column<GeneratedDownload, SafeHtml> name = new Column<GeneratedDownload, SafeHtml>(UiHelper.SAFE_HTML_PROTOTYPE) {

        @Override
        public SafeHtml getValue(GeneratedDownload object) {
            String parameters = object.parameters.replace("/send", "");
            String label = parameters.replace(Filter.QUERY + "/", "").replace("/", " > ");
            label = URL.decodeQueryString(label);
            return parameters.startsWith("proforma") || parameters.startsWith("invoice") ? Templates.INSTANCE.label(label) : Templates.INSTANCE.label(label, PageTypeHelper.slugToHref(parameters));
        }
    };
    TextColumn<GeneratedDownload> date = new TextColumn<GeneratedDownload>() {

        @Override
        public String getValue(GeneratedDownload object) {
            Date date;
            if (object.created == null) {
                date = DateTimeHelper.now();
            } else {
                date = object.created;
            }
            return DateTimeHelper.ago(date);
        }
    };
    TextColumn<GeneratedDownload> status = new TextColumn<GeneratedDownload>() {

        @Override
        public String getValue(GeneratedDownload object) {
            return object.status.toString();
        }
    };
    Column<GeneratedDownload, SafeHtml> download = new Column<GeneratedDownload, SafeHtml>(UiHelper.SAFE_HTML_PROTOTYPE) {

        @Override
        public SafeHtml getValue(GeneratedDownload object) {
            return object.status == GeneratedDownloadStatusType.GeneratedDownloadStatusTypeReady ? Templates.INSTANCE.download(UriUtils.fromString(object.url)) : SafeHtmlUtils.EMPTY_SAFE_HTML;
        }
    };
    tblDownloads.setColumnWidth(download, 1.0, Unit.PX);
    Column<GeneratedDownload, String> delete = new Column<GeneratedDownload, String>(ACTION_BUTTON_PROTOTYPE) {

        @Override
        public String getValue(GeneratedDownload object) {
            return "delete";
        }
    };
    delete.setFieldUpdater(new FieldUpdater<GeneratedDownload, String>() {

        @Override
        public void update(int index, GeneratedDownload object, String value) {
            if (Window.confirm("Are you sure you want to delete export with parameters " + URL.decodeQueryString(object.parameters) + "?")) {
                GeneratedDownloadController.get().deleteGeneratedDownload(object);
            }
        }
    });
    tblDownloads.setColumnWidth(delete, 1.0, Unit.PX);
    tblDownloads.addColumn(name, "Type");
    tblDownloads.addColumn(date, "Date");
    tblDownloads.addColumn(status, "Completion");
    // actions
    tblDownloads.addColumn(download);
    tblDownloads.addColumn(delete);
}
Also used : GeneratedDownload(com.willshex.blogwt.shared.api.datatype.GeneratedDownload) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Date(java.util.Date) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Aggregations

SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)129 Test (org.junit.Test)38 ImageResource (com.google.gwt.resources.client.ImageResource)25 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)25 UpdateColumnAuditLogEntry (org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)14 Column (com.google.gwt.user.cellview.client.Column)11 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)9 ArrayList (java.util.ArrayList)8 Cell (com.google.gwt.cell.client.Cell)7 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)7 HTML (com.google.gwt.user.client.ui.HTML)6 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)6 ConfirmDialog (org.eclipse.che.ide.api.dialogs.ConfirmDialog)6 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)4 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3 Element (com.google.gwt.dom.client.Element)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3