Search in sources :

Example 1 with PluginContentReadyEvent

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"));
            }
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) PluginContentReadyEvent(org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent)

Example 2 with PluginContentReadyEvent

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));
        }
    });
}
Also used : PluginContentReadyEvent(org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent) Post(com.willshex.blogwt.shared.api.datatype.Post) GetPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetPostsRequest) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 3 with PluginContentReadyEvent

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"));
        }
    });
}
Also used : PluginContentReadyEvent(org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent)

Aggregations

PluginContentReadyEvent (org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 GetPostsRequest (com.willshex.blogwt.shared.api.blog.call.GetPostsRequest)1 Post (com.willshex.blogwt.shared.api.datatype.Post)1