Package org.dmd.util.codegen

Examples of org.dmd.util.codegen.ImportManager


        out.close();
       
  }
 
  static public void formatImplementation(String outdir, WebApplication app, RunContextItemCollection rcic) throws IOException{
        ImportManager manager = new ImportManager();
        String       typefmt   = "%-" + rcic.getLongestTypeName() + "s";
        PrintfFormat  typeformat   = new PrintfFormat(typefmt);
        String       itemfmt   = "%-" + rcic.getLongestItemName() + "s";
        PrintfFormat  itemformat   = new PrintfFormat(itemfmt);
   
        String rcName = app.getAppName() + "RunContext";
        BufferedWriter   out = FileUpdateManager.instance().getWriter(outdir, rcName + ".java");

        out.write("package " + app.getDefinedInModule().getGenPackage() + ".generated.mvw;\n\n");

        for (RunContextItem rci :rcic.byOrder.values()){
          rci.addRunContextImplImports(manager);
        }
        out.write(manager.getFormattedImports() + "\n");
       
        out.write("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("public class " + rcName + " implements " + rcName + "IF {\n\n");
       
//        out.write("public class " + rcName + " implements " + rcic.getAllInterfaces() + " {\n\n");
View Full Code Here


    String genPackage = manager.getApplication().getDefinedInModule().getGenPackage();
   
    String name = GenUtility.capTheName(manager.getApplication().getAppName().getNameString()) + "MenuBuilder";
        BufferedWriter   out = FileUpdateManager.instance().getWriter(outdir, name + ".java");
       
        ImportManager  imports = new ImportManager();
        imports.addImport("org.dmd.mvw.client.mvw.generated.mvw.MvwRunContextIF", "Base run context");
        imports.addImport("org.dmd.mvw.client.mvwmenus.generated.mvw.MvwmenusRunContextIF", "Mvwmenus run context");
        imports.addImport("org.dmd.mvw.client.mvwmenus.base.MvwMenuFactory", "Base menu factory");
        imports.addImport("org.dmd.mvw.client.mvwmenus.extended.controllers.MenuController", "Menu controller to be populated");
       
        if (manager.getMenuBars().size() > 0)
          imports.addImport("org.dmd.mvw.client.mvwmenus.base.MvwMenu", "Menus are defined");
       
        HashMap<String,RunContextItem>    rcis = new HashMap<String, RunContextItem>();
       
        if (manager.getSubMenus().size() > 0){
          // Check to see if we need any message constants
          for(SubMenu submenu: manager.getSubMenus().values()){
            if (submenu.getRCI() != null){
              submenu.getRCI().addUsageImplImports(imports);
              rcis.put(submenu.getRCI().getObjectName().getNameString(), submenu.getRCI());
            }
          }
        }
       
        if (manager.getMenuItems().size() > 0){
          imports.addImport("org.dmd.mvw.client.mvwmenus.base.MvwMenuItem", "Menu items are defined");
         
          // Check to see if we need any message constants
          for(MenuItem mi: manager.getMenuItems().values()){
            if (mi.getRCI() != null){
              mi.getRCI().addUsageImplImports(imports);
              rcis.put(mi.getRCI().getObjectName().getNameString(), mi.getRCI());
            }
          }
        }
       
        if (manager.getSeparators().size() > 0)
          imports.addImport("org.dmd.mvw.client.mvwmenus.base.MvwSeparators", "Separators are defined");

       
        RunContextItem  menuFactoryRCI = null;
       
        MenuImplementationConfig config = manager.getMenuImplementation();
        Iterator<RunContextItem> items = config.getDefinedInModule().getItems();
        while(items.hasNext()){
          RunContextItem rci = items.next();
          if (rci.getItemName().getNameString().equals("menuFactory")){
            menuFactoryRCI = rci;
            break;
          }
        }
       
        menuFactoryRCI.addUsageImplImports(imports);
       
        out.write("package " + genPackage + ".generated.mvw;\n\n");
       
        out.write(imports.getFormattedImports());
       
        out.write("\n");
       
        out.write("public class " + name + " {\n\n");
       
View Full Code Here

  static public void formatFormBinding(String outdir, FormBindingDefinition binding) throws IOException {
    String genPackage = binding.getDefinedInModule().getGenPackage();
   
    String       name   = GenUtility.capTheName(binding.getBindingName().getNameString());
        BufferedWriter   out   = FileUpdateManager.instance().getWriter(outdir, name + ".java");
        ImportManager  imports = new ImportManager();

        imports.addImport("org.dmd.dmc.DmcNamedObjectIF", "Used when testing if an object named");
        imports.addImport("org.dmd.dmc.DmcValueException", "Required if we have modification errors");
        imports.addImport("org.dmd.dmc.DmcValueExceptionSet", "Required if we have modification errors");
        imports.addImport("org.dmd.dms.generated.dmo.MetaDMSAG", "Required when edit object has no name");
        imports.addImport("org.dmd.dms.generated.types.DmcTypeModifierMV", "Required when edit object has no name");
       
//        if (binding.getEditObject().getIsNamedBy() == null){
//            imports.addImport("org.dmd.dmc.DmcValueException", "Required when edit object is unnamed");
//            imports.addImport("org.dmd.dms.generated.dmo.MetaDMSAG", "Required when edit object is unnamed");
//            imports.addImport("org.dmd.dms.generated.types.DmcTypeModifierMV", "Required when edit object is unnamed");
//        }
       
        imports.addImport("org.dmd.dmc.presentation.DmcPresentationTrackerIF", "Presentation tracker");
        for(EditField field: binding.getEditFieldIterable()){
          imports.addImport(field.getAttrDef().getAdapterClassImport(), "Adapter for " + field.getAttribute());
          imports.addImport(field.getEditorDef().getUseClass(), "Editor");
         
          imports.addImport(field.getAttrDef().getDefinedIn().getDMSASGImport(),"Required schema");
        }
       
        ClassDefinition cd = (ClassDefinition) binding.getEditObject();
       
        imports.addImport(cd.getDefinedIn().getSchemaPackage() + ".generated.dmo." + cd.getName() + "DMO", "For the object we're editting");
       
        out.write("package " + genPackage + ".generated.mvw.forms;\n\n");
       
        out.write(imports.getFormattedImports() + "\n");
       
        out.write("// " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("public class " + name + " {\n\n");
       
        out.write("    " + cd.getName() + "DMO dmo;\n\n");
View Full Code Here

        out.write("package " + cd.getDmwPackage(genContext) + ".generated." + genContext + ";\n\n");
       
    allAttr = new ArrayList<AttributeDefinition>();
//    StringBuffer imports = new StringBuffer();
   
    ImportManager imports = new ImportManager();
   
    getAttributesAndImports(cd, allAttr, imports);
   
    // The access functions may add additional required imports
    String accessFunctions = getAccessFunctions(cd, imports);
       
        out.write(imports.getFormattedImports() + "\n\n");
       
        String impl = "";
       
        if (cd.getIsNamedBy() != null){
          if (cd.getIsNamedBy().getType().getIsHierarchicName())
View Full Code Here

        anyMVRefs    = false;
       
//    StringBuffer imports = new StringBuffer();
    allAttr = new ArrayList<AttributeDefinition>();
   
    ImportManager imports = new ImportManager();
   
    getAttributesAndImports(cd,allAttr,imports);
   
    imports.addImport("org.dmd.dms.generated.enums.ValueTypeEnum", "For AUX base functionality");
    imports.addImport("org.dmd.dms.generated.enums.DataTypeEnum", "For AUX base functionality");
   
        out.write(imports.getFormattedImports() + "\n\n");
       
        out.write(getAuxClassHeader(cd, DebugInfo.getWhereWeAreNow()));
       
        out.write(" {\n\n");
       
View Full Code Here

  }
 
  void dumpHeaderDMSAG(BufferedWriter out, SchemaManager sm, String schemaPackage, SchemaDefinition sd, StringBuffer nameBuilders, StringBuffer filterBuilders) throws IOException, ResultException {
        out.write("package " + schemaPackage + ".generated.dmo;\n\n");

      ImportManager manager = new ImportManager();

      manager.addImport("java.util.HashMap","For storage of schema info");
      manager.addImport("java.util.ArrayList","For storage of schema info");
      manager.addImport("java.util.Iterator","For access of schema info");
      manager.addImport("org.dmd.dmc.*","Basic DMC stuff");
      manager.addImport("org.dmd.dmc.rules.RuleIF","For rule info");
       
        DmcAttribute<?> cdef = sd.getDMO().get(MetaDMSAG.__classDefList);
        if (cdef != null){
          manager.addImport("org.dmd.dms.generated.enums.ClassTypeEnum", "Have class definitions");
          manager.addImport("org.dmd.dms.generated.enums.DataTypeEnum", "Have class/attribute definitions");
//          out.write("import org.dmd.dms.generated.enums.ClassTypeEnum;\n");
        }
       
        if ( (sd.getTypeDefListSize() > 0) || (sd.getInternalTypeDefListSize() > 0)){
          manager.addImport("org.dmd.dms.generated.enums.OriginalTypeEnum", "Have type/internal type definitions");
        }
                
      for(ClassDefinition cd: sd.getClassDefList()){
        for(AttributeDefinition ad: cd.getMust()){
          if (ad.getDefinedIn() != sd)
            manager.addImport(ad.getDefinedIn().getDMSASGImport(), "Required attribute from " + ad.getDefinedIn().getDMSASGName());
        }
        for(AttributeDefinition ad: cd.getMay()){
          if (ad.getDefinedIn() != sd)
            manager.addImport(ad.getDefinedIn().getDMSASGImport(), "Optional attribute from " + ad.getDefinedIn().getDMSASGName());
        }
        if (cd.getDerivedFrom() != null){
          if (cd.getDerivedFrom().getDefinedIn() != sd)
               manager.addImport(cd.getDerivedFrom().getDefinedIn().getDMSASGImport(), "Base class from " + cd.getDerivedFrom().getDefinedIn().getDMSASGName());           
        }
      }
     
        DmcAttribute<?> adef = sd.getDMO().get(MetaDMSAG.__attributeDefList);
        if (adef != null){
          manager.addImport("org.dmd.dms.generated.enums.DataTypeEnum", "Have class/attribute definitions");
          manager.addImport("org.dmd.dms.generated.enums.ValueTypeEnum", "Have attribute definitions");
//          out.write("import org.dmd.dms.generated.enums.ValueTypeEnum;\n");
//          out.write("import org.dmd.dms.generated.enums.DataTypeEnum;\n");
        }

        ///////////////////////////////////////////////////////////////////////
        // Rule definitions
       
    for(RuleDefinition rd: sd.getRuleDefinitionList()){
      manager.addImport(rd.getRuleDefinitionImport(), "To support instantiations of " + rd.getName());
    }

    ///////////////////////////////////////////////////////////////////////
    // Rule instances
    Iterator<DmcUncheckedObject> rules = sd.getParsedRules();
    if (rules != null){
      while(rules.hasNext()){
        DmcUncheckedObject rule = rules.next();
        ClassDefinition ruleDataCD = sm.isClass(rule.getConstructionClass());
       
        if (ruleDataCD == null){
          ResultException ex = new ResultException();
          ex.addError("Unknown rule data class. For Rule instance: \n" + rule.toOIF());
          throw(ex);
        }
        manager.addImport(ruleDataCD.getDmoImport(), "To instantiate " + rule.getConstructionClass() + " rule data");
        manager.addImport(ruleDataCD.getRuleDefinition().getRuleDefinitionImport(), "To instantiate rules of this type");
       
        ruleDataCD.addImportsForAdditionalAttributes(sm,manager, rule);
      }
    }
   
        out.write(manager.getFormattedImports());
      out.write("\n");
       
       
        Iterator<TypeDefinition> tds = sd.getTypeDefList();
    if (tds != null){
View Full Code Here

   * @param containsRefs a flag to indicate if the complex type contains reference types
   * @throws IOException
   */
    static public void dumpExtendedReferenceTypeDmcType(String header, String basePackage, String od, String cn, boolean containsRefs, ExtendedReferenceTypeDefinition ertd) throws IOException {
      BufferedWriter out = FileUpdateManager.instance().getWriter(od, "DmcType" + cn + ".java");
      ImportManager imports = new ImportManager();
     
      imports.addImport("org.dmd.dmc.DmcInputStreamIF", "Serialization support");
      imports.addImport("org.dmd.dmc.DmcOutputStreamIF", "Serialization support");
     
      imports.addImport("org.dmd.dmc.DmcAttributeInfo", "Standard attribute interface");
      imports.addImport("org.dmd.dmc.DmcValueException", "Value exceptions");
      imports.addImport("org.dmd.dmc.types.DmcTypeNamedObjectREF", "The class we extend");
     
      imports.addImport(ertd.getExtendedReferenceClass().getDmoImport(), "The class we refer to");
     
        imports.addImport(ertd.getExtendedReferenceClass().getIsNamedBy().getType().getPrimitiveType(), "Name type");
      imports.addImport("org.dmd.dmc.DmcOutputStreamIF", "Serialization support");

      out.write(header);
      out.write("package " + basePackage + ".generated.types;\n\n");
     
      out.write(imports.getFormattedImports() + "\n\n");
     
     
//      out.write("import java.io.Serializable;\n");
//      out.write("import org.dmd.dmc.DmcInputStreamIF;\n");
//        out.write("import org.dmd.dmc.DmcOutputStreamIF;\n");
View Full Code Here

      initialized      = true;
      types         = new ArrayList<String>();
      members       = new ArrayList<String>();
      registerForEvent   = new StringBuffer();
      abstractMethod    = new StringBuffer();
      imports        = new ImportManager();
     
          if (getImportThisHasValue()){
            for(String imp: getImportThisIterable()){
              imports.addImport(imp, "Required type");
            }
View Full Code Here

 
  public void initCodeGenInfo(){
   
    if (!initialized){
      initialized = true;
      imports = new ImportManager();   
 
      imports.addImport("org.dmd.mvw.client.mvwmenus.base.Action", "Base class");
      imports.addImport("org.dmd.mvw.client.mvwmenus.interfaces.TriggerIF", "Trigger interface");
     
      Component component = getImplementedBy();
View Full Code Here

    return(actionInstantiations.toString());
  }
 
  protected void initCodeGenInfo(boolean rpc, boolean dmp) throws ResultException {
   
    imports         = new ImportManager();   
    loadAttributeSchemas   = new StringBuffer();
    hasCommsMethods      = false;
    methodID         = 0;
    commsMethods      = new StringBuffer();
    abstractMethods      = new StringBuffer();
View Full Code Here

TOP

Related Classes of org.dmd.util.codegen.ImportManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.