Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
May 2009
- 4 participants
- 61 discussions
r1405 - in guix/trunk: . guix-runtime guix-runtime/src guix-runtime/src/main guix-runtime/src/main/java guix-runtime/src/main/java/org guix-runtime/src/main/java/org/nuiton guix-runtime/src/main/java/org/nuiton/guix guix-runtime/src/test guix-runtime/src/test/java guix-runtime/src/test/java/org guix-runtime/src/test/java/org/nuiton
by kmorin@users.labs.libre-entreprise.org 15 May '09
by kmorin@users.labs.libre-entreprise.org 15 May '09
15 May '09
Author: kmorin
Date: 2009-05-15 14:01:35 +0000 (Fri, 15 May 2009)
New Revision: 1405
Added:
guix/trunk/guix-runtime/
guix/trunk/guix-runtime/pom.xml
guix/trunk/guix-runtime/src/
guix/trunk/guix-runtime/src/main/
guix/trunk/guix-runtime/src/main/java/
guix/trunk/guix-runtime/src/main/java/org/
guix/trunk/guix-runtime/src/main/java/org/nuiton/
guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/
guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java
guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java
guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java
guix/trunk/guix-runtime/src/test/
guix/trunk/guix-runtime/src/test/java/
guix/trunk/guix-runtime/src/test/java/org/
guix/trunk/guix-runtime/src/test/java/org/nuiton/
guix/trunk/guix-runtime/src/test/java/org/nuiton/guix/
Log:
Ajout du module (pas encore fonctionnel) guix-runtime
Property changes on: guix/trunk/guix-runtime
___________________________________________________________________
Name: svn:ignore
+ target
Added: guix/trunk/guix-runtime/pom.xml
===================================================================
--- guix/trunk/guix-runtime/pom.xml (rev 0)
+++ guix/trunk/guix-runtime/pom.xml 2009-05-15 14:01:35 UTC (rev 1405)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <parent>
+ <groupId>org.nuiton.guix</groupId>
+ <artifactId>guix</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>guix-runtime</artifactId>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>guix-runtime</name>
+ <description>Guix runtime</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/guix/trunk/guix-runtime</connection>
+ <!--developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/guix/trunk</developerConnection-->
+ <!--url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/guix/trunk/?roo…</url-->
+ </scm>
+</project>
\ No newline at end of file
Added: guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java
===================================================================
--- guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java (rev 0)
+++ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java 2009-05-15 14:01:35 UTC (rev 1405)
@@ -0,0 +1,42 @@
+package org.nuiton.guix;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+
+/**
+ * A <code>PropertyChangeListener</code> which processes a data binding when it receives a
+ * <code>PropertyChangeEvent</code>.
+ */
+public class DataBindingListener implements PropertyChangeListener {
+ private GuixObject object;
+ private String dest;
+
+ /**
+ * Creates a new <code>DataBindingListener</code> which will run the given data binding
+ * when it receives a <code>PropertyChangeEvent</code>.
+ *
+ * @param object the object in which the data binding exists
+ * @param dest the name of the data binding to run
+ */
+ public DataBindingListener(GuixObject object, String dest) {
+ this.object = object;
+ this.dest = dest;
+ }
+
+
+ /**
+ * Processes the data binding in response to a <code>PropertyChangeEvent</code>.
+ *
+ * @param e the event which triggered the binding
+ */
+ public void propertyChange(PropertyChangeEvent e) {
+ object.processDataBinding(dest);
+
+ // for now, handle dependency changes by always removing & reapplying
+ // the binding. We should be more efficient and only do this when it's
+ // actually necessary
+ object.removeDataBinding(dest);
+ object.applyDataBinding(dest);
+ }
+}
\ No newline at end of file
Added: guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java
===================================================================
--- guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java (rev 0)
+++ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java 2009-05-15 14:01:35 UTC (rev 1405)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package org.nuiton.guix;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+
+/**
+ * A <code>PropertyChangeListener</code> which removes and re-applies a data binding
+ * when it receives a <code>PropertyChangeEvent</code>.
+ */
+public class DataBindingUpdateListener implements PropertyChangeListener {
+ private GuixObject object;
+ private String dest;
+
+ /**
+ * Creates a new <code>DataBindingUpdateListener</code> which will remove and re-apply a
+ * data binding when it receives a <code>PropertyChangeEvent</code>.
+ *
+ * @param object the object in which the data binding exists
+ * @param dest the name of the data binding to reapply
+ */
+ public DataBindingUpdateListener(GuixObject object, String dest) {
+ this.object = object;
+ this.dest = dest;
+ }
+
+
+ public String getBindingName() {
+ return dest;
+ }
+
+
+ /**
+ * Updates the data binding in response to a <code>PropertyChangeEvent</code>.
+ *
+ * @param e the event which triggered the binding
+ */
+ public void propertyChange(PropertyChangeEvent e) {
+ object.removeDataBinding(dest);
+ object.applyDataBinding(dest);
+ }
+}
\ No newline at end of file
Added: guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java
===================================================================
--- guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java (rev 0)
+++ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java 2009-05-15 14:01:35 UTC (rev 1405)
@@ -0,0 +1,46 @@
+package org.nuiton.guix;
+
+/** The <code>GuixObject</code> interface is implemented by all classes produced by the Guix compiler. */
+public interface GuixObject {
+ /**
+ * Retrieves an object defined in an XML tag by its ID.
+ *
+ * @param id the id of the component to retrieve
+ * @return the object
+ */
+ public Object getObjectById(String id);
+
+ /**
+ * Pretrieves the dictonary of knwon objects indexed by their ids.
+ *
+ * @return the dictonary of objects.
+ */
+ public java.util.Map<String, Object> get$objectMap();
+
+ public void applyDataBinding(String id);
+
+
+ public void removeDataBinding(String id);
+
+ /**
+ * Processes a data binding by name. Data binding names are comprised of an object ID and a property name:
+ * for example, the data binding in the tag <code><JLabel id='label' text='{foo.getText()}'/></code> is
+ * named <code>"label.text"</code>. Processing a data binding causes it to reevaluate its expression, in this
+ * case <code>foo.getText()</code>.
+ *
+ * @param dest the name of the data binding to run
+ */
+ public void processDataBinding(String dest);
+
+
+ /**
+ * All <code>GuixObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and
+ * furthermore (for technical reasons) must allow code in outside packages, specifically the Guix runtime,
+ * to trigger these events.
+ *
+ * @param name the name of the property which changed
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
+ */
+ public void firePropertyChange(String name, Object oldValue, Object newValue);
+}
\ No newline at end of file
1
0
r1404 - in guix/trunk/guix-maven-plugin: . src/main/java/org/nuiton/guix
by kmorin@users.labs.libre-entreprise.org 15 May '09
by kmorin@users.labs.libre-entreprise.org 15 May '09
15 May '09
Author: kmorin
Date: 2009-05-15 14:00:25 +0000 (Fri, 15 May 2009)
New Revision: 1404
Modified:
guix/trunk/guix-maven-plugin/pom.xml
guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java
Log:
Ajout des parametres dans le mojo
Modified: guix/trunk/guix-maven-plugin/pom.xml
===================================================================
--- guix/trunk/guix-maven-plugin/pom.xml 2009-05-15 13:59:55 UTC (rev 1403)
+++ guix/trunk/guix-maven-plugin/pom.xml 2009-05-15 14:00:25 UTC (rev 1404)
@@ -25,6 +25,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>guix-compiler-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- maven plugin project dependencies -->
<dependency>
Modified: guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java
===================================================================
--- guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-05-15 13:59:55 UTC (rev 1403)
+++ guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-05-15 14:00:25 UTC (rev 1404)
@@ -5,6 +5,9 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.guix.generator.Generator;
+import org.nuiton.guix.generator.GuixGenerator;
+import org.nuiton.guix.generator.SwingGenerator;
/**
* Launches the program
@@ -45,12 +48,21 @@
*/
private String mainClass;
+ /**
+ * Generation language
+ * @parameter expression="${guix.generationLanguage}" default-value="Swing"
+ * @since 0.0.1
+ */
+ private String generationLanguage;
+
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
GuixInitializer.initialize();
File guixFilesDir = new File(this.guixFilesDir);
File targetDirectory = new File(this.targetDirectory);
-
+ Class generatorClass = null;
+ if(generationLanguage.equals("Swing"))
+ generatorClass = SwingGenerator.class;
if(!targetDirectory.exists())
targetDirectory.mkdirs();
@@ -59,7 +71,7 @@
GuixLauncher gcl = new GuixLauncher(guixFiles.toArray(
new File[guixFiles.size()]),targetDirectory,rootPackage,
- guixFilesDir,mainClass);
+ guixFilesDir,mainClass,generatorClass);
boolean result = gcl.compile();
if(result)
getLog().info("Compilation succeeded !");
@@ -85,4 +97,5 @@
}
return result;
}
+
}
1
0
r1403 - in guix/trunk: . guix-compiler-swing guix-compiler-swing/src guix-compiler-swing/src/main guix-compiler-swing/src/main/java guix-compiler-swing/src/main/java/org guix-compiler-swing/src/main/java/org/nuiton guix-compiler-swing/src/main/java/org/nuiton/guix guix-compiler-swing/src/main/java/org/nuiton/guix/generator guix-compiler-swing/src/spring guix-compiler-swing/src/test
by kmorin@users.labs.libre-entreprise.org 15 May '09
by kmorin@users.labs.libre-entreprise.org 15 May '09
15 May '09
Author: kmorin
Date: 2009-05-15 13:59:55 +0000 (Fri, 15 May 2009)
New Revision: 1403
Added:
guix/trunk/guix-compiler-swing/
guix/trunk/guix-compiler-swing/pom.xml
guix/trunk/guix-compiler-swing/src/
guix/trunk/guix-compiler-swing/src/main/
guix/trunk/guix-compiler-swing/src/main/java/
guix/trunk/guix-compiler-swing/src/main/java/org/
guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/
guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/
guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/
guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingFileGenerator.java
guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
guix/trunk/guix-compiler-swing/src/main/resources/
guix/trunk/guix-compiler-swing/src/spring/
guix/trunk/guix-compiler-swing/src/spring/SwingAbstractClassGenerator.java
guix/trunk/guix-compiler-swing/src/spring/SwingGenerator.java
guix/trunk/guix-compiler-swing/src/spring/SwingImplementationGenerator.java
guix/trunk/guix-compiler-swing/src/spring/SwingInterfaceGenerator.java
guix/trunk/guix-compiler-swing/src/spring/SwingMainClassGenerator.java
guix/trunk/guix-compiler-swing/src/test/
guix/trunk/guix-compiler-swing/src/test/java/
guix/trunk/guix-compiler-swing/src/test/resources/
Log:
Ajout du module guix-compiler-swing
Property changes on: guix/trunk/guix-compiler-swing
___________________________________________________________________
Name: svn:ignore
+ target
Added: guix/trunk/guix-compiler-swing/pom.xml
===================================================================
--- guix/trunk/guix-compiler-swing/pom.xml (rev 0)
+++ guix/trunk/guix-compiler-swing/pom.xml 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <parent>
+ <groupId>org.nuiton.guix</groupId>
+ <artifactId>guix</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>guix-compiler-swing</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.guix</groupId>
+ <artifactId>guix-compiler</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdesktop</groupId>
+ <artifactId>beansbinding</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.4c</version>
+ </dependency>
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+ <name>guix-compiler-swing</name>
+ <description>Guix compiler for swing</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/guix/trunk/guix-compiler-swing</connection>
+ <!--developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/guix/trunk</developerConnection-->
+ <!--url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/guix/trunk/?roo…</url-->
+ </scm>
+
+</project>
Added: guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingFileGenerator.java
===================================================================
--- guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingFileGenerator.java (rev 0)
+++ guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingFileGenerator.java 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,153 @@
+package org.nuiton.guix.generator;
+
+//~--- non-JDK imports --------------------------------------------------------
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.nuiton.guix.model.GuixModelObject;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.File;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+import org.nuiton.guix.databinding.BindingUtils;
+import org.nuiton.guix.model.AttributeDescriptor;
+
+/**
+ *
+ * @author morin
+ */
+public class SwingFileGenerator extends JavaFileGenerator {
+
+ public SwingFileGenerator(GuixModelObject gmo) {
+ super(gmo);
+ jf = new JavaFile(gmo.getClassDescriptor().getPackageName(),
+ Modifier.PUBLIC,
+ gmo.getClassDescriptor().getName(),
+ null);
+ }
+
+ @Override
+ public void generate(File out) {
+ super.generate();
+ jf.addImport("javax.swing.*");
+ jf.addImport("java.awt.*");
+
+ jf.setSuperClass(gmo.getClassDescriptor().getSuperClass().getPackageName() + "." + gmo.getClassDescriptor().getSuperClass().getName());
+
+ if (!gmo.getJavadoc().equals("")) {
+ sb.append("\n/**\n* ");
+ sb.append(gmo.getJavadoc());
+ sb.append("\n*/");
+ }
+
+ jf.addField(new JavaField(Modifier.PRIVATE,
+ "org.jdesktop.beansbinding.BindingGroup",
+ "bindingGroup"),
+ true);
+ addFields(gmo);
+
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, null, gmo.getClassDescriptor().getName(),
+ null, null, "initialize();"));
+
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initialize", null, null, "createComponents();\ninitComponents();\ninitDataBinding();"));
+
+ Map<String, String> methodBodies = browseModelObjects(gmo);
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "createComponents", null, null,
+ "this.setLayout(new FlowLayout());\n" + methodBodies.get("componentsCreation")));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initComponents", null, null, methodBodies.get("componentsTree")));
+
+ StringBuffer dataBinding = new StringBuffer("bindingGroup = new org.jdesktop.beansbinding.BindingGroup();\n");
+ dataBinding.append(methodBodies.get("bindings"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initDataBinding", null, null, dataBinding.toString()));
+
+ saveFile(out);
+ }
+
+ private void addFields(GuixModelObject gmo) {
+ for (GuixModelObject child : gmo.getChildren()) {
+ jf.addField(new JavaField(Modifier.PRIVATE,
+ child.getClassDescriptor().getName(),
+ child.getId()),
+ true);
+ addFields(child);
+ }
+ }
+
+ private Map<String, String> browseModelObjects(GuixModelObject gmo) {
+ StringBuffer componentsCreation = new StringBuffer();
+ StringBuffer componentsTree = new StringBuffer();
+ StringBuffer bindings = new StringBuffer();
+
+ if (gmo.getParent() != null) {
+ String capitalizedId = (gmo.getId().length() > 0) ? Character.toUpperCase(gmo.getId().charAt(0)) + gmo.getId().substring(1) : gmo.getId();
+ StringBuffer creationMethod = new StringBuffer(gmo.getId()).append(" = new ").append(gmo.getClassDescriptor().getName()).append("();");
+ jf.addMethod(new JavaMethod(Modifier.PRIVATE, "void", "create" + capitalizedId, null, null, creationMethod.toString()));
+ componentsCreation.append("create").append(capitalizedId).append("();\n");
+
+
+ componentsTree.append(gmo.getParent().getId() == null ? "this" : gmo.getParent().getId()).append(".add(").append(gmo.getId()).append(");\n");
+
+ for (AttributeDescriptor attr : gmo.getAttributeDescriptors()) {
+ String binding = BindingUtils.processDataBindings(attr.getValue());
+ if (binding != null) {
+ bindings.append("bindingGroup.addBinding(\n").append("org.jdesktop.beansbinding.Bindings.createAutoBinding(\norg.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ,").append("this").append(",org.jdesktop.beansbinding.ELProperty.create(\"${").append(binding).append("}\"),").append(gmo.getId()).append(",org.jdesktop.beansbinding.BeanProperty.create(\"").append(attr.getName()).append("\")").append("));\n").append("bindingGroup.bind();\n");
+ }
+ else {
+ String capitalizedAttribute = (attr.getName().length() > 0) ? Character.toUpperCase(attr.getName().charAt(0)) + attr.getName().substring(1) : attr.getName();
+ boolean addQuote = false;
+ try {
+ addQuote = Class.forName(gmo.getClassDescriptor().getPackageName() + "." + gmo.getClassDescriptor().getName()).getMethod("get" + capitalizedAttribute, null).getReturnType().equals(String.class);
+ }
+ catch (ClassNotFoundException ex) {
+ log.error(ex);
+ }
+ catch (NoSuchMethodException ex) {
+ try {
+ addQuote = Class.forName(gmo.getClassDescriptor().getPackageName() + "." + gmo.getClassDescriptor().getName()).getMethod("is" + capitalizedAttribute, null).getReturnType().equals(String.class);
+ }
+ catch (ClassNotFoundException ex2) {
+ log.error(ex2);
+ }
+ catch (NoSuchMethodException ex2) {
+ log.error(ex2);
+ }
+ }
+ componentsTree.append(gmo.getId()).append(".set").append(capitalizedAttribute).append("(").append(addQuote ? "\"" : "").append(attr.getValue()).append(addQuote ? "\"" : "").append(");\n");
+ }
+ }
+ }
+ for (GuixModelObject child : gmo.getChildren()) {
+ Map<String, String> methodBodies = browseModelObjects(child);
+ componentsCreation.append(methodBodies.get("componentsCreation"));
+ componentsTree.append(methodBodies.get("componentsTree"));
+ bindings.append(methodBodies.get("bindings"));
+ }
+ Map<String, String> result = new HashMap<String, String>();
+ result.put("componentsCreation", componentsCreation.toString());
+ result.put("componentsTree", componentsTree.toString());
+ result.put("bindings", bindings.toString());
+ return result;
+ }
+
+ public void addMainMethod() {
+ //public static void main(String[] arg) {
+ //SwingUtilities.invokeLater(new Runnable() { public void run() { new JAXXDemo().setVisible(true); } });
+ //}
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC | Modifier.STATIC,
+ "void",
+ "main",
+ new JavaArgument[]{new JavaArgument("String[]", "args")},
+ null,
+ "SwingUtilities.invokeLater(" +
+ "new Runnable() {" +
+ "public void run() {" +
+ jf.getClassName() +
+ " main = new " +
+ jf.getClassName() + "();\n" +
+ "main.pack();\n" +
+ "main.setVisible(true);}});"));
+ }
+}
+
Added: guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java
===================================================================
--- guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java (rev 0)
+++ guix/trunk/guix-compiler-swing/src/main/java/org/nuiton/guix/generator/SwingGenerator.java 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,55 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.nuiton.guix.generator;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author kevin
+ */
+public class SwingGenerator extends GuixGenerator {
+
+ protected Log log = LogFactory.getLog(SwingGenerator.class);
+
+ public void generate() {
+ String gmoClassName = gmo.getClassDescriptor().getName();
+ //File f = new File(destDir, mo.getClassDescriptor().getName() + "ModelTree.xml");
+ File out = new File(destDir, gmoClassName + ".java");
+
+ if (lastModification > out.lastModified()) {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Generation of " + gmo.getClassDescriptor().getName());
+ }
+ if (!out.exists()) {
+ try {
+ out.createNewFile();
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
+ }
+ SwingFileGenerator ing = new SwingFileGenerator(gmo);
+ if (mainClass) {
+ ing.addMainMethod();
+ }
+ ing.generate(out);
+ }
+ catch (IllegalArgumentException ex) {
+ log.error(ex);
+ }
+ catch (IllegalStateException ex) {
+ log.error(ex);
+ }
+ }
+ else if (log.isWarnEnabled()) {
+ log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
+ }
+ }
+}
Added: guix/trunk/guix-compiler-swing/src/spring/SwingAbstractClassGenerator.java
===================================================================
--- guix/trunk/guix-compiler-swing/src/spring/SwingAbstractClassGenerator.java (rev 0)
+++ guix/trunk/guix-compiler-swing/src/spring/SwingAbstractClassGenerator.java 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,143 @@
+package org.nuiton.guix.generator.spring;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import org.nuiton.guix.generator.*;
+import org.nuiton.guix.model.GuixModelObject;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.File;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+import javax.swing.JComponent;
+import org.nuiton.guix.databinding.BindingUtils;
+import org.nuiton.guix.model.AttributeDescriptor;
+
+/**
+ *
+ * @author morin
+ */
+public class SwingAbstractClassGenerator extends JavaFileGenerator {
+ public SwingAbstractClassGenerator(GuixModelObject gmo) {
+ super(gmo);
+ jf = new JavaFile(gmo.getClassDescriptor().getPackageName(),
+ Modifier.PUBLIC,
+ JavaFile.ABSTRACT_CLASS,
+ gmo.getClassDescriptor().getName() + "Abstract",
+ null);
+ }
+
+ @Override
+ public void generate(File out) {
+ super.generate();
+
+ jf.setSuperClass(gmo.getClassDescriptor().getSuperClass().getPackageName()
+ + "." + gmo.getClassDescriptor().getSuperClass().getName());
+ jf.addInterface(gmo.getClassDescriptor().getName());
+
+ if (!gmo.getJavadoc().equals("")) {
+ sb.append("\n/**\n* ");
+ sb.append(gmo.getJavadoc());
+ sb.append("\n*/");
+ }
+
+ jf.addField(new JavaField(Modifier.PRIVATE,
+ "org.jdesktop.beansbinding.BindingGroup",
+ "bindingGroup"),
+ true);
+ addFields(gmo);
+
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, null, gmo.getClassDescriptor().getName() + "Abstract",
+ null, null, "initialize();"));
+
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initialize", null, null, "createComponents();\ninitComponents();\ninitDataBinding();"));
+
+ Map<String, String> methodBodies = browseModelObjects(gmo);
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "createComponents", null, null, methodBodies.get("componentsCreation")));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initComponents", null, null, methodBodies.get("componentsTree")));
+
+ StringBuffer dataBinding = new StringBuffer("bindingGroup = new org.jdesktop.beansbinding.BindingGroup();\n");
+ dataBinding.append(methodBodies.get("bindings"));
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initDataBinding", null, null, dataBinding.toString()));
+
+ //sb.append("\n\npublic abstract void test();\n\n}");
+ saveFile(out);
+ }
+
+ private void addFields(GuixModelObject gmo) {
+ for (GuixModelObject child : gmo.getChildren()) {
+ jf.addField(new JavaField(Modifier.PRIVATE,
+ child.getClassDescriptor().getName(),
+ child.getId()),
+ true);
+ addFields(child);
+ }
+ }
+
+ private Map<String,String> browseModelObjects(GuixModelObject gmo) {
+ StringBuffer componentsCreation = new StringBuffer();
+ StringBuffer componentsTree = new StringBuffer();
+ StringBuffer bindings = new StringBuffer();
+
+ if(gmo.getParent() != null) {
+ String capitalizedId = (gmo.getId().length()>0) ?
+ Character.toUpperCase(gmo.getId().charAt(0)) + gmo.getId().substring(1) : gmo.getId();
+ StringBuffer creationMethod = new StringBuffer(gmo.getId())
+ .append(" = new ")
+ .append(gmo.getClassDescriptor().getName())
+ .append("();");
+ jf.addMethod(new JavaMethod(Modifier.PRIVATE, "void", "create" + capitalizedId, null, null, creationMethod.toString()));
+ componentsCreation.append("create")
+ .append(capitalizedId)
+ .append("();\n");
+
+
+ componentsTree.append(gmo.getParent().getId() == null ? "this" : gmo.getParent().getId())
+ .append(".add(")
+ .append(gmo.getId())
+ .append(");\n");
+
+ for(AttributeDescriptor attr : gmo.getAttributeDescriptors()) {
+ String binding = BindingUtils.processDataBindings(attr.getValue());
+ if(binding != null) {
+ bindings.append("bindingGroup.addBinding(\n")
+ .append("org.jdesktop.beansbinding.Bindings.createAutoBinding(\norg.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ,")
+ .append("this")
+ .append(",org.jdesktop.beansbinding.ELProperty.create(\"${")
+ .append(binding)
+ .append("}\"),")
+ .append(gmo.getId())
+ .append(",org.jdesktop.beansbinding.BeanProperty.create(\"")
+ .append(attr.getName())
+ .append("\")")
+ .append("));\n")
+ .append("bindingGroup.bind();");
+ }
+ else {
+ String capitalizedAttribute = (attr.getName().length()>0) ?
+ Character.toUpperCase(attr.getName().charAt(0)) + attr.getName().substring(1) : attr.getName();
+ componentsTree.append(gmo.getId())
+ .append(".set")
+ .append(capitalizedAttribute)
+ .append("(")
+ .append(attr.getValue())
+ .append(");\n");
+ }
+ }
+ }
+ for (GuixModelObject child : gmo.getChildren()) {
+ Map<String,String> methodBodies = browseModelObjects(child);
+ componentsCreation.append(methodBodies.get("componentsCreation"));
+ componentsTree.append(methodBodies.get("componentsTree"));
+ bindings.append(methodBodies.get("bindings"));
+ }
+ Map<String,String> result = new HashMap<String, String>();
+ result.put("componentsCreation", componentsCreation.toString());
+ result.put("componentsTree", componentsTree.toString());
+ result.put("bindings", bindings.toString());
+ return result;
+ }
+}
+
Added: guix/trunk/guix-compiler-swing/src/spring/SwingGenerator.java
===================================================================
--- guix/trunk/guix-compiler-swing/src/spring/SwingGenerator.java (rev 0)
+++ guix/trunk/guix-compiler-swing/src/spring/SwingGenerator.java 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,116 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.nuiton.guix.generator.spring;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.guix.generator.GuixGenerator;
+
+/**
+ *
+ * @author kevin
+ */
+public class SwingGenerator extends GuixGenerator {
+
+ protected Log log = LogFactory.getLog(SwingGenerator.class);
+
+ public void generate() {
+ String gmoClassName = gmo.getClassDescriptor().getName();
+ //File f = new File(destDir, mo.getClassDescriptor().getName() + "ModelTree.xml");
+ File out = new File(destDir, gmoClassName + ".java");
+ File outAbstract = new File(destDir, gmoClassName + "Abstract.java");
+ File outImpl = new File(destDir, gmoClassName + "Impl.java");
+
+ if (lastModification > out.lastModified()) {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Generation of " + gmo.getClassDescriptor().getName());
+ }
+ if (!out.exists()) {
+ try {
+ out.createNewFile();
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
+ }
+ if (!outAbstract.exists()) {
+ try {
+ outAbstract.createNewFile();
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
+ }
+ if (!outImpl.exists()) {
+ try {
+ outImpl.createNewFile();
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
+ }
+ SwingInterfaceGenerator ing = new SwingInterfaceGenerator(gmo);
+ ing.generate(out);
+ SwingAbstractClassGenerator acg = new SwingAbstractClassGenerator(gmo);
+ acg.generate(outAbstract);
+ SwingImplementationGenerator img = new SwingImplementationGenerator(gmo);
+ img.generate(outImpl);
+ serializer.startTag("", "bean");
+ serializer.attribute("", "id", gmoClassName.replace(gmoClassName.charAt(0), Character.toLowerCase(gmoClassName.charAt(0))));
+ serializer.attribute("", "class", gmo.getClassDescriptor().getPackageName() + "." + gmoClassName + "Impl");
+ serializer.attribute("", "singleton", "false");
+ serializer.endTag("", "bean");
+ if (mainClass) {
+ SwingMainClassGenerator mcg = new SwingMainClassGenerator(gmo, destDir);
+ FileWriter fw = null;
+ try {
+ fw = new FileWriter(new File(destDir, "Main.java"));
+ fw.write(mcg.getClassContent());
+ fw.close();
+ }
+ catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error(ex);
+ }
+ }
+ finally {
+ try {
+ fw.close();
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
+ }
+ serializer.startTag("", "bean");
+ serializer.attribute("", "id", "main");
+ serializer.attribute("", "class", gmo.getClassDescriptor().getPackageName() + ".Main");
+ serializer.startTag("", "property");
+ serializer.attribute("", "name", gmoClassName.replace(gmoClassName.charAt(0), Character.toLowerCase(gmoClassName.charAt(0))));
+ serializer.startTag("", "ref");
+ serializer.attribute("", "bean", gmoClassName.replace(gmoClassName.charAt(0), Character.toLowerCase(gmoClassName.charAt(0))));
+ serializer.endTag("", "ref");
+ serializer.endTag("", "property");
+ serializer.endTag("", "bean");
+ }
+ }
+ catch (IOException ex) {
+ log.error(ex);
+ }
+ catch (IllegalArgumentException ex) {
+ log.error(ex);
+ }
+ catch (IllegalStateException ex) {
+ log.error(ex);
+ }
+ }
+ else if (log.isWarnEnabled()) {
+ log.warn(gmo.getClassDescriptor().getName() + " has already been generated and is up to date.");
+ }
+ }
+}
Added: guix/trunk/guix-compiler-swing/src/spring/SwingImplementationGenerator.java
===================================================================
--- guix/trunk/guix-compiler-swing/src/spring/SwingImplementationGenerator.java (rev 0)
+++ guix/trunk/guix-compiler-swing/src/spring/SwingImplementationGenerator.java 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,53 @@
+
+/*
+* To change this template, choose Tools | Templates
+* and open the template in the editor.
+ */
+package org.nuiton.guix.generator.spring;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import org.nuiton.guix.generator.*;
+import org.nuiton.guix.model.GuixModelObject;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.File;
+import java.lang.reflect.Modifier;
+
+/**
+ *
+ * @author morin
+ */
+public class SwingImplementationGenerator extends JavaFileGenerator {
+ public SwingImplementationGenerator(GuixModelObject gmo) {
+ super(gmo);
+ jf = new JavaFile(gmo.getClassDescriptor().getPackageName(),
+ Modifier.PUBLIC,
+ JavaFile.CLASS,
+ gmo.getClassDescriptor().getName() + "Impl",
+ gmo.getClassDescriptor().getName() + "Abstract");
+ }
+
+ @Override
+ public void generate(File out) {
+ super.generate();
+
+ if (!gmo.getJavadoc().equals("")) {
+ sb.append("\n/**\n * ");
+ sb.append(gmo.getJavadoc());
+ sb.append("\n */");
+ }
+
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, null, gmo.getClassDescriptor().getName() + "Impl",
+ null, null, "super();"));
+
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "initialize", null, null, "super.initialize();"));
+
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "test", null, null, "setVisible(true);"));
+
+ saveFile(out);
+ }
+
+}
+
Added: guix/trunk/guix-compiler-swing/src/spring/SwingInterfaceGenerator.java
===================================================================
--- guix/trunk/guix-compiler-swing/src/spring/SwingInterfaceGenerator.java (rev 0)
+++ guix/trunk/guix-compiler-swing/src/spring/SwingInterfaceGenerator.java 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,50 @@
+package org.nuiton.guix.generator.spring;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import org.nuiton.guix.generator.*;
+import org.nuiton.guix.model.GuixModelObject;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.File;
+import java.lang.reflect.Modifier;
+
+/**
+ * Generator of interfaces
+ *
+ * @author morin
+ */
+public class SwingInterfaceGenerator extends JavaFileGenerator {
+ public SwingInterfaceGenerator(GuixModelObject gmo) {
+ super(gmo);
+ jf = new JavaFile(gmo.getClassDescriptor().getPackageName(),
+ Modifier.PUBLIC,
+ JavaFile.INTERFACE,
+ gmo.getClassDescriptor().getName(),
+ null);
+ }
+
+ @Override
+ public void generate(File out) {
+ super.generate();
+ addFields(gmo);
+ jf.addMethod(new JavaMethod(Modifier.PUBLIC, "void", "test", null, null, null));
+ //sb.append("\n\npublic void test();\n\n}");
+ saveFile(out);
+ }
+
+ private void addFields(GuixModelObject gmo) {
+ for (GuixModelObject child : gmo.getChildren()) {
+ jf.addField(new JavaField(Modifier.PRIVATE,
+ child.getClassDescriptor().getName(),
+ child.getId()),
+ true);
+ addFields(child);
+ }
+ }
+
+}
+
+
+//~ Formatted by Jindent --- http://www.jindent.com
Added: guix/trunk/guix-compiler-swing/src/spring/SwingMainClassGenerator.java
===================================================================
--- guix/trunk/guix-compiler-swing/src/spring/SwingMainClassGenerator.java (rev 0)
+++ guix/trunk/guix-compiler-swing/src/spring/SwingMainClassGenerator.java 2009-05-15 13:59:55 UTC (rev 1403)
@@ -0,0 +1,66 @@
+package org.nuiton.guix.generator.spring;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import org.nuiton.guix.generator.*;
+import org.nuiton.guix.model.GuixModelObject;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.File;
+import java.lang.reflect.Modifier;
+
+/**
+ * Generator of interfaces
+ *
+ * @author morin
+ */
+public class SwingMainClassGenerator {
+ private JavaFile clazz;
+
+ public SwingMainClassGenerator(GuixModelObject gmo, File destDir) {
+ String gmoClassName = gmo.getClassDescriptor().getName();
+ String gmoAttributeName = gmoClassName.replace(gmoClassName.charAt(0),
+ Character.toLowerCase(gmoClassName.charAt(0)));
+
+ clazz = new JavaFile(gmo.getClassDescriptor().getPackageName(),
+ Modifier.PUBLIC,
+ JavaFile.CLASS, "Main", null);
+
+ clazz.addImport("java.io.File");
+ clazz.addImport("org.springframework.beans.factory.ListableBeanFactory");
+ clazz.addImport("org.springframework.beans.factory.xml.XmlBeanFactory");
+ clazz.addImport("org.springframework.core.io.FileSystemResource");
+
+ StringBuffer mainMethod = new StringBuffer();
+ mainMethod.append("//usine à beans\n")
+ .append("ListableBeanFactory bf = new XmlBeanFactory(")
+ .append("new FileSystemResource(new File(\"")
+ .append(destDir.getAbsolutePath())
+ .append("/config.xml\")));\n")
+ .append(gmoClassName)
+ .append(" ")
+ .append(gmoAttributeName)
+ .append(" = (")
+ .append(gmoClassName)
+ .append(") bf.getBean(\"")
+ .append(gmoAttributeName)
+ .append("\");\n")
+ .append(gmoAttributeName)
+ .append(".test();");
+ //SwingUtilities.invokeLater(new Runnable() { public void run() { new JAXXDemo().setVisible(true); } });
+
+ clazz.addMethod(new JavaMethod(
+ Modifier.PUBLIC | Modifier.STATIC,
+ "void",
+ "main",
+ new JavaArgument[]{new JavaArgument("String[]", "args")},
+ null,
+ mainMethod.toString()));
+ }
+
+ public String getClassContent() {
+ return clazz.toString("\n");
+ }
+}
+
1
0
r1402 - in guix/trunk/guix-compiler/src: main/java/org/nuiton/guix main/java/org/nuiton/guix/compiler main/java/org/nuiton/guix/databinding main/java/org/nuiton/guix/generator test/java/org/nuiton/guix test/java/org/nuiton/guix/compiler
by kmorin@users.labs.libre-entreprise.org 15 May '09
by kmorin@users.labs.libre-entreprise.org 15 May '09
15 May '09
Author: kmorin
Date: 2009-05-15 13:59:00 +0000 (Fri, 15 May 2009)
New Revision: 1402
Added:
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/databinding/
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/databinding/BindingUtils.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/Generator.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaArgument.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaField.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFile.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFileGenerator.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaMethod.java
Removed:
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/AbstractClassGenerator.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/ImplementationGenerator.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/InterfaceGenerator.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/MainClassGenerator.java
Modified:
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/compiler/GuixCompiler.java
guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/GuixGenerator.java
guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/GuixLauncherTest.java
guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/compiler/GuixCompilerTest.java
Log:
G?\195?\169n?\195?\169ration des classes
Modified: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -4,26 +4,21 @@
import org.nuiton.guix.compiler.GuixCompiler;
import java.io.File;
import java.io.FileWriter;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.guix.generator.AbstractClassGenerator;
-import org.nuiton.guix.generator.ImplementationGenerator;
-import org.nuiton.guix.generator.InterfaceGenerator;
-import org.nuiton.guix.generator.MainClassGenerator;
+import org.nuiton.guix.generator.Generator;
+import org.nuiton.guix.generator.GuixGenerator;
import org.nuiton.guix.model.ClassDescriptor;
import org.nuiton.guix.model.GuixModelObject;
import org.nuiton.guix.model.Rule;
import org.nuiton.guix.model.Selector;
import org.nuiton.guix.model.StyleSheet;
-import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlSerializer;
/**
@@ -45,8 +40,8 @@
protected List<String> guixFileClassNames = new ArrayList<String>();
/** Maps the root GuixModelObjects being compiled to the compiler instance
* handling the compilation. */
- protected Map<GuixModelObject, GuixCompiler> rootModelObjects =
- new HashMap<GuixModelObject, GuixCompiler>();
+ protected Map<GuixModelObject, Long> rootModelObjects =
+ new HashMap<GuixModelObject, Long>();
/** CLassDescriptor met during the compilation */
protected List<ClassDescriptor> classDescriptors =
new ArrayList<ClassDescriptor>();
@@ -55,6 +50,7 @@
private File targetDirectory;
private String rootPackage;
private String mainClass;
+ private Class generatorClass;
/**
* Constructor
@@ -62,7 +58,7 @@
* @param files the files to compile
*/
public GuixLauncher(File[] files, File targetDirectory, String rootPackage,
- File baseDir, String mainClass) {
+ File baseDir, String mainClass, Class generatorClass) {
// Set up a simple configuration that logs on the console.
this.files = files;
this.targetDirectory = targetDirectory;
@@ -94,6 +90,7 @@
else {
mainClass = "";
}
+ this.generatorClass = generatorClass;
}
/**
@@ -153,7 +150,7 @@
GuixCompiler compiler = new GuixCompiler(file, this, classPackage);
GuixModelObject rootModelObject = compiler.compile();
- rootModelObjects.put(rootModelObject, compiler);
+ rootModelObjects.put(rootModelObject, compiler.getLastModification());
if (compiler.isFailed()) {
success = false;
@@ -177,225 +174,123 @@
}
}
}
- if (success || true) {
- XmlPullParserFactory factory =
- XmlPullParserFactory.newInstance(
- System.getProperty(XmlPullParserFactory.PROPERTY_NAME),
- null);
- XmlSerializer serializer = factory.newSerializer();
- File config = new File(destDir,"config.xml");
-
- serializer.setOutput(new PrintWriter(config));
- serializer.startDocument("UTF-8", null);
- serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n");
- serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "\t");
- serializer.text("\n");
- serializer.docdecl(" beans SYSTEM \"http://www.springframework.org/dtd/spring-beans.dtd\"");
- serializer.text("\n");
- serializer.startTag("", "beans");
-
+ if (generatorClass != null) {
for (GuixModelObject mo : rootModelObjects.keySet()) {
- String moClassName = mo.getClassDescriptor().getName();
- //File f = new File(destDir, mo.getClassDescriptor().getName() + "ModelTree.xml");
- File out = new File(destDir, moClassName + ".java");
- File outAbstract = new File(destDir, moClassName + "Abstract.java");
- File outImpl = new File(destDir, moClassName + "Impl.java");
-
- if (log.isInfoEnabled()) {
- log.info(moClassName + " last modification : " + new Date(rootModelObjects.get(mo).getLastModification()));
+ try {
+ Generator gen = (GuixGenerator) generatorClass.newInstance();
+ gen.setDestDir(destDir);
+ gen.setGmo(mo);
+ gen.setLastModification(rootModelObjects.get(mo));
+ gen.setMainClass((mo.getClassDescriptor().getPackageName() + "." + mo.getClassDescriptor().getName()).equals(mainClass));
+ gen.generate();
+ /*= new SwingGenerator(mo,destDir,
+ (mo.getClassDescriptor().getPackageName() + "." + mo.getClassDescriptor().getName()).equals(mainClass),
+ rootModelObjects.get(mo), serializer);
+ }*/
}
-
- if (rootModelObjects.get(mo).getLastModification() > out.lastModified()) {
- if (log.isInfoEnabled()) {
- log.info("Generation of " + mo.getClassDescriptor().getName());
- }
- if (!out.exists()) {
- out.createNewFile();
- }
- if (!outAbstract.exists()) {
- outAbstract.createNewFile();
- }
- if (!outImpl.exists()) {
- outImpl.createNewFile();
- }
- /*XmlSerializer serializer = factory.newSerializer();
- XmlSerializer cssSerializer = factory.newSerializer();
-
- serializer.setOutput(new PrintWriter(f));
- serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n");
- serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "\t");
-
- cssSerializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n");
- cssSerializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "\t");
-
- writeModelTree(serializer, mo, cssSerializer, destDir);
-
- serializer.endDocument();*/
-
- InterfaceGenerator ing = new InterfaceGenerator(mo);
- ing.generate(out);
-
- AbstractClassGenerator acg = new AbstractClassGenerator(mo);
- acg.generate(outAbstract);
-
- ImplementationGenerator img = new ImplementationGenerator(mo);
- img.generate(outImpl);
-
- serializer.startTag("", "bean");
- serializer.attribute("", "id", moClassName.replace(moClassName.charAt(0),
- Character.toLowerCase(moClassName.charAt(0))));
- serializer.attribute("", "class",
- mo.getClassDescriptor().getPackageName() + "." + moClassName + "Impl");
- serializer.attribute("", "singleton", "false");
- serializer.endTag("", "bean");
-
- if ((mo.getClassDescriptor().getPackageName() + "." + mo.getClassDescriptor().getName()).equals(mainClass)) {
- MainClassGenerator mcg = new MainClassGenerator(mo, destDir);
- FileWriter fw = null;
- try {
- fw = new FileWriter(new File(destDir, "Main.java"));
- fw.write(mcg.getClassContent());
- fw.close();
- }
- catch (IOException ex) {
- if (log.isErrorEnabled()) {
- log.error(ex);
- }
- }
- finally {
- try {
- fw.close();
- }
- catch (IOException ex) {
- log.error(ex);
- }
- }
-
- serializer.startTag("", "bean");
- serializer.attribute("", "id", "main");
- serializer.attribute("", "class", mo.getClassDescriptor().getPackageName() + ".Main");
- serializer.startTag("", "property");
- serializer.attribute("", "name", moClassName.replace(moClassName.charAt(0),
- Character.toLowerCase(moClassName.charAt(0))));
- serializer.startTag("", "ref");
- serializer.attribute("", "bean", moClassName.replace(moClassName.charAt(0),
- Character.toLowerCase(moClassName.charAt(0))));
- serializer.endTag("", "ref");
- serializer.endTag("", "property");
- serializer.endTag("", "bean");
- }
- /*<bean id = "articlesDao" class
-
- ="istia.st.articles.dao.ArticlesDaoPlainJdbc">
- <constructor-arg index="0">
- <value>org.firebirdsql.jdbc.FBDriver</value>
- </constructor-arg>
- <constructor-arg index="1">
- <value>jdbc:firebirdsql:localhost/3050:d:/databases/dbarticles.gdb</value>
- </constructor-arg>
- <constructor-arg index="2">
- <value>someone</value>
- </constructor-arg>
- <constructor-arg index="3">
- <value>somepassword</value>
- </constructor-arg>
- </bean>*/
-
-
+ catch (InstantiationException ex) {
+ log.error(ex);
}
- else if (log.isWarnEnabled()) {
- log.warn(mo.getClassDescriptor().getName() + " has already been generated and is up to date.");
+ catch (IllegalAccessException ex) {
+ log.error(ex);
}
+ catch (NullPointerException ex) {
+ log.error(ex);
+ }
}
- serializer.endTag("", "beans");
- serializer.endDocument();
-
- /*// pass 2
- if (!nextStep(LifeCycle.compile_second_pass, success)) {
- return false;
}
-
- assert guixFiles.size() == guixFileClassNames.size();
- List<File> jaxxFilesClone = new ArrayList<File>(guixFiles);
- for (String className : guixFileClassNames) {
- JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during second pass");
- addProfileTime(compiler, currentPass.name() + "_start");
- if (log.isDebugEnabled()) {
- log.debug("runInitializers for " + className);
+ else {
+ if(log.isWarnEnabled()) {
+ log.warn("No generation language given");
+ }
}
- if (!compiler.isFailed()) {
- compiler.runInitializers();
- }
- if (log.isDebugEnabled()) {
- log.debug("compile second pass for " + className);
- }
- compiler.compileSecondPass();
- addProfileTime(compiler, currentPass.name() + "_end");
- if (log.isDebugEnabled()) {
- log.debug("done with result [" + !compiler.isFailed() + "] for " + className);
- }
- if (compiler.isFailed()) {
- success = false;
- }
- }
- if (!jaxxFilesClone.equals(guixFiles)) {
- throw new AssertionError("Internal error: compilation set altered during pass 2 (was " + jaxxFilesClone + ", modified to " + guixFiles + ")");
- }
- // stylesheet application
- if (!nextStep(LifeCycle.stylesheet_pass, success)) {
- return false;
- }
- assert guixFiles.size() == guixFileClassNames.size();
- for (String className : guixFileClassNames) {
- JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during stylesheet application");
- addProfileTime(compiler, currentPass.name() + "_start");
- compiler.applyStylesheets();
- addProfileTime(compiler, currentPass.name() + "_end");
- if (compiler.isFailed()) {
- success = false;
- }
- }
+ /*// pass 2
+ if (!nextStep(LifeCycle.compile_second_pass, success)) {
+ return false;
+ }
- // code generation
- if (!nextStep(LifeCycle.generate_pass, success)) {
- return false;
- }
- assert guixFiles.size() == guixFileClassNames.size();
- List<Generator> generators = new ArrayList<Generator>();
- for (Generator generator : ServiceLoader.load(Generator.class)) {
- generators.add(generator);
- }
- for (String className : guixFileClassNames) {
- JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation");
- addProfileTime(compiler, currentPass.name() + "_start");
- compiler.generateCode(generators);
- addProfileTime(compiler, currentPass.name() + "_end");
- //compiler.generateCode();
- if (compiler.isFailed()) {
- success = false;
- }
- }
+ assert guixFiles.size() == guixFileClassNames.size();
+ List<File> jaxxFilesClone = new ArrayList<File>(guixFiles);
+ for (String className : guixFileClassNames) {
+ JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during second pass");
+ addProfileTime(compiler, currentPass.name() + "_start");
+ if (log.isDebugEnabled()) {
+ log.debug("runInitializers for " + className);
+ }
+ if (!compiler.isFailed()) {
+ compiler.runInitializers();
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("compile second pass for " + className);
+ }
+ compiler.compileSecondPass();
+ addProfileTime(compiler, currentPass.name() + "_end");
+ if (log.isDebugEnabled()) {
+ log.debug("done with result [" + !compiler.isFailed() + "] for " + className);
+ }
+ if (compiler.isFailed()) {
+ success = false;
+ }
+ }
+ if (!jaxxFilesClone.equals(guixFiles)) {
+ throw new AssertionError("Internal error: compilation set altered during pass 2 (was " + jaxxFilesClone + ", modified to " + guixFiles + ")");
+ }
- if (options.isProfile()) {
- // profile pass (only if succes compile)
- if (!nextStep(LifeCycle.profile_pass, success)) {
- return false;
- }
- StringBuilder buffer = profiler.computeProfileReport();
- log.info(buffer.toString());
- }
+ // stylesheet application
+ if (!nextStep(LifeCycle.stylesheet_pass, success)) {
+ return false;
+ }
+ assert guixFiles.size() == guixFileClassNames.size();
+ for (String className : guixFileClassNames) {
+ JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during stylesheet application");
+ addProfileTime(compiler, currentPass.name() + "_start");
+ compiler.applyStylesheets();
+ addProfileTime(compiler, currentPass.name() + "_end");
+ if (compiler.isFailed()) {
+ success = false;
+ }
+ }
- return report(success);
+ // code generation
+ if (!nextStep(LifeCycle.generate_pass, success)) {
+ return false;
+ }
+ assert guixFiles.size() == guixFileClassNames.size();
+ List<Generator> generators = new ArrayList<Generator>();
+ for (Generator generator : ServiceLoader.load(Generator.class)) {
+ generators.add(generator);
+ }
+ for (String className : guixFileClassNames) {
+ JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation");
+ addProfileTime(compiler, currentPass.name() + "_start");
+ compiler.generateCode(generators);
+ addProfileTime(compiler, currentPass.name() + "_end");
+ //compiler.generateCode();
+ if (compiler.isFailed()) {
+ success = false;
+ }
+ }
- //FIXME : deal better the exception treatment...
- } catch (CompilerException e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- return false;*/
- }
+ if (options.isProfile()) {
+ // profile pass (only if succes compile)
+ if (!nextStep(LifeCycle.profile_pass, success)) {
+ return false;
}
+ StringBuilder buffer = profiler.computeProfileReport();
+ log.info(buffer.toString());
+ }
+
+ return report(success);
+
+ //FIXME : deal better the exception treatment...
+ } catch (CompilerException e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ return false;
+ }*/
+ }
catch (Throwable e) {
e.printStackTrace();
return false;
@@ -514,9 +409,9 @@
* @return false if another ClassDescriptor with the same classname
* and package has a different script or superclass
*/
- public boolean registerClassDescriptor(ClassDescriptor classDescriptor) {
+ public ClassDescriptor registerClassDescriptor(ClassDescriptor classDescriptor) {
if (classDescriptor == null || classDescriptor.getName() == null) {
- return false;
+ return null;
}
int i = 0;
while (i < classDescriptors.size() && (!classDescriptors.get(i).getName().equals(classDescriptor.getName()) || (classDescriptors.get(i).getPackageName() != null && classDescriptor.getPackageName() != null && !classDescriptors.get(i).getPackageName().equals(classDescriptor.getPackageName())))) {
@@ -528,8 +423,9 @@
if (log.isDebugEnabled()) {
log.debug("new ClassDescriptor " + classDescriptor + " inserted");
}
- return true;
+ return classDescriptor;
}
+ classDescriptors.get(i).setPackageName(classDescriptor.getPackageName());
if (classDescriptor.getScript() != null) {
if (classDescriptors.get(i).getScript() == null) {
classDescriptors.get(i).setScript(classDescriptor.getScript());
@@ -541,7 +437,7 @@
if (log.isDebugEnabled()) {
log.error("ClassDescriptor " + classDescriptor + " script already defined and different !");
}
- return false;
+ return null;
}
}
if (classDescriptor.getSuperClass() != null) {
@@ -555,9 +451,9 @@
if (log.isErrorEnabled()) {
log.error("ClassDescriptor " + classDescriptor + " superclass already defined and different !");
}
- return false;
+ return null;
}
}
- return true;
+ return classDescriptors.get(i);
}
}
Modified: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/compiler/GuixCompiler.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/compiler/GuixCompiler.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/compiler/GuixCompiler.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -143,7 +143,10 @@
// the class name is the name of the file minus the extension
String className = src.getName().substring(0, src.getName().lastIndexOf('.'));
- rootMO.setClassDescriptor(new ClassDescriptor(className, srcPackage));
+ // register the ClassDescriptor
+ ClassDescriptor cd = launcher.registerClassDescriptor(new ClassDescriptor(className, srcPackage));
+ rootMO.setClassDescriptor(cd);
+ failed = cd == null;
rootMO.getClassDescriptor().setSuperClass(new ClassDescriptor(tagName, tagPackageName));
rootMO.setAttributeDescriptors(getAttributes(xpp));
rootMO.setChildren(new ArrayList<GuixModelObject>());
@@ -184,9 +187,6 @@
// all the script tags have been recorded
rootMO.getClassDescriptor().setScript(script.toString());
- // register the root ClassDescriptor
- failed = !launcher.registerClassDescriptor(rootMO.getClassDescriptor());
-
return rootMO;
}
} catch (XmlPullParserException ex) {
@@ -247,7 +247,7 @@
// the parent is still the same
prev = previousMO;
} // if the tag is a script tag
- else if ((xpp.getName() != null) && xpp.getName().equals("script")) {
+ else if ((xpp.getName() != null) && xpp.getName().equals("script")) {
File scriptFile = null;
// the name of the file to load
@@ -268,7 +268,7 @@
// the parent is still the same
prev = previousMO;
} // if the tag is a class tag
- else {
+ else {
String tagNameSpace = xpp.getNamespace();
String tagPackageName = resolvePackageName(tagNameSpace, xpp.getName());
String tagName;
@@ -288,17 +288,18 @@
GuixModelObject mo = new GuixModelObject(id, javaDoc, xpp.getAttributeValue("", "styleClass"));
mo.setParent(previousMO);
- mo.setClassDescriptor(new ClassDescriptor(tagName, tagPackageName));
+ mo.setAttributeDescriptors(getAttributes(xpp));
mo.setChildren(new ArrayList<GuixModelObject>());
// add this GuixModelObject to the children of the parent
previousMO.getChildren().add(mo);
// register the ClassDescriptor
- failed = !launcher.registerClassDescriptor(mo.getClassDescriptor());
+ ClassDescriptor cd = launcher.registerClassDescriptor(new ClassDescriptor(tagName, tagPackageName));
+ mo.setClassDescriptor(cd);
+ failed = cd == null;
if (!failed) {
-
// parse the children of the tag
prev = mo;
} else {
Added: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/databinding/BindingUtils.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/databinding/BindingUtils.java (rev 0)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/databinding/BindingUtils.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -0,0 +1,155 @@
+package org.nuiton.guix.databinding;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.swing.JToggleButton;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author kevin
+ */
+public class BindingUtils {
+ /** left brace matcher */
+ protected static Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher("");
+ /** right brace matcher */
+ protected static Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher("");
+ /** log */
+ private static Log log = LogFactory.getLog(BindingUtils.class);
+
+ /**
+ * Examine an attribute value for data binding expressions. Returns a 'cooked' expression which
+ * can be used to determine the resulting value. It is expected that this expression will be used
+ * as the source expression in a call to {@link #registerDataBinding}.
+ * If the attribute value does not invoke data binding, this method returns <code>null</code>
+ *
+ * @param stringValue the string value of the property from the XML
+ * @param type the type of the property, from the <code>JAXXPropertyDescriptor</code>
+ * @return a processed version of the expression
+ * @throws jaxx.CompilerException ?
+ */
+ public static String processDataBindings(String stringValue) {
+ int pos = getNextLeftBrace(stringValue, 0);
+ if (pos != -1) {
+ StringBuffer expression = new StringBuffer();
+ int lastPos = 0;
+ while (pos != -1 && pos < stringValue.length()) {
+ if (pos > lastPos) {
+ if (expression.length() > 0) {
+ expression.append(" + ");
+ }
+ expression.append('"');
+ expression.append(escapeJavaString(stringValue.substring(lastPos, pos)));
+ expression.append('"');
+ }
+
+ if (expression.length() > 0) {
+ expression.append(" + ");
+ }
+ int pos2 = getNextRightBrace(stringValue, pos + 1);
+ if (pos2 == -1) {
+ if(log.isErrorEnabled())
+ log.error("unmatched '{' in expression: " + stringValue);
+ return "";
+ }
+ expression.append(stringValue.substring(pos + 1, pos2));
+ pos2++;
+ if (pos2 < stringValue.length()) {
+ pos = getNextLeftBrace(stringValue, pos2);
+ lastPos = pos2;
+ } else {
+ pos = stringValue.length();
+ lastPos = pos;
+ }
+ }
+ if (lastPos < stringValue.length()) {
+ if (expression.length() > 0) {
+ expression.append(" + ");
+ }
+ expression.append('"');
+ expression.append(escapeJavaString(stringValue.substring(lastPos)));
+ expression.append('"');
+ }
+
+ StringBuffer el = new StringBuffer();
+ Pattern p = Pattern .compile("\\.(get|is)([A-Z])([a-zA-Z0-9]*)\\(\\)");
+ Matcher m = p.matcher(expression.toString());
+ int mEnd = 0;
+ if(m.find()) {
+ do {
+ el.append(expression.toString().substring(mEnd, m.start()))
+ .append(".");
+ mEnd = m.end();
+ el.append(m.group(2).toLowerCase())
+ .append(m.group(3));
+ } while (m.find());
+ }
+ else {
+ el.append(expression.toString());
+ }
+ return el.toString().length() > 0 ? el.toString().substring(0, el.toString().length()) : el.toString();
+ }
+ return null;
+ }
+
+ protected static int getNextLeftBrace(String string, int pos) {
+ leftBraceMatcher.reset(string);
+ return leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1;
+ }
+
+ protected static int getNextRightBrace(String string, int pos) {
+ leftBraceMatcher.reset(string);
+ rightBraceMatcher.reset(string);
+ int openCount = 1;
+ int rightPos;
+ while (openCount > 0) {
+ pos++;
+ int leftPos = leftBraceMatcher.find(pos) ? Math.max(leftBraceMatcher.start(1), leftBraceMatcher.start(2)) : -1;
+ rightPos = rightBraceMatcher.find(pos) ? Math.max(rightBraceMatcher.start(1), rightBraceMatcher.start(2)) : -1;
+ assert leftPos == -1 || leftPos >= pos;
+ assert rightPos == -1 || rightPos >= pos;
+ if (leftPos != -1 && leftPos < rightPos) {
+ pos = leftPos;
+ openCount++;
+ } else if (rightPos != -1) {
+ pos = rightPos;
+ openCount--;
+ } else {
+ openCount = 0;
+ }
+ }
+ return pos;
+ }
+
+ /**
+ * Escapes a string using standard Java escape sequences, generally in preparation to including it in a string literal
+ * in a compiled Java file.
+ *
+ * @param raw the raw string to be escape
+ * @return a string in which all 'dangerous' characters have been replaced by equivalent Java escape sequences
+ */
+ protected static String escapeJavaString(String raw) {
+ StringBuffer out = new StringBuffer(raw);
+ for (int i = 0; i < out.length(); i++) {
+ char c = out.charAt(i);
+ if (c == '\\' || c == '"') {
+ out.insert(i, '\\');
+ i++;
+ } else if (c == '\n') {
+ out.replace(i, i + 1, "\\n");
+ i++;
+ } else if (c == '\r') {
+ out.replace(i, i + 1, "\\r");
+ i++;
+ } else if (c < 32 || c > 127) {
+ String value = Integer.toString((int) c, 16);
+ while (value.length() < 4) {
+ value = "0" + value;
+ }
+ out.replace(i, i + 1, "\\u" + value);
+ i += 5;
+ }
+ }
+ return out.toString();
+ }
+}
Deleted: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/AbstractClassGenerator.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/AbstractClassGenerator.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/AbstractClassGenerator.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -1,87 +0,0 @@
-package org.nuiton.guix.generator;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.nuiton.guix.model.GuixModelObject;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-
-/**
- *
- * @author morin
- */
-public class AbstractClassGenerator extends GuixGenerator {
- public AbstractClassGenerator(GuixModelObject gmo) {
- super(gmo);
- }
-
- @Override
- public void generate(File out) {
- super.generate();
-
- if (!gmo.getJavadoc().equals("")) {
- sb.append("\n/**\n* ");
- sb.append(gmo.getJavadoc());
- sb.append("\n*/");
- }
-
- sb.append("\npublic abstract class ");
- sb.append(gmo.getClassDescriptor().getName());
- sb.append("Abstract implements ");
- sb.append(gmo.getClassDescriptor().getName());
- sb.append(" {\n");
- addAttributes(gmo);
- sb.append("\n\n\t//Getters and Setters");
- addGettersAndSetters(gmo);
- sb.append("\n\npublic abstract void test();\n\n}");
- saveFile(out);
- }
-
- @Override
- protected void addGettersAndSetters(GuixModelObject gmo) {
- for (GuixModelObject child : gmo.getChildren()) {
- sb.append("\n\n\tpublic ");
- sb.append(child.getClassDescriptor().getName());
- sb.append(" get");
- sb.append(child.getId().replace(child.getId().charAt(0), Character.toUpperCase(child.getId().charAt(0))));
- sb.append("() {\n\t\treturn this.");
- sb.append(((child.getId() != null) &&!child.getId().equals(""))
- ? child.getId()
- : "test");
- sb.append(";\n\t}");
- sb.append("\n\n\tpublic ");
- sb.append("void set");
- sb.append(child.getId().replace(child.getId().charAt(0), Character.toUpperCase(child.getId().charAt(0))));
- sb.append("(");
- sb.append(child.getClassDescriptor().getName());
- sb.append(" ");
- sb.append(child.getId());
- sb.append("){\n\t\tthis.");
- sb.append(child.getId());
- sb.append(" = ");
- sb.append(child.getId());
- sb.append(";\n\t}");
- addGettersAndSetters(child);
- }
- }
-
- private void addAttributes(GuixModelObject gmo) {
- for (GuixModelObject child : gmo.getChildren()) {
- if (!child.getJavadoc().equals("")) {
- sb.append("\n\t/**\n\t * ");
- sb.append(child.getJavadoc());
- sb.append("\n\t */");
- }
-
- sb.append("\n\tprivate ");
- sb.append(child.getClassDescriptor().getName());
- sb.append(" ");
- sb.append(child.getId());
- sb.append(";\n");
- addAttributes(child);
- }
- }
-}
-
Copied: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/Generator.java (from rev 1395, guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/GuixGenerator.java)
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/Generator.java (rev 0)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/Generator.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -0,0 +1,30 @@
+package org.nuiton.guix.generator;
+import java.io.File;
+import org.nuiton.guix.model.GuixModelObject;
+import org.xmlpull.v1.XmlSerializer;
+
+/**
+ *
+ * @author kevin
+ */
+public interface Generator {
+
+ public void generate();
+
+ public File getDestDir();
+
+ public void setDestDir(File destDir);
+
+ public GuixModelObject getGmo();
+
+ public void setGmo(GuixModelObject gmo);
+
+ public Long getLastModification();
+
+ public void setLastModification(Long lastModification);
+
+ public boolean isMainClass();
+
+ public void setMainClass(boolean mainClass);
+
+}
Property changes on: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/Generator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/GuixGenerator.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/GuixGenerator.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/GuixGenerator.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -1,81 +1,56 @@
-package org.nuiton.guix.generator;
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
+package org.nuiton.guix.generator;
+import java.io.File;
import org.nuiton.guix.model.GuixModelObject;
+import org.xmlpull.v1.XmlSerializer;
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.List;
-
/**
- * GuixGenerator
*
+ * @author kevin
*/
-public abstract class GuixGenerator {
+public abstract class GuixGenerator implements Generator {
- /** log */
- protected Log log = LogFactory.getLog(GuixGenerator.class);
- protected StringBuffer sb = new StringBuffer();
- protected List<String> classes = new ArrayList<String>();
- protected GuixModelObject gmo;
+ protected GuixModelObject gmo = null;
+ protected File destDir = null;
+ protected boolean mainClass = false;
+ protected Long lastModification = null;
- public GuixGenerator(GuixModelObject gmo) {
- this.gmo = gmo;
+ public abstract void generate();
+
+ public File getDestDir() {
+ return destDir;
}
- public abstract void generate(File out);
+ public void setDestDir(File destDir) {
+ this.destDir = destDir;
+ }
- protected void generate() {
- sb.append("package ");
- sb.append(gmo.getClassDescriptor().getPackageName());
- sb.append(";\n\n");
- addImports(gmo);
+ public GuixModelObject getGmo() {
+ return gmo;
}
- protected abstract void addGettersAndSetters(GuixModelObject gmo);
+ public void setGmo(GuixModelObject gmo) {
+ this.gmo = gmo;
+ }
- protected void addImports(GuixModelObject gmo) {
- for (GuixModelObject child : gmo.getChildren()) {
- String fqn = child.getClassDescriptor().getPackageName() + "." + child.getClassDescriptor().getName();
+ public Long getLastModification() {
+ return lastModification;
+ }
- if (!classes.contains(fqn)) {
- classes.add(fqn);
- sb.append("import " + fqn + ";\n");
- }
+ public void setLastModification(Long lastModification) {
+ this.lastModification = lastModification;
+ }
- addImports(child);
- }
+ public boolean isMainClass() {
+ return mainClass;
}
- protected void saveFile(File out) {
- FileWriter fw = null;
-
- try {
- fw = new FileWriter(out);
- fw.write(sb.toString());
- fw.close();
- } catch (IOException ex) {
- if (log.isErrorEnabled()) {
- log.error(ex);
- }
- } finally {
- try {
- fw.close();
- } catch (IOException ex) {
- log.error(ex);
- }
- }
+ public void setMainClass(boolean mainClass) {
+ this.mainClass = mainClass;
}
-}
-
-//~ Formatted by Jindent --- http://www.jindent.com
+}
Deleted: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/ImplementationGenerator.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/ImplementationGenerator.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/ImplementationGenerator.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -1,51 +0,0 @@
-
-/*
-* To change this template, choose Tools | Templates
-* and open the template in the editor.
- */
-package org.nuiton.guix.generator;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.nuiton.guix.model.GuixModelObject;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- *
- * @author morin
- */
-public class ImplementationGenerator extends GuixGenerator {
- public ImplementationGenerator(GuixModelObject gmo) {
- super(gmo);
- }
-
- @Override
- public void generate(File out) {
- super.generate();
-
- if (!gmo.getJavadoc().equals("")) {
- sb.append("\n/**\n * ");
- sb.append(gmo.getJavadoc());
- sb.append("\n */");
- }
-
- sb.append("\npublic class ");
- sb.append(gmo.getClassDescriptor().getName());
- sb.append("Impl extends ");
- sb.append(gmo.getClassDescriptor().getName());
- sb.append("Abstract {\n");
- sb.append("public void test() {System.out.println(\"ca marche\");}");
- sb.append("\n\n}");
- saveFile(out);
- }
-
- @Override
- protected void addGettersAndSetters(GuixModelObject gmo) {}
-}
-
-
-//~ Formatted by Jindent --- http://www.jindent.com
Deleted: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/InterfaceGenerator.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/InterfaceGenerator.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/InterfaceGenerator.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -1,62 +0,0 @@
-package org.nuiton.guix.generator;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.nuiton.guix.model.GuixModelObject;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Generator of interfaces
- *
- * @author morin
- */
-public class InterfaceGenerator extends GuixGenerator {
- public InterfaceGenerator(GuixModelObject gmo) {
- super(gmo);
- }
-
- @Override
- public void generate(File out) {
- super.generate();
- sb.append("\npublic interface ");
- sb.append(gmo.getClassDescriptor().getName());
- sb.append(" {\n");
- sb.append("\n\t//Getters and Setters");
- addGettersAndSetters(gmo);
- sb.append("\n\npublic void test();\n\n}");
- saveFile(out);
- }
-
- @Override
- protected void addGettersAndSetters(GuixModelObject gmo) {
- for (GuixModelObject child : gmo.getChildren()) {
- sb.append("\n\n\tpublic ");
- sb.append(child.getClassDescriptor().getName());
- sb.append(" get");
- sb.append(child.getId().replace(child.getId().charAt(0), Character.toUpperCase(child.getId().charAt(0))));
- sb.append("();");
- sb.append("\n\n\tpublic ");
- sb.append("void set");
- sb.append(child.getId().replace(child.getId().charAt(0), Character.toUpperCase(child.getId().charAt(0))));
- sb.append("(");
- sb.append(child.getClassDescriptor().getName());
- sb.append(" ");
- sb.append(child.getId());
- sb.append(");");
- addGettersAndSetters(child);
- }
- }
-}
-
-
-//~ Formatted by Jindent --- http://www.jindent.com
Added: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaArgument.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaArgument.java (rev 0)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaArgument.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package org.nuiton.guix.generator;
+
+/**
+ * Represents an argument to a <code>JavaMethod</code>.
+ *
+ * @see JavaMethod
+ */
+public class JavaArgument {
+ private String name;
+ private String type;
+ private boolean isFinal;
+
+
+ /**
+ * Creates a new <code>JavaArgument</code> with the specified name and type. For example, the method <code>main()</code>
+ * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>.
+ *
+ * @param type the argument's type, as it would appear in Java source code
+ * @param name the argument's name
+ */
+ public JavaArgument(String type, String name) {
+ this(type, name, false);
+ }
+
+
+ /**
+ * Creates a new <code>JavaArgument</code> with the specified name, type, and finality. For example, the method <code>main()</code>
+ * might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. The
+ * <code>isFinal</code> parameter allows the presence of the <code>final</code> keyword on the argument to be controlled.
+ *
+ * @param type the argument's type, as it would appear in Java source code
+ * @param name the argument's name
+ * @param isFinal <code>true</code> if the argument should be marked final
+ */
+ public JavaArgument(String type, String name, boolean isFinal) {
+ this.type = type;
+ this.name = name;
+ this.isFinal = isFinal;
+ }
+
+
+ /**
+ * Returns the argument's name.
+ *
+ * @return the name of the argument
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Returns the argument's type as it would be represented in Java source code.
+ *
+ * @return the argument's type
+ */
+ public String getType() {
+ return type;
+ }
+
+
+ /**
+ * Returns <code>true</code> if the <code>final</code> keyword should appear before the argument.
+ *
+ * @return <code>true</code> if the argument is final
+ */
+ public boolean isFinal() {
+ return isFinal;
+ }
+
+
+ /**
+ * Returns the Java source code for this argument.
+ *
+ * @return the Java source code for this argument
+ */
+ @Override
+ public String toString() {
+ String result = type + ' ' + name;
+ return isFinal ? "final " + result : result;
+ }
+}
\ No newline at end of file
Added: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaField.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaField.java (rev 0)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaField.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package org.nuiton.guix.generator;
+
+import java.lang.reflect.Modifier;
+import java.util.Comparator;
+
+/**
+ * Represents a field in a Java source file being generated for output. <code>JavaFields</code> are created
+ * and added to a {@link JavaFile}, which can then output Java source code.
+ */
+public class JavaField implements Comparable<JavaField> {
+
+ private int modifiers;
+ private String type;
+ private String name;
+ private String initializer;
+
+
+ /**
+ * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the
+ * constants from {@link java.lang.reflect.Modifier}, and the <code>type</code> of the field should be
+ * represented as it would appear in Java source code.
+ *
+ * @param modifiers the modifier keywords that should appear as part of the field's declaration
+ * @param type the type of the field as it would appear in Java source code
+ * @param name the field's name
+ */
+ public JavaField(int modifiers, String type, String name) {
+ this(modifiers, type, name, null);
+ }
+
+
+ /**
+ * Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the
+ * constants from <code>java.lang.reflect.Modifier</code>, and the <code>type</code> of the field should be
+ * represented as it would appear in Java source code. The <code>initializer</code> is the initial
+ * value of the field as it would appear in Java source code, or <code>null</code> to leave it at the
+ * default value.
+ *
+ * @param modifiers the modifier keywords that should appear as part of the field's declaration
+ * @param type the type of the field as it would appear in Java source code
+ * @param name the field's name
+ * @param initializer the initial value of the field, as it would appear in Java source code
+ */
+ public JavaField(int modifiers, String type, String name, String initializer) {
+ this.modifiers = modifiers;
+ this.type = type;
+ this.name = name;
+ this.initializer = initializer;
+ }
+
+
+ /**
+ * Returns a bit mask describing the modifier keywords which should appear as part of this field's
+ * declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this
+ * field.
+ *
+ * @return the modifier bit mask
+ */
+ public int getModifiers() {
+ return modifiers;
+ }
+
+
+ /**
+ * Returns the field's name.
+ *
+ * @return the field's name
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Returns the field's type, as it would be represented in Java source code.
+ *
+ * @return the field's type
+ */
+ public String getType() {
+ return type;
+ }
+
+
+ /**
+ * Returns the Java source code for this field.
+ *
+ * @param lineSeparator line separator
+ * @return the Java source code for this field
+ */
+ public String toString(String lineSeparator) {
+ StringBuffer result = new StringBuffer();
+ result.append(JavaFile.getModifiersText(modifiers));
+ result.append(type).append(' ').append(name);
+ if (initializer != null) {
+ result.append(" = ").append(initializer);
+ }
+ result.append(';').append(lineSeparator);
+ return result.toString();
+ }
+
+ public int compareTo(JavaField o) {
+ return COMPARATOR.compare(this, o);
+ }
+
+ public static final Comparator<JavaField> COMPARATOR = new Comparator<JavaField>() {
+
+ public int compare(JavaField o1, JavaField o2) {
+
+ int result;
+ if ((result = compareStatic(o1, o2)) != 0) {
+ return result;
+ }
+
+ // data sources must be on the last after all other fields
+ if ((result = compareDataSource(o1, o2)) != 0) {
+ return result;
+ }
+
+ // same static
+ if ((result = compareVisibility(o1, o2)) != 0) {
+ return result;
+ }
+ // same visibility, test name
+ return o1.name.compareTo(o2.name);
+ }
+
+ public int compareStatic(JavaField o1, JavaField o2) {
+ // first comparator modifiers : static always before none static
+ if (Modifier.isStatic(o1.modifiers) && !Modifier.isStatic(o2.modifiers)) {
+ return -1;
+ }
+ if (!Modifier.isStatic(o1.modifiers) && Modifier.isStatic(o2.modifiers)) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public int compareDataSource(JavaField o1, JavaField o2) {
+ // first comparator modifiers : static always before none static
+ if (o1.name.startsWith("$DataSource") && !o2.name.startsWith("$DataSource")) {
+ return 1;
+ }
+ if (!o1.name.startsWith("$DataSource") && o2.name.startsWith("$DataSource")) {
+ return -1;
+ }
+ return 0;
+ }
+
+ public int compareVisibility(JavaField o1, JavaField o2) {
+ // first comparator modifiers : static always before none static
+ if (!Modifier.isPublic(o1.modifiers) && Modifier.isPublic(o2.modifiers)) {
+ return 1;
+ }
+
+ if (Modifier.isPublic(o1.modifiers) && !Modifier.isPublic(o2.modifiers)) {
+ return -1;
+ }
+
+ if (Modifier.isProtected(o1.modifiers) && !Modifier.isProtected(o2.modifiers)) {
+ return -1;
+ }
+ if (!Modifier.isProtected(o1.modifiers) && Modifier.isProtected(o2.modifiers)) {
+ return 1;
+ }
+
+ if (Modifier.isPrivate(o1.modifiers) && !Modifier.isPrivate(o2.modifiers)) {
+ return -1;
+ }
+ if (!Modifier.isPrivate(o1.modifiers) && Modifier.isPrivate(o2.modifiers)) {
+ return 1;
+ }
+ return 0;
+ }
+ };
+
+ public static JavaField newField(int modifiers, String returnType, String name) {
+ return newField(modifiers, returnType, name, null);
+ }
+
+ public static JavaField newField(int modifiers, String returnType, String name, String initializer) {
+ return new JavaField(modifiers, returnType, name, initializer);
+ }
+}
\ No newline at end of file
Added: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFile.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFile.java (rev 0)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFile.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -0,0 +1,337 @@
+package org.nuiton.guix.generator;
+
+import org.nuiton.guix.generator.JavaMethod.MethodOrder;
+
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map.Entry;
+
+/**
+ * A Java source file being generated for output. Once the class is completely initialized, use the
+ * {@link #toString} method to generate source code for it.
+ */
+public class JavaFile {
+
+ protected static final String GETTER_PATTERN = "return %1$s;";
+
+ protected static final String BOOLEAN_GETTER_PATTERN = "return %1$s !=null && %1$s;";
+
+ protected static final String SETTER_PATTERN = "this.%2$s = newValue;";
+
+ private int modifiers;
+ private String packageName;
+ private String className;
+ private List<String> imports = new ArrayList<String>();
+ private List<JavaField> fields = new ArrayList<JavaField>();
+ private List<JavaMethod> methods = new ArrayList<JavaMethod>();
+ private List<JavaFile> innerClasses = new ArrayList<JavaFile>();
+ private String superClass;
+ private List<String> interfaces;
+ private StringBuffer rawBodyCode = new StringBuffer();
+ private boolean superclassIsGuixObject;
+ private String genericType;
+ private String superGenericType;
+
+
+ public JavaFile() {
+ }
+
+
+ public JavaFile(String packageName, int modifiers, String className, String superClass) {
+ this(packageName, modifiers, className, superClass, null);
+ }
+
+
+ public JavaFile(String packageName, int modifiers, String className, String superClass, List<String> interfaces) {
+ this.packageName = packageName;
+ this.modifiers = modifiers;
+ this.className = className;
+ this.superClass = superClass;
+ this.interfaces = interfaces;
+ }
+
+
+ public void addImport(String importString) {
+ imports.add(importString);
+ }
+
+ public void addImport(Class importString) {
+ imports.add(importString.getName());
+ }
+
+
+ public String[] getImports() {
+ return imports.toArray(new String[imports.size()]);
+ }
+
+ public int getModifiers() {
+ return modifiers;
+ }
+
+
+ public void setModifiers(int modifiers) {
+ this.modifiers = modifiers;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+
+ public String getSuperClass() {
+ return superClass;
+ }
+
+
+ public void setSuperClass(String superClass) {
+ this.superClass = superClass;
+ }
+
+
+ public List<String> getInterfaces() {
+ if (interfaces == null) {
+ interfaces = new ArrayList<String>();
+ }
+ return interfaces;
+ }
+
+
+ public void setInterfaces(List<String> interfaces) {
+ this.interfaces = interfaces;
+ }
+
+ public void setGenericType(String genericType) {
+ this.genericType = genericType;
+ }
+
+ public void addMethod(JavaMethod method) {
+ methods.add(method);
+ }
+
+
+ public JavaMethod[] getMethods() {
+ return methods.toArray(new JavaMethod[methods.size()]);
+ }
+
+ public void addField(JavaField field) {
+ addField(field, false);
+ }
+
+ public void addField(JavaField field, boolean javaBean) {
+ addSimpleField(field);
+ String id = field.getName();
+ String capitalizedName = (id.length()>0)? Character.toUpperCase(id.charAt(0))+id.substring(1) : id;
+ // add getter file
+ String content = String.format(GETTER_PATTERN, id);
+ addMethod(new JavaMethod(Modifier.PUBLIC, field.getType(),
+ "get" + capitalizedName, null, null, content));
+
+ if (javaBean) {
+ // add full javabean support
+ if (Boolean.class.getName().equals(field.getType())) {
+ content = String.format(BOOLEAN_GETTER_PATTERN, id);
+ addMethod(new JavaMethod(Modifier.PUBLIC, field.getType(), "is" + capitalizedName, null, null, content));
+ }
+ content = String.format(SETTER_PATTERN, field.getType(), id);
+ JavaArgument arg = new JavaArgument(field.getType(), "newValue");
+ addMethod(new JavaMethod(Modifier.PUBLIC, "void", "set" + capitalizedName, new JavaArgument[]{arg}, null, content));
+ }
+ }
+
+ public void addSimpleField(JavaField field) {
+ fields.add(field);
+ }
+
+
+ public JavaField[] getFields() {
+ return fields.toArray(new JavaField[fields.size()]);
+ }
+
+
+ public static String addIndentation(String source, int indentation, String lineSeparator) {
+ return indent(source, indentation, false, lineSeparator);
+ }
+
+
+ public static String setIndentation(String source, int indentation, String lineSeparator) {
+ return indent(source, indentation, true, lineSeparator);
+ }
+
+
+ public static String indent(String source, int indentation, boolean trim, String lineSeparator) {
+ if (trim) {
+ source = source.trim();
+ }
+ char[] spaces = new char[indentation];
+ Arrays.fill(spaces, ' ');
+ StringBuffer result = new StringBuffer();
+ String[] lines = source.split(System.getProperty("line.separator") + "|\n");
+ for (int i = 0; i < lines.length; i++) {
+ if (i > 0) {
+ result.append(lineSeparator);
+ }
+ result.append(spaces);
+ result.append(trim ? lines[i].trim() : lines[i]);
+ }
+ return result.toString();
+ }
+
+
+ public void addBodyCode(String bodyCode) {
+ rawBodyCode.append(bodyCode);
+ }
+
+
+ public String getClassBody(String lineSeparator) {
+ StringBuffer result = new StringBuffer();
+ if (fields.size() > 0) {
+ java.util.Collections.sort(fields); // sort fields
+
+ for (JavaField field : fields) {
+ result.append(addIndentation(field.toString(lineSeparator), 4, lineSeparator));
+ result.append(lineSeparator);
+ }
+
+ result.append(lineSeparator);
+ }
+
+ if (rawBodyCode.length() > 0) {
+ result.append(addIndentation("/* begin raw body code */\n", 4, lineSeparator));
+ String s = rawBodyCode.toString();
+ if (!s.startsWith(lineSeparator)) {
+ result.append(lineSeparator);
+ }
+ result.append(addIndentation(s, 4, lineSeparator));
+ result.append(lineSeparator);
+ result.append(addIndentation("/* end raw body code */", 4, lineSeparator));
+ result.append(lineSeparator);
+ }
+
+ for (JavaFile innerClass : innerClasses) {
+ result.append(addIndentation(innerClass.toString(), 4, lineSeparator));
+ result.append(lineSeparator).append(lineSeparator);
+ }
+
+ EnumMap<MethodOrder, List<JavaMethod>> map = JavaMethod.getSortedMethods(methods);
+ for (Entry<MethodOrder, List<JavaMethod>> entry : map.entrySet()) {
+ List<JavaMethod> list = entry.getValue();
+ entry.getKey().generate(result, list, lineSeparator);
+ list.clear();
+ }
+ map.clear();
+
+ return result.toString();
+ }
+
+
+ public String getClassDefinition(String lineSeparator) {
+ StringBuffer result = new StringBuffer();
+ result.append(getModifiersText(modifiers))
+ .append("class ")
+ .append(className.substring(className.lastIndexOf(".") + 1));
+ if (genericType != null) {
+ result.append('<').append(genericType).append('>');
+ }
+ if(superClass != null) {
+ result.append(" extends ");
+ result.append(superClass);
+ if (superGenericType != null) {
+ result.append('<').append(superGenericType).append('>');
+ }
+ }
+ if (interfaces != null && !interfaces.isEmpty()) {
+ result.append(" implements ").append(interfaces.get(0));
+ for (int i = 1; i < interfaces.size(); i++) {
+ result.append(", ").append(interfaces.get(i));
+ }
+ }
+ result.append(" {");
+ result.append(lineSeparator);
+ result.append(getClassBody(lineSeparator));
+ result.append("}");
+ return result.toString();
+ }
+
+
+ public static String getModifiersText(int modifiers) {
+ if (modifiers == 0) {
+ return "";
+ } else {
+ return Modifier.toString(modifiers) + ' ';
+ }
+ }
+
+
+ /**
+ * Returns the Java source code for this class.
+ *
+ * @param lineSeparator line separator
+ * @return a complete Java file for this class
+ */
+ public String toString(String lineSeparator) {
+ StringBuffer result = new StringBuffer();
+ if (packageName != null && !packageName.equals("")) {
+ result.append("package ").append(packageName).append(";");
+ result.append(lineSeparator);
+ result.append(lineSeparator);
+ }
+
+ if (imports.size() > 0) {
+ for (String anImport : imports) {
+ result.append("import ");
+ result.append(anImport);
+ result.append(';');
+ result.append(lineSeparator);
+ }
+ result.append(lineSeparator);
+ }
+
+ result.append(getClassDefinition(lineSeparator));
+ return result.toString();
+ }
+
+ public void addInterface(String canonicalName) {
+ if (interfaces == null || !interfaces.contains(canonicalName)) {
+ getInterfaces().add(canonicalName);
+ }
+ }
+
+ public void addInterfaces(String[] canonicalNames) {
+ if (canonicalNames == null) {
+ return;
+ }
+ for (String canonicalName : canonicalNames) {
+ if (interfaces == null || !interfaces.contains(canonicalName)) {
+ getInterfaces().add(canonicalName);
+ }
+ }
+ }
+
+ public boolean isSuperclassIsGuixObject() {
+ return superclassIsGuixObject;
+ }
+
+ public void setSuperclassIsGuixObject(boolean superclassIsGuixObject) {
+ this.superclassIsGuixObject = superclassIsGuixObject;
+ }
+
+ public void setSuperGenericType(String superGenericType) {
+ this.superGenericType = superGenericType;
+ }
+}
\ No newline at end of file
Added: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFileGenerator.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFileGenerator.java (rev 0)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaFileGenerator.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -0,0 +1,75 @@
+package org.nuiton.guix.generator;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.nuiton.guix.model.GuixModelObject;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * GuixGenerator
+ *
+ */
+public abstract class JavaFileGenerator {
+
+ /** log */
+ protected Log log = LogFactory.getLog(JavaFileGenerator.class);
+ protected StringBuffer sb = new StringBuffer();
+ protected List<String> classes = new ArrayList<String>();
+ protected GuixModelObject gmo;
+ protected JavaFile jf;
+
+ public JavaFileGenerator(GuixModelObject gmo) {
+ this.gmo = gmo;
+ }
+
+ public abstract void generate(File out);
+
+ protected void generate() {
+ addImports(gmo);
+ }
+
+ protected void addImports(GuixModelObject gmo) {
+ for (GuixModelObject child : gmo.getChildren()) {
+ String fqn = child.getClassDescriptor().getPackageName() + "." + child.getClassDescriptor().getName();
+
+ if (!classes.contains(fqn)) {
+ classes.add(fqn);
+ jf.addImport(fqn);
+ }
+
+ addImports(child);
+ }
+ }
+
+ protected void saveFile(File out) {
+ FileWriter fw = null;
+ try {
+ fw = new FileWriter(out);
+ fw.write(jf.toString("\n"));
+ fw.close();
+ } catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error(ex);
+ }
+ } finally {
+ try {
+ fw.close();
+ } catch (IOException ex) {
+ log.error(ex);
+ }
+ }
+ }
+}
+
+
+//~ Formatted by Jindent --- http://www.jindent.com
Added: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaMethod.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaMethod.java (rev 0)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/JavaMethod.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -0,0 +1,504 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package org.nuiton.guix.generator;
+
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Represents a method in a Java source file being generated for output. <code>JavaMethods</code> are created
+ * and added to a {@link JavaFile}, which can then output Java source code. In addition to normal methods, a
+ * <code>JavaMethod</code> can represent a constructor -- constructors should be named after their containing
+ * classes and have a return type of <code>null</code>.
+ */
+public class JavaMethod implements Comparable<JavaMethod> {
+ private int modifiers;
+ private String returnType;
+ private String name;
+ private JavaArgument[] arguments;
+ private String[] exceptions;
+ private StringBuffer bodyCode;
+
+
+ /**
+ * Constructs a new no-argument <code>JavaMethod</code> which throws no checked exceptions. The
+ * <code>modifiers</code> parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier},
+ * and the <code>returnType</code> of the method should be represented as it would appear in Java source
+ * code (<code>null</code> for a constructor). The method body is initially empty.
+ *
+ * @param modifiers the modifier keywords that should appear as part of the method's declaration
+ * @param returnType the return type of the method as it would appear in Java source code
+ * @param name the method's name
+ * @see #appendBodyCode
+ */
+ //public JavaMethod(int modifiers, String returnType, String name) {
+ // this(modifiers, returnType, name, null);
+ //}
+
+
+ /**
+ * Constructs a new <code>JavaMethod</code> which throws no checked exceptions. The <code>modifiers</code>
+ * parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the
+ * <code>returnType</code> of the method should be represented as it would appear in Java source code
+ * (<code>null</code> for a constructor). The method body is initially empty.
+ *
+ * @param modifiers the modifier keywords that should appear as part of the method's declaration
+ * @param returnType the return type of the method as it would appear in Java source code
+ * @param name the method's name
+ * @param arguments the method's arguments
+ * @see #appendBodyCode
+ */
+ //public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments) {
+ // this(modifiers, returnType, name, arguments, null);
+ //}
+
+
+ /**
+ * Constructs a new <code>JavaMethod</code>. The <code>modifiers</code> parameter is a bit mask of the
+ * constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and <code>exceptions</code>
+ * of the method should be represented as they would appear in Java source code (<code>null</code> for a
+ * constructor). The method body is initially empty.
+ *
+ * @param modifiers the modifier keywords that should appear as part of the method's declaration
+ * @param returnType the return type of the method as it would appear in Java source code
+ * @param name the method's name
+ * @param arguments the method's arguments
+ * @param exceptions a list of exceptions the methods can throw, as they would be represented in Java source code
+ * @see #appendBodyCode
+ */
+ //public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions) {
+ // this(modifiers, returnType, name, arguments, exceptions, null);
+ //}
+
+
+ /**
+ * Constructs a new <code>JavaMethod</code> containing the specified body code. The <code>modifiers</code> parameter
+ * is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and
+ * <code>exceptions</code> of the method should be represented as they would appear in Java source code (<code>null</code>
+ * for a constructor). The method body is initially empty.
+ *
+ * @param modifiers the modifier keywords that should appear as part of the method's declaration
+ * @param returnType the return type of the method as it would appear in Java source code
+ * @param name the method's name
+ * @param arguments the method's arguments
+ * @param exceptions a list of exceptions the methods can throw, as they would be represented in Java source code
+ * @param bodyCode Java source code which should appear in the method body
+ */
+ public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions, String bodyCode) {
+ this.modifiers = modifiers;
+ this.returnType = returnType;
+ this.name = name;
+ this.arguments = arguments;
+ this.exceptions = exceptions;
+ this.bodyCode = bodyCode != null ? new StringBuffer(bodyCode) : null;
+ }
+
+
+ /**
+ * Returns a bit mask describing the modifier keywords which should appear as part of this method's
+ * declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this
+ * field.
+ *
+ * @return the modifier bit mask
+ */
+ public int getModifiers() {
+ return modifiers;
+ }
+
+
+ /**
+ * Returns the method's return type, as it would be represented in Java source code.
+ *
+ * @return the method's return type
+ */
+ public String getReturnType() {
+ return returnType;
+ }
+
+
+ /**
+ * Returns the method's name.
+ *
+ * @return the method's name
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Returns a list of the method's arguments.
+ *
+ * @return the method's arguments
+ */
+ public JavaArgument[] getArguments() {
+ return arguments;
+ }
+
+
+ /**
+ * Returns a list of exceptions the method can throw.
+ *
+ * @return the method's exceptions
+ */
+ public String[] getExceptions() {
+ return exceptions;
+ }
+
+
+ /**
+ * Returns the Java source code for the method's body.
+ *
+ * @return the method's body code
+ */
+ public String getBodyCode() {
+ return bodyCode.toString();
+ }
+
+
+ /**
+ * Appends additional code to the method's body.
+ *
+ * @param extraCode Java source code to append to the method's body
+ * @param lineSeparator line separator
+ */
+ public void appendBodyCode(String extraCode, String lineSeparator) {
+ if (extraCode.length() == 0) {
+ return;
+ }
+ if (bodyCode.length() > 0 && !bodyCode.toString().endsWith(lineSeparator)) {
+ bodyCode.append(lineSeparator);
+ }
+ bodyCode.append(extraCode);
+ }
+
+
+ /**
+ * Returns the Java source code for this method.
+ *
+ * @param lineSeparator line separator
+ * @return the Java source code for this method
+ */
+ public String toString(String lineSeparator) {
+ StringBuffer result = new StringBuffer();
+ result.append(JavaFile.getModifiersText(modifiers));
+ if (returnType != null) {
+ result.append(returnType);
+ result.append(' ');
+ }
+ result.append(name);
+ result.append('(');
+ if (arguments != null) {
+ for (int i = 0; i < arguments.length; i++) {
+ if (i > 0) {
+ result.append(", ");
+ }
+ result.append(arguments[i].toString());
+ }
+ }
+ result.append(")");
+
+ if (bodyCode != null) {
+ result.append(" {");
+ result.append(lineSeparator);
+ String formattedBodyCode = JavaFile.addIndentation(bodyCode.toString().trim(), 4, lineSeparator);
+ if (formattedBodyCode.length() > 0) {
+ result.append(formattedBodyCode);
+ result.append(lineSeparator);
+ }
+ result.append("}");
+ }
+ else {
+ result.append(";");
+ }
+ return result.toString();
+ }
+
+ public int compareTo(JavaMethod o) {
+ return COMPARATOR.compare(this, o);
+ }
+
+ public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, String[] exceptions, JavaArgument... arguments) {
+ return new JavaMethod(modifiers, returnType, name, arguments, exceptions, initializer);
+ }
+
+ public static JavaMethod newMethod(int modifiers, String returnType, String name, String initializer, JavaArgument... arguments) {
+ return newMethod(modifiers, returnType, name, initializer, new String[0], arguments);
+ }
+
+ public enum MethodOrder {
+
+ statics(Modifier.STATIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- Statics methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ },
+
+ constructors(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- Constructors -----------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ public boolean accept(JavaMethod method) {
+ return method.returnType == null;
+ }
+ },
+
+ JAXXObject(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- JAXXObject implementation ----------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ private List<String> methods = Arrays.asList("applyDataBinding", "firePropertyChange", "getObjectById", "get$objectMap", "processDataBinding", "removeDataBinding");
+
+ public boolean accept(JavaMethod method) {
+ return methods.contains(method.name);
+ }
+ },
+
+ JAXXContext(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- JAXXContext implementation ---------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ private List<String> methods = Arrays.asList("getContextValue", "getDelegateContext", "getParentContainer", "removeContextValue", "setContextValue");
+ public boolean accept(JavaMethod method) {
+ return methods.contains(method.name);
+ }
+ },
+
+ JAXXValidation(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- JAXXValidation implementation ------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ private List<String> methods = Arrays.asList("getValidator", "getValidatorIds");
+
+ public boolean accept(JavaMethod method) {
+ return methods.contains(method.name);
+ }
+ },
+
+ events(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- Event methods ----------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ public boolean accept(JavaMethod method) {
+ return (method.name.startsWith("do") && method.name.indexOf("__") > -1);
+ }
+ },
+
+ publicGetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- public acessor methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ public boolean accept(JavaMethod method) {
+ return (method.name.startsWith("get") || method.name.startsWith("is"));
+ }
+ },
+
+ publicSetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- public mutator methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ public boolean accept(JavaMethod method) {
+ return (method.name.startsWith("set"));
+ }
+ },
+
+ otherPublic(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- public mutator methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ @Override
+ public boolean accept(int mod) {
+ return super.accept(mod) && !Modifier.isStatic(mod);
+ }
+ },
+
+ protectedGetters(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- protected acessors methods ---------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ public boolean accept(JavaMethod method) {
+ return (method.name.startsWith("get") || method.name.startsWith("is"));
+ }
+ },
+
+ createMethod(Modifier.PROTECTED | Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- ui creation methods ----------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ public boolean accept(JavaMethod method) {
+ return method.name.startsWith("create") || method.name.startsWith("add") ||
+ method.name.equals("$completeSetup") ||
+ method.name.equals("$initialize");
+ }
+ },
+
+ protecteds(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- Other protected methods ------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ },
+
+ packageLocal(0, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- Package methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ @Override
+ public boolean accept(int mod) {
+ return !Modifier.isStatic(mod) && !Modifier.isPublic(mod) && !Modifier.isProtected(mod);
+ }},
+
+ privates(Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" +
+ "/*-- Private methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+ };
+
+ private final String header;
+
+ private int modifier;
+
+ MethodOrder(int modifier, String header) {
+ this.header = header;
+ this.modifier = modifier;
+ }
+
+ public String getHeader() {
+ return header;
+ }
+
+ public boolean accept(JavaMethod method) {
+ return true;
+ }
+
+ public boolean accept(int mod) {
+ return (mod & modifier) != 0;
+ }
+
+ public boolean accept(int mod, JavaMethod method) {
+ return accept(mod) && accept(method);
+ }
+
+ public static MethodOrder valueOf(JavaMethod method, int scope) {
+ for (MethodOrder o : values()) {
+ if (o.accept(scope, method)) {
+ return o;
+ }
+ }
+ throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + method);
+ }
+
+ public void generate(StringBuffer buffer, List<JavaMethod> methods, String lineSeparator) {
+ if (methods.isEmpty()) {
+ return;
+ }
+ buffer.append(JavaFile.addIndentation(header, 4, lineSeparator));
+ buffer.append(lineSeparator).append(lineSeparator);
+ for (JavaMethod method : methods) {
+ buffer.append(JavaFile.addIndentation(method.toString(lineSeparator), 4, lineSeparator));
+ buffer.append(lineSeparator).append(lineSeparator);
+ }
+ }
+ }
+
+ public static EnumMap<MethodOrder, List<JavaMethod>> getSortedMethods(List<JavaMethod> methods) {
+
+ EnumMap<MethodOrder, List<JavaMethod>> result = new EnumMap<MethodOrder, List<JavaMethod>>(MethodOrder.class);
+ for (MethodOrder methodOrder : MethodOrder.values()) {
+ result.put(methodOrder, new ArrayList<JavaMethod>());
+ }
+
+ EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class);
+ List<JavaMethod> allMethods = new ArrayList<JavaMethod>(methods);
+ int[] scopes = new int[]{Modifier.STATIC, Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE};
+ for (int scope : scopes) {
+ EnumSet<MethodOrder> constants = getMethodOrderScope(allConstants, scope);
+
+ Iterator<JavaMethod> itMethods = allMethods.iterator();
+ while (itMethods.hasNext()) {
+ JavaMethod method = itMethods.next();
+ for (MethodOrder constant : constants) {
+ if (constant.accept(method.getModifiers(), method)) {
+ result.get(constant).add(method);
+ itMethods.remove();
+ break;
+ }
+ }
+ }
+ constants.clear();
+ }
+
+ if (!allMethods.isEmpty()) {
+ throw new IllegalArgumentException("could not find a " + MethodOrder.class + " for method " + allMethods);
+ }
+
+ for (MethodOrder methodOrder : MethodOrder.values()) {
+ // sort methods
+ java.util.Collections.sort(result.get(methodOrder));
+ }
+ return result;
+ }
+
+ public static EnumSet<MethodOrder> getMethodOrderScope(EnumSet<MethodOrder> allConstants, int scope) {
+ EnumSet<MethodOrder> constants = EnumSet.noneOf(MethodOrder.class);
+ for (MethodOrder order : allConstants) {
+ if (order.accept(scope)) {
+ constants.add(order);
+ }
+ }
+ return constants;
+ }
+
+ public static final Comparator<JavaMethod> COMPARATOR = new Comparator<JavaMethod>() {
+
+ public int compare(JavaMethod o1, JavaMethod o2) {
+
+ /*int result;
+ if ((result = compareStatic(o1, o2)) != 0) {
+ return result;
+ }
+ if ((result = compareConstructor(o1, o2)) != 0) {
+ return result;
+ }
+ if ((result = compareVisibility(o1, o2)) != 0) {
+ return result;
+ }*/
+ return o1.name.compareTo(o2.name);
+ }
+
+ public int compareStatic(JavaMethod o1, JavaMethod o2) {
+ if (Modifier.isStatic(o1.modifiers) && !Modifier.isStatic(o2.modifiers)) {
+ return -1;
+ }
+ if (!Modifier.isStatic(o1.modifiers) && Modifier.isStatic(o2.modifiers)) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public int compareConstructor(JavaMethod o1, JavaMethod o2) {
+ if (o1.returnType == null && o2.returnType != null) {
+ return -1;
+ }
+ if (o1.returnType != null && o2.returnType == null) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public int compareVisibility(JavaMethod o1, JavaMethod o2) {
+ if (Modifier.isPublic(o1.modifiers) && !Modifier.isPublic(o2.modifiers)) {
+ return -1;
+ }
+ if (!Modifier.isPublic(o1.modifiers) && Modifier.isPublic(o2.modifiers)) {
+ return 1;
+ }
+ if (Modifier.isProtected(o1.modifiers) && !Modifier.isProtected(o2.modifiers)) {
+ return -1;
+ }
+ if (!Modifier.isProtected(o1.modifiers) && Modifier.isProtected(o2.modifiers)) {
+ return 1;
+ }
+ if (Modifier.isPrivate(o1.modifiers) && !Modifier.isPrivate(o2.modifiers)) {
+ return -1;
+ }
+ if (!Modifier.isPrivate(o1.modifiers) && Modifier.isPrivate(o2.modifiers)) {
+ return 1;
+ }
+ return 0;
+ }
+ };
+}
\ No newline at end of file
Deleted: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/MainClassGenerator.java
===================================================================
--- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/MainClassGenerator.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/generator/MainClassGenerator.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -1,60 +0,0 @@
-package org.nuiton.guix.generator;
-
-//~--- non-JDK imports --------------------------------------------------------
-
-import org.nuiton.guix.model.GuixModelObject;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Generator of interfaces
- *
- * @author morin
- */
-public class MainClassGenerator {
- private StringBuffer clazz = new StringBuffer();
-
- public MainClassGenerator(GuixModelObject gmo, File destDir) {
- String gmoClassName = gmo.getClassDescriptor().getName();
- String gmoAttributeName = gmoClassName.replace(gmoClassName.charAt(0),
- Character.toLowerCase(gmoClassName.charAt(0)));
-
- clazz.append("package ");
- clazz.append(gmo.getClassDescriptor().getPackageName());
- clazz.append(";\n\nimport java.io.File;\n"
- + "import org.springframework.beans.factory.ListableBeanFactory;\n"
- + "import org.springframework.beans.factory.xml.XmlBeanFactory;\n"
- + "import org.springframework.core.io.FileSystemResource;\n"
- + "\npublic class Main {"
- + "\n\n\tpublic static void main(String[] args) {\n" + "\t\t//usine à beans\n"
- + "\t\tListableBeanFactory bf = new XmlBeanFactory(" +
- "new FileSystemResource(new File(\"");
- clazz.append(destDir.getAbsolutePath());
- clazz.append("/config.xml\")));\n\t\t");
- clazz.append(gmoClassName);
- clazz.append(" ");
- clazz.append(gmoAttributeName);
- clazz.append(" = (");
- clazz.append(gmoClassName);
- clazz.append(") bf.getBean(\"");
- clazz.append(gmoAttributeName);
- clazz.append("\");\n\t\t");
- clazz.append(gmoAttributeName);
- clazz.append(".test();"
- + "\n\t}\n\n}");
- }
-
- public String getClassContent() {
- return clazz.toString();
- }
-}
-
Modified: guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/GuixLauncherTest.java
===================================================================
--- guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/GuixLauncherTest.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/GuixLauncherTest.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -22,7 +22,7 @@
public void compileTest() {
GuixInitializer.initialize();
- GuixLauncher gl = new GuixLauncher(null,null,null,null,null);
+ GuixLauncher gl = new GuixLauncher(null,null,null,null,null,null);
assertTrue(gl.files == null || gl.classNames.length == gl.files.length);
assertTrue(gl.compile());
assertTrue(gl.files == null || gl.rootModelObjects.size() == gl.files.length);
@@ -31,7 +31,7 @@
File f2 = new File(f.getAbsolutePath());
File dir = new File("target/test");
File dir2 = new File(dir.getAbsolutePath());
- gl = new GuixLauncher(new File[]{f2},dir2,"org.nuiton.guix",f2.getParentFile(), null);
+ gl = new GuixLauncher(new File[]{f2},dir2,"org.nuiton.guix",f2.getParentFile(), null,null);
assertTrue(gl.files == null || gl.classNames.length == gl.files.length);
assertTrue(gl.compile());
}
@@ -41,36 +41,36 @@
*/
@Test
public void registerClassDescriptorTest() {
- GuixLauncher gl = new GuixLauncher(null,null,null,null,null);
- assertFalse(gl.registerClassDescriptor(null));
- assertFalse(gl.registerClassDescriptor(new ClassDescriptor(null, null)));
+ GuixLauncher gl = new GuixLauncher(null,null,null,null,null,null);
+ assertNull(gl.registerClassDescriptor(null));
+ assertNull(gl.registerClassDescriptor(new ClassDescriptor(null, null)));
ClassDescriptor cd = new ClassDescriptor("name", "package");
- assertTrue(gl.registerClassDescriptor(cd));
+ assertNotNull(gl.registerClassDescriptor(cd));
cd.setSuperClass(new ClassDescriptor("super", "package"));
- assertTrue(gl.registerClassDescriptor(cd)
+ assertTrue(gl.registerClassDescriptor(cd) != null
&& gl.classDescriptors.get(0).getSuperClass() != null);
- assertTrue(gl.registerClassDescriptor(cd)
+ assertTrue(gl.registerClassDescriptor(cd) != null
&& gl.classDescriptors.size() == 1);
ClassDescriptor cd2 = new ClassDescriptor("name", "package");
cd2.setSuperClass(new ClassDescriptor("super2", "package"));
- assertFalse(gl.registerClassDescriptor(cd2));
+ assertFalse(gl.registerClassDescriptor(cd2) != null);
ClassDescriptor cd3 = new ClassDescriptor("name", "package");
cd3.setScript("script");
- assertTrue(gl.registerClassDescriptor(cd3)
+ assertTrue(gl.registerClassDescriptor(cd3) != null
&& gl.classDescriptors.size() == 1);
ClassDescriptor cd4 = new ClassDescriptor("name", "package");
cd4.setScript("script2");
- assertFalse(gl.registerClassDescriptor(cd4));
+ assertNull(gl.registerClassDescriptor(cd4));
- assertTrue(gl.registerClassDescriptor(new ClassDescriptor("name", null))
+ assertTrue(gl.registerClassDescriptor(new ClassDescriptor("name", null)) != null
&& gl.classDescriptors.size() == 1);
- assertTrue(gl.registerClassDescriptor(new ClassDescriptor("test", null))
+ assertTrue(gl.registerClassDescriptor(new ClassDescriptor("test", null)) != null
&& gl.classDescriptors.size() == 2);
- assertTrue(gl.registerClassDescriptor(new ClassDescriptor("test", null))
+ assertTrue(gl.registerClassDescriptor(new ClassDescriptor("test", null)) != null
&& gl.classDescriptors.size() == 2);
}
}
Modified: guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/compiler/GuixCompilerTest.java
===================================================================
--- guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/compiler/GuixCompilerTest.java 2009-05-15 13:55:29 UTC (rev 1401)
+++ guix/trunk/guix-compiler/src/test/java/org/nuiton/guix/compiler/GuixCompilerTest.java 2009-05-15 13:59:00 UTC (rev 1402)
@@ -17,7 +17,7 @@
File f = new File("src/test/test.guix");
File f2 = new File(f.getAbsolutePath());
GuixLauncher gl = new GuixLauncher(new File[]{f2}, null,
- "org.nuiton.guix",f2.getParentFile(),null);
+ "org.nuiton.guix",f2.getParentFile(),null,null);
GuixCompiler gc = new GuixCompiler(null, null,null);
assertNull(gc.compile());
1
0
Author: kmorin
Date: 2009-05-15 13:55:29 +0000 (Fri, 15 May 2009)
New Revision: 1401
Modified:
guix/trunk/pom.xml
Log:
Ajout du module guix-compiler-swing
Modified: guix/trunk/pom.xml
===================================================================
--- guix/trunk/pom.xml 2009-05-11 09:17:42 UTC (rev 1400)
+++ guix/trunk/pom.xml 2009-05-15 13:55:29 UTC (rev 1401)
@@ -19,9 +19,10 @@
<modules>
<module>guix-compiler</module>
+ <module>guix-compiler-swing</module>
<module>guix-maven-plugin</module>
<module>guix-test</module>
-
+ <module>guix-runtime</module>
</modules>
<dependencyManagement>
@@ -236,4 +237,4 @@
</profile>
</profiles>
-</project>
+</project>
\ No newline at end of file
1
0
11 May '09
Author: tchemit
Date: 2009-05-11 09:17:42 +0000 (Mon, 11 May 2009)
New Revision: 1400
Modified:
jaxx/trunk/jaxx-runtime-api/pom.xml
jaxx/trunk/pom.xml
Log:
scm values
Modified: jaxx/trunk/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
+++ jaxx/trunk/jaxx-runtime-api/pom.xml 2009-05-11 09:17:42 UTC (rev 1400)
@@ -62,8 +62,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-api</connection>
- <developerConnection>scm:svn:svn+ssh://${username}@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-api</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>${maven.scm.url.child}</url>
</scm>
</project>
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
+++ jaxx/trunk/pom.xml 2009-05-11 09:17:42 UTC (rev 1400)
@@ -193,11 +193,7 @@
</plugin>
<plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <locales>fr</locales>
- <siteDirectory>src/site</siteDirectory>
- </configuration>
+ <artifactId>maven-site-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.codelutin</groupId>
1
0
r1399 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-swing jaxx-compiler-validator jaxx-example jaxx-runtime-api jaxx-runtime-swing jaxx-runtime-swing-widget jaxx-runtime-swing-widget/src/main/resources/i18n jaxx-runtime-validator jaxx-runtime-validator-swing jaxx-swing-action maven-jaxx-plugin
by tchemit@users.labs.libre-entreprise.org 11 May '09
by tchemit@users.labs.libre-entreprise.org 11 May '09
11 May '09
Author: tchemit
Date: 2009-05-11 06:52:19 +0000 (Mon, 11 May 2009)
New Revision: 1399
Modified:
jaxx/trunk/changelog.txt
jaxx/trunk/jaxx-compiler-api/pom.xml
jaxx/trunk/jaxx-compiler-swing/pom.xml
jaxx/trunk/jaxx-compiler-validator/pom.xml
jaxx/trunk/jaxx-example/pom.xml
jaxx/trunk/jaxx-runtime-api/pom.xml
jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
jaxx/trunk/jaxx-runtime-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator/pom.xml
jaxx/trunk/jaxx-swing-action/pom.xml
jaxx/trunk/maven-jaxx-plugin/pom.xml
jaxx/trunk/pom.xml
Log:
bump versions pass to 1.5.1-SNAPSHOT for last codelutin version
Modified: jaxx/trunk/changelog.txt
===================================================================
--- jaxx/trunk/changelog.txt 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/changelog.txt 2009-05-11 06:52:19 UTC (rev 1399)
@@ -1,3 +1,9 @@
+1.6.0 ?
+ * migrate to nuiton
+
+1.5.1 chemit 20090511
+ * 20090511 [chemit] - bump versions (lutinproject, jrst, lutinutil, maven-i18n-plugin, maven-license-switcher-plugin)
+
1.5
* 20090506 [chemit] - super-pom has no dependencies, use lutinutil 1.0.5
* 20090404 [chemit] - introduce module jaxx-runtime-swing-widget for swing widgets designed with jaxx.
Modified: jaxx/trunk/jaxx-compiler-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-api/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-compiler-api/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-compiler-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-runtime-api/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-runtime-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-runtime-swing-widget/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-runtime-swing-widget/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-05-11 06:52:19 UTC (rev 1399)
@@ -24,4 +24,4 @@
numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
numbereditor.clearAll=C
numbereditor.clearOne=CE
-numbereditor.toggleSign=+/-
\ No newline at end of file
+numbereditor.toggleSign=+/-
Modified: jaxx/trunk/jaxx-runtime-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -49,7 +49,7 @@
<plugins>
<plugin>
<groupId>org.codelutin</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
+ <artifactId>maven-i18n-plugin</artifactId>
<executions>
<execution>
<goals>
@@ -57,7 +57,7 @@
<goal>gen</goal>
</goals>
</execution>
- </executions>
+ </executions>
</plugin>
</plugins>
</build>
Modified: jaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- jaxx/trunk/jaxx-swing-action/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/jaxx-swing-action/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-05-08 17:33:16 UTC (rev 1398)
+++ jaxx/trunk/pom.xml 2009-05-11 06:52:19 UTC (rev 1399)
@@ -1,3 +1,4 @@
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -9,12 +10,12 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>lutinproject</artifactId>
- <version>3.5.3</version>
+ <version>3.5.4</version>
</parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.6-SNAPSHOT</version>
+ <version>1.5.1-SNAPSHOT</version>
<modules>
<module>jaxx-runtime-api</module>
@@ -159,10 +160,10 @@
<labs.project>buix</labs.project>
<!-- libs version -->
- <lutinutil.version>1.0.5</lutinutil.version>
+ <lutinutil.version>1.0.6</lutinutil.version>
<jaxx.version>${project.version}</jaxx.version>
- <i18n.version>0.11</i18n.version>
- <lutinpluginutil.version>0.4</lutinpluginutil.version>
+ <i18n.version>0.12</i18n.version>
+ <lutinpluginutil.version>0.5</lutinpluginutil.version>
<swingx.version>0.9.6</swingx.version>
<maven.version>2.0.10</maven.version>
</properties>
@@ -177,6 +178,13 @@
<groupId>org.codelutin</groupId>
<artifactId>maven-i18n-plugin</artifactId>
<version>${i18n.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil</artifactId>
+ <version>${lutinutil.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
@@ -194,7 +202,7 @@
<dependency>
<groupId>org.codelutin</groupId>
<artifactId>doxia-module-jrst</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1</version>
</dependency>
</dependencies>
</plugin>
@@ -212,9 +220,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk</connection>
- <developerConnection>scm:svn:svn+ssh://${username}@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/?roo…</url>
+ <connection>${maven.scm.connection}</connection>
+ <developerConnection>${maven.scm.developerConnection}</developerConnection>
+ <url>${maven.scm.url}</url>
</scm>
<!-- Maven Environment : Repositories -->
@@ -253,10 +261,7 @@
<plugin>
<groupId>org.codelutin</groupId>
<artifactId>maven-license-switcher-plugin</artifactId>
- <version>0.7</version>
- <configuration>
- <licenseName>${license-switcher.licenseName}</licenseName>
- </configuration>
+ <version>0.8</version>
<executions>
<execution>
<id>attach-licenses</id>
1
0
r1398 - jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor
by tchemit@users.labs.libre-entreprise.org 08 May '09
by tchemit@users.labs.libre-entreprise.org 08 May '09
08 May '09
Author: tchemit
Date: 2009-05-08 17:33:16 +0000 (Fri, 08 May 2009)
New Revision: 1398
Modified:
jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
Log:
add FIXME :)
Modified: jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-05-07 15:20:41 UTC (rev 1397)
+++ jaxx/trunk/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-05-08 17:33:16 UTC (rev 1398)
@@ -76,12 +76,13 @@
editor.getTextField().addMouseListener(new PopupListener());
// Determine si c'est un float
- Class type = getGetter().getReturnType();
+ Class<?> type = getGetter().getReturnType();
+ //FIXME le test n'est pas assez fort (on peut avoir un long, short,...)
editor.setUseFloat(!type.equals(Integer.class) && !type.equals(int.class));
// Initialise le model
if (editor.getModel() == null){
- Number num = (Number)getGetter().invoke(editor.getBean(), null);
+ Number num = (Number)getGetter().invoke(editor.getBean());
editor.setModel(num);
}
@@ -97,13 +98,7 @@
log.error(ex);
} catch (InvocationTargetException ex) {
log.error(ex);
- }
- /*if (editor.getResetButton().getIcon() == null) {
- editor.getResetButton().setIcon(SwingUtil.createActionIcon("numbereditor-reset"));
- }
- if (editor.getButton().getIcon() == null) {
- editor.getButton().setIcon(SwingUtil.createActionIcon("numbereditor-calculator"));
- }*/
+ }
}
/**
1
0
r1397 - in guix/trunk/guix-test: . src/main/java/org/nuiton/guix src/main/java/org/nuiton/guix/demo
by kmorin@users.labs.libre-entreprise.org 07 May '09
by kmorin@users.labs.libre-entreprise.org 07 May '09
07 May '09
Author: kmorin
Date: 2009-05-07 15:20:41 +0000 (Thu, 07 May 2009)
New Revision: 1397
Added:
guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo2.guix
Removed:
guix/trunk/guix-test/src/main/java/org/nuiton/guix/App.java
Modified:
guix/trunk/guix-test/pom.xml
guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo.guix
Log:
Modified: guix/trunk/guix-test/pom.xml
===================================================================
--- guix/trunk/guix-test/pom.xml 2009-05-07 15:20:03 UTC (rev 1396)
+++ guix/trunk/guix-test/pom.xml 2009-05-07 15:20:41 UTC (rev 1397)
@@ -17,10 +17,14 @@
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
+ <artifactId>spring-core</artifactId>
<version>2.0.5</version>
- <scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>2.0.5</version>
+ </dependency>
</dependencies>
@@ -54,9 +58,10 @@
<artifactId>guix-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
- <guixFilesDir>/home/morin/NetBeansProjects/guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/</guixFilesDir>
- <targetDirectory>/home/morin/NetBeansProjects/guix/trunk/guix-test/target/generatedFiles/</targetDirectory>
+ <guixFilesDir>/home/kevin/Workspaces/NetBeansProjects/guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/</guixFilesDir>
+ <targetDirectory>/home/kevin/Workspaces/NetBeansProjects/guix/trunk/guix-test/target/generatedFiles/</targetDirectory>
<rootPackage>org.nuiton.guix</rootPackage>
+ <mainClass>org.nuiton.guix.GuixDemo2</mainClass>
</configuration>
<executions>
<execution>
Deleted: guix/trunk/guix-test/src/main/java/org/nuiton/guix/App.java
===================================================================
--- guix/trunk/guix-test/src/main/java/org/nuiton/guix/App.java 2009-05-07 15:20:03 UTC (rev 1396)
+++ guix/trunk/guix-test/src/main/java/org/nuiton/guix/App.java 2009-05-07 15:20:41 UTC (rev 1397)
@@ -1,13 +0,0 @@
-package org.nuiton.guix;
-
-/**
- * Hello world!
- *
- */
-public class App
-{
- public static void main( String[] args )
- {
- System.out.println( "Hello World!" );
- }
-}
Modified: guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo.guix
===================================================================
--- guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo.guix 2009-05-07 15:20:03 UTC (rev 1396)
+++ guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo.guix 2009-05-07 15:20:41 UTC (rev 1397)
@@ -1,4 +1,5 @@
<?xml version='1.0' encoding='UTF-8' ?>
+<!-- test javadoc Application -->
<Application title="JAXX Demo" width='1024' height='800' xmlns:swing='javax.swing.*'>
<script><![CDATA[
@@ -47,9 +48,10 @@
;
}
-]]></style>
+]]></style>
+ <!-- test javadoc $JSplitPane1 -->
<swing:JSplitPane>
- <!--JSplitPane dividerLocation='200'-->
+ <!-- JSplitPane dividerLocation='200' -->
<swing:JScrollPane>
<swing:JTree id='list' showsRootHandles='true'
onValueChanged='cardLayout.show(preview, list.getSelectionValue() instanceof DemoPanel ? ((DemoPanel) list.getSelectionValue()).getLabel() : emptyDemo.getLabel())'
@@ -60,7 +62,8 @@
return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
}
}
- }'>
+ }'>
+ <!-- test javadoc $item1 -->
<item value="Components">
<item value='Buttons'>
<item value='{buttonDemo}'/>
Added: guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo2.guix
===================================================================
--- guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo2.guix (rev 0)
+++ guix/trunk/guix-test/src/main/java/org/nuiton/guix/demo/GuixDemo2.guix 2009-05-07 15:20:41 UTC (rev 1397)
@@ -0,0 +1,5 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!-- test javadoc Application -->
+<Application title="JAXX Demo" width='1024' height='800' xmlns:swing='javax.swing.*'>
+ <swing:JPanel />
+</Application>
1
0
r1396 - guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix
by kmorin@users.labs.libre-entreprise.org 07 May '09
by kmorin@users.labs.libre-entreprise.org 07 May '09
07 May '09
Author: kmorin
Date: 2009-05-07 15:20:03 +0000 (Thu, 07 May 2009)
New Revision: 1396
Modified:
guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java
Log:
ajout de l'attribut mainClass
Modified: guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java
===================================================================
--- guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-05-07 15:19:37 UTC (rev 1395)
+++ guix/trunk/guix-maven-plugin/src/main/java/org/nuiton/guix/GuixMojo.java 2009-05-07 15:20:03 UTC (rev 1396)
@@ -37,6 +37,14 @@
*/
private String rootPackage;
+ /**
+ * Main class of the application to generate.
+ * @parameter expression="${guix.mainClass}"
+ * @required
+ * @since 0.0.1
+ */
+ private String mainClass;
+
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
GuixInitializer.initialize();
@@ -50,13 +58,17 @@
ArrayList<File> guixFiles = goDeeperInto(guixFilesDir);
GuixLauncher gcl = new GuixLauncher(guixFiles.toArray(
- new File[guixFiles.size()]),targetDirectory,rootPackage,guixFilesDir);
+ new File[guixFiles.size()]),targetDirectory,rootPackage,
+ guixFilesDir,mainClass);
boolean result = gcl.compile();
if(result)
getLog().info("Compilation succeeded !");
else
getLog().error("Compilation failed...");
}
+ else {
+ getLog().error("Sources not found.");
+ }
}
private ArrayList<File> goDeeperInto(File dir) {
1
0