Index: topia/src/java/org/codelutin/topia/generators/Util.java diff -u topia/src/java/org/codelutin/topia/generators/Util.java:1.1 topia/src/java/org/codelutin/topia/generators/Util.java:1.2 --- topia/src/java/org/codelutin/topia/generators/Util.java:1.1 Mon Jun 21 09:51:17 2004 +++ topia/src/java/org/codelutin/topia/generators/Util.java Tue Jun 22 19:01:05 2004 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Mise a jour: $Date: 2004/06/21 09:51:17 $ + * Mise a jour: $Date: 2004/06/22 19:01:05 $ * par : $Author: bpoussin $ */ @@ -39,6 +39,7 @@ import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; import org.codelutin.generator.models.object.ObjectModelOperation; /** @@ -138,6 +139,53 @@ for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); if (isDerived(attribute)) { + return true; + } + } + return false; + } + + /** + * @return vrai si la classe on une super classe a des operations de + * defini. + */ + public static boolean hasOperation(ObjectModelClassifier clazz){ + boolean result = false; + if(clazz.getOperations().size() != 0){ + return true; + } + if(clazz.getInterfaces().size() != 0){ + for(Iterator i=clazz.getInterfaces().iterator(); i.hasNext();){ + if(hasOperation((ObjectModelClassifier)i.next())){ + return true; + } + } + } + if(clazz instanceof ObjectModelClass && + ((ObjectModelClass)clazz).getSuperclasses().size() != 0){ + for(Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();){ + if(hasOperation((ObjectModelClassifier)i.next())){ + return true; + } + } + } + return false; + } + + /** + * Une class est abtraite si elle a des operations abtraite ou qu'elle + * implante des interfaces qui ont des operations. + */ + public static boolean hasAbstractOperation(ObjectModelClass clazz){ + for(Iterator i=clazz.getOperations().iterator(); i.hasNext();){ + ObjectModelOperation operation = (ObjectModelOperation)i.next(); + if(operation.isAbstract()){ + return true; + } + } + for(Iterator i=clazz.getInterfaces().iterator(); i.hasNext();){ + ObjectModelInterface interfacez = (ObjectModelInterface)i.next(); + if(hasOperation(interfacez)){ return true; } } Index: topia/src/java/org/codelutin/topia/generators/DefaultObjectModelToJavaGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/DefaultObjectModelToJavaGenerator.java:1.1 --- /dev/null Tue Jun 22 19:01:11 2004 +++ topia/src/java/org/codelutin/topia/generators/DefaultObjectModelToJavaGenerator.java Tue Jun 22 19:01:05 2004 @@ -0,0 +1,705 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * DefaultObjectModelGenerator.java + * + * Created: 21 juin 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/06/22 19:01:05 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.topia.generators.Util; +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.generator.models.object.ObjectModelParameter; + +/** +*

Cette classe permet de creer des générateurs simplemement en surchargeant +* les méthodes que l'on souhaite.

+*

Ce generateur decoupe la generation en plusieurs phase: generation de la +* declaration du package, declaration des import, declaration de la classe, +* declaration des attributes, methodes de lecture des attributs, methodes de +* modification des attributs, declaration des operations, generation du corps +* des operations, et une derenieres methode de generation qui sert a mettre ce +* que l'on souhaite. +*

+*

+* Chaque methode de generation est triplée, une pour les classifier, une pour +* les class et une pour les interfaces, par defaut les 2 dernieres appellent +* la premiere. +*

+*

+* Il y a une petite exception a cela pour les attributs qui n'existe pas sur +* les interfaces, et pour la declaration des classes, et qui n'est pas la meme +* pour les class et les interfaces. +*

+*/ +public class DefaultObjectModelToJavaGenerator extends ObjectModelGenerator { // DefaultObjectModelToJavaGenerator + + ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + //// + //// + //// F O R C L A S S + //// + //// + ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + + public String getFilenameForClass(ObjectModelClass clazz) { + return super.getFilenameForClass(clazz) + ".java"; + } + + public void generateFromClass(Writer output, ObjectModelClass clazz) + throws IOException { + + // Consider only entities, return immediately if not an entity + if (! Util.isEntity(clazz)) return; + + // ------------- File Header + generatePackageStatement(output, clazz); + + // ------------- Imports + generateImportStatement(output, clazz); + + // ------------- Class start + generateClassDeclaration(output, clazz); +/*{ { +}*/ + + // ------------- Attributes + + // ------------- Accessors + for (Iterator i=clazz.getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); + generateAttributeDeclaration(output, attribute); + generateGetAttributeAccessor(output, attribute); + generateSetAttributeAccessor(output, attribute); + } + + // ------------- Operations declarations + for(Iterator i=clazz.getOperations().iterator(); i.hasNext();){ + ObjectModelOperation operation = (ObjectModelOperation) i.next(); + generateOperationDeclation(output, operation); + generateOperationBody(output, operation); + } + + // parcours les operations des interfaces + for(Iterator i=clazz.getInterfaces().iterator(); i.hasNext();){ + ObjectModelInterface interfacez = (ObjectModelInterface) i.next(); + for(Iterator o=interfacez.getOperations().iterator(); o.hasNext();){ + ObjectModelOperation operation = (ObjectModelOperation) o.next(); + generateOperationDeclation(output, operation); + generateOperationBody(output, operation); + } + } + + // ---------------- All that framework used + generateOther(output, clazz); +/*{ +} +}*/ + + } + + ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + //// + //// + //// F O R I N T E R F A C E + //// + //// + ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + + public String getFilenameForInterface(ObjectModelInterface interfacez) { + return super.getFilenameForInterface(interfacez) + ".java"; + } + + public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException { + + // Consider only entities, return immediately if not an entity + if (! Util.isEntity(interfacez)) return; + + // ------------- File Header + generatePackageStatement(output, interfacez); + + // ------------- Imports + generateImportStatement(output, interfacez); + + // ------------- Class start + generateClassDeclaration(output, interfacez); +/*{ { +}*/ + + // ------------- Operations declarations + for(Iterator i=interfacez.getOperations().iterator(); i.hasNext();){ + ObjectModelOperation operation = (ObjectModelOperation) i.next(); + generateOperationDeclation(output, operation); + // never body for interface (i hope :) +/*{; +}*/ + } + + // ---------------- All that framework used + generateOther(output, interfacez); +/*{ +} +}*/ + } + + ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + //// + //// + //// S U B G E N E R A T O R + //// + //// + ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + + + ////////////////////////////////////////////////////////////////////// + // P A C K A G E + ////////////////////////////////////////////////////////////////////// + + /** + * Si la classe est defini dans un package, alors on utilise ce package. + */ + public void generatePackageStatement(Writer output, ObjectModelClassifier clazz) + throws IOException { + if (!"".equals(clazz.getPackageName())) { +/*{ +package <%=clazz.getPackageName()%>; + +}*/ + } + } + + /** + * Appelle la methode {@link #generatePackageStatement(Writer, ObjectModelClassifier)} + */ + public void generatePackageStatement(Writer output, ObjectModelClass clazz) + throws IOException { + generatePackageStatement(output, (ObjectModelClassifier)clazz); + } + + /** + * Appelle la methode {@link #generatePackageStatement(Writer, ObjectModelClassifier)} + */ + public void generatePackageStatement(Writer output, ObjectModelInterface interfacez) + throws IOException { + generatePackageStatement(output, (ObjectModelClassifier)interfacez); + } + + + ////////////////////////////////////////////////////////////////////// + // I M P O R T + ////////////////////////////////////////////////////////////////////// + + /** + * Importe les classes utilises utilisees le plus souvent + */ + public void generateImportStatement(Writer output, ObjectModelClassifier clazz) + throws IOException { + /*{ +import org.codelutin.topia.TopiaEntity; +import org.codelutin.topia.TopiaEntityTO; +import org.codelutin.topia.TopiaEntityDO; +import org.codelutin.topia.AbstractTopiaEntityTO; +import org.codelutin.topia.AbstractTopiaEntityDO; +import org.codelutin.topia.TopiaUser; +import org.codelutin.topia.TopiaException; +import org.codelutin.topia.TopiaPersistenceService; +import org.codelutin.topia.PrivateTopiaPersistenceService; +import java.util.List; +import java.util.Collection; +import java.util.Collections; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.HashSet; +}*/ + } + + /** + * Appelle la methode {@link #generateImportStatement(Writer, ObjectModelClassifier)} + */ + public void generateImportStatement(Writer output, ObjectModelClass clazz) + throws IOException { + generateImportStatement(output, (ObjectModelClassifier)clazz); + } + + /** + * Appelle la methode {@link #generateImportStatement(Writer, ObjectModelClassifier)} + */ + public void generateImportStatement(Writer output, ObjectModelInterface interfacez) + throws IOException { + generateImportStatement(output, (ObjectModelClassifier)interfacez); + } + + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + /** + * Genere la declaration de la classe, ceci n'inclue pas le { pour la + * declaration du corps de la classe. Si la classe contient des attributs + * derive, alors elle est marque abstract.Cette methode la plus par du temps + * n'a pas besoin d'etre surcharge, il faut utiliser les methodes + * {@link #getClassName}, {@link #getExtendsClassName}, + * {@link #getImplementsClassName} + */ + public void generateClassDeclaration(Writer output, ObjectModelClass clazz) + throws IOException { +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public<% if(isAbstract(clazz)){ %> abstract<% } %> class <%=getClassName(clazz)%>}*/ + Iterator i = clazz.getSuperclasses().iterator(); + if (i.hasNext()) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); +/*{ extends <%=getClassName(superclass)%>}*/ + } else { + String extendsClass = getExtendsClassName(clazz); + if(extendsClass != null) { +/*{ extends <%=extendsClass%>}*/ + } + } + String implementsInterface = getImplementsClassName(clazz); + i = clazz.getInterfaces().iterator(); + if(i.hasNext() || implementsInterface != null){ + /*{ implements }*/ + if(implementsInterface != null){ + /*{ <%=implementsInterface%>}*/ + if(i.hasNext()){ + /*{, }*/ + } + } + while (i.hasNext()) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); + /*{<%=getClassName(interfacezz)%>}*/ + if(i.hasNext()){ + /*{, }*/ + } + } + } + } + + public boolean isAbstract(ObjectModelClass clazz){ + return Util.isDerived(clazz) || Util.hasAbstractOperation(clazz); + } + + /** + * Genere la declaration de l'interface, ceci n'inclue pas le { pour la + * declaration du corps de la classe. Cette methode la plus par du temps + * n'a pas besoin d'etre surcharge, il faut utiliser les methodes + * {@link #getClassName}, {@link #getExtendsInterfaceName} + */ + public void generateClassDeclaration(Writer output, ObjectModelInterface interfacez) + throws IOException { +/*{ +/** +<%=interfacez.getDocumentation()%> + *) +public interface <%=getClassName(interfacez)%>}*/ + + String extendsInterface = getExtendsInterfaceName(interfacez); + Iterator i = interfacez.getInterfaces().iterator(); + if(i.hasNext() || extendsInterface != null){ + /*{ extends }*/ + if(extendsInterface != null){ + /*{ <%=extendsInterface%>}*/ + if(i.hasNext()){ + /*{, }*/ + } + } + while (i.hasNext()) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); + /*{<%=getClassName(interfacezz)%>}*/ + if(i.hasNext()){ + /*{, }*/ + } + } + } + } + + /** + * Donne le nom de la classe ou de l'interface a generer + */ + public String getClassName(ObjectModelClassifier clazz){ + return clazz.getName(); + } + + /** + * Appelle la methode {@link #getClassName(ObjectModelClassifier)} + */ + public String getClassName(ObjectModelClass clazz){ + return getClassName((ObjectModelClassifier)clazz); + } + + /** + * Appelle la methode {@link #getClassName(ObjectModelInterface)} + */ + public String getClassName(ObjectModelInterface interfacez){ + return getClassName((ObjectModelClassifier)interfacez); + } + + /** + * retourne le nom de la classe que doit etendre la classe a genere + * @return null si elle n'etant aucune classe par defaut. + */ + public String getExtendsClassName(ObjectModelClass clazz){ + return null; + } + + /** + * retourne la liste des noms des interfaces que doit implanter la classe + * @return null si aucune interface a etendre. Sinon une chaine + * representant la liste des interfaces. Cette liste a comme separateur ',' + */ + public String getImplementsClassName(ObjectModelClass clazz){ + return null; + } + + /** + * retourne la liste des noms des classes que doit etendre l'interface + * @return null si aucune interface a etendre. Sinon une chaine + * representant la liste des interfaces. Cette liste a comme separateur ',' + */ + public String getExtendsInterfaceName(ObjectModelInterface interfacez){ + return null; + } + + ////////////////////////////////////////////////////////////////////// + // A T T R I B U T S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + if(Util.isDerived(attribute)){ + generateDerivedAttributeDeclaration(output, attribute); + }else{ + if (!attribute.referenceClassifier()) { + if(!Util.isNMultiplicity(attribute)){ + generateNormalAttributeDeclaration(output, attribute); + }else{ + generateNormalNMultiplicityAttributeDeclaration(output, attribute); + } + }else{ + if(!Util.isNMultiplicity(attribute)){ + generateEntityAttributeDeclaration(output, attribute); + }else{ + generateEntityNMultiplicityAttributeDeclaration(output, attribute); + } + } + } + } + + /** + * For derived (calculated) attribute. Generate nothing + */ + public void generateDerivedAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For normal attribute, aka not entity or derived and with 0/1 cardinality. + */ + public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + protected <%=Util.getAttributeType(attribute)%> <%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; +}*/ + } + + /** + * For normal attribute, aka not entity or derived and with n cardinality. + * By default call {@link #generateNormalAttributeDeclaration} + */ + public void generateNormalNMultiplicityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateNormalAttributeDeclaration(output, attribute); + } + + /** + * For entity attribute with 0/1 cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateNormalAttributeDeclaration(output, attribute); + } + + /** + * For entity attribute with n cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateEntityNMultiplicityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateNormalAttributeDeclaration(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // G E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateGetAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + if(Util.isDerived(attribute)){ + generateGetDerivedAttributeAccessor(output, attribute); + }else{ + if (!attribute.referenceClassifier()) { + if(!Util.isNMultiplicity(attribute)){ + generateGetNormalAttributeAccessor(output, attribute); + }else{ + generateGetNormalNMultiplicityAttributeAccessor(output, attribute); + } + }else{ + if(!Util.isNMultiplicity(attribute)){ + generateGetEntityAttributeAccessor(output, attribute); + }else{ + generateGetEntityNMultiplicityAttributeAccessor(output, attribute); + } + } + } + } + + /** + * For derived (calculated) attribute. + */ + public void generateGetDerivedAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public abstract <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; +}*/ + } + + /** + * For normal attribute, aka not entity or derived. + */ + public void generateGetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + return <%=attribute.getName()%>; + } +}*/ + } + + /** + * For normal attribute, aka not entity or derived and with n cardinality. + * By default call {@link #generateNormalAttributeDeclaration} + */ + public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + /** + * @return an unmodifiable collection + *) + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + return Collections.unmodifiableCollection(<%=attribute.getName()%>); + } +}*/ + + } + + /** + * For entity attribute with 0/1 cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateGetEntityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateGetNormalAttributeAccessor(output, attribute); + } + + /** + * For entity attribute with n cardinality. By default call + * {@link #generateNormalNMultiplicityAttributeDeclaration} + */ + public void generateGetEntityNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateGetNormalNMultiplicityAttributeAccessor(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // S E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateSetAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + if (!Util.isReadOnly(attribute)){ + if(Util.isDerived(attribute)){ + generateSetDerivedAttributeAccessor(output, attribute); + }else{ + if (!attribute.referenceClassifier()) { + if(!Util.isNMultiplicity(attribute)){ + generateSetNormalAttributeAccessor(output, attribute); + }else{ + generateSetNormalNMultiplicityAttributeAccessor(output, attribute); + } + }else{ + if(!Util.isNMultiplicity(attribute)){ + generateSetEntityAttributeAccessor(output, attribute); + }else{ + generateSetEntityNMultiplicityAttributeAccessor(output, attribute); + } + } + } + } + } + + /** + * For derived (calculated) attribute. + */ + public void generateSetDerivedAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public abstract void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException; + +}*/ + } + + /** + * For normal attribute, aka not entity or derived. + */ + public void generateSetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException { + this.<%=attribute.getName()%> = <%=attribute.getName()%>; + } +}*/ + } + + /** + * For normal attribute, aka not entity or derived and with n cardinality. + * By default call {@link #generateNormalAttributeDeclaration} + */ + public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { + this.<%=attribute.getName()%>.add(value); + } + + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { + this.<%=attribute.getName()%>.remove(value); + } + + public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + this.<%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; + } +}*/ + } + + /** + * For entity attribute with 0/1 cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateSetEntityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateSetNormalAttributeAccessor(output, attribute); + } + + /** + * For entity attribute with n cardinality. By default call + * {@link #generateNormalNMultiplicityAttributeDeclaration} + */ + public void generateSetEntityNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateSetNormalNMultiplicityAttributeAccessor(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclation(Writer output, ObjectModelOperation operation) + throws IOException { +/*{ + /** + <%=operation.getDocumentation()%> + *) + <%=operation.getVisibility()%> <%=(operation.isAbstract()?"abstract ":"")%><%=operation.getReturnType()%> <%=operation.getName()%> (<%=Util.getMethodParameterDeclaration(operation.getParameters())%>) throws TopiaException}*/ + } + + /** + * Generate the body of operation. Only Operation for class is passed + * if operation's classifier is interface, is that class implement that + * interface and call is do for operation of this interface. + */ + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + if(operation.isAbstract()){ +/*{ ; + }*/ + }else{ +/*{ { + }*/ + if (! "void".equals(operation.getReturnType())) { +/*{ + return <%=Util.getInitValue(operation.getReturnType())%>; +}*/ + } +/*{ +} +}*/ + } + } + + + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + /** + * generate nothing by default + */ + public void generateOther(Writer output, ObjectModelClassifier clazz) + throws IOException { + } + public void generateOther(Writer output, ObjectModelClass clazz) + throws IOException { + generateOther(output, (ObjectModelClassifier)clazz); + } + public void generateOther(Writer output, ObjectModelInterface interfacez) + throws IOException { + generateOther(output, (ObjectModelClassifier)interfacez); + } + +} // DefaultObjectModelToJavaGenerator + Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToUIModelGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ObjectModelToUIModelGenerator.java:1.1 --- /dev/null Tue Jun 22 19:01:11 2004 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToUIModelGenerator.java Tue Jun 22 19:01:05 2004 @@ -0,0 +1,72 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectModelToUIModelGenerator.java + * + * Created: 21 juin 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/06/22 19:01:05 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModel; + +import org.codelutin.topia.generators.ui.ObjectModelToWidgetsXML; +import org.codelutin.topia.generators.ui.ObjectModelToEntityUIModel; +import org.codelutin.topia.generators.ui.ObjectModelToEntityPanel; + +/** +* Meta generateur qui applique les generateurs pour la generation des interface +* par defaut de saisie des entitees. +*/ +public class ObjectModelToUIModelGenerator extends ObjectModelGenerator { // ObjectModelToUIModelGenerator + + public ObjectModelToUIModelGenerator(){ + super(); + } + + public void generate(ObjectModel model, File destDir) throws IOException { + ObjectModelGenerator gen = null; + + System.out.println("Generation de ObjectModelToWidgetsXML"); + gen = new ObjectModelToWidgetsXML(); + gen.generate(model, destDir); + + System.out.println("Generation de ObjectModelToEntityUIModel"); + gen = new ObjectModelToEntityUIModel(); + gen.generate(model, destDir); + + System.out.println("Generation de ObjectModelToEntityPanel"); + gen = new ObjectModelToEntityPanel(); + gen.generate(model, destDir); + + } + +} // ObjectModelToUIModelGenerator + Index: topia/src/java/org/codelutin/topia/generators/UIModelToSwingGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/UIModelToSwingGenerator.java:1.1 --- /dev/null Tue Jun 22 19:01:11 2004 +++ topia/src/java/org/codelutin/topia/generators/UIModelToSwingGenerator.java Tue Jun 22 19:01:05 2004 @@ -0,0 +1,63 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * UIModelToSwingGenerator.java + * + * Created: 21 juin 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/06/22 19:01:05 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; + +import org.codelutin.generator.UIModelGenerator; +import org.codelutin.generator.models.ui.UIModel; + +import org.codelutin.topia.generators.ui.UIModelToUICallbackSwingGenerator; +import org.codelutin.topia.generators.ui.UIModelToUISwingGenerator; + +public class UIModelToSwingGenerator extends UIModelGenerator { // UIModelToSwingGenerator + + public UIModelToSwingGenerator(){ + super(); + } + + public void generate(UIModel model, File destDir) throws IOException { + UIModelGenerator gen = null; + + + System.out.println("Generation de UIModelToUICallbackSwingGenerator"); + gen = new UIModelToUICallbackSwingGenerator(); + gen.generate(model, destDir); + + System.out.println("Generation de UIModelToUISwingGenerator"); + gen = new UIModelToUISwingGenerator(); + gen.generate(model, destDir); + } + +} // UIModelToSwingGenerator +