Hi, I just want to show a small demo (proof of concept) of a XUL implementation for GWT using GWT Mosaic.
In the screenshot (http://imagebin.ca/view/q3LPurg.html) you see how the following XML file is rendered by FF3 as a XUL file (top) and with GWT Mosaic XUL library (bottom). <?xml version="1.0" encoding="UTF-8"?> <box orient="vertical"> <box align="center" > <broadcaster id="broadcaster" label="Add" decorated="true" /> <textbox id="value1" lala="user defined attribute" /> <label value="+" /> <textbox id="value2" /> <button command="add" label="=" observes="broadcaster" tooltiptext="Add operation" /> <vbox> <textbox id="result"> <observes element="value1" attribute="value" /> <observes element="broadcaster" attribute="decorated" strategy="readonce" /> </textbox> <textbox observes="result" disabled="true"> <observes element="result" attribute="value" strategy="readwrite" / > </textbox> </vbox> </box> </box> GWT Mosaic XUL does a little bit more than the default mozilla XUL by allowing to associate <observes> elements with any other element and not only with <broadcaster> elements (see broadcaster & Observer: https://developer.mozilla.org/en/XUL_Tutorial/Broadcasters_and_Observers). The GWT EntryPoint class that loads the XUL and also defines the button command="add" is: ---- import org.gwt.beansbinding.core.client.util.GWTBeansBinding; import org.gwt.mosaic.actions.client.Action; import org.gwt.mosaic.actions.client.ActionMap; import org.gwt.mosaic.actions.client.CommandAction; import org.gwt.mosaic.ui.client.MessageBox; import org.gwt.mosaic.ui.client.Viewport; import org.gwt.mosaic.xul.client.application.Application; import org.gwt.mosaic.xul.client.ui.Element; import org.gwt.mosaic.xul.client.ui.Textbox; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; public class XUL extends Application implements EntryPoint { static { GWTBeansBinding.init(); } private final XULParserServiceAsync xulParserService = GWT.create (XULParserService.class); public void onModuleLoad() { Application.launch(this); } @Override protected void initialize() { final ActionMap actionMap = getContext().getActionMap(); final CommandAction addCmd = new CommandAction(new Command() { public void execute() { Textbox tb1 = (Textbox) getContext().getElementMap().get ("value1"); Textbox tb2 = (Textbox) getContext().getElementMap().get ("value2"); Textbox tb3 = (Textbox) getContext().getElementMap().get ("result"); try { double v1 = Double.parseDouble(tb1.getValue()); double v2 = Double.parseDouble(tb2.getValue()); tb3.setValue(Double.toString(v1 + v2)); } catch (Exception e) { MessageBox.alert(Window.getTitle(), e.toString()); } } }); addCmd.put(Action.SHORT_DESCRIPTION, "Action ShortDescription"); actionMap.put("add", addCmd); } @Override protected void startup() { final Viewport viewport = new Viewport(); xulParserService.parse("calculator.xml", new AsyncCallback<Element> () { public void onFailure(Throwable caught) { Window.alert(caught.getLocalizedMessage()); } public void onSuccess(Element result) { if (result != null) { viewport.getLayoutPanel().add(result.getUI()); viewport.getLayoutPanel().setPadding(5); viewport.attach(); } } }); } } ---- The calculator demo can be found here: http://69.20.122.77:8880/gwt-mosaic-xul/ (its on port 8880, if you have any problems with that port let me know). Project homepage: http://code.google.com/p/gwt-mosaic-xul/ Any comments are welcome. Kind Regards, George. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
