Tuesday, April 15, 2014

Re: Custom CellTree Recources

I don't know of a way to replace the default styles (other than extending the class) except by providing our custom styles in the constructor. So what we do is sometimes we extend the class to provide it's own styles + custom behavior, or if we only need different styling, create custom Resources, and then provide it in the constructor:

CellTree tree = new CellTree(viewModel, rootValue, myCustomCellTreeResourcesInstance);

On Thursday, April 3, 2014 5:14:14 AM UTC-4, francesc...@gmail.com wrote:
Hi everyone,

I'm trying to write my own theme to inherit in my gwt applications.
I started out replicating the structure below the "com.google.gwt.user.theme.standard" package in a project under "com.mytheme" and editing some css rules in stanrdard.css. Exported all this in a jar and inherited the module "com.mytheme.Standard" in a GWT app. Evenerything works fine, my custom css is loaded and evaluated. Great.

Then I want to customize the style of the CellTree Widget (note, not just one cell tree in my gwt app, but all cell trees).

In CellTree.java I see that cell tree styles are loaded through
public <T> CellTree(TreeViewModel viewModel, T rootValue) {
   
this(viewModel, rootValue, getDefaultResources());
 
}

private static Resources getDefaultResources() {
   
if (DEFAULT_RESOURCES == null) {
      DEFAULT_RESOURCES
= GWT.create(Resources.class);
   
}
   
return DEFAULT_RESOURCES;
}

where Resources is a ClientBundle interface inside CellTree.java with a reference to a CssResource
public interface Resources extends ClientBundle {

   
...

   
@Source(Style.DEFAULT_CSS)
   
Style cellTreeStyle();
}

@ImportedWithPrefix("gwt-CellTree")
public interface Style extends CssResource {
   
   
String DEFAULT_CSS = "com/google/gwt/user/cellview/client/CellTree.css";

   
String cellTreeEmptyMessage();

   
String cellTreeItem();
   
   
...
}

My question is: how do i change the pointed css file?
I tought about a replace-with rule, to replace Resources with CustomeCellTreeResources like this:
import com.google.gwt.user.cellview.client.CellTree;

public interface CustomCellTreeResources extends CellTree.Resources {

   
@Override
   
@Source("CustomCellTree.css")
   
public CellTree.Style cellTreeStyle();

}

but replace-with mechanism works only for concrete classes.

Con you tell me how to do this?
Thanks


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment