Index: topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java diff -u topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java:1.9 topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java:1.10 --- topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java:1.9 Fri Jun 11 15:37:37 2004 +++ topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java Mon Jun 14 16:02:32 2004 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * - * Mise a jour: $Date: 2004/06/11 15:37:37 $ + * Mise a jour: $Date: 2004/06/14 16:02:32 $ * par : $Author: mazelier $ */ @@ -48,7 +48,7 @@ public class ObjectModelToEntityUIModel extends ObjectModelGenerator { // ObjectModelToEntityUIModel public String getFilenameForClass(ObjectModelClass clazz) { - return (Util.getParentPackageName(clazz.getPackageName()) + ".ui.") + return (clazz.getPackageName() + ".ui.") .replace('.', File.separatorChar) + clazz.getName() + ".uimodel"; } @@ -64,12 +64,25 @@ +--> package="<%=Util.getParentPackageName(clazz.getPackageName())%>.ui"<% } %>> + %> package="<%=clazz.getPackageName()%>.ui"<% } %>> - + + + + + 2 + + + + + <%= clazz.getAttributes().size()%> + + + + @@ -99,7 +112,7 @@ - <%=att.getName()%> + <%=Util.toUpperCaseFirstLetter(att.getName())%> @@ -154,6 +167,11 @@ saveButton + + + Save + + @@ -190,6 +208,11 @@ cancelButton + + + + + Cancel Index: topia/src/java/org/codelutin/topia/generators/ui/UIModelToUISwingGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ui/UIModelToUISwingGenerator.java:1.4 topia/src/java/org/codelutin/topia/generators/ui/UIModelToUISwingGenerator.java:1.5 --- topia/src/java/org/codelutin/topia/generators/ui/UIModelToUISwingGenerator.java:1.4 Fri Jun 11 15:37:37 2004 +++ topia/src/java/org/codelutin/topia/generators/ui/UIModelToUISwingGenerator.java Mon Jun 14 16:02:32 2004 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.4 $ +* @version $Revision: 1.5 $ * -* Mise a jour: $Date: 2004/06/11 15:37:37 $ +* Mise a jour: $Date: 2004/06/14 16:02:32 $ * par : $Author: mazelier $ */ @@ -51,7 +51,7 @@ public class UIModelToUISwingGenerator extends UIModelGenerator { //UIModelToUISwingGenerator private String objectName; - + private static int nbAnonymousObject = 0; /** * Methode qui permet de generer une classe UI a partir de UIModel * @@ -77,7 +77,7 @@ } // accolade de fin de classe /*{ - } +} }*/ } @@ -91,65 +91,65 @@ if (!object.getModel().getPackage().equals("")) { /*{ -//| Generated: by ToPIA Framework -//| Copyright Code Lutin -//| http://www.codelutin.com +// Generated: by ToPIA Framework +// Copyright Code Lutin +// http://www.codelutin.com - package <%=Util.getParentPackageName(object.getModel().getPackage())%>.ui; +package <%=Util.getParentPackageName(object.getModel().getPackage())%>.ui; }*/ } // ------------- Imports /*{ - import org.codelutin.topia.TopiaException; - import java.util.ArrayList; - import java.awt.Component; - import javax.swing.RootPaneContainer; - import java.util.Iterator; - import java.beans.EventHandler; - import java.awt.Container; +import org.codelutin.topia.TopiaException; +import java.util.ArrayList; +import java.awt.Component; +import javax.swing.RootPaneContainer; +import java.util.Iterator; +import java.beans.EventHandler; +import java.awt.Container; - public abstract class <%=Util.toUpperCaseFirstLetter(object.getName())%>UI extends <%=object.getType()%> implements <%=Util.toUpperCaseFirstLetter(object.getName())%>UICallback { +public abstract class <%=Util.toUpperCaseFirstLetter(object.getName())%>UI extends <%=object.getType()%> implements <%=Util.toUpperCaseFirstLetter(object.getName())%>UICallback { }*/ //creation des constructeurs selon le type de l'objet if (object.getType().equals("javax.swing.JDialog")){ /*{ - public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(){ + public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(){ this((Frame)null); - } + } - public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(Dialog owner){ - super(owner, i18n._("<%=object.getProperty("title").getStringValue()%>"), <%=object.getProperty("modal").getBooleanValue()%>); - } + public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(Dialog owner){ + super(owner, i18n._("<%=object.getProperty("title").getStringValue()%>"), <%=object.getProperty("modal").getBooleanValue()%>); + } - public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(Frame owner){ - super(owner, i18n._("<%=object.getProperty("title").getStringValue()%>"), <%=object.getProperty("modal").getBooleanValue()%>); - } + public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(Frame owner){ + super(owner, i18n._("<%=object.getProperty("title").getStringValue()%>"), <%=object.getProperty("modal").getBooleanValue()%>); + } }*/ - }else if (object.getType().equals("javax.swing.JFrame")){ + }else if (object.getType().equals("javax.swing.JFrame")){ /*{ - public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(){ - super(i18n._("<%=object.getProperty("title").getStringValue()%>")); - } + public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(){ + super(i18n._("<%=object.getProperty("title").getStringValue()%>")); + } }*/ - } + } - generateConstructorStatement(output, object); + generateConstructorStatement(output, object); /*{ - public void init() { - <%=Util.toUpperCaseFirstLetter(object.getName())%>UI result = this; + public void init() { + <%=Util.toUpperCaseFirstLetter(object.getName())%>UI result = this; }*/ generateAllStatement(output, object); // accolade de fin de init /*{ - } + } }*/ // creation de la methode qui permettra de recuperer les enfants de cet objet generateChildStatement(output, object); @@ -173,20 +173,20 @@ objectName = "__" + object.getName() + "__"; /*{ - // declaration de l'objet - private <%=object.getType()%> <%=objectName%> = null; - public <%=object.getType()%> get<%=Util.toUpperCaseFirstLetter(object.getName())%>() { + // declaration de l'objet + private <%=object.getType()%> <%=objectName%> = null; + public <%=object.getType()%> get<%=Util.toUpperCaseFirstLetter(object.getName())%>() { - // test si deja instancier - if(<%=objectName%> == null){ + // test si deja instancier + if(<%=objectName%> == null){ }*/ - generateCreationStatement(output, object); - generateAllStatement(output, object); + generateCreationStatement(output, object); + generateAllStatement(output, object); /*{ - <%=objectName%> = result; - } - return <%=objectName%> ; - } + <%=objectName%> = result; + } + return <%=objectName%> ; + } }*/ // creation de la methode qui permettra de recuperer les enfants de cet objet @@ -201,10 +201,9 @@ /** * Methode qui renvoie une liste de String des arguments */ - public String generateArgumentStatement(Writer output, UIModelObject object) + public void generateArgumentStatement(Writer output, UIModelObject object) throws IOException { - String argList = ""; ArrayList args = (ArrayList)object.getArguments(); for(Iterator i=args.iterator(); i.hasNext();){ @@ -215,29 +214,27 @@ UIModelObject objectArg = (UIModelObject)arg; if (objectArg.getName() != null) { - argList = argList + "__" + objectArg.getName() + "__"; + /*{__<%=objectArg.getName()%>__}*/ }else{ - argList = argList + "null"; + generateInstanciationObject(output, (UIModelObject)arg); } }else if (arg instanceof String){ String argString = (String)arg; - argList = argList + "\"" + argString + "\"" ; + /*{"<%=argString%>"}*/ }else if (arg instanceof Character){ char argChar = ((Character)arg).charValue(); - argList = argList + "\'" + argChar + "\'" ; + /*{'<%=argChar%>'}*/ }else{ - argList = argList + arg.toString(); + /*{<%=arg.toString()%>}*/ } if (i.hasNext()){ - argList = argList + ","; - + /*{, }*/ } } - return argList; } /** @@ -252,17 +249,18 @@ /*{ public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(){ - super(); + super(); } }*/ }else{ /*{ - /*{ - public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI(<%=generateArgumentStatement(output, object)%>){ - super(<%=generateArgumentStatement(output, object)%>); - } + public <%=Util.toUpperCaseFirstLetter(object.getName())%>UI( }*/ + generateArgumentStatement(output, object); + /*{ ){ + super(}*/generateArgumentStatement(output, object);/*{); + } }*/ } @@ -278,14 +276,14 @@ if (args.size() == 0 ){ /*{ - // instanciation de l'objet - <%=object.getType()%> result = new <%=object.getType()%>(); + // instanciation de l'objet + <%=object.getType()%> result = new <%=object.getType()%>(); }*/ }else{ /*{ - // creation de l'objet avec les arguments de construction - <%=object.getType()%> result = new <%=object.getType()%>(<%=generateArgumentStatement(output, object)%>); + // creation de l'objet avec les arguments de construction + <%=object.getType()%> result = new <%=object.getType()%>(}*/generateArgumentStatement(output, object);/*{); }*/ } } @@ -298,7 +296,7 @@ throws IOException { /*{ - // application des proprietes + // application des proprietes }*/ ArrayList properties = (ArrayList)object.getProperties(); @@ -317,25 +315,23 @@ if (arg instanceof UIModelObject){ UIModelObject objectArg = (UIModelObject)arg; - /*{ - result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%>get<%=Util.toUpperCaseFirstLetter(objectArg.getName())%>()); + result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%>get<%=Util.toUpperCaseFirstLetter(objectArg.getName())%>()); }*/ - // cas ou la propriete est de type string }else if (arg instanceof String){ /*{ - result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%>"<%=property.getStringValue()%>"); + result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%>"<%=property.getStringValue()%>"); }*/ // cas ou la propriete est de type char }else if (arg instanceof Character){ /*{ - result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%>'<%=property.getCharValue()%>'); + result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%>'<%=property.getCharValue()%>'); }*/ }else{ /*{ - result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%><%=property.getValue().toString()%>); + result.set<%=Util.toUpperCaseFirstLetter(propertyName)%>(<%=index%><%=property.getValue().toString()%>); }*/ } }catch(Exception eee){ @@ -345,9 +341,9 @@ }else if (arg instanceof UIModelObject){ UIModelObject objectArg = (UIModelObject)arg; /*{ - if (result instanceof Container) { - ((Container)result).setLayout(new <%= objectArg.getType()%>(<%=generateArgumentStatement(output, objectArg)%>)); - } + if (result instanceof Container) { + ((Container)result).setLayout(new <%= objectArg.getType()%>(}*/generateArgumentStatement(output, objectArg);/*{)); + } }*/ } } @@ -365,10 +361,10 @@ UIModelEvent event = (UIModelEvent) i.next(); /*{ - //ajout des events - Object l = EventHandler.create(<%=event.getSource()%>.class, result, "<%=event.getHandler()%>", "<%=event.getArgument()%>", "<%=event.getAction()%>"); + //ajout des events + Object l = EventHandler.create(<%=event.getSource()%>.class, result, "<%=event.getHandler()%>", "<%=event.getArgument()%>", "<%=event.getAction()%>"); - result.<%=event.getAddMethod()%>((<%=event.getSource()%>)l); + result.<%=event.getAddMethod()%>((<%=event.getSource()%>)l); }*/ } } @@ -381,19 +377,19 @@ /*{ - public ArrayList get<%=Util.toUpperCaseFirstLetter(object.getName())%>Childs() { - ArrayList children = new ArrayList(); + public ArrayList get<%=Util.toUpperCaseFirstLetter(object.getName())%>Childs() { + ArrayList children = new ArrayList(); }*/ for(Iterator i=object.getChildren().iterator(); i.hasNext();){ UIModelObject objectChild = (UIModelObject) i.next(); /*{ - children.add(get<%=Util.toUpperCaseFirstLetter(objectChild.getName())%>()); + children.add(get<%=Util.toUpperCaseFirstLetter(objectChild.getName())%>()); }*/ } /*{ - return children; - } + return children; + } }*/ } @@ -407,9 +403,8 @@ /*{ - public ArrayList get<%=Util.toUpperCaseFirstLetter(object.getName())%>Constraints() { - - ArrayList constraints = new ArrayList(); + public ArrayList get<%=Util.toUpperCaseFirstLetter(object.getName())%>Constraints() { + ArrayList constraints = new ArrayList(); }*/ for(Iterator i=object.getChildren().iterator(); i.hasNext();){ // recuperation de l'objet de l'enfant @@ -417,34 +412,30 @@ // recuperation de la constrainte pour cet objet Object objectConstraint = objectChild.getConstraint().getValue(); - // la contrainte peut etre de 2 types : un objet ou une string if (objectConstraint instanceof UIModelObject) { UIModelObject constraint = (UIModelObject)objectConstraint; - /*{ - - constraints.add(new <%=constraint.getType()%>(<%=generateArgumentStatement(output, constraint)%>)); + constraints.add(}*/generateInstanciationObject(output, constraint);/*{); }*/ }else if (objectConstraint instanceof String) { /*{ - constraints.add(<%=objectChild.getConstraint().getStringValue()%>); + constraints.add(<%=objectChild.getConstraint().getStringValue()%>); }*/ } } /*{ - return constraints; - } + return constraints; + } }*/ } /** - * Methode pour "construire" l'objet anonyme comme les constraints ou leurs arguments + * Methode pour "construire" les objets anonymes commes les constraints */ - public void generateInstanciationObject(Writer output, UIModelObject object) throws IOException { - +/*{ new <%=object.getType()%>(}*/generateArgumentStatement(output, object);/*{)}*/ } /** @@ -456,27 +447,27 @@ generateSetStatement(output, object); /*{ - // recuperation des differentes donnees concernant l'objet - ArrayList childs = get<%=Util.toUpperCaseFirstLetter(object.getName())%>Childs(); - ArrayList constraints = get<%=Util.toUpperCaseFirstLetter(object.getName())%>Constraints(); - - // ajout des enfants avec leur contrainte - Iterator iConstraints = constraints.iterator(); - for(Iterator iChilds = childs.iterator(); iChilds.hasNext(); ){ - Component c = (Component)iChilds.next(); - if (result instanceof RootPaneContainer) { - ((RootPaneContainer)result).getContentPane().add(c, iConstraints.next()); - }else{ - result.add(c, iConstraints.next()); - } + // recuperation des differentes donnees concernant l'objet + ArrayList childs = get<%=Util.toUpperCaseFirstLetter(object.getName())%>Childs(); + ArrayList constraints = get<%=Util.toUpperCaseFirstLetter(object.getName())%>Constraints(); + + // ajout des enfants avec leur contrainte + Iterator iConstraints = constraints.iterator(); + for(Iterator iChilds = childs.iterator(); iChilds.hasNext(); ){ + Component c = (Component)iChilds.next(); + if (result instanceof RootPaneContainer) { + ((RootPaneContainer)result).getContentPane().add(c, iConstraints.next()); + }else{ + result.add(c, iConstraints.next()); + } }*/ if (object.getType().equals("javax.swing.JTabbedPane")){ /*{ - result.setTitleAt(i, c.getName()); + result.setTitleAt(i, c.getName()); }*/ } /*{ - } + } }*/ // creation des events