Search in sources :

Example 26 with ModifiableFacetModel

use of com.intellij.facet.ModifiableFacetModel 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 27 with ModifiableFacetModel

use of com.intellij.facet.ModifiableFacetModel 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)

Example 28 with ModifiableFacetModel

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

the class ConflictSetTest method setUpMainModuleAsApp.

private void setUpMainModuleAsApp() {
    FacetManager facetManager = FacetManager.getInstance(myModule);
    ModifiableFacetModel facetModel = facetManager.createModifiableModel();
    try {
        AndroidFacet facet = createFacet(facetManager, PROJECT_TYPE_APP);
        facet.setAndroidModel(myApp);
        facetModel.addFacet(facet);
    } finally {
        facetModel.commit();
    }
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) FacetManager(com.intellij.facet.FacetManager) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 29 with ModifiableFacetModel

use of com.intellij.facet.ModifiableFacetModel in project intellij-plugins by JetBrains.

the class RubyMotionFacetConfigurator method configure.

public static void configure(VirtualFile baseDir, Module module) {
    final RubyMotionFacet existingFacet = RubyMotionFacet.getInstance(module);
    if (existingFacet != null) {
        return;
    }
    FacetManager facetManager = FacetManager.getInstance(module);
    final ModifiableFacetModel model = facetManager.createModifiableModel();
    RubyMotionFacetType facetType = RubyMotionFacetType.getInstance();
    RubyMotionFacetConfiguration configuration = ProjectFacetManager.getInstance(module.getProject()).createDefaultConfiguration(facetType);
    //configuration.setProjectRootPath(baseDir.getPath());
    VirtualFile testFolder = baseDir.findChild("spec");
    final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
    if (testFolder != null) {
        //configuration.setTestPath(testFolder.getPath());
        addTestSources(testFolder, rootModel);
    }
    VirtualFile libFolder = baseDir.findChild("app");
    if (libFolder != null) {
    //configuration.setLibPath(libFolder.getPath());
    }
    RubyMotionFacet.updateMotionLibrary(rootModel);
    IdeaInternalUtil.runInsideWriteAction(new ActionRunner.InterruptibleRunnable() {

        public void run() throws Exception {
            rootModel.commit();
        }
    });
    RubyMotionFacet facet = facetManager.createFacet(facetType, facetType.getDefaultFacetName(), configuration, null);
    model.addFacet(facet);
    new WriteAction() {

        protected void run(@NotNull final Result result) throws Throwable {
            model.commit();
        }
    }.execute();
    RubyMotionUtilExt.createMotionRunConfiguration(module);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionRunner(com.intellij.util.ActionRunner) WriteAction(com.intellij.openapi.application.WriteAction) RubyMotionFacetType(org.jetbrains.plugins.ruby.motion.facet.RubyMotionFacetType) RubyMotionFacetConfiguration(org.jetbrains.plugins.ruby.motion.facet.RubyMotionFacetConfiguration) Result(com.intellij.openapi.application.Result) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) RubyMotionFacet(org.jetbrains.plugins.ruby.motion.facet.RubyMotionFacet) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) ProjectFacetManager(com.intellij.facet.ProjectFacetManager) FacetManager(com.intellij.facet.FacetManager)

Aggregations

ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)29 FacetManager (com.intellij.facet.FacetManager)15 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)9 NotNull (org.jetbrains.annotations.NotNull)5 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)4 Module (com.intellij.openapi.module.Module)4 ProjectFacetManager (com.intellij.facet.ProjectFacetManager)3 Result (com.intellij.openapi.application.Result)3 WriteAction (com.intellij.openapi.application.WriteAction)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)2 NdkFacetType (com.android.tools.idea.gradle.project.facet.ndk.NdkFacetType)2 IdeModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)2 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 File (java.io.File)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1 GradleFacetType (com.android.tools.idea.gradle.project.facet.gradle.GradleFacetType)1 JavaFacet (com.android.tools.idea.gradle.project.facet.java.JavaFacet)1 GradleSyncSummary (com.android.tools.idea.gradle.project.sync.GradleSyncSummary)1