Jake, You would have to create a class org.eclipse.swt.widgets.Canvas such that it is GWT-compatible. That means only using emulated JRE classes (String, collections, etc.). Any class required for the Canvas class API has to be implemented in a GWT-compatible manner as well. This transitive dependency is what really kills you. If you get to a point where you have to use a non-emulated JRE class (e.g., java.io.* (almost)), you're hosed (I believe this was essentially Ian's point).
Assuming you manage to implement the entire API, you create a module file (gwt.xml) that includes the source you just wrote, inherit that module in your GWT app, and enjoy. For more on JRE emulation, see: http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=RefJreEmulation - Isaac On Tue, Apr 7, 2009 at 3:14 PM, Jake <[email protected]> wrote: > > I feel like I'm not expressing myself clearly. Let's just focus on the > reduced case: > > import org.eclipse.swt.widgets.Canvas; > > public class foo { > > } > > Right now, if I try to run this through GWT, it will throw an error > because it can't compile Canvas and all of its dependencies. This is > to be expected. So what I would like is to roll my own Canvas class > which extends GWT's Widget class, and have that be used instead, but > in such a way that I don't have to touch the existing program's source > code. > > Ian, you seem to be suggesting that I need to hack this into the > internals of GWT itself, and try to push it upstream. I feel like > there should be a way to do this without having modify GWT internals, > because this would allow certain applications (not all of them) that > leverage native GUI toolkits to be compiled directly to a browser- > based version, without having to port them to a GWT-friendly set of > libraries. This would be a very powerful feature, but it may not > exist. If I could just get confirmation on this, I would appreciate > it. > > Thanks, > > Jake > > On Apr 7, 2:38 pm, Ian Bambury <[email protected]> wrote: >> GWT isn't Java. It just uses Java syntax so that Java books are useful, and >> things like Eclipse work for it. >> GWT code becomes JavaScript. It is never at any point Java. >> >> A very simple compiler might recognise '"Window.alert(" and translate it to >> '"document.alert(" >> >> If you whole program consists of Window.alert("Hello"); then it will be OK. >> Anything else will fail. >> >> The Google team have emulated many other commands and structures, but not >> all of them: some are obscure and therefore not high enough up the priority >> list, and some are impossible because, like threading, JS just doesn't do >> that. >> >> It would be an impossible task to emulate every possible class in every Java >> library in existence. And would take for ever. >> >> So if it ain't emulated, it ain't gonna work because the compiler will issue >> a polite and rather technical version of 'WTF?' >> >> And just throwing any old java program into the GWT compiler is, pretty >> much, pointless. >> >> But if you really want to help Google and emulate >> rg.eclipse.swt.widgets.Canvas >> for GWT, then I'm sure they (and many others) will be eternally grateful for >> at least a week or two :-) >> >> If so, troll your little old lallies over to the very >> bonahttp://groups.google.com/group/Google-Web-Toolkit-Contributors > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
