Пример #1
0
 private void constrTabFormu(
     Programme prog,
     StringBuffer buf,
     int indent,
     String msg,
     String p_pere,
     Argument arg,
     String indice) {
   this.constrLabelFormu(prog, buf, indent, msg, p_pere, arg);
   String p_zone = "p_" + arg.nom;
   p_zone = Divers.remplacer(p_zone, ".", "_");
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   Divers.indenter(buf, indent);
   Divers.ecrire(buf, p_zone + "=new JPanel(new GridLayout(1, " + prog.getMaxTab() + ")); ");
   Divers.ecrire(buf, p_pere + ".add(" + p_zone + "); ");
   if (arg.isTabBooleens()) {
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, zone + "=new Checkbox [" + prog.getMaxTab() + "]; ");
   } else if (arg.isTabTextes() && arg.avecTexteRadio()) {
     String group = "group_" + arg.nom;
     group = Divers.remplacer(group, ".", "_");
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, group + "=new ButtonGroup[" + prog.getMaxTab() + "]; ");
     String p_group = "p_" + group;
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, p_group + "=new JPanel[ " + prog.getMaxTab() + "]; ");
     String[] liste = arg.getTexteRadio();
     int n = liste.length;
     for (int i = 0; i < n; i++) {
       String zone_bouton = "zone_" + liste[i] + "_" + arg.nom;
       zone_bouton = Divers.remplacer(zone_bouton, ".", "_");
       Divers.indenter(buf, indent);
       Divers.ecrire(buf, zone_bouton + "=new JRadioButton[ " + prog.getMaxTab() + "]; ");
     }
   } else if (arg.isTabTextes() && arg.avecTexteListe()) {
     String model = "model_" + arg.nom;
     model = Divers.remplacer(model, ".", "_");
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, zone + "=new JList [" + prog.getMaxTab() + "]; ");
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, model + "=new DefaultListModel [" + prog.getMaxTab() + "]; ");
   } else {
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, zone + "=new JTextField [" + prog.getMaxTab() + "]; ");
   }
   // la boucle
   instr_pere.addVariable(new Variable(indice, "ENTIER"));
   Divers.ecrire(
       buf,
       "for(int " + indice + "=0; " + indice + "<" + prog.getMaxTab() + "; " + indice + "++) {",
       indent);
   String msg1 = null;
   Argument arg1 = new Argument(arg.nom + "[" + indice + "]", arg.getTypeOfTab(), arg.mode);
   constrFormu(prog, buf, indent + 1, msg1, p_zone, arg1);
   Divers.ecrire(buf, "}", indent);
 }
Пример #2
0
 private void constrTexteFormu(
     Programme prog, StringBuffer buf, int indent, String msg, String p_pere, Argument arg) {
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   if (arg.avecTexteRadio()) {
     String group = "group_" + arg.nom;
     group = Divers.remplacer(group, ".", "_");
     this.constrLabelFormu(prog, buf, indent, msg, p_pere, arg);
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, group + "=new ButtonGroup(); ");
     String p_group = "p_" + group;
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, p_group + "=new JPanel(); ");
     Divers.ecrire(buf, p_pere + ".add(" + p_group + "); ");
     String[] liste = arg.getTexteRadio();
     int n = liste.length;
     for (int i = 0; i < n; i++) {
       String zone_bouton = "zone_" + liste[i] + "_" + arg.nom;
       zone_bouton = Divers.remplacer(zone_bouton, ".", "_");
       Divers.indenter(buf, indent);
       Divers.ecrire(buf, zone_bouton + " = new JRadioButton(" + prog.quote(liste[i]) + "); ");
       Divers.indenter(buf, indent);
       Divers.ecrire(buf, group + ".add(" + zone_bouton + "); ");
       Divers.indenter(buf, indent);
       Divers.ecrire(buf, p_group + ".add(" + zone_bouton + "); ");
     }
   } else if (arg.avecTexteListe()) {
     String model = "model_" + arg.nom;
     model = Divers.remplacer(model, ".", "_");
     this.constrLabelFormu(prog, buf, indent, msg, p_pere, arg);
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, model + "=new DefaultListModel(); ");
     String[] liste = arg.getTexteListe();
     int n = liste.length;
     for (int i = 0; i < n; i++) {
       Divers.ecrire(buf, model + ".addElement(" + prog.quote(liste[i]) + ");", indent);
     }
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, zone + "=new JList(" + model + "); ");
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, zone + ".setVisibleRowCount(2); ");
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, p_pere + ".add(new JScrollPane(" + zone + ")); ");
   } else {
     this.constrLabelFormu(prog, buf, indent, msg, p_pere, arg);
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, zone + "=new JTextField(); ");
     Divers.ecrire(buf, p_pere + ".add(" + zone + ");");
   }
 }
Пример #3
0
 /**
  * Initialisation des composants du formulaire.
  *
  * @param prog
  * @param buf
  * @param indent
  */
 public void constrFormu(Programme prog, StringBuffer buf, int indent) {
   for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Argument> iter =
           instr_pere.arguments.iterator();
       iter.hasNext(); ) {
     Argument arg = (Argument) iter.next();
     String msg = prog.quote(arg.nom);
     constrFormu(prog, buf, indent + 1, msg, "p", arg);
   }
 }
Пример #4
0
 private void lireTabFormu(Programme prog, StringBuffer buf, int indent, Argument arg) {
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   // la boucle
   instr_pere.addVariable(new Variable("i1", "ENTIER"));
   Divers.ecrire(buf, "for(i1=0; i1<" + prog.getDim(1, arg) + "; i1++) {", indent);
   Argument arg1 = new Argument(arg.nom + "[i1]", arg.getTypeOfTab(), arg.mode);
   lireFormu(prog, buf, indent + 1, arg1);
   Divers.ecrire(buf, "}", indent);
 }
Пример #5
0
 private void lireMatFormu(
     Programme prog, StringBuffer buf, int indent, Argument arg, String indice1, String indice2) {
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   // les boucles
   instr_pere.addVariable(new Variable(indice1, "ENTIER"));
   instr_pere.addVariable(new Variable(indice2, "ENTIER"));
   Divers.ecrire(
       buf,
       "for(int "
           + indice1
           + "=0; "
           + indice1
           + "<"
           + prog.getDim(1, arg)
           + "; "
           + indice1
           + "++) {",
       indent);
   Divers.ecrire(
       buf,
       "for(int "
           + indice2
           + "=0; "
           + indice2
           + "<"
           + prog.getDim(2, arg)
           + "; "
           + indice2
           + "++) {",
       indent + 1);
   Argument arg1 =
       new Argument(arg.nom + "[" + indice1 + "][" + indice2 + "]", arg.getTypeOfMat(), arg.mode);
   lireFormu(prog, buf, indent + 2, arg1);
   Divers.ecrire(buf, "}", indent + 1);
   Divers.ecrire(buf, "}", indent);
 }
Пример #6
0
 public void ecrire(Programme prog, StringBuffer buf, int indent) {
   Divers.ecrire(buf, "function " + nom + "()" + " {", indent);
   if ((proprietes.size() > 0)) prog.commenter(buf, "proprietes", indent + 1);
   for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Variable> iter =
           proprietes.iterator();
       iter.hasNext(); ) {
     Variable prop = (Variable) iter.next();
     prop.ecrirePropriete(prog, buf, indent + 1);
   }
   if ((operations.size() > 0)) prog.commenter(buf, "methodes", indent + 1);
   for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Operation> iter =
           operations.iterator();
       iter.hasNext(); ) {
     Operation oper = (Operation) iter.next();
     Divers.ecrire(buf, "this." + oper.nom + "=" + oper.nom + ";", indent + 1);
   }
   Divers.ecrire(buf, "}", indent);
   for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Operation> iter =
           operations.iterator();
       iter.hasNext(); ) {
     Operation oper = (Operation) iter.next();
     oper.ecrire(prog, buf, indent);
   }
 }
Пример #7
0
 private void constrClasseFormu(
     Programme prog, StringBuffer buf, int indent, String msg, String p_pere, Argument arg) {
   this.constrLabelFormu(prog, buf, indent, msg, p_pere, arg);
   Classe cl = (Classe) arg.getClasse(prog);
   String p_zone = "p_" + arg.nom;
   p_zone = Divers.remplacer(p_zone, ".", "_");
   int nb_prop = cl.proprietes.size() - cl.compterMode("OUT");
   Divers.ecrire(buf, p_zone + "=new JPanel(new GridLayout(" + (2 * nb_prop) + "," + 1 + ")); ");
   Divers.ecrire(buf, p_pere + ".add(" + p_zone + ");");
   for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Variable> iter =
           cl.proprietes.iterator();
       iter.hasNext(); ) {
     Variable prop = (Variable) iter.next();
     if (prop.isOut()) continue;
     String msg1 = prog.quote(prop.nom);
     Argument arg1 = new Argument(arg.nom + "." + prop.nom, prop.type, arg.mode);
     constrFormu(prog, buf, indent, msg1, p_zone, arg1);
   }
 }
Пример #8
0
 private void constrTabClasseFormu(
     Programme prog, StringBuffer buf, int indent, String msg, String p_pere, Argument arg) {
   this.constrLabelFormu(prog, buf, indent, msg, p_pere, arg);
   Classe cl = (Classe) arg.getClasseOfTab(prog);
   Divers.indenter(buf, indent);
   String p_zone = "p_" + arg.nom;
   p_zone = Divers.remplacer(p_zone, ".", "_");
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   int nb_prop = cl.proprietes.size() - cl.compterMode("OUT");
   Divers.ecrire(buf, p_zone + "=new JPanel(new GridLayout(" + 2 + "," + nb_prop + ")); ");
   Divers.ecrire(buf, p_pere + ".add(" + p_zone + ");");
   for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Variable> iter =
           cl.proprietes.iterator();
       iter.hasNext(); ) {
     Variable prop = (Variable) iter.next();
     if (prop.isOut()) continue;
     String msg1 = prog.quote(prop.nom);
     String label1 = "new JLabel(" + msg1 + ")";
     Divers.indenter(buf, indent);
     Divers.ecrire(buf, p_zone + ".add(" + label1 + ");");
   }
   for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Variable> iter =
           cl.proprietes.iterator();
       iter.hasNext(); ) {
     Variable prop = (Variable) iter.next();
     if (prop.isOut()) continue;
     instr_pere.addVariable(new Variable("ii", "ENTIER"));
     if (prop.isSimple()) {
       Argument arg1 = new Argument(arg.nom + "." + prop.nom, "TAB_" + prop.type, arg.mode);
       String msg1 = null;
       constrTabFormu(prog, buf, indent, msg1, p_zone, arg1, "ii");
     }
     if (prop.isTabSimple()) {
       Argument arg1 =
           new Argument(arg.nom + "." + prop.nom, "MAT_" + prop.getTypeOfTab(), arg.mode);
       String msg1 = null;
       constrMatFormu(prog, buf, indent, msg1, p_zone, arg1);
     }
   }
 }
Пример #9
0
 private void lireTexteFormu(Programme prog, StringBuffer buf, int indent, Argument arg) {
   String zone = "zone_" + arg.nom;
   zone = Divers.remplacer(zone, ".", "_");
   Divers.indenter(buf, indent);
   Divers.ecrire(buf, arg.nom + " = ");
   if (arg.avecTexteRadio()) {
     Divers.ecrire(buf, "null; ");
     String[] liste = arg.getTexteRadio();
     int n = liste.length;
     for (int i = 0; i < n; i++) {
       String zone_bouton = "zone_" + liste[i] + "_" + arg.nom;
       zone_bouton = Divers.remplacer(zone_bouton, ".", "_");
       Divers.indenter(buf, indent);
       Divers.ecrire(buf, "if (" + zone_bouton + ".isSelected()) ");
       Divers.ecrire(buf, arg.nom + "=" + prog.quote(liste[i]) + "; ");
     }
   } else if (arg.avecTexteListe()) {
     Divers.ecrire(buf, "(String) " + zone + ".getSelectedValue(); ");
   } else {
     Divers.ecrire(buf, zone + ".getText(); ");
   }
 }