use of com.willshex.blogwt.client.wizard.page.SelectPostWizardPage 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();
}
use of com.willshex.blogwt.client.wizard.page.SelectPostWizardPage 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());
}
}
use of com.willshex.blogwt.client.wizard.page.SelectPostWizardPage in project blogwt by billy1380.
the class EditPagePage method onfinished.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.client.wizard.PagePlanFinishedHandler#onfinished
* (java.util.List) */
@Override
public void onfinished(List<WizardPage<?>> pages) {
Page page = null;
Post post = null;
for (WizardPage<?> wizardPage : pages) {
if (wizardPage instanceof EditPageWizardPage) {
page = ((EditPageWizardPage) wizardPage).getData();
if (page.posts != null) {
page.posts.clear();
}
} else if (wizardPage instanceof SelectPostWizardPage) {
if (page.posts == null) {
page.posts = new ArrayList<Post>();
}
post = ((SelectPostWizardPage) wizardPage).getData();
page.posts.add(post);
}
}
if (page.id == null) {
PageController.get().createPage(page);
} else {
PageController.get().updatePage(page);
}
}
Aggregations