示例#1
0
 public GenControllerContext(
     @NotNull SRepository repository,
     @NotNull GenerationOptions options,
     @NotNull TransientModelsProvider transientModelsProvider,
     @NotNull ModelStreamManager.Provider streamProvider) {
   myRepository = repository;
   myOptions = options;
   myTransientModelProvider = transientModelsProvider;
   myStreamProvider = streamProvider;
   myExportsVault = new ExportsVault(streamProvider);
   //    myCrossModelEnvironment = new CrossModelEnvironment(transientModelsProvider);
   myCrossModelEnvironment = transientModelsProvider.getCrossModelEnvironment();
 }
示例#2
0
  /**
   * @return <code>true</code> to indicate generation success (what does constitute a success is,
   *     alas, undefined)
   */
  private boolean process0(
      @NotNull final ProgressMonitor monitor, @NotNull final List<? extends GeneratorTask> tasks) {
    final boolean[] result = new boolean[1];
    myTransientModelsProvider.startGeneration(myGenerationOptions.getNumberOfModelsToKeep());

    final GeneratorLoggerAdapter logger =
        new GeneratorLoggerAdapter(
            myMessageHandler,
            myGenerationOptions.isShowInfo(),
            myGenerationOptions.isShowWarnings());

    myRepository
        .getModelAccess()
        .runWriteAction(
            new Runnable() {
              @Override
              public void run() {
                for (GeneratorTask t : tasks) {
                  SModel d = t.getModel();
                  if (d instanceof EditableSModel && ((EditableSModel) d).needsReloading()) {
                    ((EditableSModel) d).reloadFromSource();
                    logger.info("Model " + d + " reloaded from disk.");
                  }
                  myTransientModelsProvider.createModule(d.getModule());
                }
              }
            });
    myTransientModelsProvider
        .initCheckpointModule(); // at the moment, starts write action, thus shall start outside of
                                 // read

    GenControllerContext ctx =
        new GenControllerContext(
            myRepository, myGenerationOptions, myTransientModelsProvider, myStreamProvider);
    GeneratorTaskListener<GeneratorTask> taskListener;
    if (myTaskListener != null) {
      taskListener = myTaskListener;
    } else {
      taskListener = new EmptyTaskListener();
    }

    final GenerationController gc = new GenerationController(tasks, ctx, taskListener, logger);
    myRepository
        .getModelAccess()
        .runReadAction(
            new Runnable() {
              @Override
              public void run() {
                result[0] =
                    UndoHelper.getInstance()
                        .runNonUndoableAction(
                            new Computable<Boolean>() {
                              @Override
                              public Boolean compute() {
                                return gc.generate(monitor);
                              }
                            });
              }
            });

    // XXX removeAllTransients done from make facet, perhaps publish shall be part of external code
    // as well?
    myTransientModelsProvider.publishAll();
    CleanupManager.getInstance().cleanup();
    return result[0];
  }