當前位置: 首頁>>代碼示例>>Java>>正文


Java ModifiableRootModel.setSdk方法代碼示例

本文整理匯總了Java中com.intellij.openapi.roots.ModifiableRootModel.setSdk方法的典型用法代碼示例。如果您正苦於以下問題:Java ModifiableRootModel.setSdk方法的具體用法?Java ModifiableRootModel.setSdk怎麽用?Java ModifiableRootModel.setSdk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.roots.ModifiableRootModel的用法示例。


在下文中一共展示了ModifiableRootModel.setSdk方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
@Override
public void setupRootModel(@NotNull final ModifiableRootModel rootModel) throws ConfigurationException {
    if (mySdk == null) {
        rootModel.inheritSdk();
    } else {
        rootModel.setSdk(mySdk);
    }

    // Make the entire module directory a source root.
    ContentEntry contentEntry = doAddContentEntry(rootModel);
    if (contentEntry != null) {
        final VirtualFile file = contentEntry.getFile();
        if (file != null && file.isDirectory())
            contentEntry.addSourceFolder(file, false);
    }
}
 
開發者ID:internetisalie,項目名稱:lua-for-idea,代碼行數:17,代碼來源:LuaModuleBuilder.java

示例2: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
  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, myArchetype, myPropertiesToCreateByArtifact, "Create new Maven module").configure(project, root, false);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:MavenModuleBuilder.java

示例3: setSdk

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
public void setSdk(final Sdk newJDK) {
  final ModifiableRootModel model = getModel();
  if (newJDK != null) {
    model.setSdk(newJDK);
  }
  else {
    model.inheritSdk();
  }

  if (myPanel != null) {
    myPanel.forceInitFromModel();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:ClasspathEditor.java

示例4: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
  super.setupRootModel(rootModel);
  Sdk sdk = mySdkComboBox.getSelectedSdk();
  if (sdk != null) {
    rootModel.setSdk(sdk);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:PyCCEduProjectTemplate.java

示例5: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
public void setupRootModel(final ModifiableRootModel rootModel) throws ConfigurationException {
  // false for the module automatically created in a new project
  if (myJdk != null) {
    rootModel.setSdk(myJdk);
  }
  else {
    rootModel.inheritSdk();
  }

  doAddContentEntry(rootModel);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:PythonModuleBuilderBase.java

示例6: doImportSdkAndFacetConfiguration

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
public static void doImportSdkAndFacetConfiguration(@NotNull AndroidFacet facet, @Nullable ModifiableRootModel model) {
  final Module module = facet.getModule();
  AndroidSdkUtils.setupAndroidPlatformIfNecessary(module, true);

  if (model != null && !model.isDisposed() && model.isWritable()) {
    model.setSdk(ModuleRootManager.getInstance(module).getSdk());
  }

  final Pair<String,VirtualFile> manifestMergerProp =
    AndroidRootUtil.getProjectPropertyValue(module, AndroidUtils.ANDROID_MANIFEST_MERGER_PROPERTY);
  if (manifestMergerProp != null) {
    facet.getProperties().ENABLE_MANIFEST_MERGING = Boolean.parseBoolean(manifestMergerProp.getFirst());
  }

  final Pair<String,VirtualFile> dexDisableMergerProp =
    AndroidRootUtil.getProjectPropertyValue(module, AndroidUtils.ANDROID_DEX_DISABLE_MERGER);
  if (dexDisableMergerProp != null) {
    facet.getProperties().ENABLE_PRE_DEXING = !Boolean.parseBoolean(dexDisableMergerProp.getFirst());
  }
  final Pair<String, VirtualFile> androidLibraryProp =
    AndroidRootUtil.getProjectPropertyValue(module, AndroidUtils.ANDROID_LIBRARY_PROPERTY);

  if (androidLibraryProp != null && Boolean.parseBoolean(androidLibraryProp.getFirst())) {
    facet.setLibraryProject(true);
    return;
  }
  final Pair<String,VirtualFile> dexForceJumboProp =
    AndroidRootUtil.getProjectPropertyValue(module, AndroidUtils.ANDROID_DEX_FORCE_JUMBO_PROPERTY);
  if (dexForceJumboProp != null) {
    showDexOptionNotification(module, AndroidUtils.ANDROID_DEX_FORCE_JUMBO_PROPERTY);
  }

  Manifest manifest = facet.getManifest();
  if (manifest != null) {
    if (AndroidUtils.getDefaultLauncherActivityName(manifest) != null) {
      AndroidUtils.addRunConfiguration(facet, null, false, null, null);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:AndroidFrameworkDetector.java

示例7: customizeModule

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
/**
 * Sets an Android SDK to the given module only if:
 * <ol>
 * <li>the given module was created by importing an {@code AndroidProject}</li>
 * <li>there is a matching Android SDK already defined in IDEA</li>
 * </ol>
 * @param project         project that owns the module to customize.
 * @param ideaModuleModel modifiable root module of the module to customize.
 * @param androidProject  the imported Android-Gradle project.
 */
@Override
public void customizeModule(@NotNull Project project,
                            @NotNull Module module,
                            @NotNull IdeModifiableModelsProvider modelsProvider,
                            @Nullable IdeaAndroidProject androidProject) {
  if (androidProject == null) {
    return;
  }
  File androidSdkHomePath = IdeSdks.getAndroidSdkPath();
  // Android SDK may be not configured in IntelliJ
  if (androidSdkHomePath == null) {
    return;
  }

  final ModifiableRootModel ideaModuleModel = modelsProvider.getModifiableRootModel(module);
  LanguageLevel languageLevel = androidProject.getJavaLanguageLevel();
  if (languageLevel != null) {
    ideaModuleModel.getModuleExtension(LanguageLevelModuleExtensionImpl.class).setLanguageLevel(languageLevel);
  }

  String compileTarget = androidProject.getDelegate().getCompileTarget();

  Sdk sdk = findSuitableAndroidSdk(compileTarget);
  if (sdk == null) {
    sdk = tryToCreateAndroidSdk(androidSdkHomePath, compileTarget);
  }

  if (sdk != null) {
    ideaModuleModel.setSdk(sdk);
    return;
  }

  String text = String.format("Module '%1$s': platform '%2$s' not found.", module.getName(), compileTarget);
  LOG.info(text);

  Message msg = new Message(FAILED_TO_SET_UP_SDK, Message.Type.ERROR, text);
  ProjectSyncMessages.getInstance(project).add(msg);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:49,代碼來源:AndroidSdkModuleCustomizer.java

示例8: setupRootModel

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
@Override
public void setupRootModel(final @NotNull ModifiableRootModel rootModel) throws ConfigurationException {
  final Project project = rootModel.getProject();

  // in IntelliJ wizard user is able to choose SDK (i.e. for "java library" module), so set it
  if (myJdk != null){
    rootModel.setSdk(myJdk);
  } else {
    rootModel.inheritSdk();
  }
  if (myProject == null) {
    project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
  }
  StartupManager.getInstance(project).runWhenProjectIsInitialized(new DumbAwareRunnable() {
      @Override
      public void run() {
        DumbService.getInstance(project).smartInvokeLater(new Runnable() {
          @Override
          public void run() {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
              @Override
              public void run() {
                if (myProject == null) {
                  myWizardState.putSdkDependentParams();
                  myWizardState.put(ATTR_PROJECT_LOCATION, project.getBasePath());
                  AssetStudioAssetGenerator assetGenerator = new AssetStudioAssetGenerator(myWizardState);
                  NewProjectWizard.createProject(myWizardState, project, assetGenerator);
                }
                else {
                  myWizardState.put(ATTR_MODULE_NAME, getName());
                  createModule();
                }
              }
            });
          }
        });
      }
    });
  }
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:ImportWizardModuleBuilder.java

示例9: configureJdk

import com.intellij.openapi.roots.ModifiableRootModel; //導入方法依賴的package包/類
private static void configureJdk(Element cfg, @NotNull Module module) {
  String jdkName = cfg.getChildTextTrim("jdkName");
  if (StringUtil.isEmptyOrSpaces(jdkName)) return;

  ModuleRootManager rootManager = ModuleRootManager.getInstance(module);

  String currentSdkName = null;
  Sdk sdk = rootManager.getSdk();
  if (sdk != null) {
    currentSdkName = sdk.getName();
  }

  if (!jdkName.equals(currentSdkName)) {
    ModifiableRootModel model = rootManager.getModifiableModel();

    if (jdkName.equals(ProjectRootManager.getInstance(model.getProject()).getProjectSdkName())) {
      model.inheritSdk();
    }
    else {
      Sdk jdk = ProjectJdkTable.getInstance().findJdk(jdkName);
      if (jdk != null) {
        model.setSdk(jdk);
      }
      else {
        model.setInvalidSdk(jdkName, JavaSdk.getInstance().getName());
      }
    }

    model.commit();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:32,代碼來源:MavenIdeaPluginConfigurer.java


注:本文中的com.intellij.openapi.roots.ModifiableRootModel.setSdk方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。