Rollback of r10014 "Makes EventBus available outside of the gwt package" due to broken builds Original review http://gwt-code-reviews.appspot.com/1394803 git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10016 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/DynaTableRf.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/DynaTableRf.java index d0e1bc9..3b17927 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/DynaTableRf.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/DynaTableRf.java
@@ -18,6 +18,8 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.sample.dynatablerf.client.widgets.DayFilterWidget; import com.google.gwt.sample.dynatablerf.client.widgets.FavoritesWidget; import com.google.gwt.sample.dynatablerf.client.widgets.SummaryWidget; @@ -26,8 +28,6 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.RootLayoutPanel; import com.google.gwt.user.client.ui.Widget; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.SimpleEventBus; import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryLogHandler; import com.google.web.bindery.requestfactory.shared.LoggingRequest;
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/FavoritesManager.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/FavoritesManager.java index ae5879f..de4417e 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/FavoritesManager.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/FavoritesManager.java
@@ -15,15 +15,15 @@ */ package com.google.gwt.sample.dynatablerf.client; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.sample.dynatablerf.client.events.MarkFavoriteEvent; import com.google.gwt.sample.dynatablerf.shared.PersonProxy; import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window.ClosingEvent; import com.google.gwt.user.client.Window.ClosingHandler; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; -import com.google.web.bindery.event.shared.SimpleEventBus; import com.google.web.bindery.requestfactory.shared.EntityProxyId; import com.google.web.bindery.requestfactory.shared.RequestFactory;
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/PersonEditorWorkflow.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/PersonEditorWorkflow.java index 3cc27ed..6b9073e 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/PersonEditorWorkflow.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/PersonEditorWorkflow.java
@@ -21,6 +21,7 @@ import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.shared.EventBus; import com.google.gwt.sample.dynatablerf.client.events.EditPersonEvent; import com.google.gwt.sample.dynatablerf.client.widgets.MentorSelector; import com.google.gwt.sample.dynatablerf.client.widgets.PersonEditor; @@ -35,7 +36,6 @@ import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.HTMLPanel; -import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver; import com.google.web.bindery.requestfactory.shared.Receiver; import com.google.web.bindery.requestfactory.shared.Request;
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/EditPersonEvent.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/EditPersonEvent.java index 72e4eba..cf11e14 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/EditPersonEvent.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/EditPersonEvent.java
@@ -15,8 +15,9 @@ */ package com.google.gwt.sample.dynatablerf.client.events; +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.sample.dynatablerf.shared.PersonProxy; -import com.google.web.bindery.event.shared.Event; import com.google.web.bindery.requestfactory.shared.RequestContext; /** @@ -24,13 +25,13 @@ * * TODO: Make this an Activity. */ -public class EditPersonEvent extends Event<EditPersonEvent.Handler> { - public static final Event.Type<Handler> TYPE = new Event.Type<Handler>(); +public class EditPersonEvent extends GwtEvent<EditPersonEvent.Handler> { + public static final Type<Handler> TYPE = new Type<Handler>(); /** * Handles {@link EditPersonEvent}. */ - public interface Handler { + public interface Handler extends EventHandler { void startEdit(PersonProxy person, RequestContext requestContext); } @@ -52,7 +53,7 @@ } @Override - public Event.Type<Handler> getAssociatedType() { + public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() { return TYPE; } }
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/FilterChangeEvent.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/FilterChangeEvent.java index d4ed5e1..5cb4864 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/FilterChangeEvent.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/FilterChangeEvent.java
@@ -15,22 +15,23 @@ */ package com.google.gwt.sample.dynatablerf.client.events; -import com.google.web.bindery.event.shared.Event; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HandlerRegistration; /** * An event to indicate a change in the filter options. */ -public class FilterChangeEvent extends Event<FilterChangeEvent.Handler> { +public class FilterChangeEvent extends GwtEvent<FilterChangeEvent.Handler> { /** * Handles {@link FilterChangeEvent}. */ - public interface Handler { + public interface Handler extends EventHandler { void onFilterChanged(FilterChangeEvent e); } - public static final Event.Type<Handler> TYPE = new Event.Type<Handler>(); + public static final Type<Handler> TYPE = new Type<Handler>(); public static HandlerRegistration register(EventBus eventBus, Handler handler) { return eventBus.addHandler(TYPE, handler);
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/MarkFavoriteEvent.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/MarkFavoriteEvent.java index 70e643c..c0e442d 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/MarkFavoriteEvent.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/events/MarkFavoriteEvent.java
@@ -15,22 +15,23 @@ */ package com.google.gwt.sample.dynatablerf.client.events; +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.sample.dynatablerf.shared.PersonProxy; -import com.google.web.bindery.event.shared.Event; import com.google.web.bindery.requestfactory.shared.EntityProxyId; /** * Used client-side to add entries to the favorites list. */ -public class MarkFavoriteEvent extends Event<MarkFavoriteEvent.Handler> { +public class MarkFavoriteEvent extends GwtEvent<MarkFavoriteEvent.Handler> { /** * Handles {@link MarkFavoriteEvent}. */ - public interface Handler { + public interface Handler extends EventHandler { void onMarkFavorite(MarkFavoriteEvent event); } - public static final Event.Type<Handler> TYPE = new Event.Type<Handler>(); + public static final Type<Handler> TYPE = new Type<Handler>(); private final EntityProxyId<PersonProxy> id; private final boolean isFavorite; @@ -41,7 +42,7 @@ } @Override - public Event.Type<Handler> getAssociatedType() { + public Type<Handler> getAssociatedType() { return TYPE; }
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayCheckBox.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayCheckBox.java index 590215b..79a1fc4 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayCheckBox.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayCheckBox.java
@@ -17,11 +17,11 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.sample.dynatablerf.client.events.FilterChangeEvent; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.Composite; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; /** * Used by DayFilterWidget.
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayFilterWidget.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayFilterWidget.java index f0f5942..de62579 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayFilterWidget.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/DayFilterWidget.java
@@ -17,6 +17,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.shared.EventBus; import com.google.gwt.sample.dynatablerf.client.events.FilterChangeEvent; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiConstructor; @@ -26,7 +27,6 @@ import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Widget; -import com.google.web.bindery.event.shared.EventBus; /** * A UI Widget that allows a user to filter the days being displayed in the
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/FavoritesWidget.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/FavoritesWidget.java index c7df7b1..f442235 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/FavoritesWidget.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/FavoritesWidget.java
@@ -18,6 +18,8 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.editor.client.adapters.EditorSource; import com.google.gwt.editor.client.adapters.ListEditor; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.resources.client.CssResource; import com.google.gwt.sample.dynatablerf.client.FavoritesManager; import com.google.gwt.sample.dynatablerf.client.events.MarkFavoriteEvent; @@ -27,8 +29,6 @@ import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Widget; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver; import com.google.web.bindery.requestfactory.shared.EntityProxyId; import com.google.web.bindery.requestfactory.shared.Receiver;
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/NameLabel.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/NameLabel.java index 852f3ca..b169461 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/NameLabel.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/NameLabel.java
@@ -19,12 +19,12 @@ import com.google.gwt.editor.client.ValueAwareEditor; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.sample.dynatablerf.client.events.EditPersonEvent; import com.google.gwt.sample.dynatablerf.shared.PersonProxy; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Label; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; /** * This NameLabel uses the EditorDelegate to receive notifications on updates to
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/SummaryWidget.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/SummaryWidget.java index e2524fc..889594c 100644 --- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/SummaryWidget.java +++ b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/SummaryWidget.java
@@ -22,6 +22,7 @@ import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.shared.EventBus; import com.google.gwt.resources.client.CssResource; import com.google.gwt.sample.dynatablerf.client.events.EditPersonEvent; import com.google.gwt.sample.dynatablerf.client.events.FilterChangeEvent; @@ -45,7 +46,6 @@ import com.google.gwt.view.client.RangeChangeEvent; import com.google.gwt.view.client.SelectionChangeEvent; import com.google.gwt.view.client.SingleSelectionModel; -import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.requestfactory.shared.EntityProxyChange; import com.google.web.bindery.requestfactory.shared.EntityProxyId; import com.google.web.bindery.requestfactory.shared.Receiver; @@ -255,7 +255,7 @@ } private int offsetOf(EntityProxyId<PersonProxy> personId) { - List<PersonProxy> displayedItems = table.getVisibleItems(); + List<PersonProxy> displayedItems = table.getDisplayedItems(); for (int offset = 0, j = displayedItems.size(); offset < j; offset++) { if (personId.equals(displayedItems.get(offset).stableId())) { return offset;
diff --git a/tools/api-checker/config/gwt22_23userApi.conf b/tools/api-checker/config/gwt22_23userApi.conf index d97d277..2501873 100644 --- a/tools/api-checker/config/gwt22_23userApi.conf +++ b/tools/api-checker/config/gwt22_23userApi.conf
@@ -123,32 +123,6 @@ # Overloaded SimplePanel constructor to accept a Widget. com.google.gwt.user.client.ui.SimplePanel::SimplePanel(Lcom/google/gwt/dom/client/Element;) OVERLOADED_METHOD_CALL -# Overloads for legacy compatibility after introduction of com.google.web.bindery -# - -com.google.gwt.event.shared.EventBus::addHandler(Lcom/google/gwt/event/shared/GwtEvent$Type;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL -com.google.gwt.event.shared.EventBus::addHandlerToSource(Lcom/google/gwt/event/shared/GwtEvent$Type;Ljava/lang/Object;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL - -com.google.gwt.event.shared.ResettableEventBus::addHandler(Lcom/google/gwt/event/shared/GwtEvent$Type;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL -com.google.gwt.event.shared.ResettableEventBus::addHandlerToSource(Lcom/google/gwt/event/shared/GwtEvent$Type;Ljava/lang/Object;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL - -com.google.gwt.event.shared.SimpleEventBus::addHandler(Lcom/google/gwt/event/shared/GwtEvent$Type;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL -com.google.gwt.event.shared.SimpleEventBus::addHandlerToSource(Lcom/google/gwt/event/shared/GwtEvent$Type;Ljava/lang/Object;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL - -com.google.gwt.event.shared.testing.CountingEventBus::addHandler(Lcom/google/gwt/event/shared/GwtEvent$Type;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL -com.google.gwt.event.shared.testing.CountingEventBus::addHandlerToSource(Lcom/google/gwt/event/shared/GwtEvent$Type;Ljava/lang/Object;Lcom/google/gwt/event/shared/EventHandler;) OVERLOADED_METHOD_CALL - -com.google.gwt.place.shared.PlaceController.DefaultDelegate::addWindowClosingHandler(Lcom/google/gwt/user/client/Window$ClosingHandler;) OVERRIDABLE_METHOD_RETURN_TYPE_CHANGE - -com.google.gwt.place.shared.PlaceHistoryHandler.DefaultHistorian::addValueChangeHandler(Lcom/google/gwt/event/logical/shared/ValueChangeHandler;) OVERRIDABLE_METHOD_RETURN_TYPE_CHANGE - -com.google.gwt.place.shared.PlaceHistoryHandler::register(Lcom/google/gwt/place/shared/PlaceController;Lcom/google/gwt/event/shared/EventBus;Lcom/google/gwt/place/shared/Place;) OVERRIDABLE_METHOD_ARGUMENT_TYPE_CHANGE - -com.google.gwt.place.shared.PlaceHistoryHandler::register(Lcom/google/gwt/place/shared/PlaceController;Lcom/google/gwt/event/shared/EventBus;Lcom/google/gwt/place/shared/Place;) OVERRIDABLE_METHOD_RETURN_TYPE_CHANGE - -# -# end com.google.web.bindery changes - # Renamed CellBasedWidgetImplSafari to CellBasedWidgetImplStandardBase. com.google.gwt.user.cellview.client.CellBasedWidgetImplSafari MISSING
diff --git a/user/src/com/google/gwt/activity/shared/Activity.java b/user/src/com/google/gwt/activity/shared/Activity.java index 9635841..f141171 100644 --- a/user/src/com/google/gwt/activity/shared/Activity.java +++ b/user/src/com/google/gwt/activity/shared/Activity.java
@@ -15,8 +15,8 @@ */ package com.google.gwt.activity.shared; +import com.google.gwt.event.shared.EventBus; import com.google.gwt.user.client.ui.AcceptsOneWidget; -import com.google.web.bindery.event.shared.EventBus; /** * Implemented by objects that control a piece of user interface, with a life @@ -49,7 +49,7 @@ * 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
diff --git a/user/src/com/google/gwt/activity/shared/ActivityManager.java b/user/src/com/google/gwt/activity/shared/ActivityManager.java index db2d4cc..45f41b5 100644 --- a/user/src/com/google/gwt/activity/shared/ActivityManager.java +++ b/user/src/com/google/gwt/activity/shared/ActivityManager.java
@@ -15,14 +15,14 @@ */ package com.google.gwt.activity.shared; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.ResettableEventBus; +import com.google.gwt.event.shared.UmbrellaException; import com.google.gwt.place.shared.PlaceChangeEvent; import com.google.gwt.place.shared.PlaceChangeRequestEvent; import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.gwt.user.client.ui.IsWidget; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; -import com.google.web.bindery.event.shared.ResettableEventBus; -import com.google.web.bindery.event.shared.UmbrellaException; import java.util.LinkedHashSet; import java.util.Set;
diff --git a/user/src/com/google/gwt/editor/client/EditorDelegate.java b/user/src/com/google/gwt/editor/client/EditorDelegate.java index 1fc6603..8009ebb 100644 --- a/user/src/com/google/gwt/editor/client/EditorDelegate.java +++ b/user/src/com/google/gwt/editor/client/EditorDelegate.java
@@ -15,7 +15,7 @@ */ package com.google.gwt.editor.client; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.HandlerRegistration; /** * Binds an individual Editor to the backing service. Every Editor has a peer
diff --git a/user/src/com/google/gwt/editor/client/impl/AbstractEditorDelegate.java b/user/src/com/google/gwt/editor/client/impl/AbstractEditorDelegate.java index 5875e0e..ed1e52b 100644 --- a/user/src/com/google/gwt/editor/client/impl/AbstractEditorDelegate.java +++ b/user/src/com/google/gwt/editor/client/impl/AbstractEditorDelegate.java
@@ -20,7 +20,7 @@ import com.google.gwt.editor.client.EditorDelegate; import com.google.gwt.editor.client.EditorError; import com.google.gwt.editor.client.EditorVisitor; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.HandlerRegistration; import java.util.ArrayList; import java.util.LinkedHashMap;
diff --git a/user/src/com/google/gwt/event/Event.gwt.xml b/user/src/com/google/gwt/event/Event.gwt.xml index 14f6dab..3dafaf8 100644 --- a/user/src/com/google/gwt/event/Event.gwt.xml +++ b/user/src/com/google/gwt/event/Event.gwt.xml
@@ -1,20 +1,5 @@ -<!-- - Copyright 2008 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. ---> <module> - <inherits name="com.google.gwt.event.EventBase" /> - <inherits name="com.google.gwt.event.dom.DomEvent" /> - <inherits name="com.google.gwt.event.logical.LogicalEvent" /> + <inherits name="com.google.gwt.event.EventBase" /> + <inherits name="com.google.gwt.event.dom.DomEvent" /> + <inherits name="com.google.gwt.event.logical.LogicalEvent" /> </module>
diff --git a/user/src/com/google/gwt/event/EventBase.gwt.xml b/user/src/com/google/gwt/event/EventBase.gwt.xml index 895f0ee..9f0de72 100644 --- a/user/src/com/google/gwt/event/EventBase.gwt.xml +++ b/user/src/com/google/gwt/event/EventBase.gwt.xml
@@ -1,21 +1,5 @@ -<!-- - Copyright 2008 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. ---> <module> - <inherits name="com.google.web.bindery.event.Event" /> - <inherits name="com.google.gwt.core.Core" /> + <inherits name="com.google.gwt.core.Core" /> - <source path="shared" /> + <source path="shared" /> </module>
diff --git a/user/src/com/google/gwt/event/shared/EventBus.java b/user/src/com/google/gwt/event/shared/EventBus.java index 84879d3..74460c3 100644 --- a/user/src/com/google/gwt/event/shared/EventBus.java +++ b/user/src/com/google/gwt/event/shared/EventBus.java
@@ -15,43 +15,81 @@ */ package com.google.gwt.event.shared; -import com.google.web.bindery.event.shared.Event; +import com.google.gwt.event.shared.GwtEvent.Type; /** - * Extends {com.google.web.bindery.event.shared.EventBus} for legacy - * compatibility. + * Dispatches {@link GwtEvent}s to interested parties. Eases decoupling by + * allowing objects to interact without having direct dependencies upon one + * another, and without requiring event sources to deal with maintaining handler + * lists. There will typically be one EventBus per application, broadcasting + * events that may be of general interest. * - * @deprecated Replaced by com.google.web.bindery.event.shared.EventBus + * @see SimpleEventBus + * @see ResettableEventBus + * @see com.google.gwt.event.shared.testing.CountingEventBus */ -@Deprecated -public abstract class EventBus extends com.google.web.bindery.event.shared.EventBus implements HasHandlers { - - public <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, H handler) { - return wrap(addHandler((Event.Type<H>) type, handler)); - } +public abstract class EventBus implements HasHandlers { - public <H extends EventHandler> HandlerRegistration addHandlerToSource(GwtEvent.Type<H> type, - Object source, H handler) { - return wrap(addHandlerToSource((Event.Type<H>) type, source, handler)); - } - - public void fireEvent(GwtEvent<?> event) { - try { - fireEvent((Event<?>) event); - } catch (com.google.web.bindery.event.shared.UmbrellaException e) { - throw new UmbrellaException(e.getCauses()); - } - } + /** + * Adds an unfiltered handler to receive events of this type from all sources. + * <p> + * It is rare to call this method directly. More typically a {@link GwtEvent} + * subclass will provide a static <code>register</code> method, or a widget + * will accept handlers directly. + * <p> + * A tip: to make a handler de-register itself, the following works: + * <code><pre>new MyHandler() { + * HandlerRegistration reg = MyEvent.register(eventBus, this); + * + * public void onMyThing(MyEvent event) { + * {@literal /}* do your thing *{@literal /} + * reg.removeHandler(); + * } + * }; + * </pre></code> + * + * @param <H> The type of handler + * @param type the event type associated with this handler + * @param handler the handler + * @return the handler registration, can be stored in order to remove the + * handler later + */ + public abstract <H extends EventHandler> HandlerRegistration addHandler( + Type<H> type, H handler); - public void fireEventFromSource(GwtEvent<?> event, Object source) { - try { - fireEventFromSource((Event<?>) event, source); - } catch (com.google.web.bindery.event.shared.UmbrellaException e) { - throw new UmbrellaException(e.getCauses()); - } - } + /** + * Adds a handler to receive events of this type from the given source. + * <p> + * It is rare to call this method directly. More typically a {@link GwtEvent} + * subclass will provide a static <code>register</code> method, or a widget + * will accept handlers directly. + * + * @param <H> The type of handler + * @param type the event type associated with this handler + * @param source the source associated with this handler + * @param handler the handler + * @return the handler registration, can be stored in order to remove the + * handler later + */ + public abstract <H extends EventHandler> HandlerRegistration addHandlerToSource( + Type<H> type, Object source, H handler); - protected HandlerRegistration wrap(com.google.web.bindery.event.shared.HandlerRegistration reg) { - return new LegacyHandlerWrapper(reg); - } + /** + * Fires the event from no source. Only unfiltered handlers will receive it. + * + * @param event the event to fire + */ + public abstract void fireEvent(GwtEvent<?> event); + + /** + * Fires the given event to the handlers listening to the event's type. + * <p> + * Any exceptions thrown by handlers will be bundled into a + * {@link UmbrellaException} and then re-thrown after all handlers have + * completed. An exception thrown by a handler will not prevent other handlers + * from executing. + * + * @param event the event to fire + */ + public abstract void fireEventFromSource(GwtEvent<?> event, Object source); }
diff --git a/user/src/com/google/gwt/event/shared/EventHandler.java b/user/src/com/google/gwt/event/shared/EventHandler.java index 7860744..2558629 100644 --- a/user/src/com/google/gwt/event/shared/EventHandler.java +++ b/user/src/com/google/gwt/event/shared/EventHandler.java
@@ -16,8 +16,8 @@ package com.google.gwt.event.shared; /** - * Marker interface for event handlers. All stock GWT Widget and dom event - * handlers extend {@link EventHandler}. + * Marker interface for event handlers. All GWT event handlers should extend + * {@link EventHandler}. */ public interface EventHandler {
diff --git a/user/src/com/google/gwt/event/shared/GwtEvent.java b/user/src/com/google/gwt/event/shared/GwtEvent.java index a4a8465..ef74c39 100644 --- a/user/src/com/google/gwt/event/shared/GwtEvent.java +++ b/user/src/com/google/gwt/event/shared/GwtEvent.java
@@ -15,20 +15,16 @@ */ package com.google.gwt.event.shared; -import com.google.web.bindery.event.shared.Event; - /** - * Root of all GWT widget and dom events sourced by a {@link HandlerManager}. - * All GWT events are considered dead and should no longer be accessed once the - * {@link HandlerManager} which originally fired the event finishes with it. - * That is, don't hold on to event objects outside of your handler methods. - * <p> - * There is no need for an application's custom event types to extend GwtEvent. - * Prefer {@link Event} instead. + * Root of all GWT events. All GWT events are considered dead and should no + * longer be accessed once the {@link HandlerManager} which originally fired the + * event finishes with it. That is, don't hold on to event objects outside of + * your handler methods. * * @param <H> handler type + * */ -public abstract class GwtEvent<H extends EventHandler> extends Event<H> { +public abstract class GwtEvent<H extends EventHandler> { /** * Type class used to register events with the {@link HandlerManager}. * <p> @@ -38,24 +34,79 @@ * * @param <H> handler type */ - public static class Type<H> extends com.google.web.bindery.event.shared.Event.Type<H> { + public static class Type<H> { + private static int nextHashCode; + private final int index; + + /** + * Constructor. + */ + public Type() { + index = ++nextHashCode; + } + + // We override hash code to make it as efficient as possible. + @Override + public final int hashCode() { + return index; + } + + @Override + public String toString() { + return "Event type"; + } } private boolean dead; + private Object source; + /** * Constructor. */ protected GwtEvent() { } - @Override - public abstract GwtEvent.Type<H> getAssociatedType(); + /** + * Returns the type used to register this event. Used by handler manager to + * dispatch events to the correct handlers. + * + * @return the type + */ + public abstract Type<H> getAssociatedType(); - @Override + /** + * Returns the source that last fired this event. + * + * @return object representing the source of this event + */ public Object getSource() { assertLive(); - return super.getSource(); + return source; + } + + /** + * This is a method used primarily for debugging. It gives a string + * representation of the event details. This does not override the toString + * method because the compiler cannot always optimize toString out correctly. + * Event types should override as desired. + * + * @return a string representing the event's specifics. + */ + public String toDebugString() { + String name = this.getClass().getName(); + name = name.substring(name.lastIndexOf(".") + 1); + return "event: " + name + ":"; + } + + /** + * The toString() for abstract event is overridden to avoid accidently + * including class literals in the the compiled output. Use {@link GwtEvent} + * #toDebugString to get more information about the event. + */ + @Override + public String toString() { + return "An event type"; } /** @@ -90,7 +141,7 @@ */ protected void kill() { dead = true; - setSource(null); + source = null; } /** @@ -98,10 +149,16 @@ */ protected void revive() { dead = false; - setSource(null); + source = null; } - void overrideSource(Object source) { - super.setSource(source); + /** + * Set the source that triggered this event. + * + * @param source the source of this event, should only be set by a + * {@link HandlerManager} + */ + void setSource(Object source) { + this.source = source; } }
diff --git a/user/src/com/google/gwt/event/shared/HandlerManager.java b/user/src/com/google/gwt/event/shared/HandlerManager.java index 9f4d350..7b01a51 100644 --- a/user/src/com/google/gwt/event/shared/HandlerManager.java +++ b/user/src/com/google/gwt/event/shared/HandlerManager.java
@@ -1,12 +1,12 @@ /* * Copyright 2009 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 @@ -15,7 +15,7 @@ */ package com.google.gwt.event.shared; -import com.google.web.bindery.event.shared.Event; +import com.google.gwt.event.shared.GwtEvent.Type; /** * Manager responsible for adding handlers to event sources and firing those @@ -25,40 +25,13 @@ * While widget authors should continue to use * {@link com.google.gwt.user.client.ui.Widget#addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type)} * and - * {@link com.google.gwt.user.client.ui.Widget#addHandler(EventHandler, com.google.gwt.event.shared.GwtEvent.Type)} - * , application developers are strongly discouraged from using a HandlerManager + * {@link com.google.gwt.user.client.ui.Widget#addHandler(EventHandler, com.google.gwt.event.shared.GwtEvent.Type)}, + * application developers are strongly discouraged from using a HandlerManager * instance as a global event dispatch mechanism. */ public class HandlerManager implements HasHandlers { - @SuppressWarnings("deprecation") - private static class Bus extends com.google.web.bindery.event.shared.SimpleEventBus { - public Bus(boolean fireInReverseOrder) { - super(fireInReverseOrder); - } - - @Override - protected <H> void doRemove(Event.Type<H> type, Object source, H handler) { - super.doRemove(type, source, handler); - } - - @Override - protected <H> H getHandler(Event.Type<H> type, int index) { - return super.getHandler(type, index); - } - - @Override - protected int getHandlerCount(Event.Type<?> eventKey) { - return super.getHandlerCount(eventKey); - } - - @Override - protected boolean isEventHandled(Event.Type<?> eventKey) { - return super.isEventHandled(eventKey); - } - } - - private final Bus eventBus; + private final SimpleEventBus eventBus; // source of the events private final Object source; @@ -67,7 +40,7 @@ * Creates a handler manager with a source to be set on all events fired via * {@link #fireEvent(GwtEvent)}. Handlers will be fired in the order that they * are added. - * + * * @param source the default event source */ public HandlerManager(Object source) { @@ -77,27 +50,28 @@ /** * Creates a handler manager with the given source, specifying the order in * which handlers are fired. - * + * * @param source the event source * @param fireInReverseOrder true to fire handlers in reverse order */ + @SuppressWarnings("deprecation") public HandlerManager(Object source, boolean fireInReverseOrder) { - eventBus = new Bus(fireInReverseOrder); + eventBus = new SimpleEventBus(fireInReverseOrder); this.source = source; } /** * Adds a handler. - * + * * @param <H> The type of handler * @param type the event type associated with this handler * @param handler the handler * @return the handler registration, can be stored in order to remove the * handler later */ - public <H extends EventHandler> HandlerRegistration addHandler(GwtEvent.Type<H> type, - final H handler) { - return new LegacyHandlerWrapper(eventBus.addHandler(type, handler)); + public <H extends EventHandler> HandlerRegistration addHandler( + GwtEvent.Type<H> type, final H handler) { + return eventBus.addHandler(type, handler); } /** @@ -111,7 +85,7 @@ * Note, any subclass should be very careful about overriding this method, as * adds/removes of handlers will not be safe except within this * implementation. - * + * * @param event the event */ public void fireEvent(GwtEvent<?> event) { @@ -120,65 +94,68 @@ event.revive(); } Object oldSource = event.getSource(); - event.overrideSource(source); + event.setSource(source); try { // May throw an UmbrellaException. eventBus.fireEvent(event); - } catch (com.google.web.bindery.event.shared.UmbrellaException e) { - throw new UmbrellaException(e.getCauses()); + } finally { if (oldSource == null) { // This was my event, so I should kill it now that I'm done. event.kill(); } else { // Restoring the source for the next handler to use. - event.overrideSource(oldSource); + event.setSource(oldSource); } } } /** * Gets the handler at the given index. - * + * * @param <H> the event handler type * @param index the index * @param type the handler's event type * @return the given handler */ + @SuppressWarnings("deprecation") public <H extends EventHandler> H getHandler(GwtEvent.Type<H> type, int index) { return eventBus.getHandler(type, index); } /** * Gets the number of handlers listening to the event type. - * + * * @param type the event type * @return the number of registered handlers */ - public int getHandlerCount(GwtEvent.Type<?> type) { + @SuppressWarnings("deprecation") + public int getHandlerCount(Type<?> type) { return eventBus.getHandlerCount(type); } /** * Does this handler manager handle the given event type? - * + * * @param e the event type * @return whether the given event type is handled */ - public boolean isEventHandled(GwtEvent.Type<?> e) { + @SuppressWarnings("deprecation") + public boolean isEventHandled(Type<?> e) { return eventBus.isEventHandled(e); } /** * Removes the given handler from the specified event type. - * + * * @param <H> handler type - * + * * @param type the event type * @param handler the handler */ - public <H extends EventHandler> void removeHandler(GwtEvent.Type<H> type, final H handler) { - eventBus.doRemove(type, null, handler); + public <H extends EventHandler> void removeHandler(GwtEvent.Type<H> type, + final H handler) { + eventBus.doRemove(type, null, handler); } }
diff --git a/user/src/com/google/gwt/event/shared/HandlerRegistration.java b/user/src/com/google/gwt/event/shared/HandlerRegistration.java index 5d04ac9..9031343 100644 --- a/user/src/com/google/gwt/event/shared/HandlerRegistration.java +++ b/user/src/com/google/gwt/event/shared/HandlerRegistration.java
@@ -17,8 +17,19 @@ package com.google.gwt.event.shared; /** - * Extends {com.google.bindery.event.shared.HandlerRegistration} for legacy - * compatibility. + * Registration returned from a call to + * {@link HandlerManager#addHandler(com.google.gwt.event.shared.GwtEvent.Type, EventHandler)} + * . Use the handler registration to remove handlers when they are no longer + * needed. + * + * Note, this interface is under the control of the {@link HandlerManager} class + * and may be expanded over time, so extend {@link DefaultHandlerRegistration} + * if you do not wish to get compiler errors if we extend the handler registry + * functionality. */ -public interface HandlerRegistration extends com.google.web.bindery.event.shared.HandlerRegistration { +public interface HandlerRegistration { + /** + * Removes the given handler from its manager. + */ + void removeHandler(); }
diff --git a/user/src/com/google/gwt/event/shared/LegacyHandlerWrapper.java b/user/src/com/google/gwt/event/shared/LegacyHandlerWrapper.java deleted file mode 100644 index b5396da..0000000 --- a/user/src/com/google/gwt/event/shared/LegacyHandlerWrapper.java +++ /dev/null
@@ -1,28 +0,0 @@ -/* - * Copyright 2011 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.event.shared; - -class LegacyHandlerWrapper implements HandlerRegistration { - private final com.google.web.bindery.event.shared.HandlerRegistration real; - - LegacyHandlerWrapper(com.google.web.bindery.event.shared.HandlerRegistration real) { - this.real = real; - } - - public void removeHandler() { - real.removeHandler(); - } -}
diff --git a/user/src/com/google/gwt/event/shared/ResettableEventBus.java b/user/src/com/google/gwt/event/shared/ResettableEventBus.java index 8ea5ace..50055d6 100644 --- a/user/src/com/google/gwt/event/shared/ResettableEventBus.java +++ b/user/src/com/google/gwt/event/shared/ResettableEventBus.java
@@ -15,67 +15,84 @@ */ package com.google.gwt.event.shared; -import com.google.web.bindery.event.shared.Event; -import com.google.web.bindery.event.shared.Event.Type; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.GwtEvent.Type; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; /** - * Wraps {com.google.web.bindery.event.shared.ResettableEventBus} for legacy - * compatibility. - * - * @deprecated Use com.google.web.bindery.event.shared.ResettableEventBus. + * Wraps an EventBus to hold on to any HandlerRegistrations, so that they can + * easily all be cleared at once. */ -@SuppressWarnings("deprecation") -@Deprecated public class ResettableEventBus extends EventBus { - private static class TestableResettableEventBus extends com.google.web.bindery.event.shared.ResettableEventBus { - /** - * @param wrappedBus - */ - public TestableResettableEventBus(EventBus wrappedBus) { - super(wrappedBus); - } - @Override - public int getRegistrationSize() { - return super.getRegistrationSize(); - } - } - - private final TestableResettableEventBus real; + private final EventBus wrapped; + private final Set<HandlerRegistration> registrations = new HashSet<HandlerRegistration>(); public ResettableEventBus(EventBus wrappedBus) { - real = new TestableResettableEventBus(wrappedBus); + this.wrapped = wrappedBus; } @Override - public <H> HandlerRegistration addHandler(Type<H> type, H handler) { - return real.addHandler(type, handler); + public <H extends EventHandler> HandlerRegistration addHandler(Type<H> type, H handler) { + HandlerRegistration rtn = wrapped.addHandler(type, handler); + return doRegisterHandler(rtn); } @Override - public <H> HandlerRegistration addHandlerToSource(Type<H> type, Object source, H handler) { - return real.addHandlerToSource(type, source, handler); + public <H extends EventHandler> HandlerRegistration addHandlerToSource(GwtEvent.Type<H> type, + Object source, H handler) { + HandlerRegistration rtn = wrapped.addHandlerToSource(type, source, handler); + return doRegisterHandler(rtn); } @Override - public void fireEvent(Event<?> event) { - real.fireEvent(event); + public void fireEvent(GwtEvent<?> event) { + wrapped.fireEvent(event); } @Override - public void fireEventFromSource(Event<?> event, Object source) { - real.fireEventFromSource(event, source); - } - - public void removeHandlers() { - real.removeHandlers(); + public void fireEventFromSource(GwtEvent<?> event, Object source) { + wrapped.fireEventFromSource(event, source); } /** - * Visible for testing + * Remove all handlers that have been added through this wrapper. */ + public void removeHandlers() { + Iterator<HandlerRegistration> it = registrations.iterator(); + while (it.hasNext()) { + HandlerRegistration r = it.next(); + + /* + * must remove before we call removeHandler. Might have come from nested + * ResettableEventBus + */ + it.remove(); + + r.removeHandler(); + } + } + + // Visible for testing int getRegistrationSize() { - return real.getRegistrationSize(); + return registrations.size(); + } + + private HandlerRegistration doRegisterHandler(final HandlerRegistration registration) { + registrations.add(registration); + return new HandlerRegistration() { + public void removeHandler() { + doUnregisterHandler(registration); + } + }; + } + + private void doUnregisterHandler(HandlerRegistration registration) { + if (registrations.contains(registration)) { + registration.removeHandler(); + registrations.remove(registration); + } } }
diff --git a/user/src/com/google/gwt/event/shared/SimpleEventBus.java b/user/src/com/google/gwt/event/shared/SimpleEventBus.java index 94c8207..673d698 100644 --- a/user/src/com/google/gwt/event/shared/SimpleEventBus.java +++ b/user/src/com/google/gwt/event/shared/SimpleEventBus.java
@@ -15,39 +15,309 @@ */ package com.google.gwt.event.shared; -import com.google.web.bindery.event.shared.Event; -import com.google.web.bindery.event.shared.Event.Type; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.event.shared.GwtEvent.Type; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; /** - * Wraps {com.google.web.bindery.event.shared.SimpleEventBus} for legacy - * compatibility. - * - * @deprecated Use com.google.web.bindery.event.shared.SimpleEventBus + * Basic implementation of {@link EventBus}. */ -@SuppressWarnings("deprecation") -@Deprecated public class SimpleEventBus extends EventBus { - private final com.google.web.bindery.event.shared.SimpleEventBus real = - new com.google.web.bindery.event.shared.SimpleEventBus(); + private final boolean isReverseOrder; - @Override - public <H> HandlerRegistration addHandler(Type<H> type, H handler) { - return real.addHandler(type, handler); + private int firingDepth = 0; + + /** + * Add and remove operations received during dispatch. + */ + private List<ScheduledCommand> deferredDeltas; + + /** + * Map of event type to map of event source to list of their handlers. + */ + private final Map<GwtEvent.Type<?>, Map<Object, List<?>>> map = new HashMap<GwtEvent.Type<?>, Map<Object, List<?>>>(); + + public SimpleEventBus() { + this(false); + } + + /** + * Allows creation of an instance that fires its handlers in the reverse of + * the order in which they were added, although filtered handlers all fire + * before unfiltered handlers. + * <p> + * + * @deprecated This is a legacy feature, required by HandlerManager. Package + * protected because it is a bad idea to rely upon the order of + * event dispatch, and because fully supporting it (that is, not + * segregating filtered and unfiltered handlers, a distinction not + * used by HandlerManager) is not worth the effort. + */ + @Deprecated + SimpleEventBus(boolean fireInReverseOrder) { + isReverseOrder = fireInReverseOrder; } @Override - public <H> HandlerRegistration addHandlerToSource(Type<H> type, Object source, H handler) { - return real.addHandlerToSource(type, source, handler); + public <H extends EventHandler> HandlerRegistration addHandler(Type<H> type, + H handler) { + if (type == null) { + throw new NullPointerException("Cannot add a handler with a null type"); + } + if (handler == null) { + throw new NullPointerException("Cannot add a null handler"); + } + + return doAdd(type, null, handler); } @Override - public void fireEvent(Event<?> event) { - real.fireEvent(event); + public <H extends EventHandler> HandlerRegistration addHandlerToSource( + final GwtEvent.Type<H> type, final Object source, final H handler) { + if (type == null) { + throw new NullPointerException("Cannot add a handler with a null type"); + } + if (source == null) { + throw new NullPointerException("Cannot add a handler with a null source"); + } + if (handler == null) { + throw new NullPointerException("Cannot add a null handler"); + } + + return doAdd(type, source, handler); } @Override - public void fireEventFromSource(Event<?> event, Object source) { - real.fireEventFromSource(event, source); + public void fireEvent(GwtEvent<?> event) { + if (event == null) { + throw new NullPointerException("Cannot fire null event"); + } + doFire(event, null); } -} + + @Override + public void fireEventFromSource(GwtEvent<?> event, Object source) { + if (event == null) { + throw new NullPointerException("Cannot fire null event"); + } + if (source == null) { + throw new NullPointerException("Cannot fire from a null source"); + } + doFire(event, source); + } + + /** + * Package protected to support legacy features in HandlerManager. + */ + <H extends EventHandler> void doRemove( + com.google.gwt.event.shared.GwtEvent.Type<H> type, Object source, + H handler) { + if (firingDepth > 0) { + enqueueRemove(type, source, handler); + } else { + doRemoveNow(type, source, handler); + } + } + + /** + * Package protected to support legacy features in HandlerManager. + */ + @Deprecated + <H extends EventHandler> H getHandler(GwtEvent.Type<H> type, int index) { + assert index < getHandlerCount(type) : "handlers for " + type.getClass() + + " have size: " + getHandlerCount(type) + + " so do not have a handler at index: " + index; + + List<H> l = getHandlerList(type, null); + return l.get(index); + } + + /** + * Package protected to support legacy features in HandlerManager. + */ + @Deprecated + int getHandlerCount(GwtEvent.Type<?> eventKey) { + return getHandlerList(eventKey, null).size(); + } + + /** + * Package protected to support legacy features in HandlerManager. + */ + @Deprecated + boolean isEventHandled(GwtEvent.Type<?> eventKey) { + return map.containsKey(eventKey); + } + + private void defer(ScheduledCommand command) { + if (deferredDeltas == null) { + deferredDeltas = new ArrayList<ScheduledCommand>(); + } + deferredDeltas.add(command); + } + + private <H extends EventHandler> HandlerRegistration doAdd( + final GwtEvent.Type<H> type, final Object source, final H handler) { + if (firingDepth > 0) { + enqueueAdd(type, source, handler); + } else { + doAddNow(type, source, handler); + } + + return new HandlerRegistration() { + public void removeHandler() { + doRemove(type, source, handler); + } + }; + } + + private <H extends EventHandler> void doAddNow(GwtEvent.Type<H> type, + Object source, H handler) { + List<H> l = ensureHandlerList(type, source); + l.add(handler); + } + + private <H extends EventHandler> void doFire(GwtEvent<H> event, Object source) { + try { + firingDepth++; + + if (source != null) { + event.setSource(source); + } + + List<H> handlers = getDispatchList(event.getAssociatedType(), source); + Set<Throwable> causes = null; + + ListIterator<H> it = isReverseOrder + ? handlers.listIterator(handlers.size()) : handlers.listIterator(); + while (isReverseOrder ? it.hasPrevious() : it.hasNext()) { + H handler = isReverseOrder ? it.previous() : it.next(); + + try { + event.dispatch(handler); + } catch (Throwable e) { + if (causes == null) { + causes = new HashSet<Throwable>(); + } + causes.add(e); + } + } + + if (causes != null) { + throw new UmbrellaException(causes); + } + } finally { + firingDepth--; + if (firingDepth == 0) { + handleQueuedAddsAndRemoves(); + } + } + } + + private <H> void doRemoveNow(GwtEvent.Type<H> type, Object source, H handler) { + List<H> l = getHandlerList(type, source); + + boolean removed = l.remove(handler); + assert removed : "redundant remove call"; + if (removed && l.isEmpty()) { + prune(type, source); + } + } + + private <H extends EventHandler> void enqueueAdd(final GwtEvent.Type<H> type, + final Object source, final H handler) { + defer(new ScheduledCommand() { + public void execute() { + doAddNow(type, source, handler); + } + }); + } + + private <H extends EventHandler> void enqueueRemove( + final GwtEvent.Type<H> type, final Object source, final H handler) { + defer(new ScheduledCommand() { + public void execute() { + doRemoveNow(type, source, handler); + } + }); + } + + private <H> List<H> ensureHandlerList(GwtEvent.Type<H> type, Object source) { + Map<Object, List<?>> sourceMap = map.get(type); + if (sourceMap == null) { + sourceMap = new HashMap<Object, List<?>>(); + map.put(type, sourceMap); + } + + // safe, we control the puts. + @SuppressWarnings("unchecked") + List<H> handlers = (List<H>) sourceMap.get(source); + if (handlers == null) { + handlers = new ArrayList<H>(); + sourceMap.put(source, handlers); + } + + return handlers; + } + + private <H> List<H> getDispatchList(GwtEvent.Type<H> type, Object source) { + List<H> directHandlers = getHandlerList(type, source); + if (source == null) { + return directHandlers; + } + + List<H> globalHandlers = getHandlerList(type, null); + + List<H> rtn = new ArrayList<H>(directHandlers); + rtn.addAll(globalHandlers); + return rtn; + } + + private <H> List<H> getHandlerList(GwtEvent.Type<H> type, Object source) { + Map<Object, List<?>> sourceMap = map.get(type); + if (sourceMap == null) { + return Collections.emptyList(); + } + + // safe, we control the puts. + @SuppressWarnings("unchecked") + List<H> handlers = (List<H>) sourceMap.get(source); + if (handlers == null) { + return Collections.emptyList(); + } + + return handlers; + } + + private void handleQueuedAddsAndRemoves() { + if (deferredDeltas != null) { + try { + for (ScheduledCommand c : deferredDeltas) { + c.execute(); + } + } finally { + deferredDeltas = null; + } + } + } + + private void prune(GwtEvent.Type<?> type, Object source) { + Map<Object, List<?>> sourceMap = map.get(type); + + List<?> pruned = sourceMap.remove(source); + + assert pruned != null : "Can't prune what wasn't there"; + assert pruned.isEmpty() : "Pruned unempty list!"; + + if (sourceMap.isEmpty()) { + map.remove(type); + } + } +} \ No newline at end of file
diff --git a/user/src/com/google/gwt/event/shared/UmbrellaException.java b/user/src/com/google/gwt/event/shared/UmbrellaException.java index dd34695..134af51 100644 --- a/user/src/com/google/gwt/event/shared/UmbrellaException.java +++ b/user/src/com/google/gwt/event/shared/UmbrellaException.java
@@ -15,21 +15,43 @@ */ package com.google.gwt.event.shared; +import java.util.HashSet; import java.util.Set; /** - * Wraps {com.google.web.bindery.event.shared.UmbrellaException} for legacy - * compatibility. + * A {@link RuntimeException} that collects a {@link Set} of child + * {@link Throwable}s together. Typically thrown after loop, with all of the + * exceptions thrown during that loop, but delayed so that the loop finishes + * executing. */ -public class UmbrellaException extends com.google.web.bindery.event.shared.UmbrellaException { +public class UmbrellaException extends RuntimeException { + + /** + * The causes of the exception. + */ + private Set<Throwable> causes; + + /* + * The default constructor enables RPC support. + */ + public UmbrellaException() { + this(new HashSet<Throwable>()); + } + public UmbrellaException(Set<Throwable> causes) { - super(causes); + super( + "One or more exceptions caught, see full set in UmbrellaException#getCauses", + causes.size() == 0 ? null : causes.toArray(new Throwable[0])[0]); + this.causes = causes; } /** - * Required for GWT RPC serialization. + * Get the set of exceptions that caused the failure. + * + * @return the set of causes */ - protected UmbrellaException() { - super(); + public Set<Throwable> getCauses() { + return causes; } -} + +} \ No newline at end of file
diff --git a/user/src/com/google/gwt/event/shared/testing/CountingEventBus.java b/user/src/com/google/gwt/event/shared/testing/CountingEventBus.java index 7503966..3c1a121 100644 --- a/user/src/com/google/gwt/event/shared/testing/CountingEventBus.java +++ b/user/src/com/google/gwt/event/shared/testing/CountingEventBus.java
@@ -15,50 +15,87 @@ */ package com.google.gwt.event.shared.testing; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.GwtEvent; -import com.google.web.bindery.event.shared.Event; -import com.google.web.bindery.event.shared.Event.Type; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.GwtEvent.Type; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.SimpleEventBus; + +import java.util.HashMap; +import java.util.Map; /** - * Legacy compatibility wrapper for - * {@link com.google.web.bindery.event.shared.testing.CountingEventBus}. - * @deprecated + * Wraps an {@link EventBus} to keep a count of registered handlers. Handy for + * tests. */ -@SuppressWarnings("deprecation") -@Deprecated -public class CountingEventBus extends com.google.gwt.event.shared.EventBus { - private final com.google.web.bindery.event.shared.testing.CountingEventBus real; - +public class CountingEventBus extends EventBus { + private final Map<Type<?>, Integer> counts = new HashMap<GwtEvent.Type<?>, Integer>(); + private final EventBus wrapped; + public CountingEventBus() { - real = new com.google.web.bindery.event.shared.testing.CountingEventBus(); + this(new SimpleEventBus()); } - - public CountingEventBus(com.google.gwt.event.shared.EventBus wrapped) { - real = new com.google.web.bindery.event.shared.testing.CountingEventBus(wrapped); + + public CountingEventBus(EventBus wrapped) { + this.wrapped = wrapped; } @Override - public <H> HandlerRegistration addHandler(Type<H> type, H handler) { - return real.addHandler(type, handler); + public <H extends EventHandler> HandlerRegistration addHandler(Type<H> type, + H handler) { + increment(type); + final HandlerRegistration superReg = wrapped.addHandler(type, handler); + return makeReg(type, superReg); } @Override - public <H> HandlerRegistration addHandlerToSource(Type<H> type, Object source, H handler) { - return real.addHandlerToSource(type, source, handler); + public <H extends EventHandler> HandlerRegistration addHandlerToSource( + final Type<H> type, Object source, H handler) { + increment(type); + final HandlerRegistration superReg = wrapped.addHandlerToSource(type, + source, handler); + return makeReg(type, superReg); } @Override - public void fireEvent(Event<?> event) { - real.fireEvent(event); + public void fireEvent(GwtEvent<?> event) { + wrapped.fireEvent(event); } @Override - public void fireEventFromSource(Event<?> event, Object source) { - real.fireEventFromSource(event, source); + public void fireEventFromSource(GwtEvent<?> event, Object source) { + wrapped.fireEventFromSource(event, source); } - public int getCount(GwtEvent.Type<?> type) { - return real.getCount(type); + public int getCount(Type<?> type) { + Integer count = counts.get(type); + return count == null ? 0 : count; + } + + private void decrement(Type<?> type) { + Integer count = counts.get(type); + if (count == null) { + count = 0; + } + counts.put(type, count - 1); + } + + private <H> void increment(final Type<H> type) { + Integer count = counts.get(type); + if (count == null) { + count = 0; + } + counts.put(type, count + 1); + } + + private <H> HandlerRegistration makeReg(final Type<H> type, + final HandlerRegistration superReg) { + return new HandlerRegistration() { + public void removeHandler() { + decrement(type); + superReg.removeHandler(); + } + }; } }
diff --git a/user/src/com/google/gwt/place/shared/PlaceController.java b/user/src/com/google/gwt/place/shared/PlaceController.java index 56efe51..294a963 100644 --- a/user/src/com/google/gwt/place/shared/PlaceController.java +++ b/user/src/com/google/gwt/place/shared/PlaceController.java
@@ -16,11 +16,11 @@ package com.google.gwt.place.shared; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window.ClosingEvent; import com.google.gwt.user.client.Window.ClosingHandler; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; import java.util.logging.Logger;
diff --git a/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java b/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java index fc6bb98..7117169 100644 --- a/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java +++ b/user/src/com/google/gwt/place/shared/PlaceHistoryHandler.java
@@ -18,9 +18,9 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.History; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; import java.util.logging.Logger;
diff --git a/user/src/com/google/gwt/user/client/ui/Widget.java b/user/src/com/google/gwt/user/client/ui/Widget.java index 932aaee..7bc1ba3 100644 --- a/user/src/com/google/gwt/user/client/ui/Widget.java +++ b/user/src/com/google/gwt/user/client/ui/Widget.java
@@ -23,6 +23,7 @@ import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.event.shared.GwtEvent.Type; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; @@ -245,8 +246,8 @@ * * @return the {@link HandlerManager} you want to use */ - protected HandlerManager createHandlerManager() { - return new HandlerManager(this); + protected com.google.gwt.event.shared.HandlerManager createHandlerManager() { + return new com.google.gwt.event.shared.HandlerManager(this); } /** @@ -288,7 +289,7 @@ * @param type the event type * @return the number of registered handlers */ - protected int getHandlerCount(GwtEvent.Type<?> type) { + protected int getHandlerCount(Type<?> type) { return handlerManager == null ? 0 : handlerManager.getHandlerCount(type); } @@ -411,12 +412,12 @@ * * @return the handler manager * */ - HandlerManager ensureHandlers() { + com.google.gwt.event.shared.HandlerManager ensureHandlers() { return handlerManager == null ? handlerManager = createHandlerManager() : handlerManager; } - HandlerManager getHandlerManager() { + com.google.gwt.event.shared.HandlerManager getHandlerManager() { return handlerManager; }
diff --git a/user/src/com/google/web/bindery/event/Event.gwt.xml b/user/src/com/google/web/bindery/event/Event.gwt.xml deleted file mode 100644 index 8bafd18..0000000 --- a/user/src/com/google/web/bindery/event/Event.gwt.xml +++ /dev/null
@@ -1,18 +0,0 @@ -<!-- - Copyright 2011 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. ---> -<module> - <source path="shared" /> -</module>
diff --git a/user/src/com/google/web/bindery/event/shared/Event.java b/user/src/com/google/web/bindery/event/shared/Event.java deleted file mode 100644 index 487771f..0000000 --- a/user/src/com/google/web/bindery/event/shared/Event.java +++ /dev/null
@@ -1,125 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -/** - * Base Event object. - * - * @param <H> interface implemented by handlers of this kind of event - */ -public abstract class Event<H> { - /** - * Type class used to register events with an {@link EventBus}. - * - * @param <H> handler type - */ - public static class Type<H> { - private static int nextHashCode; - private final int index; - - /** - * Constructor. - */ - public Type() { - index = ++nextHashCode; - } - - @Override - public final int hashCode() { - return index; - } - - @Override - public String toString() { - return "Event type"; - } - } - - private Object source; - - /** - * Constructor. - */ - protected Event() { - } - - /** - * Returns the {@link Type} used to register this event, allowing an - * {@link EventBus} to find handlers of the appropriate class. - * - * @return the type - */ - public abstract Type<H> getAssociatedType(); - - /** - * Returns the source for this event. The type and meaning of the source is - * arbitrary, and is most useful as a secondary key for handler registration. - * (See {@link EventBus#addHandlerToSource}, which allows a handler to - * register for events of a particular type, tied to a particular source.) - * <p> - * Note that the source is actually set at dispatch time, e.g. via - * {@link EventBus#fireEventFromSource(Event, Object)}. - * - * @return object representing the source of this event - */ - public Object getSource() { - return source; - } - - /** - * This is a method used primarily for debugging. It gives a string - * representation of the event details. This does not override the toString - * method because the compiler cannot always optimize toString out correctly. - * Event types should override as desired. - * - * @return a string representing the event's specifics. - */ - public String toDebugString() { - String name = this.getClass().getName(); - name = name.substring(name.lastIndexOf(".") + 1); - return "event: " + name + ":"; - } - - /** - * The toString() for abstract event is overridden to avoid accidently - * including class literals in the the compiled output. Use {@link Event} - * #toDebugString to get more information about the event. - */ - @Override - public String toString() { - return "An event type"; - } - - /** - * Implemented by subclasses to to invoke their handlers in a type safe - * manner. Intended to be called by {@link EventBus#fireEvent(Event)} or - * {@link EventBus#fireEventFromSource(Event, Object)}. - * - * @param handler handler - */ - protected abstract void dispatch(H handler); - - /** - * Set the source that triggered this event. Intended to be called by the - * {@link EventBus} during dispatch. - * - * @param source the source of this event. - * @see EventBus#fireEventFromSource(Event, Object) - */ - protected void setSource(Object source) { - this.source = source; - } -}
diff --git a/user/src/com/google/web/bindery/event/shared/EventBus.java b/user/src/com/google/web/bindery/event/shared/EventBus.java deleted file mode 100644 index 91ed3dc..0000000 --- a/user/src/com/google/web/bindery/event/shared/EventBus.java +++ /dev/null
@@ -1,91 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import com.google.web.bindery.event.shared.Event.Type; - -/** - * Dispatches {@link Event}s to interested parties. Eases decoupling by allowing - * objects to interact without having direct dependencies upon one another, and - * without requiring event sources to deal with maintaining handler lists. There - * will typically be one EventBus per application, broadcasting events that may - * be of general interest. - * - * @see SimpleEventBus - * @see ResettableEventBus - * @see com.google.web.bindery.event.shared.testing.CountingEventBus - */ -public abstract class EventBus { - - /** - * Adds an unfiltered handler to receive events of this type from all sources. - * <p> - * It is rare to call this method directly. More typically an {@link Event} - * subclass will provide a static <code>register</code> method, or a widget - * will accept handlers directly. - * - * @param <H> The type of handler - * @param type the event type associated with this handler - * @param handler the handler - * @return the handler registration, can be stored in order to remove the - * handler later - */ - public abstract <H> HandlerRegistration addHandler(Type<H> type, H handler); - - /** - * Adds a handler to receive events of this type from the given source. - * <p> - * It is rare to call this method directly. More typically a {@link Event} - * subclass will provide a static <code>register</code> method, or a widget - * will accept handlers directly. - * - * @param <H> The type of handler - * @param type the event type associated with this handler - * @param source the source associated with this handler - * @param handler the handler - * @return the handler registration, can be stored in order to remove the - * handler later - */ - public abstract <H> HandlerRegistration addHandlerToSource(Type<H> type, Object source, H handler); - - /** - * Fires the event from no source. Only unfiltered handlers will receive it. - * <p> - * Any exceptions thrown by handlers will be bundled into a - * {@link UmbrellaException} and then re-thrown after all handlers have - * completed. An exception thrown by a handler will not prevent other handlers - * from executing. - * - * @throws UmbrellaException wrapping exceptions thrown by handlers - * - * @param event the event to fire - */ - public abstract void fireEvent(Event<?> event); - - /** - * Fires the given event to the handlers listening to the event's type. - * <p> - * Any exceptions thrown by handlers will be bundled into a - * {@link UmbrellaException} and then re-thrown after all handlers have - * completed. An exception thrown by a handler will not prevent other handlers - * from executing. - * - * @throws UmbrellaException wrapping exceptions thrown by handlers - * - * @param event the event to fire - */ - public abstract void fireEventFromSource(Event<?> event, Object source); -}
diff --git a/user/src/com/google/web/bindery/event/shared/HandlerRegistration.java b/user/src/com/google/web/bindery/event/shared/HandlerRegistration.java deleted file mode 100644 index ce34e39..0000000 --- a/user/src/com/google/web/bindery/event/shared/HandlerRegistration.java +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -/** - * Registration objects returned when an event handler is bound (e.g. via - * {@link EventBus#addHandler}), used to deregister. - * <p> - * A tip: to make a handler deregister itself try something like the following: - * <code><pre>new MyHandler() { - * HandlerRegistration reg = MyEvent.register(eventBus, this); - * - * public void onMyThing(MyEvent event) { - * {@literal /}* do your thing *{@literal /} - * reg.removeHandler(); - * } - * }; - * </pre></code> - */ -public interface HandlerRegistration { - - /** - * Deregisters the handler associated with this registration object if the - * handler is still attached to the event source. If the handler is no longer - * attached to the event source, this is a no-op. - */ - void removeHandler(); -}
diff --git a/user/src/com/google/web/bindery/event/shared/ResettableEventBus.java b/user/src/com/google/web/bindery/event/shared/ResettableEventBus.java deleted file mode 100644 index a1b56ce..0000000 --- a/user/src/com/google/web/bindery/event/shared/ResettableEventBus.java +++ /dev/null
@@ -1,98 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import com.google.web.bindery.event.shared.Event.Type; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -/** - * Wraps an EventBus to hold on to any HandlerRegistrations, so that they can - * easily all be cleared at once. - */ -public class ResettableEventBus extends EventBus { - private final EventBus wrapped; - private final Set<HandlerRegistration> registrations = new HashSet<HandlerRegistration>(); - - public ResettableEventBus(EventBus wrappedBus) { - this.wrapped = wrappedBus; - } - - @Override - public <H> HandlerRegistration addHandler(Type<H> type, H handler) { - HandlerRegistration rtn = wrapped.addHandler(type, handler); - return doRegisterHandler(rtn); - } - - @Override - public <H> HandlerRegistration addHandlerToSource(Event.Type<H> type, Object source, H handler) { - HandlerRegistration rtn = wrapped.addHandlerToSource(type, source, handler); - return doRegisterHandler(rtn); - } - - @Override - public void fireEvent(Event<?> event) { - wrapped.fireEvent(event); - } - - @Override - public void fireEventFromSource(Event<?> event, Object source) { - wrapped.fireEventFromSource(event, source); - } - - /** - * Remove all handlers that have been added through this wrapper. - */ - public void removeHandlers() { - Iterator<HandlerRegistration> it = registrations.iterator(); - while (it.hasNext()) { - HandlerRegistration r = it.next(); - - /* - * must remove before we call removeHandler. Might have come from nested - * ResettableEventBus - */ - it.remove(); - - r.removeHandler(); - } - } - - /** - * Visible for testing - */ - protected int getRegistrationSize() { - return registrations.size(); - } - - private HandlerRegistration doRegisterHandler(final HandlerRegistration registration) { - registrations.add(registration); - return new HandlerRegistration() { - public void removeHandler() { - doUnregisterHandler(registration); - } - }; - } - - private void doUnregisterHandler(HandlerRegistration registration) { - if (registrations.contains(registration)) { - registration.removeHandler(); - registrations.remove(registration); - } - } -}
diff --git a/user/src/com/google/web/bindery/event/shared/SimpleEventBus.java b/user/src/com/google/web/bindery/event/shared/SimpleEventBus.java deleted file mode 100644 index 14a1f3c..0000000 --- a/user/src/com/google/web/bindery/event/shared/SimpleEventBus.java +++ /dev/null
@@ -1,310 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import com.google.web.bindery.event.shared.Event.Type; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; - -/** - * Basic implementation of {@link EventBus}. - */ -public class SimpleEventBus extends EventBus { - private interface Command { - void execute(); - } - - private final boolean isReverseOrder; - - private int firingDepth = 0; - - /** - * Add and remove operations received during dispatch. - */ - private List<Command> deferredDeltas; - - /** - * Map of event type to map of event source to list of their handlers. - */ - private final Map<Event.Type<?>, Map<Object, List<?>>> map = - new HashMap<Event.Type<?>, Map<Object, List<?>>>(); - - public SimpleEventBus() { - this(false); - } - - /** - * Allows creation of an instance that fires its handlers in the reverse of - * the order in which they were added, although filtered handlers all fire - * before unfiltered handlers. - * <p> - * - * @deprecated This is a legacy feature, required by GWT's old HandlerManager. - * Reverse order is not honored for handlers tied to a specific - * event source (via {@link #addHandlerToSource}. - */ - @Deprecated - protected SimpleEventBus(boolean fireInReverseOrder) { - isReverseOrder = fireInReverseOrder; - } - - @Override - public <H> HandlerRegistration addHandler(Type<H> type, H handler) { - return doAdd(type, null, handler); - } - - @Override - public <H> HandlerRegistration addHandlerToSource(final Event.Type<H> type, final Object source, - final H handler) { - if (source == null) { - throw new NullPointerException("Cannot add a handler with a null source"); - } - - return doAdd(type, source, handler); - } - - @Override - public void fireEvent(Event<?> event) { - doFire(event, null); - } - - @Override - public void fireEventFromSource(Event<?> event, Object source) { - if (source == null) { - throw new NullPointerException("Cannot fire from a null source"); - } - doFire(event, source); - } - - /** - * @deprecated required by legacy features in GWT's old HandlerManager - */ - @Deprecated - protected <H> void doRemove(Event.Type<H> type, Object source, H handler) { - if (firingDepth > 0) { - enqueueRemove(type, source, handler); - } else { - doRemoveNow(type, source, handler); - } - } - - /** - * @deprecated required by legacy features in GWT's old HandlerManager - */ - @Deprecated - protected <H> H getHandler(Event.Type<H> type, int index) { - assert index < getHandlerCount(type) : "handlers for " + type.getClass() + " have size: " - + getHandlerCount(type) + " so do not have a handler at index: " + index; - - List<H> l = getHandlerList(type, null); - return l.get(index); - } - - /** - * @deprecated required by legacy features in GWT's old HandlerManager - */ - @Deprecated - protected int getHandlerCount(Event.Type<?> eventKey) { - return getHandlerList(eventKey, null).size(); - } - - /** - * @deprecated required by legacy features in GWT's old HandlerManager - */ - @Deprecated - protected boolean isEventHandled(Event.Type<?> eventKey) { - return map.containsKey(eventKey); - } - - private void defer(Command command) { - if (deferredDeltas == null) { - deferredDeltas = new ArrayList<Command>(); - } - deferredDeltas.add(command); - } - - private <H> HandlerRegistration doAdd(final Event.Type<H> type, final Object source, - final H handler) { - if (type == null) { - throw new NullPointerException("Cannot add a handler with a null type"); - } - if (handler == null) { - throw new NullPointerException("Cannot add a null handler"); - } - - if (firingDepth > 0) { - enqueueAdd(type, source, handler); - } else { - doAddNow(type, source, handler); - } - - return new HandlerRegistration() { - public void removeHandler() { - doRemove(type, source, handler); - } - }; - } - - private <H> void doAddNow(Event.Type<H> type, Object source, H handler) { - List<H> l = ensureHandlerList(type, source); - l.add(handler); - } - - private <H> void doFire(Event<H> event, Object source) { - if (event == null) { - throw new NullPointerException("Cannot fire null event"); - } - try { - firingDepth++; - - if (source != null) { - event.setSource(source); - } - - List<H> handlers = getDispatchList(event.getAssociatedType(), source); - Set<Throwable> causes = null; - - ListIterator<H> it = - isReverseOrder ? handlers.listIterator(handlers.size()) : handlers.listIterator(); - while (isReverseOrder ? it.hasPrevious() : it.hasNext()) { - H handler = isReverseOrder ? it.previous() : it.next(); - - try { - event.dispatch(handler); - } catch (Throwable e) { - if (causes == null) { - causes = new HashSet<Throwable>(); - } - causes.add(e); - } - } - - if (causes != null) { - throw new UmbrellaException(causes); - } - } finally { - firingDepth--; - if (firingDepth == 0) { - handleQueuedAddsAndRemoves(); - } - } - } - - private <H> void doRemoveNow(Event.Type<H> type, Object source, H handler) { - List<H> l = getHandlerList(type, source); - - boolean removed = l.remove(handler); - assert removed : "redundant remove call"; - if (removed && l.isEmpty()) { - prune(type, source); - } - } - - private <H> void enqueueAdd(final Event.Type<H> type, final Object source, final H handler) { - defer(new Command() { - public void execute() { - doAddNow(type, source, handler); - } - }); - } - - private <H> void enqueueRemove(final Event.Type<H> type, final Object source, final H handler) { - defer(new Command() { - public void execute() { - doRemoveNow(type, source, handler); - } - }); - } - - private <H> List<H> ensureHandlerList(Event.Type<H> type, Object source) { - Map<Object, List<?>> sourceMap = map.get(type); - if (sourceMap == null) { - sourceMap = new HashMap<Object, List<?>>(); - map.put(type, sourceMap); - } - - // safe, we control the puts. - @SuppressWarnings("unchecked") - List<H> handlers = (List<H>) sourceMap.get(source); - if (handlers == null) { - handlers = new ArrayList<H>(); - sourceMap.put(source, handlers); - } - - return handlers; - } - - private <H> List<H> getDispatchList(Event.Type<H> type, Object source) { - List<H> directHandlers = getHandlerList(type, source); - if (source == null) { - return directHandlers; - } - - List<H> globalHandlers = getHandlerList(type, null); - - List<H> rtn = new ArrayList<H>(directHandlers); - rtn.addAll(globalHandlers); - return rtn; - } - - private <H> List<H> getHandlerList(Event.Type<H> type, Object source) { - Map<Object, List<?>> sourceMap = map.get(type); - if (sourceMap == null) { - return Collections.emptyList(); - } - - // safe, we control the puts. - @SuppressWarnings("unchecked") - List<H> handlers = (List<H>) sourceMap.get(source); - if (handlers == null) { - return Collections.emptyList(); - } - - return handlers; - } - - private void handleQueuedAddsAndRemoves() { - if (deferredDeltas != null) { - try { - for (Command c : deferredDeltas) { - c.execute(); - } - } finally { - deferredDeltas = null; - } - } - } - - private void prune(Event.Type<?> type, Object source) { - Map<Object, List<?>> sourceMap = map.get(type); - - List<?> pruned = sourceMap.remove(source); - - assert pruned != null : "Can't prune what wasn't there"; - assert pruned.isEmpty() : "Pruned unempty list!"; - - if (sourceMap.isEmpty()) { - map.remove(type); - } - } -} \ No newline at end of file
diff --git a/user/src/com/google/web/bindery/event/shared/UmbrellaException.java b/user/src/com/google/web/bindery/event/shared/UmbrellaException.java deleted file mode 100644 index 3ed254b..0000000 --- a/user/src/com/google/web/bindery/event/shared/UmbrellaException.java +++ /dev/null
@@ -1,58 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import java.util.Collections; -import java.util.Set; - -/** - * A {@link RuntimeException} that collects a {@link Set} of child - * {@link Throwable}s together. Typically thrown after a loop, with all of the - * exceptions thrown during that loop, but delayed so that the loop finishes - * executing. - */ -public class UmbrellaException extends RuntimeException { - - private static final String MSG = - "One or more exceptions caught, see full set in UmbrellaException#getCauses"; - /** - * The causes of the exception. - */ - private Set<Throwable> causes; - - public UmbrellaException(Set<Throwable> causes) { - super(MSG, causes.size() == 0 ? null : causes.toArray(new Throwable[0])[0]); - this.causes = causes; - } - - /** - * Required for GWT RPC serialization. - */ - protected UmbrellaException() { - // Can't delegate to the other constructor or GWT RPC gets cranky - super(MSG); - this.causes = Collections.<Throwable> emptySet(); - } - - /** - * Get the set of exceptions that caused the failure. - * - * @return the set of causes - */ - public Set<Throwable> getCauses() { - return causes; - } -}
diff --git a/user/src/com/google/web/bindery/event/shared/testing/CountingEventBus.java b/user/src/com/google/web/bindery/event/shared/testing/CountingEventBus.java deleted file mode 100644 index 4b657a4..0000000 --- a/user/src/com/google/web/bindery/event/shared/testing/CountingEventBus.java +++ /dev/null
@@ -1,88 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared.testing; - -import com.google.web.bindery.event.shared.Event; -import com.google.web.bindery.event.shared.Event.Type; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; -import com.google.web.bindery.event.shared.SimpleEventBus; - -import java.util.HashMap; -import java.util.Map; - -/** - * Wraps an {@link EventBus} to keep a count of registered handlers. Handy for - * tests. - */ -public class CountingEventBus extends EventBus { - private final Map<Type<?>, Integer> counts = new HashMap<Event.Type<?>, Integer>(); - private final EventBus wrapped; - - public CountingEventBus() { - this(new SimpleEventBus()); - } - - public CountingEventBus(EventBus wrapped) { - this.wrapped = wrapped; - } - - @Override - public <H> HandlerRegistration addHandler(Type<H> type, H handler) { - increment(type); - final HandlerRegistration superReg = wrapped.addHandler(type, handler); - return makeReg(type, superReg); - } - - @Override - public <H> HandlerRegistration addHandlerToSource(final Type<H> type, Object source, H handler) { - increment(type); - final HandlerRegistration superReg = wrapped.addHandlerToSource(type, source, handler); - return makeReg(type, superReg); - } - - @Override - public void fireEvent(Event<?> event) { - wrapped.fireEvent(event); - } - - @Override - public void fireEventFromSource(Event<?> event, Object source) { - wrapped.fireEventFromSource(event, source); - } - - public int getCount(Type<?> type) { - Integer count = counts.get(type); - return count == null ? 0 : count; - } - - private void decrement(Type<?> type) { - counts.put(type, getCount(type) - 1); - } - - private <H> void increment(final Type<H> type) { - counts.put(type, getCount(type) + 1); - } - - private <H> HandlerRegistration makeReg(final Type<H> type, final HandlerRegistration superReg) { - return new HandlerRegistration() { - public void removeHandler() { - decrement(type); - superReg.removeHandler(); - } - }; - } -}
diff --git a/user/src/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryEditorDriver.java b/user/src/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryEditorDriver.java index e5535e2..4b25470 100644 --- a/user/src/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryEditorDriver.java +++ b/user/src/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryEditorDriver.java
@@ -17,7 +17,7 @@ import com.google.gwt.editor.client.Editor; import com.google.gwt.editor.client.EditorDriver; -import com.google.web.bindery.event.shared.EventBus; +import com.google.gwt.event.shared.EventBus; import com.google.web.bindery.requestfactory.shared.RequestContext; import com.google.web.bindery.requestfactory.shared.RequestFactory; import com.google.web.bindery.requestfactory.shared.Violation; @@ -87,15 +87,6 @@ String[] getPaths(); /** - * Initializes a driver that will not be able to support subscriptions. Calls - * to {@link com.google.gwt.editor.client.EditorDelegate#subscribe()} will do - * nothing. - * - * @param editor an {@link Editor} of type E - */ - void initialize(E editor); - - /** * Overload of {@link #initialize(RequestFactory, Editor)} to allow a modified * {@link EventBus} to be monitored for subscription services. * @@ -120,6 +111,15 @@ void initialize(RequestFactory requestFactory, E editor); /** + * Initializes a driver that will not be able to support subscriptions. Calls + * to {@link com.google.gwt.editor.client.EditorDelegate#subscribe()} will do + * nothing. + * + * @param editor an {@link Editor} of type E + */ + void initialize(E editor); + + /** * Show Violations returned from an attempt to submit a request. The * violations will be converted into * {@link com.google.gwt.editor.client.EditorError EditorError} objects whose
diff --git a/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractClientRequestFactory.java b/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractClientRequestFactory.java index b122674..15267b7 100644 --- a/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractClientRequestFactory.java +++ b/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractClientRequestFactory.java
@@ -15,7 +15,7 @@ */ package com.google.web.bindery.requestfactory.gwt.client.impl; -import com.google.web.bindery.event.shared.EventBus; +import com.google.gwt.event.shared.EventBus; import com.google.web.bindery.requestfactory.gwt.client.DefaultRequestTransport; import com.google.web.bindery.requestfactory.shared.impl.AbstractRequestFactory;
diff --git a/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractRequestFactoryEditorDriver.java b/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractRequestFactoryEditorDriver.java index 94f71ba..df21135 100644 --- a/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractRequestFactoryEditorDriver.java +++ b/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/AbstractRequestFactoryEditorDriver.java
@@ -25,7 +25,7 @@ import com.google.gwt.editor.client.impl.DelegateMap; import com.google.gwt.editor.client.impl.DelegateMap.KeyMethod; import com.google.gwt.editor.client.impl.SimpleViolation; -import com.google.web.bindery.event.shared.EventBus; +import com.google.gwt.event.shared.EventBus; import com.google.web.bindery.requestfactory.gwt.client.HasRequestContext; import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver; import com.google.web.bindery.requestfactory.shared.EntityProxy;
diff --git a/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/RequestFactoryEditorDelegate.java b/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/RequestFactoryEditorDelegate.java index 1acfcd3..7b8b3af 100644 --- a/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/RequestFactoryEditorDelegate.java +++ b/user/src/com/google/web/bindery/requestfactory/gwt/client/impl/RequestFactoryEditorDelegate.java
@@ -18,8 +18,8 @@ import com.google.gwt.editor.client.Editor; import com.google.gwt.editor.client.impl.AbstractEditorDelegate; import com.google.gwt.editor.client.impl.Refresher; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.web.bindery.requestfactory.shared.BaseProxy; import com.google.web.bindery.requestfactory.shared.EntityProxy; import com.google.web.bindery.requestfactory.shared.EntityProxyChange;
diff --git a/user/src/com/google/web/bindery/requestfactory/gwt/client/testing/MockRequestFactoryEditorDriver.java b/user/src/com/google/web/bindery/requestfactory/gwt/client/testing/MockRequestFactoryEditorDriver.java index 5cc2223..98da89c 100644 --- a/user/src/com/google/web/bindery/requestfactory/gwt/client/testing/MockRequestFactoryEditorDriver.java +++ b/user/src/com/google/web/bindery/requestfactory/gwt/client/testing/MockRequestFactoryEditorDriver.java
@@ -18,7 +18,7 @@ import com.google.gwt.editor.client.Editor; import com.google.gwt.editor.client.EditorError; import com.google.gwt.editor.client.EditorVisitor; -import com.google.web.bindery.event.shared.EventBus; +import com.google.gwt.event.shared.EventBus; import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver; import com.google.web.bindery.requestfactory.shared.RequestContext; import com.google.web.bindery.requestfactory.shared.RequestFactory;
diff --git a/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java b/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java index f1e4718..d3d609c 100644 --- a/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java +++ b/user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java
@@ -30,7 +30,7 @@ import com.google.gwt.dev.asm.commons.Method; import com.google.gwt.dev.util.Name; import com.google.gwt.dev.util.Util; -import com.google.web.bindery.event.shared.SimpleEventBus; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.web.bindery.requestfactory.server.RequestFactoryInterfaceValidator.ClassLoaderLoader; import com.google.web.bindery.requestfactory.server.RequestFactoryInterfaceValidator.ErrorContext; import com.google.web.bindery.requestfactory.server.RequestFactoryInterfaceValidator.Loader; @@ -529,7 +529,7 @@ typeName = type.getClassName(); } - public State call() { + public State call() throws Exception { ClassWriter writer = new ClassWriter(0); ClassVisitor cv = writer; cv = new ClassProcessor(typeName, cv, state);
diff --git a/user/src/com/google/web/bindery/requestfactory/shared/EntityProxyChange.java b/user/src/com/google/web/bindery/requestfactory/shared/EntityProxyChange.java index ab013cb..c146efb 100644 --- a/user/src/com/google/web/bindery/requestfactory/shared/EntityProxyChange.java +++ b/user/src/com/google/web/bindery/requestfactory/shared/EntityProxyChange.java
@@ -15,9 +15,10 @@ */ package com.google.web.bindery.requestfactory.shared; -import com.google.web.bindery.event.shared.Event; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HandlerRegistration; /** * Event posted by a {@link RequestFactory} when changes to an entity are @@ -35,14 +36,14 @@ * @see RequestFactory#find(EntityProxyId) */ public class EntityProxyChange<P extends EntityProxy> extends - Event<EntityProxyChange.Handler<P>> { + GwtEvent<EntityProxyChange.Handler<P>> { /** * Implemented by methods that handle EntityProxyChange events. * * @param <P> the proxy type */ - public interface Handler<P extends EntityProxy> { + public interface Handler<P extends EntityProxy> extends EventHandler { /** * Called when an {@link EntityProxyChange} event is fired. * @@ -86,11 +87,11 @@ /** * Returns the type associated with this instance. * - * @return an instance of {@link Event.Type Type} of type Handler<P> + * @return an instance of {@link com.google.gwt.event.shared.GwtEvent.Type Type} of type Handler<P> */ @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public Event.Type<Handler<P>> getAssociatedType() { + public GwtEvent.Type<Handler<P>> getAssociatedType() { /* * The instance knows its handler is of type P, but the TYPE field itself * does not, so we have to do an unsafe cast here.
diff --git a/user/src/com/google/web/bindery/requestfactory/shared/RequestFactory.java b/user/src/com/google/web/bindery/requestfactory/shared/RequestFactory.java index c265cd9..7f66954 100644 --- a/user/src/com/google/web/bindery/requestfactory/shared/RequestFactory.java +++ b/user/src/com/google/web/bindery/requestfactory/shared/RequestFactory.java
@@ -15,7 +15,7 @@ */ package com.google.web.bindery.requestfactory.shared; -import com.google.web.bindery.event.shared.EventBus; +import com.google.gwt.event.shared.EventBus; /** * Marker interface for the RequestFactory code generator.
diff --git a/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestContext.java b/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestContext.java index 0e10a3a..dd61fa2 100644 --- a/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestContext.java +++ b/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestContext.java
@@ -29,7 +29,7 @@ import com.google.web.bindery.autobean.shared.impl.AbstractAutoBean; import com.google.web.bindery.autobean.shared.impl.EnumMap; import com.google.web.bindery.autobean.shared.impl.StringQuoter; -import com.google.web.bindery.event.shared.UmbrellaException; +import com.google.gwt.event.shared.UmbrellaException; import com.google.web.bindery.requestfactory.shared.BaseProxy; import com.google.web.bindery.requestfactory.shared.EntityProxy; import com.google.web.bindery.requestfactory.shared.EntityProxyChange;
diff --git a/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestFactory.java b/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestFactory.java index 4b3d69e..a13e62d 100644 --- a/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestFactory.java +++ b/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestFactory.java
@@ -16,7 +16,7 @@ package com.google.web.bindery.requestfactory.shared.impl; import com.google.web.bindery.autobean.shared.AutoBeanFactory; -import com.google.web.bindery.event.shared.EventBus; +import com.google.gwt.event.shared.EventBus; import com.google.web.bindery.requestfactory.shared.EntityProxy; import com.google.web.bindery.requestfactory.shared.EntityProxyId; import com.google.web.bindery.requestfactory.shared.ProxySerializer;
diff --git a/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestFactory.java b/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestFactory.java index d9129c3..3d931ca 100644 --- a/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestFactory.java +++ b/user/src/com/google/web/bindery/requestfactory/vm/InProcessRequestFactory.java
@@ -19,7 +19,7 @@ import com.google.web.bindery.autobean.shared.AutoBeanFactory.Category; import com.google.web.bindery.autobean.shared.AutoBeanFactory.NoWrap; import com.google.web.bindery.autobean.vm.AutoBeanFactorySource; -import com.google.web.bindery.event.shared.EventBus; +import com.google.gwt.event.shared.EventBus; import com.google.web.bindery.requestfactory.shared.BaseProxy; import com.google.web.bindery.requestfactory.shared.EntityProxy; import com.google.web.bindery.requestfactory.shared.EntityProxyId; @@ -27,11 +27,11 @@ import com.google.web.bindery.requestfactory.shared.RequestContext; import com.google.web.bindery.requestfactory.shared.RequestFactory; import com.google.web.bindery.requestfactory.shared.ValueProxy; -import com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.Dialect; import com.google.web.bindery.requestfactory.shared.impl.AbstractRequestFactory; import com.google.web.bindery.requestfactory.shared.impl.BaseProxyCategory; import com.google.web.bindery.requestfactory.shared.impl.EntityProxyCategory; import com.google.web.bindery.requestfactory.shared.impl.ValueProxyCategory; +import com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.Dialect; import com.google.web.bindery.requestfactory.vm.InProcessRequestContext.RequestContextHandler; import java.lang.reflect.InvocationHandler;
diff --git a/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java b/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java index ea4ba53..7287d92 100644 --- a/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java +++ b/user/test/com/google/gwt/activity/shared/ActivityManagerTest.java
@@ -15,16 +15,17 @@ */ package com.google.gwt.activity.shared; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.UmbrellaException; +import com.google.gwt.event.shared.testing.CountingEventBus; import com.google.gwt.place.shared.Place; import com.google.gwt.place.shared.PlaceChangeEvent; import com.google.gwt.place.shared.PlaceChangeRequestEvent; import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.Widget; -import com.google.web.bindery.event.shared.Event; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.UmbrellaException; -import com.google.web.bindery.event.shared.testing.CountingEventBus; import junit.framework.TestCase; @@ -48,11 +49,11 @@ } } - private static class MyEvent extends Event<Handler> { - private static Event.Type<Handler> TYPE = new Event.Type<Handler>(); + private static class Event extends GwtEvent<Handler> { + private static GwtEvent.Type<EventHandler> TYPE = new GwtEvent.Type<EventHandler>(); @Override - public Event.Type<Handler> getAssociatedType() { + public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() { throw new UnsupportedOperationException("Auto-generated method stub"); } @@ -62,7 +63,7 @@ } } - private static class Handler { + private static class Handler implements EventHandler { }; private static class MyDisplay implements AcceptsOneWidget { @@ -260,29 +261,29 @@ public void testDropHandlersOnStop() { manager.setDisplay(realDisplay); - assertEquals(0, eventBus.getCount(MyEvent.TYPE)); + assertEquals(0, eventBus.getCount(Event.TYPE)); activity1 = new SyncActivity(null) { @Override public void start(AcceptsOneWidget panel, EventBus eventBus) { super.start(panel, eventBus); - bus.addHandler(MyEvent.TYPE, new Handler()); + bus.addHandler(Event.TYPE, new Handler()); } @Override public void onStop() { super.onStop(); - bus.addHandler(MyEvent.TYPE, new Handler()); + bus.addHandler(Event.TYPE, new Handler()); } }; PlaceChangeEvent event = new PlaceChangeEvent(place1); eventBus.fireEvent(event); - assertEquals(1, eventBus.getCount(MyEvent.TYPE)); + assertEquals(1, eventBus.getCount(Event.TYPE)); event = new PlaceChangeEvent(place2); eventBus.fireEvent(event); - assertEquals(0, eventBus.getCount(MyEvent.TYPE)); + assertEquals(0, eventBus.getCount(Event.TYPE)); // Make sure we didn't nuke the ActivityManager's own handlers assertEquals(1, eventBus.getCount(PlaceChangeEvent.TYPE)); @@ -309,12 +310,12 @@ @Override public void start(AcceptsOneWidget panel, EventBus eventBus) { super.start(panel, eventBus); - bus.addHandler(MyEvent.TYPE, new Handler()); + bus.addHandler(Event.TYPE, new Handler()); } @Override public void onStop() { super.onStop(); - bus.addHandler(MyEvent.TYPE, new Handler()); + bus.addHandler(Event.TYPE, new Handler()); throw new UnsupportedOperationException("Auto-generated method stub"); } }; @@ -332,7 +333,7 @@ try { PlaceChangeEvent event = new PlaceChangeEvent(place1); eventBus.fireEvent(event); - assertEquals(1, eventBus.getCount(MyEvent.TYPE)); + assertEquals(1, eventBus.getCount(Event.TYPE)); event = new PlaceChangeEvent(place2); eventBus.fireEvent(event); @@ -348,7 +349,7 @@ assertTrue(activity1.stopped); assertNotNull(activity2.display); - assertEquals(0, eventBus.getCount(MyEvent.TYPE)); + assertEquals(0, eventBus.getCount(Event.TYPE)); } /**
diff --git a/user/test/com/google/gwt/editor/rebind/model/EditorModelTest.java b/user/test/com/google/gwt/editor/rebind/model/EditorModelTest.java index 5746f56..1f1e329 100644 --- a/user/test/com/google/gwt/editor/rebind/model/EditorModelTest.java +++ b/user/test/com/google/gwt/editor/rebind/model/EditorModelTest.java
@@ -38,9 +38,9 @@ import com.google.gwt.editor.client.LeafValueEditor; import com.google.gwt.editor.client.ValueAwareEditor; import com.google.gwt.editor.client.adapters.SimpleEditor; +import com.google.gwt.event.shared.EventBus; import com.google.gwt.user.client.TakesValue; import com.google.gwt.user.client.ui.HasText; -import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver; import com.google.web.bindery.requestfactory.shared.EntityProxy; import com.google.web.bindery.requestfactory.shared.Request; @@ -503,7 +503,6 @@ assertNull(editorField.getSetterName()); } - @SuppressWarnings("deprecation") private Set<Resource> getJavaResources() { MockJavaResource[] javaFiles = {new MockJavaResource("t.AddressProxy") { @Override @@ -945,7 +944,6 @@ new RealJavaResource(EditorError.class), new EmptyMockJavaResource(EntityProxy.class), new EmptyMockJavaResource(EventBus.class), - new EmptyMockJavaResource(com.google.gwt.event.shared.EventBus.class), new EmptyMockJavaResource(HasEditorDelegate.class), new EmptyMockJavaResource(HasEditorErrors.class), new RealJavaResource(HasText.class),
diff --git a/user/test/com/google/gwt/event/shared/HandlerManagerTest.java b/user/test/com/google/gwt/event/shared/HandlerManagerTest.java index b003e32..7b96e17 100644 --- a/user/test/com/google/gwt/event/shared/HandlerManagerTest.java +++ b/user/test/com/google/gwt/event/shared/HandlerManagerTest.java
@@ -27,6 +27,7 @@ * Handler manager test. Very redundant with {@link SimpleEventBusTest}, but * preserved to guard against regressions. */ +@SuppressWarnings("deprecation") public class HandlerManagerTest extends HandlerTestBase { public void testAddAndRemoveHandlers() { @@ -351,7 +352,6 @@ assertFired(mouse1, mouse2, mouse3); } - @SuppressWarnings("deprecation") public void testNullSourceOkay() { SimpleEventBus reg = new SimpleEventBus();
diff --git a/user/test/com/google/gwt/event/shared/ResettableEventBusTest.java b/user/test/com/google/gwt/event/shared/ResettableEventBusTest.java index 0044a4c..9e14a8d 100644 --- a/user/test/com/google/gwt/event/shared/ResettableEventBusTest.java +++ b/user/test/com/google/gwt/event/shared/ResettableEventBusTest.java
@@ -24,7 +24,6 @@ * Eponymous unit test. */ public class ResettableEventBusTest extends HandlerTestBase { - public void testSimple() { CountingEventBus wrapped = new CountingEventBus(); ResettableEventBus subject = new ResettableEventBus(wrapped);
diff --git a/user/test/com/google/gwt/event/shared/SimpleEventBusTest.java b/user/test/com/google/gwt/event/shared/SimpleEventBusTest.java index 944cd77..3221e83 100644 --- a/user/test/com/google/gwt/event/shared/SimpleEventBusTest.java +++ b/user/test/com/google/gwt/event/shared/SimpleEventBusTest.java
@@ -17,22 +17,82 @@ package com.google.gwt.event.shared; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.DomEvent.Type; import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.MouseDownHandler; +import com.google.gwt.event.shared.testing.CountingEventBus; import junit.framework.AssertionFailedError; import java.util.Set; /** - * Eponymous unit test. Redundant with - * {@link com.google.web.bindery.event.shared.SimpleEventBusTest}, here to - * ensure legacy compatibility. + * Eponymous unit test. */ -@SuppressWarnings("deprecation") public class SimpleEventBusTest extends HandlerTestBase { + public void testAddAndRemoveHandlers() { + CountingEventBus eventBus = new CountingEventBus(new SimpleEventBus()); + eventBus.addHandler(MouseDownEvent.getType(), mouse1); + eventBus.addHandler(MouseDownEvent.getType(), mouse2); + HandlerRegistration reg1 = eventBus.addHandler(MouseDownEvent.getType(), + adaptor1); + eventBus.fireEvent(new MouseDownEvent() { + }); + assertEquals(3, eventBus.getCount(MouseDownEvent.getType())); + assertFired(mouse1, mouse2, adaptor1); + eventBus.addHandler(MouseDownEvent.getType(), mouse3); + assertEquals(4, eventBus.getCount(MouseDownEvent.getType())); + + eventBus.addHandler(MouseDownEvent.getType(), mouse1); + eventBus.addHandler(MouseDownEvent.getType(), mouse2); + HandlerRegistration reg2 = eventBus.addHandler(MouseDownEvent.getType(), + adaptor1); + + /* + * You can indeed add handlers twice, they will only be removed one at a + * time though. + */ + assertEquals(7, eventBus.getCount(MouseDownEvent.getType())); + eventBus.addHandler(ClickEvent.getType(), adaptor1); + eventBus.addHandler(ClickEvent.getType(), click1); + eventBus.addHandler(ClickEvent.getType(), click2); + + assertEquals(7, eventBus.getCount(MouseDownEvent.getType())); + assertEquals(3, eventBus.getCount(ClickEvent.getType())); + + reset(); + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(mouse1, mouse2, mouse3, adaptor1); + assertNotFired(click1, click2); + + // Gets rid of first instance. + reg1.removeHandler(); + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(mouse1, mouse2, mouse3, adaptor1); + assertNotFired(click1, click2); + + // Gets rid of second instance. + reg2.removeHandler(); + reset(); + eventBus.fireEvent(new MouseDownEvent() { + }); + + assertFired(mouse1, mouse2, mouse3); + assertNotFired(adaptor1, click1, click2); + + // Checks to see if click events are still working. + reset(); + eventBus.fireEvent(new ClickEvent() { + }); + + assertNotFired(mouse1, mouse2, mouse3); + assertFired(click1, click2, adaptor1); + } + public void testConcurrentAdd() { final SimpleEventBus eventBus = new SimpleEventBus(); final MouseDownHandler two = new MouseDownHandler() { @@ -70,6 +130,26 @@ } } + public void testConcurrentRemove() { + final SimpleEventBus eventBus = new SimpleEventBus(); + + ShyHandler h = new ShyHandler(); + + eventBus.addHandler(MouseDownEvent.getType(), mouse1); + h.r = eventBus.addHandler(MouseDownEvent.getType(), h); + eventBus.addHandler(MouseDownEvent.getType(), mouse2); + eventBus.addHandler(MouseDownEvent.getType(), mouse3); + + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(h, mouse1, mouse2, mouse3); + reset(); + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(mouse1, mouse2, mouse3); + assertNotFired(h); + } + class SourcedHandler implements MouseDownHandler { final String expectedSource; @@ -231,6 +311,109 @@ assertNotFired(two); } + public void testRemoveSelf() { + final SimpleEventBus eventBus = new SimpleEventBus(); + + MouseDownHandler h = new MouseDownHandler() { + HandlerRegistration reg = eventBus.addHandler(MouseDownEvent.getType(), + this); + + public void onMouseDown(MouseDownEvent event) { + add(this); + reg.removeHandler(); + } + }; + + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(h); + + reset(); + + eventBus.fireEvent(new MouseDownEvent() { + }); + assertNotFired(h); + } + + public void testNoDoubleRemove() { + final SimpleEventBus eventBus = new SimpleEventBus(); + HandlerRegistration reg = eventBus.addHandler(MouseDownEvent.getType(), + mouse1); + reg.removeHandler(); + + boolean assertsOn = getClass().desiredAssertionStatus(); + + if (assertsOn) { + try { + reg.removeHandler(); + fail("Should have thrown on remove"); + } catch (AssertionError e) { /* pass */ + } + } else { + reg.removeHandler(); + // Succeed on no assert failure + } + } + + public void testConcurrentAddAfterRemoveIsNotClobbered() { + final SimpleEventBus eventBus = new SimpleEventBus(); + + MouseDownHandler one = new MouseDownHandler() { + HandlerRegistration reg = addIt(); + + public void onMouseDown(MouseDownEvent event) { + reg.removeHandler(); + addIt(); + add(this); + } + + private HandlerRegistration addIt() { + return eventBus.addHandler(MouseDownEvent.getType(), mouse1); + } + }; + + eventBus.addHandler(MouseDownEvent.getType(), one); + + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(one); + + reset(); + + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(one, mouse1); + } + + public void testReverseOrder() { + @SuppressWarnings("deprecation") + final SimpleEventBus eventBus = new SimpleEventBus(true); + final MouseDownHandler handler0 = new MouseDownHandler() { + public void onMouseDown(MouseDownEvent event) { + add(this); + } + }; + final MouseDownHandler handler1 = new MouseDownHandler() { + public void onMouseDown(MouseDownEvent event) { + assertNotFired(handler0); + add(this); + } + }; + final MouseDownHandler handler2 = new MouseDownHandler() { + public void onMouseDown(MouseDownEvent event) { + assertNotFired(handler0, handler1); + add(this); + } + }; + eventBus.addHandler(MouseDownEvent.getType(), handler0); + eventBus.addHandler(MouseDownEvent.getType(), handler1); + eventBus.addHandler(MouseDownEvent.getType(), handler2); + + reset(); + eventBus.fireEvent(new MouseDownEvent() { + }); + assertFired(handler0, handler1, handler2); + } static class ThrowingHandler implements MouseDownHandler { private final RuntimeException e;
diff --git a/user/test/com/google/gwt/user/client/ui/WidgetTest.java b/user/test/com/google/gwt/user/client/ui/WidgetTest.java index 8a2d482..9d78fd7 100644 --- a/user/test/com/google/gwt/user/client/ui/WidgetTest.java +++ b/user/test/com/google/gwt/user/client/ui/WidgetTest.java
@@ -18,7 +18,6 @@ import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.junit.client.GWTTestCase; @@ -45,11 +44,13 @@ return "com.google.gwt.user.User"; } + @SuppressWarnings("deprecation") public void testCreateHandlerManager() { - final HandlerManager manager = new HandlerManager(null); + final com.google.gwt.event.shared.HandlerManager manager = new com.google.gwt.event.shared.HandlerManager( + null); Widget w = new Widget() { @Override - protected HandlerManager createHandlerManager() { + protected com.google.gwt.event.shared.HandlerManager createHandlerManager() { return manager; } };
diff --git a/user/test/com/google/web/bindery/event/shared/BarEvent.java b/user/test/com/google/web/bindery/event/shared/BarEvent.java deleted file mode 100644 index 35b21f9..0000000 --- a/user/test/com/google/web/bindery/event/shared/BarEvent.java +++ /dev/null
@@ -1,45 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -/** - * For {@link EventBus} tests. - */ -public class BarEvent extends Event<BarEvent.Handler> { - interface Handler { - void onBar(BarEvent e); - } - - static final Type<Handler> TYPE = new Type<Handler>(); - - public static HandlerRegistration register(EventBus bus, Handler handler) { - return bus.addHandler(TYPE, handler); - } - - public static HandlerRegistration register(EventBus bus, Object source, Handler handler) { - return bus.addHandlerToSource(TYPE, source, handler); - } - - @Override - public com.google.web.bindery.event.shared.Event.Type<Handler> getAssociatedType() { - return TYPE; - } - - @Override - protected void dispatch(Handler handler) { - handler.onBar(this); - } -}
diff --git a/user/test/com/google/web/bindery/event/shared/EventBusTestBase.java b/user/test/com/google/web/bindery/event/shared/EventBusTestBase.java deleted file mode 100644 index 129b182..0000000 --- a/user/test/com/google/web/bindery/event/shared/EventBusTestBase.java +++ /dev/null
@@ -1,138 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import junit.framework.TestCase; - -import java.util.HashSet; - -/** - * Support code for handler tests. - */ -public abstract class EventBusTestBase extends TestCase { - - class Adaptor implements FooEvent.Handler, BarEvent.Handler { - - public void onFoo(FooEvent event) { - add(this); - } - - public void onBar(BarEvent event) { - add(this); - } - - @Override - public String toString() { - return "adaptor 1"; - } - } - - Adaptor adaptor1 = new Adaptor(); - - private HashSet<Object> active = new HashSet<Object>(); - - FooEvent.Handler fooHandler1 = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - add(fooHandler1); - } - - @Override - public String toString() { - return "fooHandler 1"; - } - }; - - FooEvent.Handler fooHandler2 = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - add(fooHandler2); - } - - @Override - public String toString() { - return "fooHandler 2"; - } - }; - - FooEvent.Handler fooHandler3 = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - add(fooHandler3); - } - - @Override - public String toString() { - return "fooHandler 3"; - } - }; - - BarEvent.Handler barHandler1 = new BarEvent.Handler() { - - public void onBar(BarEvent event) { - add(barHandler1); - } - - @Override - public String toString() { - return "barHandler 1"; - } - }; - - BarEvent.Handler barHandler2 = new BarEvent.Handler() { - - public void onBar(BarEvent event) { - add(barHandler2); - } - - @Override - public String toString() { - return "barHandler 2"; - } - }; - - BarEvent.Handler barHandler3 = new BarEvent.Handler() { - - public void onBar(BarEvent event) { - add(barHandler3); - } - - @Override - public String toString() { - return "barHandler 3"; - } - }; - - void add(Object handler) { - active.add(handler); - } - - void assertFired(Object... handler) { - for (int i = 0; i < handler.length; i++) { - assertTrue(handler[i] + " should have fired", active.contains(handler[i])); - } - } - - void assertNotFired(Object... handler) { - for (int i = 0; i < handler.length; i++) { - assertFalse(handler[i] + " should not have fired", - active.contains(handler[i])); - } - } - - void reset() { - active.clear(); - } - -}
diff --git a/user/test/com/google/web/bindery/event/shared/EventSharedSuite.java b/user/test/com/google/web/bindery/event/shared/EventSharedSuite.java deleted file mode 100644 index cf26579..0000000 --- a/user/test/com/google/web/bindery/event/shared/EventSharedSuite.java +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Tests of shared Event code. - */ -public class EventSharedSuite { - public static Test suite() { - TestSuite suite = new TestSuite("Tests of shared Event code"); - - suite.addTestSuite(SimpleEventBusTest.class); - suite.addTestSuite(ResettableEventBusTest.class); - - return suite; - } - - private EventSharedSuite() { - } -}
diff --git a/user/test/com/google/web/bindery/event/shared/FooEvent.java b/user/test/com/google/web/bindery/event/shared/FooEvent.java deleted file mode 100644 index a63f53a..0000000 --- a/user/test/com/google/web/bindery/event/shared/FooEvent.java +++ /dev/null
@@ -1,45 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -/** - * For {@link EventBus} tests. - */ -public class FooEvent extends Event<FooEvent.Handler> { - interface Handler { - void onFoo(FooEvent e); - } - - static final Type<Handler> TYPE = new Type<Handler>(); - - public static HandlerRegistration register(EventBus bus, Handler handler) { - return bus.addHandler(TYPE, handler); - } - - public static HandlerRegistration register(EventBus bus, Object source, Handler handler) { - return bus.addHandlerToSource(TYPE, source, handler); - } - - @Override - public com.google.web.bindery.event.shared.Event.Type<Handler> getAssociatedType() { - return TYPE; - } - - @Override - protected void dispatch(Handler handler) { - handler.onFoo(this); - } -}
diff --git a/user/test/com/google/web/bindery/event/shared/ResettableEventBusTest.java b/user/test/com/google/web/bindery/event/shared/ResettableEventBusTest.java deleted file mode 100644 index b8591a8..0000000 --- a/user/test/com/google/web/bindery/event/shared/ResettableEventBusTest.java +++ /dev/null
@@ -1,171 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import com.google.web.bindery.event.shared.testing.CountingEventBus; - -/** - * Eponymous unit test. - */ -public class ResettableEventBusTest extends EventBusTestBase { - public void testSimple() { - CountingEventBus wrapped = new CountingEventBus(); - ResettableEventBus subject = new ResettableEventBus(wrapped); - - Event.Type<FooEvent.Handler> type = FooEvent.TYPE; - - assertEquals(0, wrapped.getCount(type)); - - subject.addHandler(type, fooHandler1); - subject.addHandlerToSource(type, "baker", fooHandler2); - subject.addHandler(type, fooHandler3); - - assertEquals(3, wrapped.getCount(type)); - - subject.fireEvent(new FooEvent()); - assertFired(fooHandler1, fooHandler3); - assertNotFired(fooHandler2); - - reset(); - - subject.fireEventFromSource(new FooEvent(), "baker"); - assertFired(fooHandler1, fooHandler2, fooHandler3); - - reset(); - - subject.removeHandlers(); - assertEquals(0, wrapped.getCount(type)); - - subject.fireEvent(new FooEvent()); - assertNotFired(fooHandler1, fooHandler2, fooHandler3); - } - - public void testNestedResetInnerFirst() { - CountingEventBus wrapped = new CountingEventBus(); - ResettableEventBus wideScope = new ResettableEventBus(wrapped); - ResettableEventBus narrowScope = new ResettableEventBus(wideScope); - - Event.Type<FooEvent.Handler> type = FooEvent.TYPE; - - wideScope.addHandler(type, fooHandler1); - narrowScope.addHandler(type, fooHandler2); - - wrapped.fireEvent(new FooEvent()); - assertFired(fooHandler1, fooHandler2); - - reset(); - - /* - * When I remove handlers from the narrow resettable, it should have no - * effect on handlers registered with the wider instance. - */ - - narrowScope.removeHandlers(); - - wrapped.fireEvent(new FooEvent()); - assertFired(fooHandler1); - assertNotFired(fooHandler2); - } - - public void testNestedResetOuterFirst() { - CountingEventBus wrapped = new CountingEventBus(); - ResettableEventBus wideScope = new ResettableEventBus(wrapped); - ResettableEventBus narrowScope = new ResettableEventBus(wideScope); - - Event.Type<FooEvent.Handler> type = FooEvent.TYPE; - - wideScope.addHandler(type, fooHandler1); - narrowScope.addHandler(type, fooHandler2); - - wrapped.fireEvent(new FooEvent()); - assertFired(fooHandler1, fooHandler2); - - reset(); - - /* - * When I remove handlers from the first resettable, handlers registered by - * the narrower scoped one that wraps it should also be severed. - */ - - wideScope.removeHandlers(); - - wrapped.fireEvent(new FooEvent()); - assertNotFired(fooHandler1); - assertNotFired(fooHandler2); - } - - public void testManualRemoveMemory() { - SimpleEventBus eventBus = new SimpleEventBus(); - ResettableEventBus subject = new ResettableEventBus(eventBus); - - Event.Type<FooEvent.Handler> type = FooEvent.TYPE; - - HandlerRegistration registration1 = subject.addHandler(type, fooHandler1); - HandlerRegistration registration2 = subject.addHandler(type, fooHandler2); - HandlerRegistration registration3 = subject.addHandler(type, fooHandler3); - - registration1.removeHandler(); - registration2.removeHandler(); - registration3.removeHandler(); - - /* - * removing handlers manually should remove registration from the internal - * set. - */ - - assertEquals(0, subject.getRegistrationSize()); - - subject.removeHandlers(); - - // Expect nothing to happen. Especially no exceptions. - registration1.removeHandler(); - } - - public void testNestedRemoveMemory() { - SimpleEventBus eventBus = new SimpleEventBus(); - ResettableEventBus wideScope = new ResettableEventBus(eventBus); - ResettableEventBus narrowScope = new ResettableEventBus(wideScope); - - Event.Type<FooEvent.Handler> type = FooEvent.TYPE; - - wideScope.addHandler(type, fooHandler1); - narrowScope.addHandler(type, fooHandler2); - narrowScope.addHandler(type, fooHandler3); - - narrowScope.removeHandlers(); - wideScope.removeHandlers(); - - /* - * Internal registeration should be empty after calling removeHandlers - */ - - assertEquals(0, wideScope.getRegistrationSize()); - assertEquals(0, narrowScope.getRegistrationSize()); - - wideScope.addHandler(type, fooHandler1); - narrowScope.addHandler(type, fooHandler2); - - /* - * Reverse remove order - */ - - wideScope.removeHandlers(); - narrowScope.removeHandlers(); - - assertEquals(0, wideScope.getRegistrationSize()); - assertEquals(0, narrowScope.getRegistrationSize()); - } -}
diff --git a/user/test/com/google/web/bindery/event/shared/SimpleEventBusTest.java b/user/test/com/google/web/bindery/event/shared/SimpleEventBusTest.java deleted file mode 100644 index 29e6541..0000000 --- a/user/test/com/google/web/bindery/event/shared/SimpleEventBusTest.java +++ /dev/null
@@ -1,449 +0,0 @@ -/* - * Copyright 2011 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.web.bindery.event.shared; - -import com.google.web.bindery.event.shared.testing.CountingEventBus; - -import junit.framework.AssertionFailedError; - -import java.util.Set; - -/** - * Eponymous unit test. - */ -public class SimpleEventBusTest extends EventBusTestBase { - - interface Command { - void execute(); - } - - class ShyHandler implements FooEvent.Handler { - HandlerRegistration r; - - public void onFoo(FooEvent event) { - add(this); - r.removeHandler(); - } - } - - class SourcedHandler implements FooEvent.Handler { - final String expectedSource; - - SourcedHandler(String source) { - this.expectedSource = source; - } - - public void onFoo(FooEvent event) { - add(this); - assertEquals(expectedSource, event.getSource()); - } - } - - static class ThrowingHandler implements FooEvent.Handler { - private final RuntimeException e; - - public ThrowingHandler(RuntimeException e) { - this.e = e; - } - - public void onFoo(FooEvent event) { - throw e; - } - } - - public void testAddAndRemoveHandlers() { - CountingEventBus eventBus = new CountingEventBus(new SimpleEventBus()); - FooEvent.register(eventBus, fooHandler1); - FooEvent.register(eventBus, fooHandler2); - HandlerRegistration reg1 = FooEvent.register(eventBus, adaptor1); - eventBus.fireEvent(new FooEvent()); - assertEquals(3, eventBus.getCount(FooEvent.TYPE)); - assertFired(fooHandler1, fooHandler2, adaptor1); - FooEvent.register(eventBus, fooHandler3); - assertEquals(4, eventBus.getCount(FooEvent.TYPE)); - - FooEvent.register(eventBus, fooHandler1); - FooEvent.register(eventBus, fooHandler2); - HandlerRegistration reg2 = FooEvent.register(eventBus, adaptor1); - - /* - * You can indeed add handlers twice, they will only be removed one at a - * time though. - */ - assertEquals(7, eventBus.getCount(FooEvent.TYPE)); - eventBus.addHandler(BarEvent.TYPE, adaptor1); - eventBus.addHandler(BarEvent.TYPE, barHandler1); - eventBus.addHandler(BarEvent.TYPE, barHandler2); - - assertEquals(7, eventBus.getCount(FooEvent.TYPE)); - assertEquals(3, eventBus.getCount(BarEvent.TYPE)); - - reset(); - eventBus.fireEvent(new FooEvent()); - assertFired(fooHandler1, fooHandler2, fooHandler3, adaptor1); - assertNotFired(barHandler1, barHandler2); - - // Gets rid of first instance. - reg1.removeHandler(); - eventBus.fireEvent(new FooEvent()); - assertFired(fooHandler1, fooHandler2, fooHandler3, adaptor1); - assertNotFired(barHandler1, barHandler2); - - // Gets rid of second instance. - reg2.removeHandler(); - reset(); - eventBus.fireEvent(new FooEvent()); - - assertFired(fooHandler1, fooHandler2, fooHandler3); - assertNotFired(adaptor1, barHandler1, barHandler2); - - // Checks to see if barHandler events are still working. - reset(); - eventBus.fireEvent(new BarEvent()); - - assertNotFired(fooHandler1, fooHandler2, fooHandler3); - assertFired(barHandler1, barHandler2, adaptor1); - } - - public void testAssertThrowsNpe() { - final SimpleEventBus eventBus = new SimpleEventBus(); - - try { - assertThrowsNpe(new Command() { - public void execute() { - FooEvent.register(eventBus, fooHandler1); - } - }); - fail("expected AssertionFailedError"); - } catch (AssertionFailedError e) { - /* pass */ - } - } - - public void testConcurrentAdd() { - final SimpleEventBus eventBus = new SimpleEventBus(); - final FooEvent.Handler two = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - add(this); - } - }; - FooEvent.Handler one = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - FooEvent.register(eventBus, two); - add(this); - } - }; - FooEvent.register(eventBus, one); - FooEvent.register(eventBus, fooHandler1); - FooEvent.register(eventBus, fooHandler2); - FooEvent.register(eventBus, fooHandler3); - eventBus.fireEvent(new FooEvent()); - assertFired(one, fooHandler1, fooHandler2, fooHandler3); - assertNotFired(two); - - reset(); - eventBus.fireEvent(new FooEvent()); - assertFired(one, two, fooHandler1, fooHandler2, fooHandler3); - } - - public void testConcurrentAddAfterRemoveIsNotClobbered() { - final SimpleEventBus eventBus = new SimpleEventBus(); - - FooEvent.Handler one = new FooEvent.Handler() { - HandlerRegistration reg = addIt(); - - public void onFoo(FooEvent event) { - reg.removeHandler(); - addIt(); - add(this); - } - - private HandlerRegistration addIt() { - return FooEvent.register(eventBus, fooHandler1); - } - }; - - FooEvent.register(eventBus, one); - - eventBus.fireEvent(new FooEvent()); - assertFired(one); - - reset(); - - eventBus.fireEvent(new FooEvent()); - assertFired(one, fooHandler1); - } - - public void testConcurrentAddAndRemoveByNastyUsersTryingToHurtUs() { - final SimpleEventBus eventBus = new SimpleEventBus(); - final FooEvent.Handler two = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - add(this); - } - - @Override - public String toString() { - return "two"; - } - }; - FooEvent.Handler one = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - FooEvent.register(eventBus, two).removeHandler(); - add(this); - } - - @Override - public String toString() { - return "one"; - } - }; - FooEvent.register(eventBus, one); - FooEvent.register(eventBus, fooHandler1); - FooEvent.register(eventBus, fooHandler2); - FooEvent.register(eventBus, fooHandler3); - eventBus.fireEvent(new FooEvent()); - assertFired(one, fooHandler1, fooHandler2, fooHandler3); - assertNotFired(two); - - reset(); - eventBus.fireEvent(new FooEvent()); - assertFired(one, fooHandler1, fooHandler2, fooHandler3); - assertNotFired(two); - } - - public void testConcurrentRemove() { - final SimpleEventBus eventBus = new SimpleEventBus(); - - ShyHandler h = new ShyHandler(); - - FooEvent.register(eventBus, fooHandler1); - h.r = FooEvent.register(eventBus, h); - FooEvent.register(eventBus, fooHandler2); - FooEvent.register(eventBus, fooHandler3); - - eventBus.fireEvent(new FooEvent()); - assertFired(h, fooHandler1, fooHandler2, fooHandler3); - reset(); - eventBus.fireEvent(new FooEvent()); - assertFired(fooHandler1, fooHandler2, fooHandler3); - assertNotFired(h); - } - - public void testFromSource() { - final SimpleEventBus eventBus = new SimpleEventBus(); - - SourcedHandler global = new SourcedHandler("able"); - SourcedHandler able = new SourcedHandler("able"); - SourcedHandler baker = new SourcedHandler("baker"); - - FooEvent.register(eventBus, global); - FooEvent.register(eventBus, "able", able); - FooEvent.register(eventBus, "baker", baker); - - eventBus.fireEventFromSource(new FooEvent(), "able"); - assertFired(global, able); - assertNotFired(baker); - } - - public void testHandlersThrow() { - RuntimeException exception1 = new RuntimeException("first exception"); - RuntimeException exception2 = new RuntimeException("second exception"); - - final SimpleEventBus eventBus = new SimpleEventBus(); - - FooEvent.register(eventBus, fooHandler1); - FooEvent.register(eventBus, new ThrowingHandler(exception1)); - FooEvent.register(eventBus, fooHandler2); - FooEvent.register(eventBus, new ThrowingHandler(exception2)); - FooEvent.register(eventBus, fooHandler3); - - FooEvent event = new FooEvent(); - - try { - eventBus.fireEvent(event); - fail("eventBus should have thrown"); - } catch (UmbrellaException e) { - Set<Throwable> causes = e.getCauses(); - assertEquals("Exception should wrap the two thrown exceptions", 2, causes.size()); - assertTrue("First exception should be under the umbrella", causes.contains(exception1)); - assertTrue("Second exception should be under the umbrella", causes.contains(exception2)); - } - - /* - * Exception should not have prevented all three mouse handlers from getting - * the event. - */ - assertFired(fooHandler1, fooHandler2, fooHandler3); - } - - public void testNoDoubleRemove() { - final SimpleEventBus eventBus = new SimpleEventBus(); - HandlerRegistration reg = FooEvent.register(eventBus, fooHandler1); - reg.removeHandler(); - - boolean assertsOn = getClass().desiredAssertionStatus(); - - if (assertsOn) { - try { - reg.removeHandler(); - fail("Should have thrown on remove"); - } catch (AssertionError e) { /* pass */ - } - } else { - reg.removeHandler(); - // Succeed on no assert failure - } - } - - public void testNoSource() { - final SimpleEventBus eventBus = new SimpleEventBus(); - - SourcedHandler global = new SourcedHandler(null); - SourcedHandler able = new SourcedHandler("able"); - SourcedHandler baker = new SourcedHandler("baker"); - - FooEvent.register(eventBus, global); - FooEvent.register(eventBus, "able", able); - FooEvent.register(eventBus, "baker", baker); - - eventBus.fireEvent(new FooEvent()); - assertFired(global); - assertNotFired(able, baker); - } - - public void testNullChecks() { - final SimpleEventBus eventBus = new SimpleEventBus(); - assertThrowsNpe(new Command() { - public void execute() { - eventBus.addHandler(null, fooHandler1); - } - }); - - assertThrowsNpe(new Command() { - public void execute() { - FooEvent.register(eventBus, "foo", null); - } - }); - assertThrowsNpe(new Command() { - public void execute() { - FooEvent.register(eventBus, null, fooHandler1); - } - }); - assertThrowsNpe(new Command() { - public void execute() { - eventBus.addHandlerToSource(null, "foo", fooHandler1); - } - }); - - assertThrowsNpe(new Command() { - public void execute() { - eventBus.fireEvent(null); - } - }); - - assertThrowsNpe(new Command() { - public void execute() { - eventBus.fireEventFromSource(null, ""); - } - }); - - assertThrowsNpe(new Command() { - public void execute() { - eventBus.fireEventFromSource(new FooEvent() { - }, null); - } - }); - assertThrowsNpe(new Command() { - public void execute() { - eventBus.fireEventFromSource(null, "baker"); - } - }); - } - - public void testNullSourceOkay() { - SimpleEventBus reg = new SimpleEventBus(); - - FooEvent.Handler handler = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - add(this); - assertNull(event.getSource()); - } - }; - reg.addHandler(FooEvent.TYPE, handler); - reg.fireEvent(new FooEvent()); - assertFired(handler); - } - - public void testRemoveSelf() { - final SimpleEventBus eventBus = new SimpleEventBus(); - - FooEvent.Handler h = new FooEvent.Handler() { - HandlerRegistration reg = FooEvent.register(eventBus, this); - - public void onFoo(FooEvent event) { - add(this); - reg.removeHandler(); - } - }; - - eventBus.fireEvent(new FooEvent()); - assertFired(h); - - reset(); - - eventBus.fireEvent(new FooEvent()); - assertNotFired(h); - } - - public void testReverseOrder() { - @SuppressWarnings("deprecation") - final SimpleEventBus eventBus = new SimpleEventBus(true); - final FooEvent.Handler handler0 = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - add(this); - } - }; - final FooEvent.Handler handler1 = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - assertNotFired(handler0); - add(this); - } - }; - final FooEvent.Handler handler2 = new FooEvent.Handler() { - public void onFoo(FooEvent event) { - assertNotFired(handler0, handler1); - add(this); - } - }; - FooEvent.register(eventBus, handler0); - FooEvent.register(eventBus, handler1); - FooEvent.register(eventBus, handler2); - - reset(); - eventBus.fireEvent(new FooEvent()); - assertFired(handler0, handler1, handler2); - } - - private void assertThrowsNpe(Command command) { - try { - command.execute(); - fail("expected NullPointerException"); - } catch (NullPointerException e) { - /* pass */ - } - } -}
diff --git a/user/test/com/google/web/bindery/requestfactory/gwt/client/FindServiceTest.java b/user/test/com/google/web/bindery/requestfactory/gwt/client/FindServiceTest.java index ca82e36..de1aab9 100644 --- a/user/test/com/google/web/bindery/requestfactory/gwt/client/FindServiceTest.java +++ b/user/test/com/google/web/bindery/requestfactory/gwt/client/FindServiceTest.java
@@ -15,7 +15,7 @@ */ package com.google.web.bindery.requestfactory.gwt.client; -import com.google.web.bindery.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.web.bindery.requestfactory.shared.EntityProxyChange; import com.google.web.bindery.requestfactory.shared.EntityProxyId; import com.google.web.bindery.requestfactory.shared.Receiver;
diff --git a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryExceptionPropagationTest.java b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryExceptionPropagationTest.java index 48482c7..45cf3d8 100644 --- a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryExceptionPropagationTest.java +++ b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryExceptionPropagationTest.java
@@ -16,7 +16,7 @@ package com.google.web.bindery.requestfactory.gwt.client; import com.google.gwt.core.client.GWT; -import com.google.web.bindery.event.shared.UmbrellaException; +import com.google.gwt.event.shared.UmbrellaException; import com.google.web.bindery.requestfactory.shared.Receiver; import com.google.web.bindery.requestfactory.shared.RequestContext; import com.google.web.bindery.requestfactory.shared.ServerFailure; @@ -302,7 +302,7 @@ } @Override - protected void gwtTearDown() { + protected void gwtTearDown() throws Exception { GWT.setUncaughtExceptionHandler(defaultUncaughtExceptionHandler); } }
diff --git a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryPolymorphicTest.java b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryPolymorphicTest.java index 83baef3..1e0fa52 100644 --- a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryPolymorphicTest.java +++ b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryPolymorphicTest.java
@@ -16,9 +16,9 @@ package com.google.web.bindery.requestfactory.gwt.client; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.junit.client.GWTTestCase; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.SimpleEventBus; import com.google.web.bindery.requestfactory.shared.SimpleFooProxy; import com.google.web.bindery.requestfactory.shared.TestRequestFactory;
diff --git a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTestBase.java b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTestBase.java index cac062b..02a347b 100644 --- a/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTestBase.java +++ b/user/test/com/google/web/bindery/requestfactory/gwt/client/RequestFactoryTestBase.java
@@ -15,12 +15,12 @@ */ package com.google.web.bindery.requestfactory.gwt.client; -import com.google.gwt.core.client.GWT; -import com.google.gwt.junit.client.GWTTestCase; import com.google.web.bindery.autobean.shared.AutoBean; import com.google.web.bindery.autobean.shared.AutoBeanUtils; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.SimpleEventBus; +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.SimpleEventBus; +import com.google.gwt.junit.client.GWTTestCase; import com.google.web.bindery.requestfactory.shared.BaseProxy; import com.google.web.bindery.requestfactory.shared.DefaultProxyStore; import com.google.web.bindery.requestfactory.shared.EntityProxy;
diff --git a/user/test/com/google/web/bindery/requestfactory/gwt/client/SimpleRequestFactoryInstance.java b/user/test/com/google/web/bindery/requestfactory/gwt/client/SimpleRequestFactoryInstance.java index da4c61e..daaf415 100644 --- a/user/test/com/google/web/bindery/requestfactory/gwt/client/SimpleRequestFactoryInstance.java +++ b/user/test/com/google/web/bindery/requestfactory/gwt/client/SimpleRequestFactoryInstance.java
@@ -16,7 +16,7 @@ package com.google.web.bindery.requestfactory.gwt.client; import com.google.gwt.core.client.GWT; -import com.google.web.bindery.event.shared.SimpleEventBus; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.web.bindery.requestfactory.shared.SimpleRequestFactory; /**
diff --git a/user/test/com/google/web/bindery/requestfactory/server/BoxesAndPrimitivesJreTest.java b/user/test/com/google/web/bindery/requestfactory/server/BoxesAndPrimitivesJreTest.java index c38d6c5..74e26a4 100644 --- a/user/test/com/google/web/bindery/requestfactory/server/BoxesAndPrimitivesJreTest.java +++ b/user/test/com/google/web/bindery/requestfactory/server/BoxesAndPrimitivesJreTest.java
@@ -113,7 +113,7 @@ } @Override - protected void gwtSetUp() { + protected void gwtSetUp() throws Exception { super.gwtSetUp(); errors = new VisibleErrorContext(Logger.getAnonymousLogger()); v = new RequestFactoryInterfaceValidator(errors,
diff --git a/user/test/com/google/web/bindery/requestfactory/server/RequestFactoryJreTest.java b/user/test/com/google/web/bindery/requestfactory/server/RequestFactoryJreTest.java index d17b608..dbe0645 100644 --- a/user/test/com/google/web/bindery/requestfactory/server/RequestFactoryJreTest.java +++ b/user/test/com/google/web/bindery/requestfactory/server/RequestFactoryJreTest.java
@@ -15,8 +15,8 @@ */ package com.google.web.bindery.requestfactory.server; -import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.SimpleEventBus; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.web.bindery.requestfactory.gwt.client.RequestFactoryTest; import com.google.web.bindery.requestfactory.server.testing.InProcessRequestTransport; import com.google.web.bindery.requestfactory.shared.RequestFactory;
diff --git a/user/test/com/google/web/bindery/requestfactory/shared/BoxesAndPrimitivesTest.java b/user/test/com/google/web/bindery/requestfactory/shared/BoxesAndPrimitivesTest.java index 87f962e..2d3fde4 100644 --- a/user/test/com/google/web/bindery/requestfactory/shared/BoxesAndPrimitivesTest.java +++ b/user/test/com/google/web/bindery/requestfactory/shared/BoxesAndPrimitivesTest.java
@@ -16,8 +16,8 @@ package com.google.web.bindery.requestfactory.shared; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.junit.client.GWTTestCase; -import com.google.web.bindery.event.shared.SimpleEventBus; /** * Contains a set of checks of how primitive and boxed method declarations @@ -224,7 +224,7 @@ } @Override - protected void gwtSetUp() { + protected void gwtSetUp() throws Exception { factory = createFactory(); }
diff --git a/user/test/com/google/web/bindery/requestfactory/shared/ComplexKeysTest.java b/user/test/com/google/web/bindery/requestfactory/shared/ComplexKeysTest.java index 8c43a16..7184cd9 100644 --- a/user/test/com/google/web/bindery/requestfactory/shared/ComplexKeysTest.java +++ b/user/test/com/google/web/bindery/requestfactory/shared/ComplexKeysTest.java
@@ -16,8 +16,8 @@ package com.google.web.bindery.requestfactory.shared; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.junit.client.GWTTestCase; -import com.google.web.bindery.event.shared.SimpleEventBus; /** * Tests the use of non-trivial EntityProxy and ValueProxy key types. @@ -213,7 +213,7 @@ } @Override - protected void gwtSetUp() { + protected void gwtSetUp() throws Exception { factory = createFactory(); }
diff --git a/user/test/com/google/web/bindery/requestfactory/shared/LocatorTest.java b/user/test/com/google/web/bindery/requestfactory/shared/LocatorTest.java index 632ffb7..14376bd 100644 --- a/user/test/com/google/web/bindery/requestfactory/shared/LocatorTest.java +++ b/user/test/com/google/web/bindery/requestfactory/shared/LocatorTest.java
@@ -16,8 +16,8 @@ package com.google.web.bindery.requestfactory.shared; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.junit.client.GWTTestCase; -import com.google.web.bindery.event.shared.SimpleEventBus; /** * Tests the use of Locator objects. @@ -120,7 +120,7 @@ } @Override - protected void gwtSetUp() { + protected void gwtSetUp() throws Exception { factory = createFactory(); }
diff --git a/user/test/com/google/web/bindery/requestfactory/shared/ServiceInheritanceTest.java b/user/test/com/google/web/bindery/requestfactory/shared/ServiceInheritanceTest.java index ee604b9..f4df2e6 100644 --- a/user/test/com/google/web/bindery/requestfactory/shared/ServiceInheritanceTest.java +++ b/user/test/com/google/web/bindery/requestfactory/shared/ServiceInheritanceTest.java
@@ -16,8 +16,8 @@ package com.google.web.bindery.requestfactory.shared; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.junit.client.GWTTestCase; -import com.google.web.bindery.event.shared.SimpleEventBus; /** * Tests the ability of instance services to inherit methods