Package com.antonytrupe.client.activity

Source Code of com.antonytrupe.client.activity.DisplayActivity

package com.antonytrupe.client.activity;

import com.antonytrupe.client.ClientFactory;
import com.antonytrupe.client.place.DisplayPlace;
import com.antonytrupe.client.ui.DisplayView;
import com.antonytrupe.shared.Page;
import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

public class DisplayActivity extends AbstractActivity implements
    DisplayView.Presenter {

  private ClientFactory clientFactory;
  private DisplayPlace place;

  public DisplayActivity(DisplayPlace place, ClientFactory clientFactory) {
    this.place = place;
    this.clientFactory = clientFactory;
  }

  /**
   * Navigate to a new Place in the browser
   */
  @Override
  public void goTo(Place place) {
    this.clientFactory.getPlaceController().goTo(place);
  }

  /**
   * Invoked by the ActivityManager to start a new Activity
   */
  @Override
  public void start(final AcceptsOneWidget containerWidget, EventBus eventBus) {
    final DisplayView displayView = this.clientFactory.getDisplayView();

    // get page content
    this.clientFactory.getPageService().get(
        this.place.getPageNameDecoded(), new AsyncCallback<Page>() {

          @Override
          public void onFailure(Throwable caught) {
          }

          @Override
          public void onSuccess(Page result) {
            displayView.setPageName(result.getName());
            displayView.setContent(SafeHtmlUtils
                .fromTrustedString(result.getContent()));
            displayView.setPresenter(DisplayActivity.this);
            containerWidget.setWidget(displayView.asWidget());

          }
        });
  }
}
TOP

Related Classes of com.antonytrupe.client.activity.DisplayActivity

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.