use of org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent in project blogwt by billy1380.
the class GalleryPlugin method emit.
/* (non-Javadoc)
*
* @see org.markdown4j.Plugin#emit(java.lang.StringBuilder, java.util.List,
* java.util.Map) */
@Override
public void emit(StringBuilder out, final List<String> lines, final Map<String, String> params) {
final String id = HTMLPanel.createUniqueId();
out.append("<div id=\"");
out.append(id);
out.append("\"> Loading gallery...</div>");
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (manager != null) {
manager.fireEvent(new PluginContentReadyEvent(GalleryPlugin.this, lines, params, id, "None"));
}
}
});
}
use of org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent in project blogwt by billy1380.
the class PostsPlugin method emit.
/* (non-Javadoc)
*
* @see org.markdown4j.Plugin#emit(java.lang.StringBuilder, java.util.List,
* java.util.Map) */
@Override
public void emit(StringBuilder out, List<String> lines, Map<String, String> params) {
String count = params.get("count");
final String id = HTMLPanel.createUniqueId();
out.append("<div id=\"");
out.append(id);
out.append("\">Loading...</div>");
ApiHelper.createBlogClient().getPosts(SessionController.get().setSession(ApiHelper.setAccessCode(new GetPostsRequest())).pager(PagerHelper.createDefaultPager().count(Integer.valueOf(count)).sortBy(PostSortType.PostSortTypeCreated.toString())), (i, o) -> {
if (manager != null) {
String content = "";
if (o.status == StatusType.StatusTypeSuccess && o.posts != null && !o.posts.isEmpty()) {
SafeHtmlBuilder b = new SafeHtmlBuilder();
for (Post object : o.posts) {
RENDERER.render(null, object, b);
}
content = b.toSafeHtml().asString();
}
manager.fireEvent(new PluginContentReadyEvent(this, lines, params, id, content));
}
}, (i, c) -> {
if (manager != null) {
String content = "";
manager.fireEvent(new PluginContentReadyEvent(this, lines, params, id, content));
}
});
}
use of org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent in project blogwt by billy1380.
the class FormPlugin method emit.
/* (non-Javadoc)
*
* @see org.markdown4j.Plugin#emit(java.lang.StringBuilder, java.util.List,
* java.util.Map) */
@Override
public void emit(StringBuilder out, final List<String> lines, final Map<String, String> params) {
final String id = HTMLPanel.createUniqueId();
out.append("<div id=\"");
out.append(id);
out.append("\"> Loading form...</div>");
Scheduler.get().scheduleDeferred(() -> {
if (manager != null) {
manager.fireEvent(new PluginContentReadyEvent(FormPlugin.this, lines, params, id, "None"));
}
});
}
Aggregations