示例#1
0
 protected void readModules(FileMPSProject.ProjectDescriptor projDesc) {
   myErrors = null;
   //  load solutions
   Set<ModuleReference> existingModules = getModuleReferences();
   for (Path modulePath : projDesc.getModules()) {
     String path = modulePath.getPath();
     IFile descriptorFile = FileSystem.getInstance().getFileByPath(path);
     if (descriptorFile.exists()) {
       ModuleDescriptor descriptor =
           ModulesMiner.getInstance().loadModuleDescriptor(descriptorFile);
       if (descriptor != null) {
         ModulesMiner.ModuleHandle moduleHandle =
             new ModulesMiner.ModuleHandle(descriptorFile, descriptor);
         IModule m = ModuleRepositoryFacade.createModule(moduleHandle, this);
         ModuleReference moduleReference = m.getModuleReference();
         if (!(existingModules.remove(moduleReference))) {
           super.addModule(moduleReference);
         }
       } else {
         error("Can't load module from " + descriptorFile.getPath() + " Unknown file type.");
       }
     } else {
       error("Can't load module from " + descriptorFile.getPath() + " File doesn't exist.");
     }
   }
   for (ModuleReference ref : existingModules) {
     super.removeModule(ref);
   }
 }
示例#2
0
  private Iterable<SModule> loadModule(String modulePath) {
    final List<ModulesMiner.ModuleHandle> collectModules =
        ModulesMiner.getInstance()
            .collectModules(FileSystem.getInstance().getFileByPath(modulePath), false);

    if (collectModules.isEmpty()) {
      return ListSequence.fromList(new ArrayList<SModule>());
    }

    return ModelAccess.instance()
        .runWriteAction(
            new Computable<List<SModule>>() {
              public List<SModule> compute() {
                List<SModule> modules = new ArrayList<SModule>();
                BaseMPSModuleOwner owner = new BaseMPSModuleOwner() {};
                for (ModulesMiner.ModuleHandle moduleHandle : collectModules) {
                  SModule module = ModuleRepositoryFacade.createModule(moduleHandle, owner);
                  if (module != null) {
                    modules.add(module);
                  }
                }
                CleanupManager.getInstance().cleanup();
                ClassLoaderManager.getInstance().reloadAll(new EmptyProgressMonitor());
                return modules;
              }
            });
  }
示例#3
0
文件: SLibrary.java 项目: brigand/MPS
 @Override
 public void update(ProgressMonitor monitor, FileSystemEvent event) {
   boolean changed = false;
   for (IFile f : event.getChanged()) {
     if (ModulesMiner.getInstance().isModuleFile(f)) {
       changed = true;
     }
   }
   for (IFile f : event.getCreated()) {
     if (ModulesMiner.getInstance().isModuleFile(f)) {
       changed = true;
     }
   }
   if (changed) {
     update(false);
   }
 }
示例#4
0
文件: SLibrary.java 项目: brigand/MPS
  void update(boolean refreshFiles) {
    ModelAccess.assertLegalWrite();

    List<ModuleHandle> moduleHandles =
        Collections.unmodifiableList(ModulesMiner.getInstance().collectModules(file, refreshFiles));
    myHandles.set(moduleHandles);
    List<SModule> loaded = new ArrayList<SModule>();
    for (ModuleHandle moduleHandle : moduleHandles) {
      SModule module = ModuleRepositoryFacade.createModule(moduleHandle, this);
      if (module != null) {
        loaded.add(module);
      }
    }
    for (SModule module : loaded) {
      ((AbstractModule) module).onModuleLoad();
    }
  }