Exemplo n.º 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);
   }
 }
Exemplo n.º 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;
              }
            });
  }
Exemplo n.º 3
0
 @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);
   }
 }
Exemplo n.º 4
0
  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();
    }
  }