Index: topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityPanel.java diff -u topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityPanel.java:1.7 topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityPanel.java:1.8 --- topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityPanel.java:1.7 Wed Jun 30 13:40:36 2004 +++ topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityPanel.java Tue Jul 6 15:58:13 2004 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.7 $ +* @version $Revision: 1.8 $ * -* Mise a jour: $Date: 2004/06/30 13:40:36 $ -* par : $Author: pineau $ +* Mise a jour: $Date: 2004/07/06 15:58:13 $ +* par : $Author: mazelier $ */ package org.codelutin.topia.generators.ui; @@ -41,14 +41,20 @@ import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.topia.generators.Util; +/** +* Ce generateur permet de generer la classe avec l'ensemble des methodes a implanter +*/ public class ObjectModelToEntityPanel extends ObjectModelGeneratorWithCapitalizeName { // ObjectModelToEntityPanel public String getFilenameForClass(ObjectModelClass clazz) { return (clazz.getPackageName() + ".ui.") .replace('.', File.separatorChar) - + clazz.getName() + "Panel.java"; + + capitalizeName(clazz) + "Panel.java"; } - +/** +* Methodes a implanter : les handlers des buttons Save, Delete et Cancel + les buttons +* Add +*/ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { if(Util.isEntity(clazz)){ @@ -66,9 +72,9 @@ } /*{ -public class <%=clazz.getName()%>Panel extends <%=clazz.getName()%>PanelUI { +public class <%=capitalizeName(clazz)%>Panel extends <%=capitalizeName(clazz)%>UI { - public <%=clazz.getName()%>Panel(){ + public <%=capitalizeName(clazz)%>Panel(){ init(); } @@ -77,10 +83,21 @@ System.out.println("on_save"); } + public void on_delete(){ + // TODO a implanter + System.out.println("on_delete"); + } + public void on_cancel(){ // TODO a implanter System.out.println("on_cancel"); } + + public void on_search(){ + // TODO a implanter + System.out.println("on_search"); + } + }*/ for(Iterator i=clazz.getAttributes().iterator(); i.hasNext();) { Index: topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java diff -u topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java:1.17 topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java:1.18 --- topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java:1.17 Wed Jun 30 13:40:36 2004 +++ topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityUIModel.java Tue Jul 6 15:58:13 2004 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.17 $ + * @version $Revision: 1.18 $ * - * Mise a jour: $Date: 2004/06/30 13:40:36 $ - * par : $Author: pineau $ + * Mise a jour: $Date: 2004/07/06 15:58:13 $ + * par : $Author: mazelier $ */ package org.codelutin.topia.generators.ui; @@ -43,19 +43,28 @@ /** -* Ce g�n�rateur permet de g�n�rer des interfaces par defaut de saisie et de -* modification des Entities. -* @todo a implanter comme il faut +* Ce generateur permet de generer l'interface globale (saisie, modification, +* recherche, suppression des Entities) */ public class ObjectModelToEntityUIModel extends ObjectModelGeneratorWithCapitalizeName { // ObjectModelToEntityUIModel public String getFilenameForClass(ObjectModelClass clazz) { // put .uimodel file in uimodel directory - return ".." + File.separator + "uimodel" + File.separator + clazz.getName() + ".uimodel"; + return ".." + File.separator + "uimodel" + File.separator + capitalizeName(clazz) + ".uimodel"; } + /** + * Genere un panel qui contient deux autres panels (en haut : le panel + * de saisie appele registerPanel et en bas le panel de recherche + * appele searchPanel) + * registerPanel est un panel de saisie. Ce panel est compose par deux autres + * panels de panels avec l'ensemble des attributs de l'entite et le panel de + * boutons pour ajouter, + * supprimer et annuler l'enregistrement) + */ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException { + if(Util.isEntity(clazz)){ /*{ + + package="<%=clazz.getPackageName()%>.ui"<% } %>> + + + + + <%=clazz.getName()%>AttributesPanel + + + + + + + + + + }*/ + int counterArguments = 1; + for(Iterator i=clazz.getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute att = (ObjectModelAttribute)i.next(); + /*{ + + + + + + + <%=att.getName()+"Label"%> + + + + + <%=capitalizeName(att)%> + + + + + + + + 0 + <%=counterArguments%> + 1 + 1 + 0.0 + 0.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + }*/ + if(att.referenceClassifier()){ + generateEntityEditor(output, att, counterArguments); + }else if(att.getType().equalsIgnoreCase("boolean")){ + generateBooleanEditor(output, att, counterArguments); + }else if(att.getType().equalsIgnoreCase("char")){ + generateCharEditor(output, att, counterArguments); + }else{ + generateDefaultEditor(output, att, counterArguments); + } + counterArguments++; + } +/*{ + + + + +}*/ + } + } + + + /** + * Genere un JTextField : element par defaut + */ + public void generateDefaultEditor(Writer output, ObjectModelAttribute att, int counterArguments) + throws IOException { + /*{ + + + + + + + 6 + + + + + <%=att.getName()+"Editor"%> + + + + + + + + 1 + <%=counterArguments%> + 1 + 1 + 1.0 + 1.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + }*/ + } + + + /** + * todo il faudra creer un model + * Genere une combobox ou une Jlist tout depend la multiplicite de l'attribut + * de l'association + */ + public void generateEntityEditor(Writer output, ObjectModelAttribute att, + int counterArguments) throws IOException { + +/*{ + + +}*/ + if (att.getMaxMultiplicity()>1 || att.getMaxMultiplicity()==-1){ +/*{ + + + + +}*/ + }else{ +/*{ + +}*/ + } +/*{ + + + + <%=att.getName()%>Editor + + + +}*/ + if (att.getMaxMultiplicity()>1 || att.getMaxMultiplicity()==-1){ +/*{ + + + + + + + add<%=capitalizeName(att)%>Entities + + + + + Add + + +}*/ + ObjectModelAttribute attRev = att.getReverseAttribute(); + if (attRev != null && attRev.getMinMultiplicity()>=1){ +/*{ + + + false + + +}*/ + } +/*{ + + + + + + + + + 2 + <%=counterArguments%> + 1 + 1 + 0.0 + 0.0 + 10 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + + }*/ + } + + /*{ + + + + + 1 + <%=counterArguments%> + 1 + 1 + 1.0 + 1.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + }*/ + } + + /** + * Genere une checkbox + */ + public void generateBooleanEditor(Writer output, ObjectModelAttribute att, int counterArguments) + throws IOException { +/*{ + + + + + + + <%=att.getName()%>Editor + + + + + + + + 1 + <%=counterArguments%> + 1 + 1 + 0.0 + 0.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + }*/ + } + + /** + * todo faudra peut etre creer un editor + * Genere un JTextField (normalement avec 1 char) + */ + public void generateCharEditor(Writer output, ObjectModelAttribute att, + int counterArguments) throws IOException { + /*{ + + + + + + + 1 + + + + + <%=att.getName()%>Editor + + + + + + + + 1 + <%=counterArguments%> + 1 + 1 + 1.0 + 1.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + }*/ + } + + +} // ObjectModelToEntityAttributesUIModel + Index: topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityTablePanel.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityTablePanel.java:1.1 --- /dev/null Tue Jul 6 15:58:19 2004 +++ topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityTablePanel.java Tue Jul 6 15:58:13 2004 @@ -0,0 +1,77 @@ +/* *##% + * 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. + *##%*/ + +/* * + * ObjectModelToEntityTablePanel.java + * + * Created: Jul 6, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/06 15:58:13 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.generators.ui; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; + +import org.codelutin.generator.ObjectModelGeneratorWithCapitalizeName; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.topia.generators.Util; + +/** +* Ce generateur permet de generer la classe avec le panel compose de +* la JTable compose des attributs des differentes entites +*/ +public class ObjectModelToEntityTablePanel extends ObjectModelGeneratorWithCapitalizeName{ // ObjectModelToEntityTablePanel + + public String getFilenameForClass(ObjectModelClass clazz) { + return (clazz.getPackageName() + ".ui.") + .replace('.', File.separatorChar) + + capitalizeName(clazz) + "TablePanelPanel.java"; + } + + public void generateFromClass(Writer output, ObjectModelClass clazz) + throws IOException { + if(Util.isEntity(clazz) && !"".equals(clazz.getPackageName())) { + +/*{ +/** +* Generated: by ToPIA Framework +* Copyright Code Lutin +* http://www.codelutin.com +*) + +package <%=clazz.getPackageName()%>.ui; + +public class <%=capitalizeName(clazz)%>TablePanelPanel extends <%=capitalizeName(clazz)%>TablePanelUI { + + public <%=capitalizeName(clazz)%>TablePanelPanel(){ + init(); + } +} +}*/ + } + } +} // ObjectModelToEntityTablePanel + Index: topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityTableUIModel.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityTableUIModel.java:1.1 --- /dev/null Tue Jul 6 15:58:19 2004 +++ topia/src/java/org/codelutin/topia/generators/ui/ObjectModelToEntityTableUIModel.java Tue Jul 6 15:58:13 2004 @@ -0,0 +1,131 @@ +/* *##% + * 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. + *##%*/ + +/* * + * ObjectModelToEntityTableUIModel.java + * + * Created: Jul 2, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/06 15:58:13 $ + * par : $Author: mazelier $ + */ + +package org.codelutin.topia.generators.ui; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGeneratorWithCapitalizeName; +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.topia.generators.Util; + +/** +* Ce generateur permet de generer un panel compose d'une table pour permettre la +* recherche, selection d'element +*/ +public class ObjectModelToEntityTableUIModel extends ObjectModelGeneratorWithCapitalizeName{ // ObjectModelToEntityTableUIModel + + public String getFilenameForClass(ObjectModelClass clazz) { + // put .uimodel file in uimodel directory + return ".." + File.separator + "uimodel" + File.separator + capitalizeName(clazz) + "TablePanel.uimodel"; + } + + /** + * Genere un panel de recherche appele searchPanel + */ + public void generateFromClass(Writer output, ObjectModelClass clazz) + throws IOException { + + if(Util.isEntity(clazz)){ +/*{ + + + package="<%=clazz.getPackageName()%>.ui"<% } %>> + + + + + <%=clazz.getName()%>TablePanel + + + + + + + + + + + + + + + + + + <%=clazz.getName()%>ScrollPane + + + + + + + + 0 + 0 + 1 + 1 + 1.0 + 1.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + + + +}*/ + } + } + +} // ObjectModelToEntityTableUIModel +