2 * Copyright (C) 2011 Openismus GmbH
4 * This file is part of GWT-Glom.
6 * GWT-Glom is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
11 * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with GWT-Glom. If not, see <http://www.gnu.org/licenses/>.
20 package org.glom.web.client.activity;
22 import org.glom.web.client.ClientFactory;
23 import org.glom.web.client.OnlineGlomServiceAsync;
24 import org.glom.web.client.StringUtils;
25 import org.glom.web.client.Utils;
26 import org.glom.web.client.place.DocumentSelectionPlace;
27 import org.glom.web.client.place.ReportPlace;
28 import org.glom.web.client.ui.OnlineGlomConstants;
29 import org.glom.web.client.ui.ReportView;
30 import org.glom.web.client.ui.TableSelectionView;
31 import org.glom.web.client.ui.View;
33 import com.google.gwt.core.client.GWT;
34 import com.google.gwt.event.shared.EventBus;
35 import com.google.gwt.place.shared.Place;
36 import com.google.gwt.user.client.rpc.AsyncCallback;
37 import com.google.gwt.user.client.ui.AcceptsOneWidget;
39 public class ReportActivity extends HasTableActivity implements View.Presenter {
41 private final String reportName;
42 private final String quickFind;
43 private final ClientFactory clientFactory;
44 private final ReportView reportView;
46 // OnlineGlomConstants.java is generated in the target/ directory,
47 // from OnlineGlomConstants.properties
48 // by the gwt-maven-plugin's i18n (mvn:i18n) goal.
49 private final OnlineGlomConstants constants = GWT.create(OnlineGlomConstants.class);
51 public ReportActivity(final ReportPlace place, final ClientFactory clientFactory) {
52 super(place, clientFactory);
53 this.quickFind = place.getQuickFind();
54 this.reportName = place.getReportName();
55 this.clientFactory = clientFactory;
56 reportView = clientFactory.getReportView();
60 public void start(final AcceptsOneWidget panel, final EventBus eventBus) {
61 if (StringUtils.isEmpty(documentID)) {
62 goTo(new DocumentSelectionPlace());
65 // register this class as the presenter
66 reportView.setPresenter(this);
68 checkAuthentication(eventBus);
70 // populate the report part:
71 final AsyncCallback<String> callback = new AsyncCallback<String>() {
73 public void onFailure(final Throwable caught) {
74 // TODO: create a way to notify users of asynchronous callback failures
75 GWT.log("AsyncCallback Failed: OnlineGlomService.getReportHTML(): " + caught.getMessage());
79 public void onSuccess(final String result) {
80 reportView.setReportHTML(result);
84 final TableSelectionView tableSelectionView = clientFactory.getTableSelectionView();
85 tableSelectionView.setSelectedReport(reportName);
87 reportView.setWaitingText(constants.generatingReport()); // This is cleared by setReportHTML().
88 final String localeID = Utils.getCurrentLocaleID();
89 OnlineGlomServiceAsync.Util.getInstance().getReportHTML(documentID, tableName, reportName, quickFind, localeID,
92 // indicate that the view is ready to be displayed
93 panel.setWidget(reportView.asWidget());
97 protected void clearView() {
105 * @see com.google.gwt.activity.shared.AbstractActivity#onCancel()
108 public void onCancel() {
115 * @see com.google.gwt.activity.shared.AbstractActivity#onStop()
118 public void onStop() {
125 * @see org.glom.web.client.ui.View.Presenter#goTo(com.google.gwt.place.shared.Place)
128 public void goTo(final Place place) {
129 clientFactory.getPlaceController().goTo(place);