• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DisposeAwareProjectChange类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange的典型用法代码示例。如果您正苦于以下问题:Java DisposeAwareProjectChange类的具体用法?Java DisposeAwareProjectChange怎么用?Java DisposeAwareProjectChange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DisposeAwareProjectChange类属于com.intellij.openapi.externalSystem.util包,在下文中一共展示了DisposeAwareProjectChange类的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: renameProject

点赞 3

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
private static void renameProject(@NotNull final String newName,
                                  @NotNull final ProjectSystemId externalSystemId,
                                  @NotNull final Project project)
{
  if (!(project instanceof ProjectEx) || newName.equals(project.getName())) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
    @Override
    public void execute() {
      String oldName = project.getName();
      ((ProjectEx)project).setProjectName(newName);
      ExternalSystemApiUtil.getSettings(project, externalSystemId).getPublisher().onProjectRenamed(oldName, newName);
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:17,
代码来源:ProjectDataServiceImpl.java

示例2: syncJavaLangLevel

点赞 3

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
private void syncJavaLangLevel() {
  Boolean updateJavaLangLevel = myProject.getUserData(UPDATE_JAVA_LANG_LEVEL_AFTER_BUILD);
  if (updateJavaLangLevel == null || !updateJavaLangLevel.booleanValue()) {
    return;
  }

  myProject.putUserData(UPDATE_JAVA_LANG_LEVEL_AFTER_BUILD, null);

  executeProjectChangeAction(true, new DisposeAwareProjectChange(myProject) {
    @Override
    public void execute() {
      if (myProject.isOpen()) {
        //noinspection TestOnlyProblems
        LanguageLevel langLevel = getMaxJavaLangLevel();
        if (langLevel != null) {
          LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(myProject);
          if (langLevel != ext.getLanguageLevel()) {
            ext.setLanguageLevel(langLevel);
          }
        }
      }
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:25,
代码来源:PostProjectBuildTasksExecutor.java

示例3: createAndSetJdk

点赞 3

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@NotNull
public static Sdk createAndSetJdk(@NotNull final Project project) {
  String[] names = {"JAVA6_HOME", "JAVA_HOME"};
  String jdkHomePath = AndroidTestCaseHelper.getSystemPropertyOrEnvironmentVariable(names);
  assertNotNull("Please set one of the following env vars (or system properties) to point to the JDK: " + Joiner.on(",").join(names),
                jdkHomePath);
  final Sdk jdk = SdkConfigurationUtil.createAndAddSDK(jdkHomePath, JavaSdk.getInstance());
  assertNotNull(jdk);

  ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
    @Override
    public void execute() {
      NewProjectUtil.applyJdkToProject(project, jdk);
    }
  });
  return jdk;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:18,
代码来源:AndroidTestCaseHelper.java

示例4: importData

点赞 3

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public void importData(@NotNull final Collection<DataNode<HoldrData>> toImport, @NotNull final Project project, boolean synchronous) {
    if (!toImport.isEmpty()) {
        ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
            @Override
            public void execute() {
                Map<String, HoldrConfig> holdrConfigMap = indexByModuleName(toImport);
                ModuleManager moduleManager = ModuleManager.getInstance(project);

                for (Module module : moduleManager.getModules()) {
                    HoldrConfig holdrConfig = holdrConfigMap.get(module.getName());
                    if (holdrConfig != null) {
                        HoldrModel.create(module, holdrConfig);
                    } else {
                        HoldrModel.delete(module);
                    }
                }
            }
        });
    }
}
 

开发者ID:evant,
项目名称:holdr,
代码行数:22,
代码来源:HoldrDataService.java

示例5: removeData

点赞 3

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public void removeData(@NotNull final Collection<? extends HoldrData> toRemove, @NotNull final Project project, boolean synchronous) {
    if (!toRemove.isEmpty()) {
        ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
            @Override
            public void execute() {
                Map<String, HoldrConfig> holdrConfigMap = indexRemoveByModuleName(toRemove);
                ModuleManager moduleManager = ModuleManager.getInstance(project);

                for (Module module : moduleManager.getModules()) {
                    HoldrModel.delete(module);
                }
            }
        });
    }
}
 

开发者ID:evant,
项目名称:holdr,
代码行数:17,
代码来源:HoldrDataService.java

示例6: onSuccess

点赞 3

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public void onSuccess(@javax.annotation.Nullable final DataNode<ProjectData> externalProject) {
  if (externalProject != null) {
    ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(myProject) {
      @RequiredDispatchThread
      @Override
      public void execute() {
        ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() {
          @Override
          public void run() {
            myProjectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), myProject, true);
          }
        });
      }
    });
  }
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:18,
代码来源:ExternalSystemAutoImporter.java

示例7: removeData

点赞 3

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public void removeData(@Nonnull final Collection<? extends Module> modules, @Nonnull final Project project, boolean synchronous) {
  if (modules.isEmpty()) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
    @RequiredDispatchThread
    @Override
    @RequiredWriteAction
    public void execute() {
      ModuleManager moduleManager = ModuleManager.getInstance(project);

      for (Module module : modules) {
        if (module.isDisposed()) continue;
        moduleManager.disposeModule(module);
      }
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:20,
代码来源:ModuleDataService.java

示例8: setLanguageLevel

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@SuppressWarnings("MethodMayBeStatic")
public void setLanguageLevel(@NotNull final LanguageLevel languageLevel, @NotNull Project project) {
  final LanguageLevelProjectExtension languageLevelExtension = LanguageLevelProjectExtension.getInstance(project);
  if (languageLevelExtension.getLanguageLevel().isAtLeast(languageLevel)) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
    @Override
    public void execute() {
      languageLevelExtension.setLanguageLevel(languageLevel);
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:14,
代码来源:JavaProjectDataService.java

示例9: commit

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
private static void commit(@NotNull final IdeModifiableModelsProvider modelsProvider,
                           @NotNull Project project,
                           boolean synchronous,
                           @NotNull final String commitDesc) {
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
    @Override
    public void execute() {
      final long startTime = System.currentTimeMillis();
      modelsProvider.commit();
      final long timeInMs = System.currentTimeMillis() - startTime;
      LOG.debug(String.format("%s committed in %d ms", commitDesc, timeInMs));
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:15,
代码来源:ProjectDataManager.java

示例10: dispose

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
private static void dispose(@NotNull final IdeModifiableModelsProvider modelsProvider,
                            @NotNull Project project,
                            boolean synchronous) {
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
    @Override
    public void execute() {
      modelsProvider.dispose();
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:11,
代码来源:ProjectDataManager.java

示例11: testPopulateJvmArgsWithGradleExecutionSettings

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
public void testPopulateJvmArgsWithGradleExecutionSettings() {
  executeProjectChangeAction(true, new DisposeAwareProjectChange(myProject) {
    @Override
    public void execute() {
      removeAllKnownJdks();
      String jdkHome = myJdk.getHomePath();
      assertNotNull(jdkHome);
      File jdkHomePath = new File(toSystemDependentName(jdkHome));
      IdeSdks.setJdkPath(jdkHomePath);
    }
  });

  GradleExecutionSettings settings = createMock(GradleExecutionSettings.class);

  expect(settings.getGradleHome()).andReturn("~/gradle-1.6");
  expect(settings.isVerboseProcessing()).andReturn(true);
  expect(settings.getServiceDirectory()).andReturn("~./gradle");
  expect(settings.getDaemonVmOptions()).andReturn("-Xmx2048m -XX:MaxPermSize=512m");

  replay(settings);

  List<String> jvmArgList = Lists.newArrayList();
  myParametersProvider.populateJvmArgs(settings, jvmArgList);
  Map<String, String> jvmArgs = convertJvmArgsToMap(jvmArgList);

  verify(settings);

  String projectDirPath = Projects.getBaseDirPath(myProject).getPath();
  assertEquals(projectDirPath, jvmArgs.get("-Dcom.android.studio.gradle.project.path"));
  assertEquals("~" + File.separatorChar + "gradle-1.6", jvmArgs.get("-Dcom.android.studio.gradle.home.path"));
  assertEquals("true", jvmArgs.get("-Dcom.android.studio.gradle.use.verbose.logging"));
  assertEquals("~." + File.separatorChar + "gradle", jvmArgs.get("-Dcom.android.studio.gradle.service.dir.path"));
  assertEquals("-Xmx2048m", jvmArgs.get("-Dcom.android.studio.gradle.daemon.jvm.option.0"));
  assertEquals("-XX:MaxPermSize=512m", jvmArgs.get("-Dcom.android.studio.gradle.daemon.jvm.option.1"));
  String javaHomeDirPath = myJdk.getHomePath();
  assertNotNull(javaHomeDirPath);
  javaHomeDirPath = toSystemDependentName(javaHomeDirPath);
  assertEquals(javaHomeDirPath, jvmArgs.get("-Dcom.android.studio.gradle.java.home.path"));
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:40,
代码来源:AndroidGradleBuildProcessParametersProviderTest.java

示例12: setupLibraries

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
/**
 * The whole import sequence looks like below:
 * <p>
 * <pre>
 * <ol>
 *   <li>Get project view from the gradle tooling api without resolving dependencies (downloading libraries);</li>
 *   <li>Allow to adjust project settings before importing;</li>
 *   <li>Create IJ project and modules;</li>
 *   <li>Ask gradle tooling api to resolve library dependencies (download the if necessary);</li>
 *   <li>Configure libraries used by the gradle project at intellij;</li>
 *   <li>Configure library dependencies;</li>
 * </ol>
 * </pre>
 * <p>
 *
 * @param projectWithResolvedLibraries gradle project with resolved libraries (libraries have already been downloaded and
 *                                     are available at file system under gradle service directory)
 * @param project                      current intellij project which should be configured by libraries and module library
 *                                     dependencies information available at the given gradle project
 */
private void setupLibraries(@Nonnull final DataNode<ProjectData> projectWithResolvedLibraries, final Project project) {
  ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
        @Override
        public void run() {
          if (ExternalSystemApiUtil.isNewProjectConstruction()) {
            // Clean existing libraries (if any).
            LibraryTable projectLibraryTable = ProjectLibraryTable.getInstance(project);
            if (projectLibraryTable == null) {
              LOG.warn("Can't resolve external dependencies of the target gradle project (" + project + "). Reason: project " + "library table is undefined");
              return;
            }
            LibraryTable.ModifiableModel model = projectLibraryTable.getModifiableModel();
            try {
              for (Library library : model.getLibraries()) {
                model.removeLibrary(library);
              }
            }
            finally {
              model.commit();
            }
          }

          // Register libraries.
          myProjectDataManager.importData(Collections.<DataNode<?>>singletonList(projectWithResolvedLibraries), project, false);
        }
      });
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:54,
代码来源:AbstractExternalModuleImportProvider.java

示例13: importData

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public void importData(@Nonnull final Collection<DataNode<ModuleData>> toImport, @Nonnull final Project project, final boolean synchronous) {
  if (toImport.isEmpty()) {
    return;
  }
  if (!project.isInitialized()) {
    myFuture = AppExecutorUtil.getAppScheduledExecutorService()
            .schedule(new ImportModulesTask(project, toImport, synchronous), PROJECT_INITIALISATION_DELAY_MS, TimeUnit.MILLISECONDS);
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      final Collection<DataNode<ModuleData>> toCreate = filterExistingModules(toImport, project);
      if (!toCreate.isEmpty()) {
        createModules(toCreate, project);
      }
      for (DataNode<ModuleData> node : toImport) {
        Module module = ProjectStructureHelper.findIdeModule(node.getData(), project);
        if (module != null) {
          syncPaths(module, node.getData());
        }
      }
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:28,
代码来源:ModuleDataService.java

示例14: setScope

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
public void setScope(@Nonnull final DependencyScope scope, @Nonnull final ExportableOrderEntry dependency, boolean synchronous) {
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(dependency.getOwnerModule()) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      doForDependency(dependency, new Consumer<ExportableOrderEntry>() {
        @Override
        public void consume(ExportableOrderEntry entry) {
          entry.setScope(scope);
        }
      });
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:15,
代码来源:AbstractDependencyDataService.java

示例15: setExported

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
public void setExported(final boolean exported, @Nonnull final ExportableOrderEntry dependency, boolean synchronous) {
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(dependency.getOwnerModule()) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      doForDependency(dependency, new Consumer<ExportableOrderEntry>() {
        @Override
        public void consume(ExportableOrderEntry entry) {
          entry.setExported(exported);
        }
      });
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:15,
代码来源:AbstractDependencyDataService.java

示例16: removeData

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
public void removeData(@Nonnull Collection<? extends ExportableOrderEntry> toRemove, @Nonnull final Module module, boolean synchronous) {
  if (toRemove.isEmpty()) {
    return;
  }
  for (final ExportableOrderEntry dependency : toRemove) {
    ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(dependency.getOwnerModule()) {
      @RequiredDispatchThread
      @Override
      public void execute() {
        ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
        final ModifiableRootModel moduleRootModel = moduleRootManager.getModifiableModel();
        try {
          // The thing is that intellij created order entry objects every time new modifiable model is created,
          // that's why we can't use target dependency object as is but need to get a reference to the current
          // entry object from the model instead.
          for (OrderEntry entry : moduleRootModel.getOrderEntries()) {
            if (entry instanceof ExportableOrderEntry) {
              ExportableOrderEntry orderEntry = (ExportableOrderEntry)entry;
              if (orderEntry.getPresentableName().equals(dependency.getPresentableName()) &&
                  orderEntry.getScope().equals(dependency.getScope())) {
                moduleRootModel.removeOrderEntry(entry);
                break;
              }
            }
            else if (entry.getPresentableName().equals(dependency.getPresentableName())) {
              moduleRootModel.removeOrderEntry(entry);
              break;
            }
          }
        }
        finally {
          moduleRootModel.commit();
        }
      }
    });
  }
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:38,
代码来源:AbstractDependencyDataService.java

示例17: importLibrary

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
public void importLibrary(@Nonnull final String libraryName,
                          @Nonnull final Map<OrderRootType, Collection<File>> libraryFiles,
                          @Nonnull final Project project,
                          boolean synchronous)
{
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      // Is assumed to be called from the EDT.
      final LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
      final LibraryTable.ModifiableModel projectLibraryModel = libraryTable.getModifiableModel();
      final Library intellijLibrary;
      try {
        intellijLibrary = projectLibraryModel.createLibrary(libraryName);
      }
      finally {
        projectLibraryModel.commit();
      }
      final Library.ModifiableModel libraryModel = intellijLibrary.getModifiableModel();
      try {
        registerPaths(libraryFiles, libraryModel, libraryName);
      }
      finally {
        libraryModel.commit();
      }
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:30,
代码来源:LibraryDataService.java

示例18: removeData

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public void removeData(@Nonnull final Collection<? extends Library> libraries, @Nonnull final Project project, boolean synchronous) {
  if (libraries.isEmpty()) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      final LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
      final LibraryTable.ModifiableModel model = libraryTable.getModifiableModel();
      try {
        for (Library library : libraries) {
          String libraryName = library.getName();
          if (libraryName != null) {
            Library libraryToRemove = model.getLibraryByName(libraryName);
            if (libraryToRemove != null) {
              model.removeLibrary(libraryToRemove);
            }
          }
        }
      }
      finally {
        model.commit();
      }
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:29,
代码来源:LibraryDataService.java

示例19: setupLibraries

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
/**
 * The whole import sequence looks like below:
 * <p/>
 * <pre>
 * <ol>
 *   <li>Get project view from the gradle tooling api without resolving dependencies (downloading libraries);</li>
 *   <li>Allow to adjust project settings before importing;</li>
 *   <li>Create IJ project and modules;</li>
 *   <li>Ask gradle tooling api to resolve library dependencies (download the if necessary);</li>
 *   <li>Configure libraries used by the gradle project at intellij;</li>
 *   <li>Configure library dependencies;</li>
 * </ol>
 * </pre>
 * <p/>
 *
 * @param projectWithResolvedLibraries  gradle project with resolved libraries (libraries have already been downloaded and
 *                                      are available at file system under gradle service directory)
 * @param project                       current intellij project which should be configured by libraries and module library
 *                                      dependencies information available at the given gradle project
 */
private void setupLibraries(@Nonnull final DataNode<ProjectData> projectWithResolvedLibraries, final Project project) {
  ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
        @Override
        public void run() {
          if (ExternalSystemApiUtil.isNewProjectConstruction()) {
            // Clean existing libraries (if any).
            LibraryTable projectLibraryTable = ProjectLibraryTable.getInstance(project);
            if (projectLibraryTable == null) {
              LOG.warn(
                "Can't resolve external dependencies of the target gradle project (" + project + "). Reason: project "
                + "library table is undefined"
              );
              return;
            }
            LibraryTable.ModifiableModel model = projectLibraryTable.getModifiableModel();
            try {
              for (Library library : model.getLibraries()) {
                model.removeLibrary(library);
              }
            }
            finally {
              model.commit();
            }
          }

          // Register libraries.
          myProjectDataManager.importData(Collections.<DataNode<?>>singletonList(projectWithResolvedLibraries), project, false);
        }
      });
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:57,
代码来源:AbstractExternalProjectImportBuilder.java

示例20: commit

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Nonnull
@Override
public List<Module> commit(@Nonnull ExternalModuleImportContext context,
                           @Nonnull final Project project,
                           ModifiableModuleModel model,
                           @Nonnull ModulesProvider modulesProvider,
                           ModifiableArtifactModel artifactModel) {
  project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
  final DataNode<ProjectData> externalProjectNode = getExternalProjectNode();
  if (externalProjectNode != null) {
    beforeCommit(externalProjectNode, project);
  }

  StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
    @SuppressWarnings("unchecked")
    @Override
    public void run() {
      AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
      final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
      Set<ExternalProjectSettings> projects = ContainerUtilRt.<ExternalProjectSettings>newHashSet(systemSettings.getLinkedProjectsSettings());
      // add current importing project settings to linked projects settings or replace if similar already exist
      projects.remove(projectSettings);
      projects.add(projectSettings);

      systemSettings.copyFrom(myControl.getSystemSettings());
      systemSettings.setLinkedProjectsSettings(projects);

      if (externalProjectNode != null) {
        ExternalSystemUtil.ensureToolWindowInitialized(project, myExternalSystemId);
        ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
          @RequiredDispatchThread
          @Override
          public void execute() {
            ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
              @Override
              public void run() {
                myProjectDataManager.importData(externalProjectNode.getKey(), Collections.singleton(externalProjectNode), project, true);
                myExternalProjectNode = null;
              }
            });
          }
        });

        final Runnable resolveDependenciesTask = new Runnable() {
          @Override
          public void run() {
            String progressText = ExternalSystemBundle.message("progress.resolve.libraries", myExternalSystemId.getReadableName());
            ProgressManager.getInstance().run(new Task.Backgroundable(project, progressText, false) {
              @Override
              public void run(@Nonnull final ProgressIndicator indicator) {
                if (project.isDisposed()) return;
                ExternalSystemResolveProjectTask task =
                        new ExternalSystemResolveProjectTask(myExternalSystemId, project, projectSettings.getExternalProjectPath(), false);
                task.execute(indicator, ExternalSystemTaskNotificationListener.EP_NAME.getExtensions());
                DataNode<ProjectData> projectWithResolvedLibraries = task.getExternalProject();
                if (projectWithResolvedLibraries == null) {
                  return;
                }

                setupLibraries(projectWithResolvedLibraries, project);
              }
            });
          }
        };
        UIUtil.invokeLaterIfNeeded(resolveDependenciesTask);
      }
    }
  });
  return Collections.emptyList();
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:71,
代码来源:AbstractExternalModuleImportProvider.java

示例21: importData

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
public void importData(@Nonnull final Collection<DataNode<LibraryDependencyData>> nodesToImport,
                       @Nonnull final Module module,
                       final boolean synchronous)
{
  ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(module) {
    @RequiredDispatchThread
    @Override
    public void execute() {
      importMissingProjectLibraries(module, nodesToImport, synchronous);
      
      // The general idea is to import all external project library dependencies and module libraries which don't present at the
      // ide side yet and remove all project library dependencies and module libraries which present at the ide but not at
      // the given collection.
      // The trick is that we should perform module settings modification inside try/finally block against target root model.
      // That means that we need to prepare all necessary data, obtain a model and modify it as necessary.
      Map<Set<String>/* library paths */, LibraryDependencyData> moduleLibrariesToImport = ContainerUtilRt.newHashMap();
      Map<String/* library name + scope */, LibraryDependencyData> projectLibrariesToImport = ContainerUtilRt.newHashMap();
      Set<LibraryDependencyData> toImport = ContainerUtilRt.newLinkedHashSet();
      
      boolean hasUnresolved = false;
      for (DataNode<LibraryDependencyData> dependencyNode : nodesToImport) {
        LibraryDependencyData dependencyData = dependencyNode.getData();
        LibraryData libraryData = dependencyData.getTarget();
        hasUnresolved |= libraryData.isUnresolved();
        switch (dependencyData.getLevel()) {
          case MODULE:
            if (!libraryData.isUnresolved()) {
              Set<String> paths = ContainerUtilRt.newHashSet();
              for (String path : libraryData.getPaths(LibraryPathType.BINARY)) {
                paths.add(ExternalSystemApiUtil.toCanonicalPath(path) + dependencyData.getScope().name());
              }
              moduleLibrariesToImport.put(paths, dependencyData);
              toImport.add(dependencyData);
            }
            break;
          case PROJECT:
            projectLibrariesToImport.put(libraryData.getInternalName() + dependencyData.getScope().name(), dependencyData);
            toImport.add(dependencyData);
        }
      }

      ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
      final ModifiableRootModel moduleRootModel = moduleRootManager.getModifiableModel();
      LibraryTable moduleLibraryTable = moduleRootModel.getModuleLibraryTable();
      LibraryTable libraryTable = ProjectLibraryTable.getInstance(module.getProject());
      try {
        filterUpToDateAndRemoveObsolete(moduleLibrariesToImport, projectLibrariesToImport, toImport, moduleRootModel, hasUnresolved);

        // Import missing library dependencies.
        if (!toImport.isEmpty()) {
          importMissing(toImport, moduleRootModel, moduleLibraryTable, libraryTable, module);
        }
      }
      finally {
        moduleRootModel.commit();
      }
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:60,
代码来源:LibraryDependencyDataService.java

示例22: commit

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public List<Module> commit(final Project project,
                           ModifiableModuleModel model,
                           ModulesProvider modulesProvider,
                           ModifiableArtifactModel artifactModel)
{
  project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
  final DataNode<ProjectData> externalProjectNode = getExternalProjectNode();
  if (externalProjectNode != null) {
    beforeCommit(externalProjectNode, project);
  }
  StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
    @SuppressWarnings("unchecked")
    @Override
    public void run() {
      AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
      final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
      Set<ExternalProjectSettings> projects = ContainerUtilRt.<ExternalProjectSettings>newHashSet(systemSettings.getLinkedProjectsSettings());
      // add current importing project settings to linked projects settings or replace if similar already exist
      projects.remove(projectSettings);
      projects.add(projectSettings);

      systemSettings.copyFrom(myControl.getSystemSettings());
      systemSettings.setLinkedProjectsSettings(projects);

      if (externalProjectNode != null) {
        ExternalSystemUtil.ensureToolWindowInitialized(project, myExternalSystemId);
        ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
          @RequiredDispatchThread
          @Override
          public void execute() {
            ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
              @Override
              public void run() {
                myProjectDataManager.importData(externalProjectNode.getKey(), Collections.singleton(externalProjectNode), project, true);
                myExternalProjectNode = null;
              }
            });
          }
        });

        final Runnable resolveDependenciesTask = new Runnable() {
          @Override
          public void run() {
            String progressText = ExternalSystemBundle.message("progress.resolve.libraries", myExternalSystemId.getReadableName());
            ProgressManager.getInstance().run(
              new Task.Backgroundable(project, progressText, false) {
                @Override
                public void run(@Nonnull final ProgressIndicator indicator) {
                  if(project.isDisposed()) return;
                  ExternalSystemResolveProjectTask task
                    = new ExternalSystemResolveProjectTask(myExternalSystemId, project, projectSettings.getExternalProjectPath(), false);
                  task.execute(indicator, ExternalSystemTaskNotificationListener.EP_NAME.getExtensions());
                  DataNode<ProjectData> projectWithResolvedLibraries = task.getExternalProject();
                  if (projectWithResolvedLibraries == null) {
                    return;
                  }

                  setupLibraries(projectWithResolvedLibraries, project);
                }
              });
          }
        };
        UIUtil.invokeLaterIfNeeded(resolveDependenciesTask);
      }
    }
  });
  return Collections.emptyList();
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:70,
代码来源:AbstractExternalProjectImportBuilder.java

示例23: importData

点赞 2

import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange; //导入依赖的package包/类
@Override
public void importData(@NotNull Collection<DataNode<JavaProjectData>> toImport, @NotNull final Project project, boolean synchronous)
{
	if(toImport.size() != 1)
	{
		throw new IllegalArgumentException(String.format("Expected to get a single project but got %d: %s", toImport.size(), toImport));
	}
	JavaProjectData projectData = toImport.iterator().next().getData();

	final Sdk jdk = findJdk(projectData.getJdkVersion());
	final LanguageLevel languageLevel = projectData.getLanguageLevel();

	ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project)
	{
		@Override
		public void execute()
		{
			ModuleManager moduleManager = ModuleManager.getInstance(project);

			for(Module module : moduleManager.getModules())
			{
				if(module.isDisposed())
				{
					continue;
				}
				ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);

				ModifiableRootModel modifiableModel = moduleRootManager.getModifiableModel();

				JavaMutableModuleExtension<?> e = modifiableModel.getExtensionWithoutCheck("java");
				if(!e.isEnabled())
				{
					e.setEnabled(true);
					modifiableModel.addModuleExtensionSdkEntry(e);
				}
				if(jdk != null)
				{
					e.getInheritableSdk().set(null, jdk);
				}
				e.getInheritableLanguageLevel().set(null, languageLevel);
				modifiableModel.commit();
			}
		}
	});
}
 

开发者ID:consulo,
项目名称:consulo-java,
代码行数:46,
代码来源:JavaProjectDataService.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)