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());
}
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);
}
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());
}
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();
}
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);
}
Aggregations