use of com.intellij.facet.ModifiableFacetModel in project kotlin by JetBrains.
the class AbstractAndroidQuickFixMultiFileTest method addAndroidFacet.
private void addAndroidFacet() {
FacetManager facetManager = FacetManager.getInstance(myModule);
AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
final ModifiableFacetModel facetModel = facetManager.createModifiableModel();
facetModel.addFacet(facet);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
facetModel.commit();
}
});
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class NewProjectImportGradleSyncListener method createTopLevelModule.
@VisibleForTesting
public static void createTopLevelModule(@NotNull Project project) {
ModuleManager moduleManager = ModuleManager.getInstance(project);
File projectRootDir = getBaseDirPath(project);
VirtualFile contentRoot = findFileByIoFile(projectRootDir, true);
if (contentRoot != null) {
File moduleFile = new File(projectRootDir, projectRootDir.getName() + ".iml");
Module module = moduleManager.newModule(moduleFile.getPath(), JAVA.getId());
// This prevents the balloon "Unsupported Modules detected".
ExternalSystemModulePropertyManager.getInstance(module).setExternalId(GRADLE_SYSTEM_ID);
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
model.addContentEntry(contentRoot);
if (IdeInfo.getInstance().isAndroidStudio()) {
// If sync fails, make sure that the project has a JDK, otherwise Groovy indices won't work (a common scenario where
// users will update build.gradle files to fix Gradle sync.)
// See: https://code.google.com/p/android/issues/detail?id=194621
Sdk jdk = IdeSdks.getInstance().getJdk();
if (jdk != null) {
model.setSdk(jdk);
}
}
model.commit();
FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel facetModel = facetManager.createModifiableModel();
try {
GradleFacet gradleFacet = GradleFacet.getInstance(module);
if (gradleFacet == null) {
// Add "gradle" facet, to avoid balloons about unsupported compilation of modules.
gradleFacet = facetManager.createFacet(GradleFacet.getFacetType(), GradleFacet.getFacetName(), null);
facetModel.addFacet(gradleFacet);
}
gradleFacet.getConfiguration().GRADLE_PROJECT_PATH = GRADLE_PATH_SEPARATOR;
// Add "android" facet to avoid the balloon "Android Framework detected".
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet == null) {
androidFacet = facetManager.createFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
facetModel.addFacet(androidFacet);
}
// This is what actually stops Studio from showing the balloon.
androidFacet.getProperties().ALLOW_USER_CONFIGURATION = false;
} finally {
facetModel.commit();
}
}
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class NdkFacetModuleSetupStep method gradleModelNotFound.
@Override
protected void gradleModelNotFound(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider) {
ModifiableFacetModel facetModel = ideModelsProvider.getModifiableFacetModel(module);
removeAllFacets(facetModel, NdkFacet.getFacetTypeId());
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class AndroidFacetModuleSetupStep method createAndAddFacet.
@NotNull
private static AndroidFacet createAndAddFacet(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider) {
ModifiableFacetModel model = ideModelsProvider.getModifiableFacetModel(module);
AndroidFacetType facetType = AndroidFacet.getFacetType();
AndroidFacet facet = facetType.createFacet(module, AndroidFacet.NAME, facetType.createDefaultConfiguration(), null);
model.addFacet(facet);
return facet;
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class AndroidFacetModuleSetupStep method gradleModelNotFound.
@Override
protected void gradleModelNotFound(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider) {
ModifiableFacetModel facetModel = ideModelsProvider.getModifiableFacetModel(module);
removeAllFacets(facetModel, AndroidFacet.ID);
}
Aggregations