Exemple #1
0
  protected CloudCoderPage createPageForPageId(PageId pageId, String pageParams) {
    CloudCoderPage page = createPageForPageId(pageId);

    // Create a reasonable PageStack.
    // (Note that we need to disable notifications while we do this,
    // since we're not actually navigating pages.)
    PageStack pageStack = session.get(PageStack.class);
    pageStack.setNotifications(false);
    page.initDefaultPageStack(pageStack);
    pageStack.push(page.getPageId());
    pageStack.setNotifications(true);

    // Set initial page parameters (if any)
    if (pageParams != null) {
      page.setUrlFragmentParams(pageParams);
    }

    return page;
  }
Exemple #2
0
  /** This is the entry point method. */
  public void onModuleLoad() {
    theInstance = this;

    GWT.log("loading, fragment name is " + Window.Location.getHash());

    session = new Session();
    pageStack = new PageStack();
    session.add(pageStack);
    subscriptionRegistrar = new DefaultSubscriptionRegistrar();

    // Subscribe to PAGE_CHANGE events in the PageStack
    pageStack.subscribe(PageStack.Event.PAGE_CHANGE, this, subscriptionRegistrar);

    // Subscribe to all Session events
    session.subscribeToAll(Session.Event.values(), this, subscriptionRegistrar);

    // Go to whatever initial page is appropriate.
    createInitialPage();
  }
Exemple #3
0
 @Override
 public void eventOccurred(Object key, Publisher publisher, Object hint) {
   // This is where we monitor for events that indicate page changes.
   // The PageStack makes this pretty straightforward.
   if (key == PageStack.Event.PAGE_CHANGE) {
     PageId current = session.get(PageStack.class).getTop();
     changePage(createPageForPageId(current));
   } else if (key == Session.Event.LOGOUT) {
     // On logout, go back to the LoginPage, then
     // clear the Session and PageStack,
     // add the PageStack back to the Session.
     // We clear the Session after navigating away from the
     // current page, because some pages
     // (e.g., CoursesAndProblemsPage3) add a memento to the
     // Session to save UI context information.
     changePage(new LoginPage());
     session.clear();
     pageStack.clear();
     session.add(pageStack);
   }
 }
 @Override
 public void initDefaultPageStack(PageStack pageStack) {
   pageStack.push(PageId.COURSES_AND_PROBLEMS);
   pageStack.push(PageId.USER_ADMIN);
 }