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);
}
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 drools-wb by kiegroup.
the class IssuePresenterTest method testShow.
@Test
public void testShow() throws Exception {
Issue issue = new Issue(Severity.WARNING, CheckType.REDUNDANT_ROWS, new HashSet<>(Arrays.asList(1, 2, 3)));
screen.show(issue);
verify(view).setIssueTitle("RedundantRows");
ArgumentCaptor<SafeHtml> safeHtmlArgumentCaptor = ArgumentCaptor.forClass(SafeHtml.class);
verify(view).setExplanation(safeHtmlArgumentCaptor.capture());
assertEquals("<p>MissingRangeP1(1)</p>", safeHtmlArgumentCaptor.getValue().asString());
verify(view).setLines("1, 2, 3");
}
use of com.google.gwt.safehtml.shared.SafeHtml in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_Condition.
@Test
public void getSafeHtml_Condition() {
ConditionCol52 originalColumn = new ConditionCol52();
originalColumn.setBinding("bind1");
originalColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
originalColumn.setFactField("field1");
originalColumn.setFieldType("FieldType1");
originalColumn.setOperator("==");
originalColumn.setValueList("a,b,c");
originalColumn.setHeader("condition1");
originalColumn.setHideColumn(false);
originalColumn.setDefaultValue(new DTCellValue52("def1"));
ConditionCol52 newColumn = new ConditionCol52();
newColumn.setBinding("bind2");
newColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
newColumn.setFactField("field2");
newColumn.setFieldType("FieldType2");
newColumn.setOperator("!=");
newColumn.setValueList("x,y,z");
newColumn.setHeader("condition2");
newColumn.setHideColumn(true);
newColumn.setDefaultValue(new DTCellValue52("def2"));
Pattern52 originalPattern = new Pattern52();
originalPattern.setBoundName("patBind1");
originalPattern.setFactType("FactType1");
originalPattern.setEntryPointName("ep1");
Pattern52 newPattern = new Pattern52();
newPattern.setBoundName("patBind2");
newPattern.setFactType("FactType2");
newPattern.setEntryPointName("ep2");
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
diffs.addAll(originalPattern.diff(newPattern));
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getConditionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
Aggregations