Package com.antonytrupe.client.activity

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

package com.antonytrupe.client.activity;

import com.antonytrupe.client.ClientFactory;
import com.antonytrupe.client.place.EditPlace;
import com.antonytrupe.client.ui.EditView;
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 EditActivity extends AbstractActivity implements
    EditView.Presenter {
  private ClientFactory clientFactory;
  private EditPlace place;

  public EditActivity(EditPlace place, ClientFactory clientFactory) {
    this.place = place;
    this.clientFactory = clientFactory;
  }

  @Override
  public void goTo(Place place) {
    this.clientFactory.getPlaceController().goTo(place);
  }

  @Override
  public void start(final AcceptsOneWidget containerWidget, EventBus eventBus) {
    final EditView editView = this.clientFactory.getPageEditView();

    // 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) {
            editView.setPageName(result.getName());
            editView.setContent(SafeHtmlUtils
                .fromTrustedString(result.getContent()));
            editView.setPresenter(EditActivity.this);
            editView.setPageService(EditActivity.this.clientFactory
                .getPageService());
            containerWidget.setWidget(editView.asWidget());

          }
        });
  }
}
TOP

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

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.