Search in sources :

Example 16 with Page

use of com.willshex.blogwt.shared.api.datatype.Page 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);
    }
}
Also used : SelectPostWizardPage(com.willshex.blogwt.client.wizard.page.SelectPostWizardPage) EditPageWizardPage(com.willshex.blogwt.client.wizard.page.EditPageWizardPage) Post(com.willshex.blogwt.shared.api.datatype.Post) ArrayList(java.util.ArrayList) 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 17 with Page

use of com.willshex.blogwt.shared.api.datatype.Page in project blogwt by billy1380.

the class PageDetailPage method onAttach.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.client.page.Page#onAttach() */
@Override
protected void onAttach() {
    super.onAttach();
    register(DefaultEventBus.get().addHandlerToSource(NavigationChangedEventHandler.TYPE, NavigationController.get(), (p, c) -> {
        String slug = null;
        if (PageType.fromString(c.getPage()) == PageType.PageDetailPageType) {
            slug = c.getAction();
        } else {
            slug = c.getPageSlug();
        }
        if (slug == null) {
            Page home;
            if ((home = PageController.get().homePage()) != null) {
                slug = home.slug;
            }
        }
        if (slug == null) {
            NavigationController.get().lost();
        } else {
            PageController.get().getPage(new Page().slug(slug), true);
        }
        pnlLoading.setVisible(true);
        boolean canChange = SessionController.get().isAuthorised(Arrays.asList(PermissionHelper.create(PermissionHelper.MANAGE_PAGES)));
        if (canChange) {
            getElement().insertFirst(elToolbar);
        } else {
            elToolbar.removeFromParent();
        }
    }));
    register(DefaultEventBus.get().addHandlerToSource(GetPageEventHandler.TYPE, PageController.get(), this));
    register(DefaultEventBus.get().addHandlerToSource(DeletePageEventHandler.TYPE, PageController.get(), this));
    register(PostHelper.handlePluginContentReady());
}
Also used : SectionPart(com.willshex.blogwt.client.part.SectionPart) Arrays(java.util.Arrays) Page(com.willshex.blogwt.shared.api.datatype.Page) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FooterPart(com.willshex.blogwt.client.part.FooterPart) LoadingPanel(com.willshex.blogwt.client.part.LoadingPanel) UiHandler(com.google.gwt.uibinder.client.UiHandler) NavigationChangedEventHandler(com.willshex.blogwt.client.event.NavigationChangedEventHandler) GWT(com.google.gwt.core.client.GWT) PageType(com.willshex.blogwt.shared.page.PageType) UiBinder(com.google.gwt.uibinder.client.UiBinder) GetPageResponse(com.willshex.blogwt.shared.api.page.call.GetPageResponse) SessionController(com.willshex.blogwt.client.controller.SessionController) InlineHyperlink(com.google.gwt.user.client.ui.InlineHyperlink) Post(com.willshex.blogwt.shared.api.datatype.Post) StatusType(com.willshex.gson.web.service.shared.StatusType) Window(com.google.gwt.user.client.Window) PostHelper(com.willshex.blogwt.client.helper.PostHelper) DeletePageResponse(com.willshex.blogwt.shared.api.page.call.DeletePageResponse) GetPageRequest(com.willshex.blogwt.shared.api.page.call.GetPageRequest) Button(com.google.gwt.user.client.ui.Button) PageController(com.willshex.blogwt.client.controller.PageController) UiHelper(com.willshex.blogwt.client.helper.UiHelper) HTMLPanel(com.google.gwt.user.client.ui.HTMLPanel) DeletePageEventHandler(com.willshex.blogwt.client.api.page.event.DeletePageEventHandler) PermissionHelper(com.willshex.blogwt.shared.helper.PermissionHelper) GetPageEventHandler(com.willshex.blogwt.client.api.page.event.GetPageEventHandler) Widget(com.google.gwt.user.client.ui.Widget) UiField(com.google.gwt.uibinder.client.UiField) NavigationController(com.willshex.blogwt.client.controller.NavigationController) Element(com.google.gwt.dom.client.Element) DefaultEventBus(com.willshex.blogwt.client.DefaultEventBus) DeletePageRequest(com.willshex.blogwt.shared.api.page.call.DeletePageRequest) PageTypeHelper(com.willshex.blogwt.client.helper.PageTypeHelper) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 18 with Page

use of com.willshex.blogwt.shared.api.datatype.Page in project blogwt by billy1380.

the class HeaderPart method setupNavBarPages.

private void setupNavBarPages() {
    String titleInNavBar = PropertyController.get().stringProperty(PropertyHelper.TITLE_IN_NAVBAR);
    boolean removedHome = false;
    if (titleInNavBar == null || titleInNavBar.contains(PropertyHelper.TITLE_VALUE)) {
        elName.setInnerText(PropertyController.get().title());
    } else if (titleInNavBar.equals(PropertyHelper.NONE_VALUE)) {
        btnHome.removeFromParent();
        removedHome = true;
    } else {
        elName.removeFromParent();
    }
    boolean foundBrandPage = false, addedBlog = false;
    List<Page> pages;
    SafeUri href;
    Map<Long, Page> possibleParents = new HashMap<Long, Page>();
    if ((pages = PageController.get().getHeaderPages()) != null) {
        for (Page page : pages) {
            if (page.priority != null && page.priority.floatValue() == 0.0f && !removedHome) {
                btnHome.setHref(PageTypeHelper.slugToHref(page.slug));
                foundBrandPage = true;
            } else {
                if (page.priority != null && page.priority.floatValue() > 2 && (foundBrandPage || removedHome) && !addedBlog) {
                    href = PageTypeHelper.asHref(PageType.PostsPageType);
                    addItem(elNavLeft, SafeHtmlUtils.fromSafeConstant("Blog"), href);
                    addedBlog = true;
                }
                Element el;
                if (page.parent == null) {
                    href = PageTypeHelper.slugToHref(page.slug);
                    if (possibleParents.get(page.id) == null) {
                        addItem(elNavLeft, SafeHtmlUtils.fromString(page.title), href);
                        possibleParents.put(page.id, page);
                    } else {
                        possibleParents.put(page.id, page);
                        swapTitle(PageTypeHelper.slugToTargetHistoryToken("pageid_" + page.id), HeaderTemplates.INSTANCE.openableTitle(page.title), href);
                    }
                } else {
                    Page parent;
                    if ((parent = possibleParents.get(page.parent.id)) != null) {
                        el = getOpenable(PageTypeHelper.slugToTargetHistoryToken(parent.slug));
                        if (el == null) {
                            el = getOpenable(PageTypeHelper.slugToTargetHistoryToken("pageid_" + parent.id));
                        }
                        if (el == null) {
                            el = getItem(PageTypeHelper.slugToTargetHistoryToken(parent.slug));
                            if (el != null) {
                                el = convertItemToOpenable(PageTypeHelper.slugToTargetHistoryToken(parent.slug), HeaderTemplates.INSTANCE.openableTitle(parent.title));
                            }
                        }
                    } else {
                        String dummySlug = "pageid_" + page.parent.id;
                        el = addOpenable(elNavLeft, HeaderTemplates.INSTANCE.openableTitle(dummySlug), PageTypeHelper.slugToHref(dummySlug));
                        possibleParents.put(page.parent.id, page.parent);
                    }
                    if (el != null) {
                        href = PageTypeHelper.slugToHref(page.slug);
                        addItem(el.getFirstChildElement().getNextSiblingElement(), SafeHtmlUtils.fromString(page.title), href);
                    }
                }
            }
        }
    }
    if (foundBrandPage || removedHome) {
        if (!addedBlog) {
            href = PageTypeHelper.asHref(PageType.PostsPageType);
            addItem(elNavLeft, SafeHtmlUtils.fromSafeConstant("Blog"), href);
        }
    } else {
        btnHome.setHref(PageTypeHelper.asHref(PageType.PostsPageType));
    }
    ensureItems().put(PageType.AllPostsPageType.asTargetHistoryToken(), elPosts);
    ensureItems().put(PageType.PagesPageType.asTargetHistoryToken(), elPages);
    ensureItems().put(PageType.PropertiesPageType.asTargetHistoryToken(), elProperties);
    ensureItems().put(PageType.UsersPageType.asTargetHistoryToken(), elUsers);
    ensureItems().put(PageType.RolesPageType.asTargetHistoryToken(), elRoles);
    ensureItems().put(PageType.PermissionsPageType.asTargetHistoryToken(), elPermissions);
    ensureItems().put(PageType.ResourcesPageType.asTargetHistoryToken(), elResources);
    ensureItems().put(PageType.MetaNotificationsPageType.asTargetHistoryToken(), elMetaNotifications);
    elAdmin.removeFromParent();
    elAccount.removeFromParent();
}
Also used : HashMap(java.util.HashMap) Element(com.google.gwt.dom.client.Element) AnchorElement(com.google.gwt.dom.client.AnchorElement) ImageElement(com.google.gwt.dom.client.ImageElement) SafeUri(com.google.gwt.safehtml.shared.SafeUri) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 19 with Page

use of com.willshex.blogwt.shared.api.datatype.Page in project blogwt by billy1380.

the class GetPagesActionHandler method handle.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.gson.web.service.server.ActionHandler#handle(com.willshex.
	 * gson.web.service.shared.Request,
	 * com.willshex.gson.web.service.shared.Response) */
@Override
protected void handle(GetPagesRequest input, GetPagesResponse output) throws Exception {
    ApiValidator.request(input, GetPagesRequest.class);
    ApiValidator.accessCode(input.accessCode, "input.accessCode");
    output.session = input.session = SessionValidator.lookupCheckAndExtend(input.session, "input.session");
    if (input.pager == null) {
        input.pager = PagerHelper.createDefaultPager();
    }
    if (input.query == null || input.query.trim().length() == 0) {
        output.pages = PageServiceProvider.provide().getPages(input.includePosts, input.pager.start, input.pager.count, PageSortType.fromString(input.pager.sortBy), input.pager.sortDirection);
    } else {
        output.pages = PageServiceProvider.provide().getPartialSlugPages(input.query, input.includePosts, input.pager.start, input.pager.count, PageSortType.fromString(input.pager.sortBy), input.pager.sortDirection);
    }
    Map<Long, User> owners = new HashMap<Long, User>();
    Long id;
    for (Page page : output.pages) {
        id = keyToId(page.ownerKey);
        page.owner = owners.get(id);
        if (page.owner == null) {
            owners.put(id, page.owner = UserHelper.stripSensitive(UserServiceProvider.provide().getUser(id)));
        }
    }
    output.pager = PagerHelper.moveForward(input.pager);
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) HashMap(java.util.HashMap) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 20 with Page

use of com.willshex.blogwt.shared.api.datatype.Page in project blogwt by billy1380.

the class SearchController method fetchSearchResults.

private void fetchSearchResults(String query) {
    final SearchAllRequest input = ApiHelper.setAccessCode(new SearchAllRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.query = query;
    if (searchAllRequest != null) {
        searchAllRequest.cancel();
    }
    searchAllRequest = ApiHelper.createSearchClient().searchAll(input, new AsyncCallback<SearchAllResponse>() {

        @Override
        public void onSuccess(SearchAllResponse output) {
            searchAllRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                List<SearchResult> results = new ArrayList<SearchController.SearchResult>();
                if (output.posts != null) {
                    for (Post post : output.posts) {
                        results.add(new SearchResult(post));
                    }
                }
                if (output.pages != null) {
                    for (Page page : output.pages) {
                        results.add(new SearchResult(page));
                    }
                }
                if (output.users != null) {
                    for (User user : output.users) {
                        results.add(new SearchResult(user));
                    }
                }
                updateRowCount(results.size(), true);
                updateRowData(0, results);
            }
            DefaultEventBus.get().fireEventFromSource(new SearchAllSuccess(input, output), SearchController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            searchAllRequest = null;
            DefaultEventBus.get().fireEventFromSource(new SearchAllFailure(input, caught), SearchController.this);
        }
    });
}
Also used : SearchAllResponse(com.willshex.blogwt.shared.api.search.call.SearchAllResponse) SearchAllFailure(com.willshex.blogwt.client.api.search.event.SearchAllEventHandler.SearchAllFailure) SearchAllSuccess(com.willshex.blogwt.client.api.search.event.SearchAllEventHandler.SearchAllSuccess) User(com.willshex.blogwt.shared.api.datatype.User) Post(com.willshex.blogwt.shared.api.datatype.Post) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) Page(com.willshex.blogwt.shared.api.datatype.Page) SearchAllRequest(com.willshex.blogwt.shared.api.search.call.SearchAllRequest)

Aggregations

Page (com.willshex.blogwt.shared.api.datatype.Page)28 JsonElement (com.google.gson.JsonElement)10 Post (com.willshex.blogwt.shared.api.datatype.Post)9 ArrayList (java.util.ArrayList)6 User (com.willshex.blogwt.shared.api.datatype.User)4 HashMap (java.util.HashMap)4 Pager (com.willshex.blogwt.shared.api.Pager)3 GetPageRequest (com.willshex.blogwt.shared.api.page.call.GetPageRequest)3 GWT (com.google.gwt.core.client.GWT)2 Element (com.google.gwt.dom.client.Element)2 Key (com.googlecode.objectify.Key)2 DefaultEventBus (com.willshex.blogwt.client.DefaultEventBus)2 GetPageEventHandler (com.willshex.blogwt.client.api.page.event.GetPageEventHandler)2 NavigationController (com.willshex.blogwt.client.controller.NavigationController)2 PageController (com.willshex.blogwt.client.controller.PageController)2 NavigationChangedEventHandler (com.willshex.blogwt.client.event.NavigationChangedEventHandler)2 PageTypeHelper (com.willshex.blogwt.client.helper.PageTypeHelper)2 WizardDialogPage (com.willshex.blogwt.client.page.wizard.WizardDialogPage)2 WizardPage (com.willshex.blogwt.client.wizard.WizardPage)2 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)2