Search in sources :

Example 11 with ModifiableFacetModel

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

the class ContentRootsModuleSetupStepTest method addNativeAndroidFacet.

@NotNull
private NdkFacet addNativeAndroidFacet(@NotNull IdeModifiableModelsProvider modelsProvider) {
    Module module = getModule();
    ModifiableFacetModel model = modelsProvider.getModifiableFacetModel(module);
    NdkFacetType facetType = NdkFacet.getFacetType();
    NdkFacet facet = facetType.createFacet(module, NdkFacet.getFacetName(), facetType.createDefaultConfiguration(), null);
    model.addFacet(facet);
    return facet;
}
Also used : NdkFacetType(com.android.tools.idea.gradle.project.facet.ndk.NdkFacetType) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with ModifiableFacetModel

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

the class PostProjectBuildTasksExecutorTest method addAndroidFacet.

private static void addAndroidFacet(@NotNull Module module) {
    FacetManager facetManager = FacetManager.getInstance(module);
    ModifiableFacetModel facetModel = facetManager.createModifiableModel();
    try {
        AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
        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 13 with ModifiableFacetModel

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

the class AddFacetTest method testAddFacetAfterCreatingManifest.

public void testAddFacetAfterCreatingManifest() {
    new WriteAction() {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            VirtualFile[] roots = ModuleRootManager.getInstance(myModule).getContentRoots();
            VirtualFile metaInf = roots[0].createChildDirectory(this, "META-INF");
            VirtualFile manifest = metaInf.createChildData(this, "MANIFEST.MF");
            VfsUtil.saveText(manifest, "Manifest-Version: 1.0\n" + "Bundle-ManifestVersion: 2\n" + "Bundle-Name: Test\n" + "Bundle-SymbolicName: test\n" + "Bundle-Version: 1.0.0\n");
            PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
        }
    }.execute();
    new WriteAction() {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            ModifiableFacetModel model = FacetManager.getInstance(myModule).createModifiableModel();
            OsmorcFacet facet = new OsmorcFacet(myModule);
            facet.getConfiguration().setManifestGenerationMode(ManifestGenerationMode.Manually);
            model.addFacet(facet);
            model.commit();
        }
    }.execute();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) WriteAction(com.intellij.openapi.application.WriteAction) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) Result(com.intellij.openapi.application.Result)

Example 14 with ModifiableFacetModel

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

the class MvcModuleStructureUtil method updateAuxModuleStructure.

public static void updateAuxModuleStructure(Module auxModule, Collection<VirtualFile> pluginDirs, MvcFramework framework) {
    final MvcProjectStructure structure = framework.createProjectStructure(auxModule, true);
    Pair<Collection<Consumer<ModifiableRootModel>>, Collection<Consumer<ModifiableFacetModel>>> actions = getUpdateProjectStructureActions(pluginDirs, structure);
    for (final ContentEntry root : ModuleRootManager.getInstance(auxModule).getContentEntries()) {
        if (!pluginDirs.contains(root.getFile())) {
            actions.first.add(removeStaleContentEntries(pluginDirs));
            break;
        }
    }
    if (!actions.first.isEmpty()) {
        actions.first.add(exportDefaultLibrary(structure.getUserLibraryName()));
    }
    if (!actions.first.isEmpty()) {
        final ModifiableRootModel model = ModuleRootManager.getInstance(auxModule).getModifiableModel();
        for (final Consumer<ModifiableRootModel> pluginsUpdateAction : actions.first) {
            pluginsUpdateAction.consume(model);
        }
        model.commit();
    }
    if (!actions.second.isEmpty()) {
        final ModifiableFacetModel model = FacetManager.getInstance(auxModule).createModifiableModel();
        for (Consumer<ModifiableFacetModel> action : actions.second) {
            action.consume(model);
        }
        model.commit();
    }
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel)

Example 15 with ModifiableFacetModel

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

the class BuildoutConfigurable method removeFacet.

private void removeFacet(BuildoutFacet facet) {
    final ModifiableFacetModel model = FacetManager.getInstance(myModule).createModifiableModel();
    model.removeFacet(facet);
    ApplicationManager.getApplication().runWriteAction(() -> model.commit());
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel)

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