Hi Jeffrey, Indeed this is a functionality we have to add (I've talked about that in my presentation about GSS at gwt.create) for GWT 2.8.
But it's not a good idea to give the possibility to developers to change the behavior of GwtGssFunctionMapProvider by extending it and giving their own implementation. I think the best approach is that add a configuration-property named " *CssResource.customGssFunctionMapProvider*". This value of this property must be the fully qualified name of a class implementing the interface *com.google.gwt.thirdparty.common.css.GssFunctionMapProvider* Then the GssResourceGenerator looks to this property and create an instance of this class and pass this instance to the GwtGssFunctionMapProvider. GwtGssFunctionMapProvider will add the functions defined in this custom GssMapFunctionProvider at the end of its map. If you could propose a patch for that it would be great. Don't hesitate to contact me if you need more info. Julien On Thu Feb 19 2015 at 11:30:09 AM Jeffrey Kleiss <[email protected]> wrote: > I noticed in the Closure Stylesheet docs that you can define your own > custom functions in Java when you use the *--gss-function-map-provider* flag. > > > Is there this option with GWT? > > I did notice that GwtGssFunctionMapProvider provides extra GSS GWT > functions, but found no way of extending this for my own custom methods. > The GssResourceGenerator constructs it via a new. It would be nice to > extend GwtGssFunctionMapProvider, or create a new class that > GwtGssFunctionMapProvider uses to add custom functions. > > I would propose changing GwtGssFunctionMapProvider to: > > public class GwtGssFunctionMapProvider extends DefaultGssFunctionMapProvider { > private final ResourceContext context; > > public GwtGssFunctionMapProvider() { > } > > public void setResourceContext(ResourceContext context) { > this.context = context; > } > > @Override > public Map<String, GssFunction> get() { > Map<String, GssFunction> gssFunctionMap = super.get(); > > return ImmutableMap.<String, GssFunction>builder().putAll(gssFunctionMap) > // TODO add a namespace for gwt-specific function ? > .put(EvalFunction.getName(), new EvalFunction()) > .put(ValueFunction.getName(), new ValueFunction()) > .put(ResourceUrlFunction.getName(), new ResourceUrlFunction(context)) > .build(); > } > } > > > This would allow it to be constructed with no arguments, which allows > Reflection to easily be used to construct the object. Next we could change > GssResourceGenerator to look for a configuration-property to be added to the > gwt.xml file to define the new class that must extend > GwtGssFunctionMapProvider, could then add custom functions. > > > If this sounds like an interesting approach, I could start coding a patch to > accomplish this. > > > Thanks, > > Jeffrey > > -- > 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]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-web-toolkit-contributors/3135e1af-bdce-45ed-bfbf-4d3192573e25%40googlegroups.com > <https://groups.google.com/d/msgid/google-web-toolkit-contributors/3135e1af-bdce-45ed-bfbf-4d3192573e25%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CABb_3%3D4EvyE6K6pTC0poy7-fk%3D7Yt5Cq80zt_8sYdpc%3DDbhyAw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
