Package org.dmd.mvw.tools.mvwgenerator.extended

Examples of org.dmd.mvw.tools.mvwgenerator.extended.RunContextItem


  public TreeMap<String,RunContextItem> getItemsByName(){
    return(byName);
  }
 
  public void addItem(RunContextItem rci) throws ResultException{
    RunContextItem existing = byName.get(rci.getItemName().getNameString());
    if (existing != null){
      ResultException ex = new ResultException();
      ex.addError("Clashing run context item name: " + rci.getItemName());
      ex.result.lastResult().moreMessages("Originally defined in module: " + existing.getDefinedInModule().getModuleName());
      ex.result.lastResult().moreMessages("Redefined in module: " + rci.getDefinedInModule().getModuleName());
      throw(ex);
    }
    byName.put(rci.getItemName().getNameString(), rci);
    byOrder.put(rci.getSortKey(), rci);
View Full Code Here


       
        ImportManager manager = new ImportManager();
       
        it = module.getItems();
        while(it.hasNext()){
          RunContextItem rci = it.next();
          rci.addInterfaceImports(manager);
        }
        out.write(manager.getFormattedImports());
       
        out.write("\n\n");
        out.write("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("public interface " + interfaceName + "RunContextIF {\n\n");
       
        it = module.getItems();
        while(it.hasNext()){
          RunContextItem rci = it.next();
          out.write(rci.getInterfaceMethod(typeformat));
        }
       
        out.write("}\n\n");
       
        out.close();
View Full Code Here

       
        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");
       
        out.write("    final MenuController MenuControllerRCI;\n");
        out.write(menuFactoryRCI.getImplVariable() + "\n\n");

        for(RunContextItem rci: rcis.values()){
          out.write(rci.getImplVariable() + "\n");
        }
             
      ///////////////////////////////////////////////////////////////////////
      // Constructor
     
        out.write("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
      out.write("    public " + name + "(MvwRunContextIF rc){\n\n");
     
        out.write("        MenuControllerRCI = ((MvwmenusRunContextIF)rc).getMenuControllerRCI();\n\n");
        out.write(menuFactoryRCI.getImplVariableAssignment() + "\n");
        for(RunContextItem rci: rcis.values()){
          out.write(rci.getImplVariableAssignment() + "\n");
        }
       
        if (manager.getMenuBars().size() > 0)
          out.write("        MvwMenu      menu      = null;\n");
       
View Full Code Here

        }
        else{
          // We have the mvwmenus module, so indicate that the component uses the menu controller
          key.setNameString("MenuControllerRCI");
          RunContextItemCollection rcic = contexts.get("Default");
          RunContextItem rci = rcic.getItem("MenuControllerRCI");
          controller.addUsesRunContextItem(rci);
        }
      }
    }
   
    // And ensure that all actions are implemented
    for(ActionBinding action: actions.values()){
      if (action.getImplementedBy() == null){
        if (errors == null)
          errors = new ResultException();
       
        errors.addError("The " + action.getActionBindingName() + " action is not implemented by any Controller, Presenter or Activity.");
      }
    }
   
    if (application != null){
      if (centralAsyncErrorHandler != null){
        DebugInfo.debug("CHANGING THE PLACEHOLDER");
                  // We will fill in the details of the predefined place holder context item - defined in the mvw module
        RunContextItemCollection rcic = contexts.get(centralAsyncErrorHandlerRCI.getContextImpl());
        RunContextItem rci = rcic.getItem("centralAsyncErrorHandler");
         
        // The construction is just the assignment of the controller to this item
        rci.setConstruction(centralAsyncErrorHandlerRCI.getItemName());

        int order = centralAsyncErrorHandlerRCI.getItemOrder() + 1;
        rci.setItemOrder(order);
      }
               
      // We're generating the application, so some additional checking is required
      if (menuBars.size() > 0){
        // We have menu related functionality, so the application must specify a
        // menu implementation
        if (application.getMenuImplementation() == null){
          if (errors == null)
            errors = new ResultException();
         
          errors.addError("The " + application.getAppName() + " uses menu functionality and you must set the menuImplementation.");
        }
       
        try{
          menuImplementation.validateImplementations(menuElements);
        }
        catch(ResultException ex){
          if (errors == null)
            errors = ex;
          else
            errors.result.addResults(ex.result);
        }
       
        // We create a run context item for the menu builder that we'll generate.
        // It will be instantiated after all other components are initialized.
        // All Presenters are available for access from the run context. They are created on demand.
        RunContextItem rci = new RunContextItem();
        rci.setAutoCreated(true);
        RunContextItemCollection rcic = contexts.get(rci.getContextImpl());
       
        rci.setItemName("menuBuilder");
        rci.setItemOrder(200);
        rci.setUseClass(application.getDefinedInModule().getGenPackage() + ".generated.mvw." + application.getAppName() + "MenuBuilder");
        rci.setConstruction("new " + application.getAppName() + "MenuBuilder" + "(this)");
        rci.setDefinedInModule(application.getDefinedInModule());
       
        if (rcic == null){
          rcic = new RunContextItemCollection(rci.getContextImpl());
          contexts.put(rci.getContextImpl(), rcic);
        }
        rcic.addItem(rci);
       
        // Add the item to its module
        rci.getDefinedInModule().addRunContextItem(rci);

       
        // Some additional checking to allow the use of display labels from I18N resources
        for(MenuElementDefinitionDMW def: menuElements.values()){
          try{
View Full Code Here

      WebApplication app = (WebApplication) def;
      if (app.getDefinedInModule() == codeGenModule){
        application = app;
       
        // We create an internal run context item for the generated PlaceHistoryMapper
        RunContextItem rci = new RunContextItem();
        rci.setAutoCreated(true);
        RunContextItemCollection rcic = contexts.get(rci.getContextImpl());
       
        rci.setItemName("historyMapper");
        rci.setDescription("This is the auto generated run context item that provides a handle to the application specific PlaceHistoryMapper for a web application.");
        rci.setItemOrder(7);
        rci.setUseClass(codeGenModule.getGenPackage() + ".generated.mvw.places." + app.getAppName() + "PlaceHistoryMapper");
        rci.setConstruction("GWT.create(" + app.getAppName() + "PlaceHistoryMapper.class)");
        rci.addImportThis("com.google.gwt.core.client.GWT");
        rci.setDefinedInModule(app.getDefinedInModule());
       
        if (rcic == null){
          rcic = new RunContextItemCollection(rci.getContextImpl());
          contexts.put(rci.getContextImpl(), rcic);
        }
        rcic.addItem(rci);
       
        // Add the item to its module
        rci.getDefinedInModule().addRunContextItem(rci);

      }
    }
    else if (def instanceof Controller){
      Controller controller = (Controller) def;
//      controller.getDMO().addUsesRunContextItem("eventBus");
      controllers.put(def.getCamelCaseName(), controller);
      components.put(def.getCamelCaseName(), controller);
     
      RunContextItem controllerRCI = null;
      if (controller.isAddedToRunContext()){
        // All Controllers run for the life of the application and so, are added to the run context
        // so that they are created on start up
        controllerRCI = new RunContextItem();
        controllerRCI.setAutoCreated(true);
        RunContextItemCollection rcic = contexts.get(controllerRCI.getContextImpl());
       
        controllerRCI.setItemName(controller.getControllerName().getNameString() + "RCI");
        controllerRCI.setDescription("The auto generated run context item for the " + controller.getControllerName());
       
        if (controller.getSubpackage() == null)
          controllerRCI.setUseClass(currentModule.getGenPackage() + ".extended." + controller.getControllerName());
        else
          controllerRCI.setUseClass(currentModule.getGenPackage() + ".extended." + controller.getSubpackage() + "." + controller.getControllerName());
         
        if (controller.usesRunContext())
          controllerRCI.setConstruction("new " + controller.getControllerName() + "(this)");
        else
          controllerRCI.setConstruction("new " + controller.getControllerName() + "()");
       
        controllerRCI.setDefinedInModule(controller.getDefinedInModule());
       
        if (controller.getItemOrder() != null)
          controllerRCI.setItemOrder(controller.getItemOrder());
       
        if (rcic == null){
          rcic = new RunContextItemCollection(controllerRCI.getContextImpl());
          contexts.put(controllerRCI.getContextImpl(), rcic);
        }
        rcic.addItem(controllerRCI);
       
        // Add the item to its module
        controllerRCI.getDefinedInModule().addRunContextItem(controllerRCI);
       
//DebugInfo.debug("\n" + rci.toOIF());
       
        // Tell the controller its item
        controller.setRunContextItem(controllerRCI);
       
        // Add to all definitions so that references can be resolved
        controllerRCI.setCamelCaseName(controllerRCI.getObjectName());
        checkAndAdd(controllerRCI,allDefs);

      }
     
      if (controller.isCentralRPCErrorHandler()){
        if (centralRpcErrorHandler != null){
          ResultException ex = new ResultException();
          ex.addError("Multiple controllers are specified as the central RPC error handler.");
          ex.result.lastResult().moreMessages(centralRpcErrorHandler.getControllerName() + " in " + centralRpcErrorHandler.getDefinedInModule().getFile() + " at line " + centralRpcErrorHandler.getDefinedInModule().getLineNumber());
          ex.result.lastResult().moreMessages(controller.getControllerName() + " in " + controller.getDefinedInModule().getFile() + " at line " + controller.getDefinedInModule().getLineNumber());
          throw(ex);
        }
        centralRpcErrorHandler = controller;
      }
      if (controller.isCentralDMPErrorHandler()){
        if (centralDmpErrorHandler != null){
          ResultException ex = new ResultException();
          ex.addError("Multiple controllers are specified as the central DMP error handler.");
          ex.result.lastResult().moreMessages(centralDmpErrorHandler.getControllerName() + " in " + centralDmpErrorHandler.getDefinedInModule().getFile() + " at line " + centralDmpErrorHandler.getDefinedInModule().getLineNumber());
          ex.result.lastResult().moreMessages(controller.getControllerName() + " in " + controller.getDefinedInModule().getFile() + " at line " + controller.getDefinedInModule().getLineNumber());
          throw(ex);
        }
        centralDmpErrorHandler = controller;
      }
      if (controller.isCentralAsyncErrorHandler()){
        if (centralAsyncErrorHandler != null){
          ResultException ex = new ResultException();
          ex.addError("Multiple controllers are specified as the central asynchronous code loading error handler.");
          ex.result.lastResult().moreMessages(centralAsyncErrorHandler.getControllerName() + " in " + centralAsyncErrorHandler.getDefinedInModule().getFile() + " at line " + centralDmpErrorHandler.getDefinedInModule().getLineNumber());
          ex.result.lastResult().moreMessages(controller.getControllerName() + " in " + controller.getDefinedInModule().getFile() + " at line " + controller.getDefinedInModule().getLineNumber());
          throw(ex);
        }
        centralAsyncErrorHandler = controller;
        centralAsyncErrorHandlerRCI = controllerRCI;
//       
//        // We will fill in the details of the predefined place holder context item - defined in the mvw module
//        RunContextItemCollection rcic = contexts.get(controllerRCI.getContextImpl());
//        RunContextItem rci = rcic.getItem("centralAsyncErrorHandler");
//
//        // The construction is just the assignment of the controller to this item
//        rci.setConstruction(controllerRCI.getItemName());
//
//        int order = controllerRCI.getItemOrder() + 1;
//        rci.setItemOrder(order);
       
      }
    }
    else if (def instanceof Presenter){
      Presenter presenter = (Presenter) def;
//      presenter.getDMO().addUsesRunContextItem("eventBus");
      presenters.put(def.getCamelCaseName(), presenter);
      components.put(def.getCamelCaseName(), presenter);
     
      // All Presenters are available for access from the run context. They are created on demand.
      RunContextItem rci = new RunContextItem();
      rci.setAutoCreated(true);
      RunContextItemCollection rcic = contexts.get(rci.getContextImpl());
     
      rci.setItemName(presenter.getPresenterName().getNameString() + "RCI");
      rci.setDescription("The auto generated run context item for the " + presenter.getPresenterName());
     
      if (presenter.getSubpackage() == null)
        rci.setUseClass(currentModule.getGenPackage() + ".extended." + presenter.getPresenterName());
      else
        rci.setUseClass(currentModule.getGenPackage() + ".extended." + presenter.getSubpackage() + "." + presenter.getPresenterName());
       
      if (presenter.usesRunContext()){
        if (presenter.isCodeSplit())
          rci.setConstruction("new " + presenter.getPresenterName() + "(thisContext)");
        else
          rci.setConstruction("new " + presenter.getPresenterName() + "(this)");
      }
      else
        rci.setConstruction("new " + presenter.getPresenterName() + "()");
     
      rci.setDefinedInModule(presenter.getDefinedInModule());
     
      rci.setPresenter(presenter);
     
      if (rcic == null){
        rcic = new RunContextItemCollection(rci.getContextImpl());
        contexts.put(rci.getContextImpl(), rcic);
      }
      rcic.addItem(rci);
     
      // Add the item to its module
      rci.getDefinedInModule().addRunContextItem(rci);
     
      // We make it so that the presenter instance is created as required
      rci.setCreateOnDemand(true);
      rci.setSingleton(presenter.isSingleton());
     
      // Tell the presenter its item
      presenter.setRunContextItem(rci);
     
      // Also add to our full set of definitions
      allDefs.put(rci.getItemName(), rci);
     
    }
    else if (def instanceof Activity){
      Activity activity = (Activity) def;
//      if (activity.getHandlesEventHasValue())
//        activity.getDMO().addUsesRunContextItem("eventBus");
//      if (activity.getFiresEventHasValue())
//        activity.getDMO().addUsesRunContextItem("eventBus");
      activities.put(def.getCamelCaseName(), activity);
      components.put(def.getCamelCaseName(), activity);
    }
    else if (def instanceof View){
      View view = (View) def;
      views.put(def.getCamelCaseName(), view);
     
      if (view.requiresEventBus()){
        view.getDMO().addUsesRunContextItem("eventBus");
      }
     
      // All Views are available for access from the run context. They are created on demand.
      RunContextItem rci = new RunContextItem();
      rci.setAutoCreated(true);
      RunContextItemCollection rcic = contexts.get(rci.getContextImpl());
     
      rci.setItemName(view.getViewName().getNameString() + "RCI");
      rci.setDescription("The auto generated run context item for the " + view.getViewName());
     
      if (view.getSubpackage() == null)
        rci.setUseClass(currentModule.getGenPackage() + ".extended." + view.getViewName());
      else
        rci.setUseClass(currentModule.getGenPackage() + ".extended." + view.getSubpackage() + "." + view.getViewName());
       
      if (view.getUsesRunContextItemHasValue()){
        if (view.isCodeSplit())
          rci.setConstruction("new " + view.getViewName() + "(presenter, thisContext)");
        else
          rci.setConstruction("new " + view.getViewName() + "(presenter, this)");
      }
      else
        rci.setConstruction("new " + view.getViewName() + "(presenter)");

//      // BIG NOTE: we don't specify the arguments to the constructor, this will depend on figuring
//      // out if the component needs run context items. We determine this in the RunContextItem.
//      rci.setConstruction("new " + view.getViewName());
     
     
      // NOTE: in addition to setting the construction mechanism, we also set the view
      // on the context item so that it knows how to create the on demand method that takes
      // the View's presenter.
      rci.setView(view);
      rci.setDefinedInModule(view.getDefinedInModule());
     
      if (rcic == null){
        rcic = new RunContextItemCollection(rci.getContextImpl());
        contexts.put(rci.getContextImpl(), rcic);
      }
      rcic.addItem(rci);
     
      // Add the item to its module
      rci.getDefinedInModule().addRunContextItem(rci);
     
      // We make it so that the view instance is created as required
      rci.setCreateOnDemand(true);
//      rci.setTheOne(view.isTheOne());
     
      // Tell the view its item
      view.setRunContextItem(rci);

    }
    else if (def instanceof Event){
      events.put(def.getCamelCaseName(), (Event) def);
    }
    else if (def instanceof Place){
      places.put(def.getCamelCaseName(), (Place) def);
    }
    else if (def instanceof SubPlace){
      subPlaces.put(def.getCamelCaseName(), (SubPlace) def);
    }
    else if (def instanceof EnumMappingGenerator){
      enumGenerators.put(def.getCamelCaseName(), (EnumMappingGenerator) def);
    }
    else if (def instanceof RunContextItem){
      RunContextItem rci = (RunContextItem) def;
      RunContextItemCollection rcic = contexts.get(rci.getContextImpl());
     
      if (rcic == null){
        rcic = new RunContextItemCollection(rci.getContextImpl());
        contexts.put(rci.getContextImpl(), rcic);
      }
      rcic.addItem(rci);
     
      // Add the item to its module
      rci.getDefinedInModule().addRunContextItem(rci);
    }
    else if (def instanceof I18NConfig){
      I18NConfig i18n = (I18NConfig) def;
      RunContextItemCollection rcic = contexts.get(i18n.getContextImpl());
     
      if (rcic == null){
        rcic = new RunContextItemCollection(i18n.getContextImpl());
        contexts.put(i18n.getContextImpl(), rcic);
      }
      rcic.addItem(i18n);
     
      // Add the item to its module
      i18n.getDefinedInModule().addRunContextItem(i18n);
    }
    else if (def instanceof MenuBar){
      MenuBar menu = (MenuBar) def;
      menuBars.put(menu.getCamelCaseName(), menu);
      menuElements.put(menu.getCamelCaseName(), menu);
    }
    else if (def instanceof SubMenu){
      SubMenu menu = (SubMenu) def;
      subMenus.put(menu.getCamelCaseName(), menu);
      menuElements.put(menu.getCamelCaseName(), menu);
    }
    else if (def instanceof MenuItem){
      MenuItem item = (MenuItem) def;
      menuItems.put(item.getCamelCaseName(), item);
      menuElements.put(item.getCamelCaseName(), item);
    }
    else if (def instanceof Separator){
      Separator sep = (Separator) def;
      separators.put(sep.getCamelCaseName(), sep);
      menuElements.put(sep.getCamelCaseName(), sep);
    }
    else if (def instanceof ActionBinding){
      ActionBinding action = (ActionBinding) def;
      actions.put(action.getCamelCaseName(), action);
    }
    else if (def instanceof MenuImplementationConfig){
      if (menuImplementation == null){
        menuImplementation = (MenuImplementationConfig) def;
       
        // The menu factory specified by the menu implementation is added
        // as a run context item.
        RunContextItem rci = new RunContextItem();
        rci.setAutoCreated(true);
        RunContextItemCollection rcic = contexts.get(rci.getContextImpl());
       
        rci.setItemName("menuFactory");
        rci.setDescription("The auto generated run context item for the generic menuFactory; this was created because a MenuImplementationConfig was provided by the " + menuImplementation.getDefinedInModule().getModuleName() + " module");

        rci.setUseClass("org.dmd.mvw.client.mvwmenus.base.MvwMenuFactory");
        rci.setItemOrder(16);
         
        // We use the class specified in the menu implementation config to
        // create the construction call.
        rci.setConstruction("new " + menuImplementation.getUseClass() + "()");
        rci.setDefinedInModule(menuImplementation.getDefinedInModule());
       
        if (rcic == null){
          rcic = new RunContextItemCollection(rci.getContextImpl());
          contexts.put(rci.getContextImpl(), rcic);
        }
        rcic.addItem(rci);
       
        // Add the item to its module
        rci.getDefinedInModule().addRunContextItem(rci);
       
        menuFactoryRCI = rci;
      }
      else{
        MenuImplementationConfig config = (MenuImplementationConfig) def;
View Full Code Here

        super(new RunContextItemDMO(mods), org.dmd.mvw.tools.mvwgenerator.generated.MvwSchemaAG._RunContextItem);
    }

    // Generated from: org.dmd.dmg.generators.BaseDMWGeneratorNewest.dumpWrapper(BaseDMWGeneratorNewest.java:491)
    public RunContextItem getModificationRecorder(){
        RunContextItem rc = new RunContextItem();
        rc.setItemName(getItemName());
        rc.setModifier(new DmcTypeModifierMV(MetaDMSAG.__modify));
        return(rc);
    }
View Full Code Here

    public RunContextItemDMW(RunContextItemDMO obj) {
        super(obj, org.dmd.mvw.tools.mvwgenerator.generated.MvwSchemaAG._RunContextItem);
    }

    public RunContextItem cloneIt() {
        RunContextItem rc = new RunContextItem();
        rc.setDmcObject(getDMO().cloneIt());
        return(rc);
    }
View Full Code Here

        errors.result.lastResult().lineNumber(getLineNumber());     
        throw(errors);
      }
      String rciString = getDisplayLabelI18N().substring(0, period).trim();
     
      RunContextItem rci = context.getItem(rciString);
     
      if (rci == null){
        ResultException errors  = new ResultException();
        errors.addError("The " + getElementName() + " SubMenu refers to an unknown RunContextItem in its displayLabelI18N: " + rciString);
        errors.result.lastResult().fileName(getFile());
View Full Code Here

        errors.result.lastResult().lineNumber(getLineNumber());     
        throw(errors);
      }
      String rciString = getDisplayLabelI18N().substring(0, period).trim();
     
      RunContextItem rci = context.getItem(rciString);
     
      if (rci == null){
        ResultException errors  = new ResultException();
        errors.addError("The " + getElementName() + " MenuItem refers to an unknown RunContextItem in its displayLabelI18N: " + rciString);
        errors.result.lastResult().fileName(getFile());
View Full Code Here

TOP

Related Classes of org.dmd.mvw.tools.mvwgenerator.extended.RunContextItem

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.