Revision: 9766
Author: jlaba...@google.com
Date: Thu Feb 24 13:59:13 2011
Log: Edited wiki page CellBackedWIdgets through web user interface.
http://code.google.com/p/google-web-toolkit/source/detail?r=9766
Modified:
/wiki/CellBackedWIdgets.wiki
=======================================
--- /wiki/CellBackedWIdgets.wiki Thu Feb 24 13:46:49 2011
+++ /wiki/CellBackedWIdgets.wiki Thu Feb 24 13:59:13 2011
@@ -153,10 +153,50 @@
</replace-with>
}}}
-By overriding the deferred binding rule, a user can reskin a Cell for an
entire application. Alternatively, third party libraries can provide skins
for multiple widgets, which would be applied by inheriting a single Module
containing a bunch of deferred binding overrides.
+By overriding the deferred binding rule, a user can reskin a Cell for an
entire application. Alternatively, third party libraries can provide skins
for multiple widgets, which would be applied by inheriting a single Module
containing a bunch of deferred binding overrides. This also allows the GWT
team to replace Appearances with more modern ones from time to time without
breaking applications.
Finally, note that Appearance is an abstract class. This allows us to add
more state logic in the future without breaking existing Appearances. For
example, we could add new methods "setRightFlush()" and "setLeftFlush()"
which would make the right and left edges of the button flat, such that
they could be lined up next to each other. Existing appearances may not
support the new feature, but they would still work.
= Cell Backed Widgets =
+
+Every Cell will have an equivalent Widget, which is backed by the Cell and
shares all of the logic. We will use the existing {{{CellWidget}}} class
to wrap the widget:
+{{{
+public class ButtonWidget extends CellWidget<String> {
+
+ public ButtonWidget() {
+ this(new ButtonCell());
+ }
+
+ public ButtonWidget(ButtonCell.Appearance appearance) {
+ this(new ButtonCell(appearance));
+ }
+
+ public ButtonWidget(ButtonCell.DefaultAppearance.Resources resources) {
+ this(new ButtonCell(resources));
+ }
+
+ public ButtonWidget(ButtonCell cell) {
+ super(cell);
+ }
+
+ public void setTabIndex(int tabIndex) {
+ getCell().setTabIndex(tabIndex);
+ }
+
+ protected ButtonCell getButtonCell() {
+ return (ButtonCell) getCell();
+ }
+}
+}}}
+
+ButtonWidget provides convenience constructors to specify the
{{{ButtonCell.Appearance}}} or
{{{ButtonCell.DefaultAppearance.Resources}}}. ButtonWidget inherits
{{{addValueChangeHandler()}}} from CellWidget, but users can add additional
event handlers just as they would with any other widget.
+
+Some Cells support methods to change how the Cell is rendered. For
example, ButtonCell could provide a setTabIndex() method to set the tab
index of the element. ButtonWidget would expose the same methods and
forward through to the Cell.
+
+
+
+= Conclusion =
+
+The new pattern described above will allow us to update widgets by
providing new Appearances to replace old Appearances. We will start with
the basic form widgets (buttons, text boxes, etc.) and move on to more
complex widgets over time.
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors