use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class JavaFacetModuleSetupStep method setAndGetJavaGradleFacet.
@NotNull
private static JavaFacet setAndGetJavaGradleFacet(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider) {
JavaFacet facet = findFacet(module, modelsProvider, JavaFacet.getFacetTypeId());
if (facet != null) {
return facet;
}
FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel model = modelsProvider.getModifiableFacetModel(module);
facet = facetManager.createFacet(JavaFacet.getFacetType(), JavaFacet.getFacetName(), null);
model.addFacet(facet);
return facet;
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class AndroidTestCase method addAndroidFacet.
private static AndroidFacet addAndroidFacet(Module module, boolean attachSdk) {
FacetManager facetManager = FacetManager.getInstance(module);
AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
if (attachSdk) {
addLatestAndroidSdk(module);
}
ModifiableFacetModel facetModel = facetManager.createModifiableModel();
facetModel.addFacet(facet);
ApplicationManager.getApplication().runWriteAction(facetModel::commit);
return facet;
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class GradleModuleSetup method setUpModule.
public void setUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull GradleModuleModel model) {
GradleFacet facet = findFacet(module, ideModelsProvider, GradleFacet.getFacetTypeId());
if (facet == null) {
ModifiableFacetModel facetModel = ideModelsProvider.getModifiableFacetModel(module);
GradleFacetType facetType = GradleFacet.getFacetType();
facet = facetType.createFacet(module, GradleFacet.getFacetName(), facetType.createDefaultConfiguration(), null);
facetModel.addFacet(facet);
}
facet.setGradleModuleModel(model);
String gradleVersion = model.getGradleVersion();
GradleSyncSummary syncReport = GradleSyncState.getInstance(module.getProject()).getSummary();
if (isNotEmpty(gradleVersion) && syncReport.getGradleVersion() == null) {
syncReport.setGradleVersion(GradleVersion.parse(gradleVersion));
}
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class GradleProjectInfoTest method removeAndroidGradleFacetFromModule.
private void removeAndroidGradleFacetFromModule() {
FacetManager facetManager = FacetManager.getInstance(getModule());
GradleFacet facet = facetManager.findFacet(GradleFacet.getFacetTypeId(), GradleFacet.getFacetName());
if (facet != null) {
ApplicationManager.getApplication().runWriteAction(() -> {
ModifiableFacetModel facetModel = facetManager.createModifiableModel();
facetModel.removeFacet(facet);
facetModel.commit();
});
}
}
use of com.intellij.facet.ModifiableFacetModel in project android by JetBrains.
the class FacetsTest method testRemoveAllFacetsWithAndroidGradleFacets.
public void testRemoveAllFacetsWithAndroidGradleFacets() throws Exception {
createAndAddGradleFacet(myModule);
FacetManager facetManager = FacetManager.getInstance(myModule);
assertEquals(1, facetManager.getFacetsByType(GradleFacet.getFacetTypeId()).size());
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(myModule);
Facets.removeAllFacets(facetModel, GradleFacet.getFacetTypeId());
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
assertEquals(0, facetManager.getFacetsByType(GradleFacet.getFacetTypeId()).size());
}
Aggregations