Let me see if I understand this Type 1/2 discussion correctly:
yes, the short Has* interfaces are a bit of a pain: awkward names, mass of
small interfaces, must-use of class generics if you need to more Has*
interfaces.
Buttt, they make them very nice manageable through general Utils* methods..
For example: My root IsWidget interface:
----
public interface FlexWidget extends IsWidget, AsIsWidget, HasTitle,
HasVisible, HasStyleName, HasEnabled, HasEnsureDebugId, HasEventManagement
{}
----
And The HasStyleName look like:
----
public interface HasStyleName extends HasAddStyleName {
void setStyleName(final String style);
String getStyleName();
void removeStyleName(final String style);
}
---
In the UtilsWidget class I have all kind of methods like:
----
public static <W extends HasAddStyleName > W addStyle(final W widget, final
String styleName) {
if (isNotNull(widget)) {
widget.addStyleName(styleName);
}
return widget;
}
public static <W extends HasStyleName> W setStyle(final W widget, final
String styleName) {
if (isNotNull(widget)) {
widget.setStyleName(styleName);
}
return widget;
}
public static <W extends HasEnsureDebugId> W ensureDebugId(final W widget,
final String debugId) {
if (isNotNull(widget)) {
widget.ensureDebugId(debugId);
}
return widget;
}
----
This makes coding safe, short and easy to understand/maintain (fluent
coding)...
Concerning implementation:
If you create a Is* widget like IsButton you have to think about when to
create the contains Widget variant like the Button class. I want to do this
as lazy as possible...
So the question is, if you call IsButton.addStyle(String), do you forward
this directly to the contained Button or do you buffer it? I buffer it,
such that I can run these operations in unit tests (not GWTTestCase...
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "GWT
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.