Revision: 9391
Author: [email protected]
Date: Thu Dec 9 07:23:07 2010
Log: Cherry pick r9386, rollback Change Activity to an abstract class
Original review at http://gwt-code-reviews.appspot.com/1200801
Issue 5730
http://code.google.com/p/google-web-toolkit/source/detail?r=9391
Added:
/releases/2.1/user/src/com/google/gwt/activity/shared/AbstractActivity.java
Deleted:
/releases/2.1/samples/expenses/src/main/resources
/releases/2.1/user/src/com/google/gwt/activity/shared/IsActivity.java
/releases/2.1/user/src/com/google/gwt/activity/shared/SimpleActivity.java
Modified:
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpenseReportDetails.java
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpenseReportList.java
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpensesActivityMapper.java
/releases/2.1/tools/api-checker/config/gwt21_22userApi.conf
/releases/2.1/user/src/com/google/gwt/activity/shared/Activity.java
/releases/2.1/user/src/com/google/gwt/activity/shared/ActivityManager.java
/releases/2.1/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java
=======================================
--- /dev/null
+++
/releases/2.1/user/src/com/google/gwt/activity/shared/AbstractActivity.java
Thu Dec 9 07:23:07 2010
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
+ * use this file except in compliance with the License. You may obtain a
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package com.google.gwt.activity.shared;
+
+/**
+ * Simple Activity implementation that is always willing to stop,
+ * and does nothing onStop and onCancel.
+ */
+public abstract class AbstractActivity implements Activity {
+
+ public String mayStop() {
+ return null;
+ }
+
+ public void onCancel() {
+ }
+
+ public void onStop() {
+ }
+}
=======================================
--- /releases/2.1/user/src/com/google/gwt/activity/shared/IsActivity.java
Wed Dec 8 14:18:19 2010
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.activity.shared;
-
-
-/**
- * Implemented by objects that can return an {...@link Activity} aspect.
- */
-public interface IsActivity {
-
- /**
- * Return the {...@link Activity} aspect of this object.
- */
- Activity asActivity();
-}
=======================================
---
/releases/2.1/user/src/com/google/gwt/activity/shared/SimpleActivity.java
Wed Dec 8 14:18:19 2010
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.activity.shared;
-
-
-/**
- * Simple base implementation of {...@link Activity}.
- */
-public abstract class SimpleActivity extends Activity {
-
- /**
- * Return null.
- */
- public String mayStop() {
- return null;
- }
-
- /**
- * No-op.
- */
- public void onCancel() {
- }
-
- /**
- * No-op.
- */
- public void onStop() {
- }
-}
=======================================
---
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpenseReportDetails.java
Wed Dec 8 14:18:19 2010
+++
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpenseReportDetails.java
Thu Dec 9 07:23:07 2010
@@ -16,8 +16,6 @@
package com.google.gwt.sample.expenses.client;
import com.google.gwt.activity.shared.Activity;
-import com.google.gwt.activity.shared.IsActivity;
-import com.google.gwt.activity.shared.SimpleActivity;
import com.google.gwt.cell.client.AbstractInputCell;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.DateCell;
@@ -25,6 +23,7 @@
import com.google.gwt.cell.client.NumberCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.cell.client.ValueUpdater;
+import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
@@ -48,7 +47,6 @@
import com.google.gwt.requestfactory.ui.client.EntityProxyKeyProvider;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
-import com.google.gwt.safehtml.client.SafeHtmlTemplates.Template;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
@@ -91,11 +89,11 @@
* Details about the current expense report on the right side of the app,
* including the list of expenses.
*/
-public class ExpenseReportDetails extends Composite implements IsActivity {
+public class ExpenseReportDetails extends Composite implements Activity {
interface Binder extends UiBinder<Widget, ExpenseReportDetails> {
}
-
+
/**
* Fetches an employee and a report in parallel. A fine example of the
kind of
* thing that will no longer be necessary when RequestFactory provides
server
@@ -129,7 +127,7 @@
});
}
}
-
+
/**
* The resources applied to the table.
*/
@@ -325,13 +323,6 @@
}
}
- private final Activity activityAspect = new SimpleActivity() {
- @Override
- public void start(AcceptsOneWidget panel, EventBus eventBus) {
- ExpenseReportDetails.this.start(panel, eventBus);
- }
- };
-
private static Template template;
/**
@@ -477,10 +468,6 @@
}
});
}
-
- public Activity asActivity() {
- return activityAspect;
- }
public ReportListPlace getReportListPlace() {
ReportListPlace listPlace = place.getListPlace();
@@ -490,6 +477,13 @@
public Anchor getReportsLink() {
return reportsLink;
}
+
+ public String mayStop() {
+ return null;
+ }
+
+ public void onCancel() {
+ }
public void onExpenseRecordChanged(EntityProxyChange<ExpenseProxy>
event) {
final EntityProxyId<ExpenseProxy> proxyId = event.getProxyId();
@@ -537,17 +531,10 @@
}
}
- /**
- * In this application, called by {...@link ExpensesActivityMapper} each
time a
- * ReportListPlace is posted. In a more typical set up, this would be a
- * constructor argument to a one shot activity, perhaps managing a shared
- * widget view instance.
- */
- public void updateForPlace(final ReportPlace place) {
- this.place = place;
+ public void onStop() {
}
- void start(AcceptsOneWidget panel, EventBus eventBus) {
+ public void start(AcceptsOneWidget panel, EventBus eventBus) {
final ReportListPlace listPlace = place.getListPlace();
if (listPlace.getEmployeeId() == null) {
@@ -586,6 +573,16 @@
panel.setWidget(this);
}
+
+ /**
+ * In this application, called by {...@link ExpensesActivityMapper} each
time a
+ * ReportListPlace is posted. In a more typical set up, this would be a
+ * constructor argument to a one shot activity, perhaps managing a shared
+ * widget view instance.
+ */
+ public void updateForPlace(final ReportPlace place) {
+ this.place = place;
+ }
/**
* Add a column of a {...@link Comparable} type using default comparators.
=======================================
---
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpenseReportList.java
Wed Dec 8 14:18:19 2010
+++
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpenseReportList.java
Thu Dec 9 07:23:07 2010
@@ -16,8 +16,6 @@
package com.google.gwt.sample.expenses.client;
import com.google.gwt.activity.shared.Activity;
-import com.google.gwt.activity.shared.IsActivity;
-import com.google.gwt.activity.shared.SimpleActivity;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.DateCell;
@@ -78,7 +76,7 @@
* The list of expense reports on the right side of the app.
*/
public class ExpenseReportList extends Composite implements
- EntityProxyChange.Handler<ReportProxy>, IsActivity {
+ EntityProxyChange.Handler<ReportProxy>, Activity {
interface Binder extends UiBinder<Widget, ExpenseReportList> {
}
@@ -179,23 +177,6 @@
}
}
- private final Activity activityAspect = new SimpleActivity() {
- @Override
- public void onCancel() {
- ExpenseReportList.this.onCancel();
- }
-
- @Override
- public void onStop() {
- ExpenseReportList.this.onStop();
- }
-
- @Override
- public void start(AcceptsOneWidget panel, EventBus eventBus) {
- ExpenseReportList.this.start(panel, eventBus);
- }
- };
-
private static final ProvidesKey<ReportProxy> keyProvider = new
EntityProxyKeyProvider<ReportProxy>();
/**
@@ -356,8 +337,12 @@
});
}
- public Activity asActivity() {
- return activityAspect;
+ public String mayStop() {
+ return null;
+ }
+
+ public void onCancel() {
+ onStop();
}
public void onProxyChange(EntityProxyChange<ReportProxy> event) {
@@ -373,10 +358,24 @@
i++;
}
}
+
+ public void onStop() {
+ running = false;
+ refreshTimer.cancel();
+ }
public void setListener(Listener listener) {
this.listener = listener;
}
+
+ public void start(AcceptsOneWidget panel, EventBus eventBus) {
+ running = true;
+ doUpdateForPlace();
+
+ EntityProxyChange.registerForProxyType(eventBus, ReportProxy.class,
this);
+ requestReports(false);
+ panel.setWidget(this);
+ }
/**
* In this application, called by {...@link ExpensesActivityMapper} each
time a
@@ -398,24 +397,6 @@
p.setRangeLimited(true);
return p;
}
-
- void onCancel() {
- onStop();
- }
-
- void onStop() {
- running = false;
- refreshTimer.cancel();
- }
-
- void start(AcceptsOneWidget panel, EventBus eventBus) {
- running = true;
- doUpdateForPlace();
-
- EntityProxyChange.registerForProxyType(eventBus, ReportProxy.class,
this);
- requestReports(false);
- panel.setWidget(this);
- }
/**
* Add a sortable column to the table.
=======================================
---
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpensesActivityMapper.java
Wed Dec 8 14:18:19 2010
+++
/releases/2.1/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpensesActivityMapper.java
Thu Dec 9 07:23:07 2010
@@ -38,12 +38,12 @@
public Activity getActivity(Place place) {
if (place instanceof ReportListPlace) {
expenseList.updateForPlace((ReportListPlace) place);
- return expenseList.asActivity();
+ return expenseList;
}
if (place instanceof ReportPlace) {
expenseDetails.updateForPlace((ReportPlace) place);
- return expenseDetails.asActivity();
+ return expenseDetails;
}
return null;
=======================================
--- /releases/2.1/tools/api-checker/config/gwt21_22userApi.conf Wed Dec 8
14:18:19 2010
+++ /releases/2.1/tools/api-checker/config/gwt21_22userApi.conf Thu Dec 9
07:23:07 2010
@@ -111,10 +111,6 @@
# when adding to the white-list, include comments as to why the addition is
# being made.
-# Changes to make Activity api evolvable in 2.1.1
-com.google.gwt.activity.shared.AbstractActivity MISSING
-com.google.gwt.activity.shared.Activity STATIC_REMOVED
-
# RequestFactory tweaks in 2.1.1
com.google.gwt.requestfactory.client.DefaultRequestTransport::DefaultRequestTransport(Lcom/google/gwt/event/shared/EventBus;)
MISSING
com.google.gwt.requestfactory.shared.RequestEvent MISSING
=======================================
--- /releases/2.1/user/src/com/google/gwt/activity/shared/Activity.java Wed
Dec 8 14:18:19 2010
+++ /releases/2.1/user/src/com/google/gwt/activity/shared/Activity.java Thu
Dec 9 07:23:07 2010
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may
not
* use this file except in compliance with the License. You may obtain a
copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -19,51 +19,45 @@
import com.google.gwt.user.client.ui.AcceptsOneWidget;
/**
- * Object that controls a piece of user interface, with a life cycle
managed by
- * an {...@link ActivityManager}.
- * <p>
- * Ideally this would be an interface rather than an abstract class, but we
- * expect its api will need to evolve (slightly) in the near term. When it
- * settles down, an interface may be introduced. To this end, future
versions of
- * this class should not introduce non-trivial behavior.
- * <p>
- * For composition, see {...@link IsActivity}.
+ * Implemented by objects that control a piece of user interface, with a
life
+ * cycle managed by an {...@link ActivityManager}, in response to
+ * {...@link com.google.gwt.place.shared.PlaceChangeEvent} events as the user
+ * navigates through the app.
*/
-public abstract class Activity {
-
+public interface Activity {
/**
* Called when the user is trying to navigate away from this activity.
- *
+ *
* @return A message to display to the user, e.g. to warn of unsaved
work, or
* null to say nothing
*/
- public abstract String mayStop();
+ String mayStop();
/**
* Called when {...@link #start} has not yet replied to its callback, but
the
* user has lost interest.
*/
- public abstract void onCancel();
+ void onCancel();
/**
* Called when the Activity's widget has been removed from view. All
event
* handlers it registered will have been removed before this method is
called.
*/
- public abstract void onStop();
+ void onStop();
/**
* Called when the Activity should ready its widget for the user. When
the
* widget is ready (typically after an RPC response has been received),
* receiver should present it by calling
- * {...@link AcceptsOneWidget#setWidget()} on the given panel.
+ * {...@link AcceptsOneWidget#setWidget(IsWidget)} on the given panel.
* <p>
* Any handlers attached to the provided event bus will be de-registered
when
* the activity is stopped, so activities will rarely need to hold on to
the
* {...@link com.google.gwt.event.shared.HandlerRegistration
HandlerRegistration}
* instances returned by {...@link EventBus#addHandler}.
- *
+ *
* @param panel the panel to display this activity's widget when it is
ready
* @param eventBus the event bus
*/
- public abstract void start(AcceptsOneWidget panel, EventBus eventBus);
-}
+ void start(AcceptsOneWidget panel, EventBus eventBus);
+}
=======================================
---
/releases/2.1/user/src/com/google/gwt/activity/shared/ActivityManager.java
Wed Dec 8 14:18:19 2010
+++
/releases/2.1/user/src/com/google/gwt/activity/shared/ActivityManager.java
Thu Dec 9 07:23:07 2010
@@ -54,7 +54,7 @@
}
}
- private static final Activity NULL_ACTIVITY = new SimpleActivity() {
+ private static final Activity NULL_ACTIVITY = new AbstractActivity() {
public void start(AcceptsOneWidget panel, EventBus eventBus) {
}
};
=======================================
---
/releases/2.1/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java
Wed Dec 8 14:18:19 2010
+++
/releases/2.1/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java
Thu Dec 9 07:23:07 2010
@@ -81,7 +81,7 @@
return null;
}
}
- private static class SyncActivity extends Activity {
+ private static class SyncActivity implements Activity {
boolean canceled = false;
boolean stopped = false;
AcceptsOneWidget display;
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors