17 Nov 2012, 10:47 PM
Look at Colin's post above. The path to the image has the theme in it. Without looking, I suspect the values would either be "blue" or "gray" (or maybe "grey" depending on how they spell it).
I will suggest that you really give some thought to whether or not you actually need (and want) this. How often are you going to be changing themes? Is this a feature you're going to be giving to your users? If so, why? Is this such a critical feature to have?
Additionally, as Colin mentioned you've now made your application tightly coupled to internal portions of the GXT API. Portions that are not meant to be used by API developers. Just because you can do something, doesn't necessarily mean it's a good idea. And in this case, I would strongly advise you, as Colin did, to just make your own ClientBundle. There are literally thousands of free icon libraries out there. http://www.iconfinder.com is a good place to start and is where we got our icon set.
I have a quick extended question from this question. I now understand how to create the ImageResource. I'm converting a project from 2.2.6 to gxt 3. In 2.2.6 we supplied icons to a button by applying a style: addMenuItem.setIconStyle("perceptive-icon-add"); The style was built in our css in our webapps directory and our images were in the webapp directory as well under images. Is there a way for me to reuse the icons in my webapp/images directory using a relative path? Or is the better option just to move the icons into a package.
According to the javadocs for ClientBundle.Source(...), the value is a classpath location so as long as the webapp/images directory is on your classpath (and I don't think it is by default) it should, in theory, work.
Note, however, that if you have two files w/ the same name, IIRC, the first one found on the classpath wins. I believe this also depends on the class loader, i.e., if you have two different class loaders and each one has a resource foo.png, I think Java thinks they are different and I don't know what class loader GWT uses by default when loading those resources (maybe the class loader in which the class that's using the @Source).
Here's the javadocs: http://google-web-toolkit.googlecode...le.Source.html
Tags for this Thread