Wednesday, April 16, 2014

Re: Custom CellTree Recources

Hi Rogelio,
thanks for you response.

I know that I can pass a custom resources instance to the constructor. I've done this many times and works fine.

What I was trying to do is to create a seprate module that contains all my styles, let's say a theme, and simply by inheriting this module in my applications apply these styles by default (like it would by changing to Standard theme to Dark theme).

I think that CellTree should implement the Appearance pattern (https://code.google.com/p/google-web-toolkit/wiki/CellBackedWIdgets#Appearance_Pattern), as well as all others cell widgets. Maybe I'll file an issue on this tipic 'cause I can't find one and also can't find a roadmap that says "we are planning to implement the appearance pattern on all widgets for release X.Y.Z".

My question is if there is an alternative to changing the sources to let celltree implement the appearance pattern.


Il giorno martedì 15 aprile 2014 17:27:13 UTC+2, Rogelio Flores ha scritto:
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