Search in sources :

Example 1 with PagePlanBuilder

use of com.willshex.blogwt.client.wizard.PagePlan.PagePlanBuilder in project blogwt by billy1380.

the class EditPagePage method onAttach.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.client.page.Page#onAttach() */
@Override
protected void onAttach() {
    register(DefaultEventBus.get().addHandlerToSource(NavigationChangedEventHandler.TYPE, NavigationController.get(), (p, c) -> {
        String action = c.getAction();
        if (action != null && "new".equalsIgnoreCase(action)) {
            setPlan((new PagePlanBuilder()).addPage(new EditPageWizardPage()).addPage(new SelectPostWizardPage()).setName("New Page").addFinishedHandler(this).build());
        } else {
            Page page = null;
            if (c.getParameterCount() >= 1) {
                switch(c.getAction()) {
                    case "id":
                        (page = new Page()).id(Long.valueOf(c.getParameter(0)));
                        break;
                    case "slug":
                        page = new Page().slug(c.getParameter(0));
                        break;
                }
            } else {
                page = new Page().slug(c.getAction());
            }
            if (page != null) {
                PageController.get().getPage(page, true);
            }
        }
    }));
    register(DefaultEventBus.get().addHandlerToSource(CreatePageEventHandler.TYPE, PageController.get(), this));
    register(DefaultEventBus.get().addHandlerToSource(GetPageEventHandler.TYPE, PageController.get(), this));
    register(DefaultEventBus.get().addHandlerToSource(UpdatePageEventHandler.TYPE, PageController.get(), this));
    super.onAttach();
}
Also used : UpdatePageResponse(com.willshex.blogwt.shared.api.page.call.UpdatePageResponse) Page(com.willshex.blogwt.shared.api.datatype.Page) PagePlanBuilder(com.willshex.blogwt.client.wizard.PagePlan.PagePlanBuilder) NavigationChangedEventHandler(com.willshex.blogwt.client.event.NavigationChangedEventHandler) CreatePageEventHandler(com.willshex.blogwt.client.api.page.event.CreatePageEventHandler) UpdatePageEventHandler(com.willshex.blogwt.client.api.page.event.UpdatePageEventHandler) GWT(com.google.gwt.core.client.GWT) ArrayList(java.util.ArrayList) PageType(com.willshex.blogwt.shared.page.PageType) CreatePageResponse(com.willshex.blogwt.shared.api.page.call.CreatePageResponse) GetPageResponse(com.willshex.blogwt.shared.api.page.call.GetPageResponse) Post(com.willshex.blogwt.shared.api.datatype.Post) StatusType(com.willshex.gson.web.service.shared.StatusType) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) WizardPage(com.willshex.blogwt.client.wizard.WizardPage) UpdatePageRequest(com.willshex.blogwt.shared.api.page.call.UpdatePageRequest) GetPageRequest(com.willshex.blogwt.shared.api.page.call.GetPageRequest) CreatePageRequest(com.willshex.blogwt.shared.api.page.call.CreatePageRequest) PageController(com.willshex.blogwt.client.controller.PageController) GetPageEventHandler(com.willshex.blogwt.client.api.page.event.GetPageEventHandler) List(java.util.List) PagePlanFinishedHandler(com.willshex.blogwt.client.wizard.PagePlanFinishedHandler) WizardDialogPage(com.willshex.blogwt.client.page.wizard.WizardDialogPage) NavigationController(com.willshex.blogwt.client.controller.NavigationController) DefaultEventBus(com.willshex.blogwt.client.DefaultEventBus) SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage) PageTypeHelper(com.willshex.blogwt.client.helper.PageTypeHelper) SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage) PagePlanBuilder(com.willshex.blogwt.client.wizard.PagePlan.PagePlanBuilder) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) Page(com.willshex.blogwt.shared.api.datatype.Page) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) WizardPage(com.willshex.blogwt.client.wizard.WizardPage) WizardDialogPage(com.willshex.blogwt.client.page.wizard.WizardDialogPage) SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage)

Example 2 with PagePlanBuilder

use of com.willshex.blogwt.client.wizard.PagePlan.PagePlanBuilder in project blogwt by billy1380.

the class EditPagePage method getPageSuccess.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.shared.api.page.call.event.GetPageEventHandler#
	 * getPageSuccess(com.willshex.blogwt.shared.api.page.call.GetPageRequest,
	 * com.willshex.blogwt.shared.api.page.call.GetPageResponse) */
@Override
public void getPageSuccess(GetPageRequest input, GetPageResponse output) {
    if (output.status == StatusType.StatusTypeSuccess) {
        PagePlanBuilder builder = new PagePlanBuilder();
        EditPageWizardPage ewp = new EditPageWizardPage();
        ewp.setData(output.page);
        builder.addPage(ewp);
        SelectPostWizardPage spwp = new SelectPostWizardPage();
        for (Post post : output.page.posts) {
            spwp = new SelectPostWizardPage();
            spwp.setData(post);
            builder.addPage(spwp, post != output.page.posts.get(0));
        }
        setPlan(builder.setName("Edit " + output.page.title).addFinishedHandler(this).build());
    }
}
Also used : SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage) PagePlanBuilder(com.willshex.blogwt.client.wizard.PagePlan.PagePlanBuilder) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) Post(com.willshex.blogwt.shared.api.datatype.Post)

Aggregations

PagePlanBuilder (com.willshex.blogwt.client.wizard.PagePlan.PagePlanBuilder)2 EditPageWizardPage (com.willshex.blogwt.client.wizard.page.EditPageWizardPage)2 SelectPostWizardPage (com.willshex.blogwt.client.wizard.page.SelectPostWizardPage)2 Post (com.willshex.blogwt.shared.api.datatype.Post)2 GWT (com.google.gwt.core.client.GWT)1 DefaultEventBus (com.willshex.blogwt.client.DefaultEventBus)1 CreatePageEventHandler (com.willshex.blogwt.client.api.page.event.CreatePageEventHandler)1 GetPageEventHandler (com.willshex.blogwt.client.api.page.event.GetPageEventHandler)1 UpdatePageEventHandler (com.willshex.blogwt.client.api.page.event.UpdatePageEventHandler)1 NavigationController (com.willshex.blogwt.client.controller.NavigationController)1 PageController (com.willshex.blogwt.client.controller.PageController)1 NavigationChangedEventHandler (com.willshex.blogwt.client.event.NavigationChangedEventHandler)1 PageTypeHelper (com.willshex.blogwt.client.helper.PageTypeHelper)1 WizardDialogPage (com.willshex.blogwt.client.page.wizard.WizardDialogPage)1 PagePlanFinishedHandler (com.willshex.blogwt.client.wizard.PagePlanFinishedHandler)1 WizardPage (com.willshex.blogwt.client.wizard.WizardPage)1 Page (com.willshex.blogwt.shared.api.datatype.Page)1 CreatePageRequest (com.willshex.blogwt.shared.api.page.call.CreatePageRequest)1 CreatePageResponse (com.willshex.blogwt.shared.api.page.call.CreatePageResponse)1 GetPageRequest (com.willshex.blogwt.shared.api.page.call.GetPageRequest)1