Index: topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityAttributesPanel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityAttributesPanel.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityAttributesPanel.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,78 @@ +/* *##% + * 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. + *##%*/ + +/* * + * ObjectModelToEntityAttributesPanel.java + * + * Created: Jul 6, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +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 des attributs de +* chaque entite +*/ +public class ObjectModelToEntityAttributesPanel extends ObjectModelGeneratorWithCapitalizeName{ // ObjectModelToEntityAttributesPanel + + public String getFilenameForClass(ObjectModelClass clazz) { + return (clazz.getPackageName() + ".ui.") + .replace('.', File.separatorChar) + + capitalizeName(clazz) + "AttributesPanelPanel.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)%>AttributesPanelPanel extends <%=capitalizeName(clazz)%>TablePanelUI { + + public <%=capitalizeName(clazz)%>AttributesPanelPanel(){ + init(); + } +} +}*/ + } + } + +} // ObjectModelToEntityAttributesPanel + Index: topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityAttributesUIModel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityAttributesUIModel.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityAttributesUIModel.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,429 @@ +/* *##% + * 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. + *##%*/ + +/* * + * ObjectModelToEntityAttributesUIModel.java + * + * Created: Jul 2, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +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; +import java.util.ArrayList; + +//,org.codelutin.topia.generators.ui.ObjectModelToEntityTableUIModel,org.codelutin.topia.generators.ObjectModelToTJDOGenerator,org.codelutin.topia.generators.ObjectModelToUIModelGenerator +/** +* Ce generateur permet de generer un panel de saisie +* avec l'ensemble des attributs de la classe +*/ +public class ObjectModelToEntityAttributesUIModel extends ObjectModelGeneratorWithCapitalizeName{ // ObjectModelToEntityAttributesUIModel + + public String getFilenameForClass(ObjectModelClass clazz) { + // put .uimodel file in uimodel directory + return ".." + File.separator + "uimodel" + File.separator + capitalizeName(clazz) + "AttributesPanel.uimodel"; + } + + /** + * Genere un panel appele AttributesPanel + */ + 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/ui/generators/ObjectModelToEntityPanel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityPanel.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityPanel.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,119 @@ +/* *##% +* 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. +*##%*/ + +/* * +* ObjectModelToEntityPanel.java +* +* Created: 11 mai 2004 +* +* @author Benjamin Poussin +* Copyright Code Lutin +* @version $Revision: 1.1 $ +* +* Mise a jour: $Date: 2004/07/15 13:13:13 $ +* par : $Author: bpoussin $ +*/ + +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 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) + + 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)){ + if (!"".equals(clazz.getPackageName())) { + +/*{ +/** +* Generated: by ToPIA Framework +* Copyright Code Lutin +* http://www.codelutin.com +*) + +package <%=clazz.getPackageName()%>.ui; +}*/ + } +/*{ + +public class <%=capitalizeName(clazz)%>Panel extends <%=capitalizeName(clazz)%>PanelUI { + + public <%=capitalizeName(clazz)%>Panel(){ + init(); + } + + public void on_save(){ + // TODO a implanter + 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();) { + ObjectModelAttribute att = (ObjectModelAttribute)i.next(); +/*{ + public void on_add<%=capitalizeName(att)%>Entities(){ + // TODO a implanter + System.out.println("on_add<%=capitalizeName(att)%>Entities"); + } +}*/ +} +/*{ +} +}*/ + } + } + +} // ObjectModelToEntityPanel + Index: topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityTablePanel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityTablePanel.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityTablePanel.java Thu Jul 15 13:13: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/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +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/ui/generators/ObjectModelToEntityTableUIModel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityTableUIModel.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityTableUIModel.java Thu Jul 15 13:13: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/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +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 + Index: topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityUIModel.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityUIModel.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToEntityUIModel.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,235 @@ +/* *##% + * 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. + *##%*/ + +/* * + * ObjectModelToEntityUIModel.java + * + * Created: 1 mai 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +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 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 + 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()%>Panel + + + +}*/ +//String title = clazz.getName(); +//generateBorderPanel(output, clazz, title); +/*{ + + + + + + + + <%=capitalizeName(clazz)%>AttributesPanel + + + + + + + + 0 + 0 + 1 + 1 + 1.0 + 1.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + + + + + + <%=capitalizeName(clazz)%>ButtonsPanel + + + + + + + + 1 + 0 + 1 + 1 + 1.0 + 1.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + + + + + + <%=capitalizeName(clazz)%>TablePanel + + + + + + + + 0 + 1 + 1 + 2 + 1.0 + 1.0 + 10 + 1 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + + + + + +}*/ + } + } + + /** + * Genere le border du panel + */ + public void generateBorderPanel(Writer output, ObjectModelClass clazz, + String name) throws IOException { +/*{ + + + + + + + 0 + + + <%=capitalizeName(clazz)%> + 0 + 0 + + + + +}*/ + } + +} // ObjectModelToEntityUIModel + Index: topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToWidgetsXML.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToWidgetsXML.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/ObjectModelToWidgetsXML.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,85 @@ +/* *##% +* 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. +*##%*/ + +/* * +* ObjectModelToWidgetsXML.java +* +* Created: Jun 16, 2004 +* +* @author Benjamin Poussin +* Copyright Code Lutin +* @version $Revision: 1.1 $ +* +* Mise a jour: $Date: 2004/07/15 13:13:13 $ +* par : $Author: bpoussin $ +*/ + +package org.codelutin.topia.generators.ui; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGeneratorWithCapitalizeName; +import org.codelutin.generator.models.object.ObjectModel; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.topia.generators.Util; + +/** +* Cette classe permet de generer un fichier xml de type Buix, ainsi ce fichier +* pourra etre charge et le panel genere dans Topia pourra apparaitre dans la palette +* de Buix +*/ +public class ObjectModelToWidgetsXML extends ObjectModelGeneratorWithCapitalizeName{ // ObjectModelToWidgetsXML + + public String getFilenameForModel(ObjectModel model) { + return model.getName()+"-widgets.xml"; + } + + public void generateFromModel(Writer output, ObjectModel model) throws IOException { + +/*{ + +}*/ + Iterator classes = model.getClasses().iterator(); + while (classes.hasNext()) { + ObjectModelClass clazz = (ObjectModelClass) classes.next(); + generate(output, clazz, model); + } +/*{ + +}*/ + + } + + /** + * Creation d'un tag pour chaque class du model + */ + public void generate(Writer output, ObjectModelClass clazz, + ObjectModel model) throws IOException{ + + if(! Util.isEntity(clazz)) return; +/*{ + + +}*/ + + } + +} // ObjectModelToWidgetsXML + Index: topia/src/java/org/codelutin/topia/ui/generators/UIModelToUICallbackSwingGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/UIModelToUICallbackSwingGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/UIModelToUICallbackSwingGenerator.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,106 @@ +/* *##% + * 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. + *##%*/ + +/* * + * UIModelToUICallbackSwingGenerator.java + * + * Created: Jun 1, 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +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.UIModelGeneratorWithCapitalizeName; +import org.codelutin.generator.models.ui.UIModel; +import org.codelutin.generator.models.ui.UIModelEvent; +import org.codelutin.generator.models.ui.UIModelObject; + +/** +* Classe qui permet de generer une interface a partir d'un uimodel +* Cette classe etend le generator present dans lutingenerator +* @see UIModel +*/ +public class UIModelToUICallbackSwingGenerator extends UIModelGeneratorWithCapitalizeName { // UIModelToUICallbackSwingGenerator + + /** + * Methode qui permet de generer une interface UICallback a partir de UIModel + */ + public String getFilenameForUIModel(UIModel model) { + + return model.getPackage().replace('.', File.separatorChar) + File.separatorChar + capitalizeName(model.getRoot()) + "UICallback.java"; + } + + /** + * Methode qui permet de generer une interface UICallback a partir de UIModel + */ + public void generateFromUIModel(Writer output, UIModel model) + throws IOException { + // ------------- File Header + if (!model.getPackage().equals("")) { +/*{ +/** +* Generated: by ToPIA Framework +* Copyright Code Lutin +* http://www.codelutin.com + *) + +package <%=model.getPackage()%>; +}*/ + } + // ------------- Imports +/*{ +import org.codelutin.topia.TopiaException; + +public interface <%=capitalizeName(model.getRoot())%>UICallback { +}*/ + // generation des signatures des handlers de l'objet + for(Iterator o = model.getObjects().iterator(); o.hasNext();) { + UIModelObject object = (UIModelObject)o.next(); + for(Iterator i = object.getEvents().iterator(); i.hasNext();){ + UIModelEvent event = (UIModelEvent)i.next(); + if (event.getArgument()==null){ +/*{ + + public void <%= event.getHandler() %>(); +}*/ + }else{ +/*{ + + public void <%= event.getHandler() %>(<%= event.getArgument() %>); +}*/ + } + } + } +// accolade de fin d'interface +/*{ +} +}*/ + } +} // UIModelToUICallbackSwingGenerator + Index: topia/src/java/org/codelutin/topia/ui/generators/UIModelToUISwingGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/UIModelToUISwingGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/UIModelToUISwingGenerator.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,490 @@ +/* *##% +* 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. +*##%*/ + +/* * +* UIModelToUISwingGenerator.java +* +* Created: Jun 1, 2004 +* +* @author Benjamin Poussin +* Copyright Code Lutin +* @version $Revision: 1.1 $ +* +* Mise a jour: $Date: 2004/07/15 13:13:13 $ +* par : $Author: bpoussin $ +*/ + +package org.codelutin.topia.generators.ui; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Iterator; + +import org.codelutin.generator.UIModelGeneratorWithCapitalizeName; +import org.codelutin.generator.models.ui.UIModel; +import org.codelutin.generator.models.ui.UIModelEvent; +import org.codelutin.generator.models.ui.UIModelObject; +import org.codelutin.generator.models.ui.UIModelProperty; + +/** +* Classe qui permet de generer une classe java a partir d'un uimodel +* Cette classe etend le generator present dans lutingenerator +* @see UIModel +*/ +public class UIModelToUISwingGenerator extends UIModelGeneratorWithCapitalizeName { //UIModelToUISwingGenerator + + protected String objectName; + protected static int nbAnonymousObject = 0; + + /** + * Methode qui permet de generer une classe UI a partir de UIModel + * + */ + public String getFilenameForUIModel(UIModel model) { + return model.getPackage().replace('.', File.separatorChar) + + File.separatorChar + capitalizeName(model.getRoot()) + "UI.java"; + } + + /** + * Methode qui permet de generer une classe UI a partir de UIModel + * + */ + public void generateFromUIModel(Writer output, UIModel model) + throws IOException { + generateForRoot(output, model.getRoot()); + for(Iterator o = model.getObjects().iterator(); o.hasNext();){ + UIModelObject object = (UIModelObject)o.next(); + if(object.getParent() != null){ + generateForUIModelObject(output, object); + } + } +// accolade de fin de classe +/*{ +} +}*/ + } + + /** + * Methode qui permet de creer l'entete de classe generee + */ + public void generateForRoot(Writer output, UIModelObject object) + throws IOException { + +// ------------- File Header + if (!object.getModel().getPackage().equals("")) { +/*{ +/** +* Generated: by ToPIA Framework +* Copyright Code Lutin +* http://www.codelutin.com + *) + +package <%=object.getModel().getPackage()%>; +}*/ + } + +// ------------- Imports +/*{ + +import org.codelutin.topia.TopiaException; +import org.codelutin.i18n.I18n; + +import java.util.ArrayList; +import java.util.Iterator; + +import java.awt.Component; +import java.awt.Container; + +import javax.swing.RootPaneContainer; +import java.beans.EventHandler; + +public abstract class <%=capitalizeName(object)%>UI extends <%=object.getType()%> implements <%=capitalizeName(object)%>UICallback { +}*/ + //creation des constructeurs selon le type de l'objet + if (object.getType().equals("javax.swing.JDialog")){ +/*{ + + public <%=capitalizeName(object)%>UI(){ + this((Frame)null); + } + + public <%=capitalizeName(object)%>UI(Dialog owner){ + super(owner, I18n._("<%=object.getProperty("title").getStringValue()%>"), <%=object.getProperty("modal").getBooleanValue()%>); + } + + public <%=capitalizeName(object)%>UI(Frame owner){ + super(owner, I18n._("<%=object.getProperty("title").getStringValue()%>"), <%=object.getProperty("modal").getBooleanValue()%>); + } +}*/ + + }else if (object.getType().equals("javax.swing.JFrame")){ +/*{ + + public <%=capitalizeName(object)%>UI(){ + super(I18n._("<%=object.getProperty("title").getStringValue()%>")); + } +}*/ + } + + generateConstructorStatement(output, object); + +/*{ + + public void init() { + <%=capitalizeName(object)%>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); + // creation de la methode qui permettra de recuperer les constraints des enfants de cet objet + generateConstraintStatement(output, object); + } + + /** + * Methode qui permet de generer une classe UI a partir de UIModelObject + * + */ + public void generateForUIModelObject(Writer output, UIModelObject object) + throws IOException { + + if(object.getParent() == null){ + objectName = "this"; + // appel a l'entete de la classe + generateForRoot(output, object); + + }else{ + objectName = "__" + object.getName() + "__"; +/*{ + + // declaration de l'objet + private <%=object.getType()%> <%=objectName%> = null; + public <%=object.getType()%> get<%=capitalizeName(object)%>() { + + // test si deja instancier + if(<%=objectName%> == null){ +}*/ + generateCreationStatement(output, object); + generateAllStatement(output, object); + /*{ + <%=objectName%> = result; + } + return <%=objectName%> ; + } +}*/ + + // creation de la methode qui permettra de recuperer les enfants de cet objet + generateChildStatement(output, object); + // creation de la methode qui permettra de recuperer les constraints des enfants de cet objet + generateConstraintStatement(output, object); + + } + } + + + /** + * Methode qui renvoie une liste de String des arguments + */ + public void generateArgumentStatement(Writer output, UIModelObject object) + throws IOException { + + ArrayList args = (ArrayList)object.getArguments(); + + for(Iterator i=args.iterator(); i.hasNext();){ + + Object arg = i.next(); + + if (arg instanceof UIModelObject){ + + UIModelObject objectArg = (UIModelObject)arg; + if (objectArg.getName() != null) { + /*{__<%=objectArg.getName()%>__}*/ + }else{ + generateInstanciationObject(output, (UIModelObject)arg); + } + + }else if (arg instanceof String){ + String argString = (String)arg; + /*{"<%=argString%>"}*/ + + }else if (arg instanceof Character){ + char argChar = ((Character)arg).charValue(); + /*{'<%=argChar%>'}*/ + + }else{ + /*{<%=arg.toString()%>}*/ + + } + if (i.hasNext()){ + /*{, }*/ + } + } + } + + /** + * Methode pour creer le constructeur de la classe avec les arguments + * definis dans l'uimodel + */ + public void generateConstructorStatement(Writer output, UIModelObject object) + throws IOException { + + ArrayList args = (ArrayList)object.getArguments(); + if (args.size() == 0){ + if (!(object.getType().equals("javax.swing.JFrame")) + && !(object.getType().equals("javax.swing.JDialog"))){ + +/*{ + + public <%=capitalizeName(object)%>UI(){ + super(); + } +}*/ + } + }else{ + +/*{ + + public <%=capitalizeName(object)%>UI(}*/ + generateArgumentStatement(output, object); + /*{){ + super(}*/generateArgumentStatement(output, object);/*{); + } +}*/ + } + + } + + /** + * Methode pour creer l'objet avec les arguments definis dans l'uimodel + */ + public void generateCreationStatement(Writer output, UIModelObject object) + throws IOException { + + ArrayList args = (ArrayList)object.getArguments(); + if (args.size() == 0 ){ +/*{ + + // 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);/*{); +}*/ + } + } + + /** + * Methode pour modifier les prorpietes de l'objet selon les valeurs definies dans + * l'uimodel + */ + public void generateSetStatement(Writer output, UIModelObject object) + throws IOException { +/*{ + + // application des proprietes +}*/ + ArrayList properties = (ArrayList)object.getProperties(); + + for(Iterator i=properties.iterator(); i.hasNext();){ + + UIModelProperty property = (UIModelProperty) i.next(); + Object arg = property.getValue(); + String propertyName = property.getName(); + + if (! propertyName.equals("layout")){ + try{ + // cas ou la propriete est indexee + String index = (property.isIndexed()) ? new String(property.getIndex()+", "):""; + + // cas ou la propriete est un objet + if (arg instanceof UIModelObject){ + + UIModelObject objectArg = (UIModelObject)arg; +/*{ + result.set<%=capitalizeName(property)%>(<%=index%>get<%=capitalizeName(objectArg)%>()); +}*/ + // cas ou la propriete est de type string + }else if (arg instanceof String){ +/*{ + result.set<%=capitalizeName(property)%>(<%=index%>"<%=property.getStringValue()%>"); +}*/ + + // cas ou la propriete est de type char + }else if (arg instanceof Character){ +/*{ + result.set<%=capitalizeName(property)%>(<%=index%>'<%=property.getCharValue()%>'); +}*/ + }else{ +/*{ + result.set<%=capitalizeName(property)%>(<%=index%><%=property.getValue().toString()%>); +}*/ + } + }catch(Exception eee){ + System.out.println("Impossible d'acceder a l'index de la propriete " + propertyName); + System.out.println(eee); + } + }else if (arg instanceof UIModelObject){ + UIModelObject objectArg = (UIModelObject)arg; +/*{ + if (result instanceof RootPaneContainer){ + ((RootPaneContainer)result).getContentPane().setLayout(new <%= objectArg.getType()%>(}*/generateArgumentStatement(output, objectArg);/*{)); + }else if (result instanceof Container) { + ((Container)result).setLayout(new <%= objectArg.getType()%>(}*/generateArgumentStatement(output, objectArg);/*{)); + } +}*/ + } + } + } + + /** + * Methode pour affecter les events a l'objet + */ + public void generateHandlerEventStatement(Writer output, UIModelObject object) + throws IOException { + + ArrayList events = (ArrayList)object.getEvents(); + for(Iterator i=events.iterator(); i.hasNext();){ + + UIModelEvent event = (UIModelEvent) i.next(); +/*{ + + //ajout des events + Object l = EventHandler.create(<%=event.getSource()%>.class, result, "<%=event.getHandler()%>", "<%=event.getArgument()%>", "<%=event.getAction()%>"); + + result.<%=event.getAddMethod()%>((<%=event.getSource()%>)l); +}*/ + } + } + + /** + * Methode pour generer une methode qui permet de retourner les enfants de l'objet + */ + public void generateChildStatement(Writer output, UIModelObject object) + throws IOException { + +/*{ + + public ArrayList get<%=capitalizeName(object)%>Childs() { + ArrayList children = new ArrayList(); +}*/ + for(Iterator i=object.getChildren().iterator(); i.hasNext();){ + UIModelObject objectChild = (UIModelObject) i.next(); + +/*{ + children.add(get<%=capitalizeName(objectChild)%>()); +}*/ + } +/*{ + return children; + } +}*/ + + } + + /** + * Methode pour generer une methode qui permet de retourner les constraints + * enfants de l'objet + */ + public void generateConstraintStatement(Writer output, UIModelObject object) + throws IOException { + +/*{ + + public ArrayList get<%=capitalizeName(object)%>Constraints() { + ArrayList constraints = new ArrayList(); +}*/ + for(Iterator i=object.getChildren().iterator(); i.hasNext();){ + // recuperation de l'objet de l'enfant + UIModelObject objectChild = (UIModelObject) i.next(); + // recuperation de la constrainte pour cet objet + Object objectConstraint = objectChild.getConstraint().getValue(); + + if (objectConstraint instanceof UIModelObject) { + UIModelObject constraint = (UIModelObject)objectConstraint; +/*{ + constraints.add(}*/generateInstanciationObject(output, constraint);/*{); +}*/ + }else if (objectConstraint instanceof String) { +/*{ + constraints.add(<%=objectChild.getConstraint().getStringValue()%>); +}*/ + } + } +/*{ + return constraints; + } +}*/ + + } + + /** + * Methode pour "construire" les objets anonymes commes les constraints + */ + public void generateInstanciationObject(Writer output, UIModelObject object) + throws IOException { +/*{ new <%=object.getType()%>(}*/generateArgumentStatement(output, object);/*{)}*/ + } + + /** + * Methode pour "construire" l'objet (events, properties, child ...) + */ + public void generateAllStatement(Writer output, UIModelObject object) + throws IOException { + // generation des proprietes + generateSetStatement(output, object); +/*{ + + // recuperation des differentes donnees concernant l'objet + ArrayList childs = get<%=capitalizeName(object)%>Childs(); + ArrayList constraints = get<%=capitalizeName(object)%>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()); +}*/ + } +/*{ + } +}*/ + + // creation des events + generateHandlerEventStatement(output, object); + } + +} // UIModelToUISwingGenerator + Index: topia/src/java/org/codelutin/topia/ui/generators/package.html diff -u /dev/null topia/src/java/org/codelutin/topia/ui/generators/package.html:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/ui/generators/package.html Thu Jul 15 13:13:13 2004 @@ -0,0 +1,47 @@ + + +

Générateur d'interface

+

+Ce package contient les générateurs d'interface à partir du modèle objet et à +partir du modèle ui. +

+ +

Génération à partir du modèle ui

+

+Cette génération est composé de deux générateur. +

+

+Le premier génère une interface contenant toutes les méthodes de callback dont +l'interface graphique a besoin. Par exemple le clique sur un bouton, l'appuie +sur une touche, la sélection dans une liste, .... Tout ces évènements appellent +une méthode lorsqu'ils ont lieu. Le nom du fichier généré prend le nom du +fichier .uimodel en lui ajoutant UICallback. +

+

+Le second générateur implante l'interface UICallback, mais celle-ci est +abstraite car elle n'implante pas les méthodes de l'interface. Son nom est +celui du fichier .uimodel suivi de UI. On retrouve dans cette classe tous les +widgets graphiques de l'interface. Il sont tous disponible par une méthode +d'accès, cette méthode porte le nom du widget précédé de get. Donc pour un +widget JButton de nom saveButton nous aurons la méthode +getSaveButton():JButton +

+ +

Génération à partir du modèle objet

+

+Cette génération est composée de deux générateur +{@link ObjectModelToEntityUIModel} et {@link ObjectModelToEntityPanel}. +

+

+Le premier permet de générer l'interface graphique de saisie modification sous +le format du modèle ui qui sera alors utilisé par la génération à partir de +ce modèle. +

+

+Le second générateur permet de générer une classe concrète elle étendra la +classe UI. Elle finira d'initialiser l'interface graphique, de mettre en place +des modèles de composant graphique pour ce connecter aux données, ... Cette +classe étant la classe générée à partir du modèle ui. +

+ +