Beispiel #1
0
 protected void createConsoleModel() {
   this.myModel =
       TemporaryModels.getInstance()
           .create(false, TempModuleOptions.forDefaultModuleWithSourceAndClassesGen());
   if (myModel == null) {
     if (LOG.isEnabledFor(Level.ERROR)) {
       LOG.error("Error: could not create console model");
     }
     return;
   }
 }
Beispiel #2
0
 protected void validateImports() {
   SModelInternal modelInternal = (SModelInternal) myModel;
   for (SModuleReference devKit :
       ListSequence.fromListWithValues(
           new ArrayList<SModuleReference>(), modelInternal.importedDevkits())) {
     modelInternal.deleteDevKit(devKit);
   }
   for (SLanguage language :
       ListSequence.fromListWithValues(
           new ArrayList<SLanguage>(), modelInternal.importedLanguageIds())) {
     modelInternal.deleteLanguageId(language);
   }
   for (jetbrains.mps.smodel.SModel.ImportElement model :
       ListSequence.fromListWithValues(
           new ArrayList<jetbrains.mps.smodel.SModel.ImportElement>(),
           modelInternal.importedModels())) {
     modelInternal.deleteModelImport(model.getModelReference());
   }
   addBuiltInImports();
   TemporaryModels.getInstance().addMissingImports(myModel);
 }
 @Override
 public void init() {
   this.myTransientModel =
       TemporaryModels.getInstance().create(false, TempModuleOptions.forDefaultModule());
   new CloneUtil(this.myModel, this.myTransientModel).cloneModelWithAllImports();
 }
 @Override
 public void dispose() {
   TemporaryModels.getInstance().dispose(myTransientModel);
   myTransientModel = null;
 }
Beispiel #5
0
    @Override
    public void navigate(boolean requestFocus) {
      final SModuleReference[] module = {null};
      final boolean[] dependency = {true};

      ModelAccess.instance()
          .runReadAction(
              new Runnable() {
                @Override
                public void run() {
                  SModelReference mrefToImport = getModelReference();
                  SModel modelToImport =
                      SModelRepository.getInstance().getModelDescriptor(mrefToImport);
                  SModule moduleToImport = modelToImport.getModule();

                  if (moduleToImport instanceof Language
                      && myModule instanceof Solution
                      && ((Language) moduleToImport).isAccessoryModel(mrefToImport)) {
                    dependency[0] = false;
                  }

                  if (!VisibilityUtil.isVisible(myModule, myModel)) {
                    module[0] = moduleToImport.getModuleReference();
                  }
                }
              });

      if (module[0] != null) {
        int res;
        if (TemporaryModels.isTemporary(myModel)) {
          res = JOptionPane.YES_OPTION;
        } else {
          res =
              JOptionPane.showConfirmDialog(
                  getFrame(),
                  "<html>Model <b>"
                      + getModelReference().getModelName()
                      + "</b> is owned by module <b>"
                      + module[0].getModuleName()
                      + "</b> which is not imported.</html>\n\n"
                      + "Importing the module will take some time.\n"
                      + "Do you want to automatically import the module?",
                  "Module import",
                  JOptionPane.YES_NO_OPTION);
        }
        if (res == JOptionPane.YES_OPTION) {
          ModelAccess.instance()
              .runWriteActionInCommand(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (dependency[0]) {
                        ((AbstractModule) myModule).addDependency(module[0], false);
                        ((jetbrains.mps.smodel.SModelInternal) myModel)
                            .addModelImport(getModelReference(), false);
                      } else {
                        ((AbstractModule) myModule).addUsedLanguage(module[0]);
                        ((jetbrains.mps.smodel.SModelInternal) myModel).addLanguage(module[0]);
                      }
                      ClassLoaderManager.getInstance()
                          .unloadClasses(Arrays.asList(myModule), new EmptyProgressMonitor());
                      ClassLoaderManager.getInstance()
                          .loadAllPossibleClasses(new EmptyProgressMonitor());
                    }
                  });
        }
      } else {
        ModelAccess.instance()
            .runWriteActionInCommand(
                new Runnable() {
                  @Override
                  public void run() {
                    ((jetbrains.mps.smodel.SModelInternal) myModel)
                        .addModelImport(getModelReference(), false);
                  }
                });
      }
    }