I thinks there is a misunderstanding. My proposal is just to not provide the 
convenience constructor, so instead of:
  new ButtonCell(resources);
You'd do:
  new ButtonCell(new DefaultAppearance(resources));
Making it crystal-clear that your ButtonCell is using DefaultAppearance. The 
convenience constructor leads you to believe you're using "resources" 
together with the Appearance you bound in the .gwt.xml -- which is not true: 
you are using DefaultAppearance no matter which <replace-with> you provided.


Sorry, that is far better, but there still is a problem. With that way of 
doing things is then you've lost your ability to use the .gwt.xml file to 
swap out the Appearance as you're now using a new instead of a GWT.create.  


Now, addStyleName is very limited since you can only style the wrapping 
<div>. It's good enough to add blank padding, but it wont let you make the 
internal part of the button wider or taller... Unless you use CSS type 
selectors but, as Stephen points out, this makes the app dependent on a 
specific widget style, and the app breaks as soon as this widget DOM 
structure changes. (So you can't easily upgrade to newer styles.)
In fact, I almost wish CellWidgets did not have a addStyleName given that 
it's really not that useful. I would rather have a slightly richer set of 
semantic styling methods in Appearance and having ways to access them from 
ButtonWidget (and UiBinder).


All true, I guess if I'm looking to alter the height/width of a cell 
widget's internals or its internal structure I would expect to extend the 
bundle. If I'm just looking to do things like set the float, padding/margine 
addStyleName is the perfect tool. Maybe there is a better way for dealing 
with boilerplate code, maybe with UiBinder as the hook. I'm not sure I'm 
still a little foggy on the best practices when dealing with CssResources 
especially with UiBinder. 

Another option would be an enhancement GEP to make it codegen that 
boilerplate for you. Admittedly it doesn't get rid of the code smell, but it 
does save your fingers some work. 

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to