Search in sources :

Example 11 with FacetManager

use of com.intellij.facet.FacetManager 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;
}
Also used : JavaFacet(com.android.tools.idea.gradle.project.facet.java.JavaFacet) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) FacetManager(com.intellij.facet.FacetManager) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with FacetManager

use of com.intellij.facet.FacetManager 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();
        });
    }
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) GradleFacet(com.android.tools.idea.gradle.project.facet.gradle.GradleFacet) FacetManager(com.intellij.facet.FacetManager)

Example 13 with FacetManager

use of com.intellij.facet.FacetManager 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());
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) FacetManager(com.intellij.facet.FacetManager)

Example 14 with FacetManager

use of com.intellij.facet.FacetManager in project android by JetBrains.

the class FacetsTest method testRemoveAllFacetsWithAndroidFacets.

public void testRemoveAllFacetsWithAndroidFacets() throws Exception {
    createAndAddAndroidFacet(myModule);
    FacetManager facetManager = FacetManager.getInstance(myModule);
    assertEquals(1, facetManager.getFacetsByType(AndroidFacet.ID).size());
    IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
    ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(myModule);
    Facets.removeAllFacets(facetModel, AndroidFacet.ID);
    ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
    assertEquals(0, facetManager.getFacetsByType(AndroidFacet.ID).size());
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) FacetManager(com.intellij.facet.FacetManager)

Example 15 with FacetManager

use of com.intellij.facet.FacetManager in project android by JetBrains.

the class ConflictSetTest method setUpLibModule.

private void setUpLibModule() {
    FacetManager facetManager = FacetManager.getInstance(myLibModule);
    ModifiableFacetModel facetModel = facetManager.createModifiableModel();
    try {
        AndroidFacet androidFacet = createFacet(facetManager, PROJECT_TYPE_LIBRARY);
        androidFacet.setAndroidModel(myLib);
        facetModel.addFacet(androidFacet);
        GradleFacet gradleFacet = facetManager.createFacet(GradleFacet.getFacetType(), GradleFacet.getFacetName(), null);
        gradleFacet.getConfiguration().GRADLE_PROJECT_PATH = myLibGradlePath;
        facetModel.addFacet(gradleFacet);
    } finally {
        facetModel.commit();
    }
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) GradleFacet(com.android.tools.idea.gradle.project.facet.gradle.GradleFacet) FacetManager(com.intellij.facet.FacetManager) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Aggregations

FacetManager (com.intellij.facet.FacetManager)20 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)18 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)9 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)3 ProjectFacetManager (com.intellij.facet.ProjectFacetManager)3 Module (com.intellij.openapi.module.Module)3 NotNull (org.jetbrains.annotations.NotNull)3 AppEngineEnvironment (com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment)2 AppEngineProjectService (com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService)2 Result (com.intellij.openapi.application.Result)2 WriteAction (com.intellij.openapi.application.WriteAction)2 IdeModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)2 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)2 ModuleManager (com.intellij.openapi.module.ModuleManager)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ModuleDeploymentSource (com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1 JavaFacet (com.android.tools.idea.gradle.project.facet.java.JavaFacet)1