PDA

View Full Version : GXT client side file generation + Integration with Adobe Flex



Ekambos
24 Feb 2011, 2:40 PM
Hello community,
sometimes ago i started the project located at http://code.google.com/p/gwt4air/
wich goal was tu bring Java and AIR together so one can easely export his GWT(GXT) application to the desktop without rewriting any code. On top of that the project added support for PDF and Excel generation. Now with gwt4air 2.1 coming out soon I m glad to announce a way to add client side file generation on your GWT (GXT) apps(note that Flash Player version 9 or above is required).

I create a GWT widget wich you can include into your GXT application and interact with to access the file generation libraries inside gwt4air. The API will be something like this.


ContentPanel cp = new ContentPanel();
cp.setHeaderVisible(true);
cp.setHeading("Reports");
cp.add(Exporter.get(100, 100, new ExporterInitializationHandler() {
@Override
public void onInitialization() {
Exporter.getExportButton().setLabel("Export PDF");
Exporter.getExportButton().setHeight(40);
Exporter.addClickHandler(new FlashEventListener<Event>() {
@Override
protected void onFlashEvent(Event event) {
PDF pdf =PDF.newInstance();
pdf.addPage();
pdf.setTextStyle(RGBColor.newInstance(0x006400));
pdf.writeText(15, "Export Preview");

FileReference fr = FileReference.newInstance();
fr.save(pdf.save(), "GXT.PDF");

}
});

}
}));

cp.add(ChartWidget.newInstance());


24848


If you even want to combine your GWXT project with the Adobe FLEX framework, you know that this is not straigthforward.
Now leaveraging a simpe java API you will be able to bring GXT and Flex together



Flex.init(new FlexInitializationHandler() {
@Override
public void onInitialization() {
Application.get().setStyle("backgroundColor", "#268CE1");
Panel panel = Panel.newInstance("EXT-GWT and Adobe FLEX");
IFrame iframe = Frame.newInstance("http://www.sencha.com/examples/#overview");

panel.addElement(iframe);

ControlBar controlBar = ControlBar.newInstance();
controlBar.addElement(Button.newInstance("Reload"));
panel.addElement(controlBar);

Application.get().addElement(panel);

}
});




I hope you guyz will like this.

Regards,

Alain