@Override
 public void exec() throws TransformationNotApplicable {
   Iterator<Form> itForms = p.getDynamicModel().getForms().iterator();
   while (itForms.hasNext()) {
     Form form = (Form) itForms.next();
     Iterator<GUIElement> itEls = form.getItems().iterator();
     while (itEls.hasNext()) {
       GUIElement element = (GUIElement) itEls.next();
       if (element instanceof Grid) {
         Grid g = (Grid) element;
         g.addOrder(g.getBaseClass().getPrimaryKeyAttribute());
       }
       if (element instanceof ComboBox) {
         ComboBox c = (ComboBox) element;
         c.addOrder(c.getRefClass().getPrimaryKeyAttribute());
         c.addShow((c.getRefClass().getPrimaryKeyAttribute()));
       }
     }
   }
 }
Ejemplo n.º 2
0
  protected void processPackage(Package pack, Menu menu) {
    if (pack.getAllClasses().size() > 0) {
      MenuItem menuPack =
          new MenuItem(
              o.getProperty("app.menu.item.prefix")
                  + "Pack"
                  + pack.getName()
                  + o.getProperty("app.menu.item.suffix"));
      menuPack.setCaption(pack.getName());
      Iterator<Class> c = pack.getAllPersistentClasses().iterator();
      while (c.hasNext()) {
        Class class1 = (Class) c.next();
        // General item for all the forms associated to the class
        MenuItem mi =
            new MenuItem(
                o.getProperty("app.menu.item.prefix")
                    + class1.getName()
                    + o.getProperty("app.menu.item.suffix"));
        mi.setCaption(class1.getName());

        // Specific forms (and menu items) for each individual form
        MenuItem miVis =
            new MenuItem(
                o.getProperty("app.menu.item.prefix")
                    + "Vis"
                    + class1.getName()
                    + o.getProperty("app.menu.item.suffix"));
        Form fVis =
            new Form(
                o.getProperty("app.form.prefix")
                    + "Vis"
                    + class1.getName()
                    + o.getProperty("app.form.suffix"));
        fVis.setCaption(l.getString("app.caption.form.visualization") + class1.getName());
        fVis.setActionKind(FormActionKind.FA_VISUALIZE);
        fVis.setBaseClass(class1);
        d.addForm(fVis);
        mi.addItem(miVis);
        miVis.setDestination(fVis);
        miVis.setCaption(l.getString("app.caption.menu.item.visualize"));
        if (!class1
            .isReadOnly()) // For non-read only classes we create a form for inserting data and
                           // another for updating it
        {
          Form fIns =
              new Form(
                  o.getProperty("app.form.prefix")
                      + "Ins"
                      + class1.getName()
                      + o.getProperty("app.form.suffix"));
          fIns.setCaption(l.getString("app.caption.form.insert") + class1.getName());
          fIns.setActionKind(FormActionKind.FA_INSERT);
          fIns.setBaseClass(class1);
          d.addForm(fIns);
          fVis.addRelatedForm(fIns);
          if (o.getProperty("app.menu.item.insert")
              .equals("true")) // We create a separate menu entry for the insert form
          {
            MenuItem miIns =
                new MenuItem(
                    o.getProperty("app.menu.item.prefix")
                        + "Ins"
                        + class1.getName()
                        + o.getProperty("app.menu.item.suffix"));
            mi.addItem(miIns);
            miIns.setDestination(fIns);
            miIns.setCaption(l.getString("app.caption.menu.item.insert"));
          }

          Form fUpd =
              new Form(
                  o.getProperty("app.form.prefix")
                      + "Upd"
                      + class1.getName()
                      + o.getProperty("app.form.suffix"));
          fUpd.setCaption(l.getString("app.caption.form.update") + class1.getName());
          fUpd.setActionKind(FormActionKind.FA_UPDATE);
          fUpd.setBaseClass(class1);
          d.addForm(fUpd);
          fVis.addRelatedForm(fUpd);
        } else // if it is read only we just create a form to visualize the details of the row
        {
          Form fDet =
              new Form(
                  o.getProperty("app.form.prefix")
                      + "Det"
                      + class1.getName()
                      + o.getProperty("app.form.suffix"));
          fDet.setCaption(l.getString("app.caption.form.visdetails") + class1.getName());
          fDet.setActionKind(FormActionKind.FA_VISDETAILS);
          fDet.setBaseClass(class1);
          d.addForm(fDet);
          fVis.addRelatedForm(fDet);
        }
        if (o.getProperty("app.menu.groupby.package").equals("true")
            && !s.getPackages().get(0).getName().equals(o.getProperty("db.package.default.name"))) {
          menuPack.addItem(mi);
        } // We create submenu for each package
        else {
          menu.addItem(mi);
        }
      }
      if (o.getProperty("app.menu.groupby.package").equals("true")
          && !s.getPackages().get(0).getName().equals(o.getProperty("db.package.default.name"))) {
        menu.addItem(menuPack);
      }
    }
    if (pack.getFirstLevelPackages().size() > 0) {
      Iterator<Package> p = pack.getFirstLevelPackages().iterator();
      while (p.hasNext()) {
        Package package1 = (Package) p.next();
        processPackage(package1, menu);
      }
    }
  }