Let’s first separate interfaces from classes.
Interfaces are great for mocking (thus allowing for testing your app without the need for the sluggish
IsWidget: when all you need is a handle on a widget, without depending on the
Widgetclass. This is typically used with MVP as a way to represent the view.
AcceptsOneWidget: when you need a placeholder for a single widget (in the form of an
IsWidget). This is typically used with Activities, to insert the view (
IsWidget) into the given slot(
The classes you list all extend
Widget, so they rely on JSNI and (most of the time) need to run in aGWT environment (for unit tests, that means a
Widget: the base of all widgets. Implements
IsWidgetreturning itself from
Composite: a base class when you need to create a widget built from other widgets while hiding their implementation. While you could extend an existing widget, it’s generally better to hide it inside a
Compositeso you only expose the API you need/want to expose.
Compositeis about “composition rather than inheritance” and encapsulation. Examples of composites in standard widgets include
TabPanel(built from a
DateBox(built from a
ValueListBoxthat wraps a
ValuePickerthat wraps a
CellList. In many cases, given that panels accept
IsWidgetchildren, you could simply implement
Composite, but it’s sometimes useful to have a true
SimplePanela panel that implements
AcceptsOneWidget, useful as a slot when using activities (but you could also easily implement
AcceptsOneWidgetto insert into any kind of panel)
That being said, Google recently open-sourced GWT-Mockito that plugs Mockito into
GWT.create()and uses classloader magic to rewrite JSNI methods and remove
final modifiers so you can directly use widgets in tests without the need for
GWTTestCase or MVP.
So, all in all, it depends how you approach your code, how you architecture your app. If you use MVP, stick to depending on interfaces only (
AcceptsOneWidget) in your presenter so you can easily mock your view in your tests.
Otherwise, or if you want a “simplified MVP” where the view is a UiBinder template, try GWT-Mockito for your tests and directly use widgets.
Of course, you can mix both approaches in the same application. And in any case, build your own widgets as
Widgets for low-level things (rarely needed), and
IsWidgets for everything else, rather than extending existing widgets.