Java Code Examples for com.intellij.openapi.roots.ModifiableRootModel#setSdk()

The following examples show how to use com.intellij.openapi.roots.ModifiableRootModel#setSdk() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringBootModuleBuilder.java    From crud-intellij-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
	Selection selection = SelectionContext.copyToSelection();
	if (this.myJdk != null) {
		rootModel.setSdk(this.myJdk);
	} else {
		rootModel.inheritSdk();
	}
	SelectionContext.clearAllSet();
	Project project = rootModel.getProject();
	VirtualFile root = createAndGetContentEntry();
	rootModel.addContentEntry(root);
	CrudUtils.runWhenInitialized(project, () -> new WriteCommandAction<VirtualFile>(project) {
		@Override
		protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
			initProject(project, selection);
		}
	}.execute());
}
 
Example 2
Source File: DubboPluginModuleBuilder.java    From intellij-idea-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {

    String s = new Gson().toJson(userChooseDependency);
    System.out.println("set up root model json is:" + s);
    Project project = rootModel.getProject();
    VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);
    if (myJdk != null) {
        rootModel.setSdk(myJdk);
    } else {
        rootModel.inheritSdk();
    }
    System.out.println("start to create folder in path");


}
 
Example 3
Source File: SlingMavenModuleBuilder.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
public void setupRootModel(ModifiableRootModel rootModel) {
    final Project project = rootModel.getProject();

    final VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);

    // todo this should be moved to generic ModuleBuilder
    if (myJdk != null){
        rootModel.setSdk(myJdk);
    } else {
        rootModel.inheritSdk();
    }

    MavenUtil.runWhenInitialized(
        project, new DumbAwareRunnable() {
        public void run() {
            if (myEnvironmentForm != null) {
                myEnvironmentForm.setData(MavenProjectsManager.getInstance(project).getGeneralSettings());
            }

            new MavenModuleBuilderHelper(myProjectId, myAggregatorProject, myParentProject, myInheritGroupId,
                myInheritVersion, archetypeTemplate.getMavenArchetype(), myPropertiesToCreateByArtifact, "Create new Sling Maven module").configure(project, root, false);
            }
        }
    );
}
 
Example 4
Source File: RPiJavaModuleBuilder.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Used to define the hierachy of the project definition
 *
 * @param rootModel
 * @throws ConfigurationException
 */
@Override
public void setupRootModel(final ModifiableRootModel rootModel) throws ConfigurationException {
    super.setupRootModel(rootModel);

    final Project project = rootModel.getProject();

    final VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);

    if (myJdk != null) {
        rootModel.setSdk(myJdk);
    } else {
        rootModel.inheritSdk();
    }

    createProjectFiles(rootModel, project);

}
 
Example 5
Source File: InitializrModuleBuilder.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
@Override
public void setupRootModel(ModifiableRootModel modifiableRootModel) {
  Sdk moduleOrProjectSdk = getModuleJdk() != null ?
      getModuleJdk() :
      getInstance(modifiableRootModel.getProject()).getProjectSdk();
  if (moduleOrProjectSdk != null) {
    modifiableRootModel.setSdk(moduleOrProjectSdk);
  }

  LanguageLevelModuleExtension languageLevelModuleExtension =
      modifiableRootModel.getModuleExtension(LanguageLevelModuleExtension.class);
  if (languageLevelModuleExtension != null && moduleOrProjectSdk != null) {
    if (safeGetProjectCreationRequest().isJavaVersionSet()) {
      LanguageLevel lastSelectedLanguageLevel =
          parse(safeGetProjectCreationRequest().getJavaVersion().getId());
      if (lastSelectedLanguageLevel != null) {
        JavaSdkVersion lastSelectedJavaSdkVersion = fromLanguageLevel(lastSelectedLanguageLevel);
        JavaSdkVersion moduleOrProjectLevelJavaSdkVersion =
            getInstance().getVersion(moduleOrProjectSdk);
        if (moduleOrProjectLevelJavaSdkVersion != null && moduleOrProjectLevelJavaSdkVersion
            .isAtLeast(lastSelectedJavaSdkVersion)) {
          languageLevelModuleExtension.setLanguageLevel(lastSelectedLanguageLevel);
        }
      }
    }
  }

  doAddContentEntry(modifiableRootModel);
}
 
Example 6
Source File: NutzBootModuleBuilder.java    From NutzCodeInsight with Apache License 2.0 5 votes vote down vote up
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
    VirtualFile root = createAndGetContentEntry();
    rootModel.addContentEntry(root);
    if (myJdk != null) {
        rootModel.setSdk(myJdk);
    } else {
        rootModel.inheritSdk();
    }
    System.out.println("start to create folder in path");
}