r1512 - trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator
Author: kmorin Date: 2009-07-23 12:49:33 +0200 (Thu, 23 Jul 2009) New Revision: 1512 Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtConfigGenerator.java trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator1.java Log: Added a list of cssfiles to the model object, in order to copy them to the target directory for GWT Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtConfigGenerator.java =================================================================== --- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtConfigGenerator.java 2009-07-23 10:49:18 UTC (rev 1511) +++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtConfigGenerator.java 2009-07-23 10:49:33 UTC (rev 1512) @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.guix.model.GuixModelObject; @@ -37,6 +38,8 @@ /** GuixModelObject representing the main class */ private GuixModelObject gmo; + /** List of the CSS files needed of the generation */ + protected List<File> cssFiles; /** log */ private Log log = LogFactory.getLog(GwtConfigGenerator.class); @@ -45,8 +48,9 @@ * * @param gmo GuixModelObject representing the class to generate */ - public GwtConfigGenerator(GuixModelObject gmo) { + public GwtConfigGenerator(GuixModelObject gmo, List<File> cssFiles) { this.gmo = gmo; + this.cssFiles = cssFiles; } /** @@ -66,31 +70,34 @@ serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "\t"); serializer.startTag("", "module"); - serializer.comment("Inherit the core Web Toolkit stuff."); - serializer.startTag("", "inherits"); - serializer.attribute("", "name", "com.google.gwt.user.User"); - serializer.endTag("","inherits"); + serializer.comment("Inherit the core Web Toolkit stuff."); + serializer.startTag("", "inherits"); + serializer.attribute("", "name", "com.google.gwt.user.User"); + serializer.endTag("","inherits"); - serializer.startTag("", "inherits"); + serializer.startTag("", "inherits"); int i = 0; while(i < gmo.getAttributeDescriptors().size() - && !gmo.getAttributeDescriptors().get(i).getName().equals("theme")) + && !gmo.getAttributeDescriptors().get(i).getName().equals("theme")) { i++; - serializer.attribute("", "name", i < gmo.getAttributeDescriptors().size() ? - gmo.getAttributeDescriptors().get(i).getValue() - : "com.google.gwt.user.theme.standard.Standard"); - serializer.endTag("","inherits"); + } + serializer.attribute("", "name", i < gmo.getAttributeDescriptors().size() ? + gmo.getAttributeDescriptors().get(i).getValue() + : "com.google.gwt.user.theme.standard.Standard"); + serializer.endTag("","inherits"); - serializer.comment("Specify the app entry point class."); - serializer.startTag("","entry-point"); - serializer.attribute("", "class", gmo.getClassDescriptor().getPackageName() - + ".client." + gmo.getClassDescriptor().getName() + "Impl"); - serializer.endTag("","entry-point"); + serializer.comment("Specify the app entry point class."); + serializer.startTag("","entry-point"); + serializer.attribute("", "class", gmo.getClassDescriptor().getPackageName() + + ".client." + gmo.getClassDescriptor().getName() + "Impl"); + serializer.endTag("","entry-point"); - serializer.comment("Specify the application specific style sheet."); + serializer.comment("Specify the application specific style sheet."); + for(File f : cssFiles) { serializer.startTag("", "stylesheet"); - serializer.attribute("","src",gmo.getClassDescriptor().getName() + ".css"); + serializer.attribute("","src", f.getName()); serializer.endTag("", "stylesheet"); + } serializer.endTag("", "module"); serializer.endDocument(); Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java =================================================================== --- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-07-23 10:49:18 UTC (rev 1511) +++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator.java 2009-07-23 10:49:33 UTC (rev 1512) @@ -20,6 +20,10 @@ import com.google.gwt.user.client.ui.Label; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -76,7 +80,7 @@ if (mainClass) { gimg.addMainMethod(); - GwtConfigGenerator gcg = new GwtConfigGenerator(gmo); + GwtConfigGenerator gcg = new GwtConfigGenerator(gmo, getCSSFiles()); GwtHtmlGenerator ghg = new GwtHtmlGenerator(gmo, launcherName); File outConfigMain = new File(destDir, launcherName.substring(launcherName.lastIndexOf('.') + 1) + ".gwt.xml"); File publicDir = new File(destDir, "public"); @@ -85,6 +89,25 @@ } File outHtmlMain = new File(publicDir, launcherName.substring(launcherName.lastIndexOf('.') + 1) + ".html"); gcg.generate(outConfigMain); + for(File f : getCSSFiles()) { + try { + File fPublic = new File(publicDir, f.getName()); + fPublic.createNewFile(); + FileInputStream fis = new FileInputStream(f); + FileOutputStream fos = new FileOutputStream(fPublic); + // segment size : 0.5Mo + byte buffer[] = new byte[512*1024]; + int read; + while((read = fis.read(buffer)) != -1) { + fos.write(buffer, 0, read); + } + fis.close(); + fos.close(); + } + catch(IOException eee) { + log.error(eee); + } + } ghg.generate(outHtmlMain); } Modified: trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator1.java =================================================================== --- trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator1.java 2009-07-23 10:49:18 UTC (rev 1511) +++ trunk/guix-compiler-gwt/src/main/java/org/nuiton/guix/generator/GwtGenerator1.java 2009-07-23 10:49:33 UTC (rev 1512) @@ -75,7 +75,7 @@ if (mainClass) { gimg.addMainMethod(); - GwtConfigGenerator gcg = new GwtConfigGenerator(gmo); + GwtConfigGenerator gcg = new GwtConfigGenerator(gmo, getCSSFiles()); GwtHtmlGenerator ghg = new GwtHtmlGenerator(gmo, launcherName); File outConfigMain = new File(destDir, launcherName.substring(launcherName.lastIndexOf('.') + 1) + ".gwt.xml"); File publicDir = new File(destDir, "public");
participants (1)
-
kmorin@users.labs.libre-entreprise.org