Search in sources :

Example 1 with FacetManager

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

the class BuildoutFacetConfigurator method setupFacet.

static void setupFacet(Module module, @NotNull BuildoutFacetConfiguration config) {
    //TODO: refactor, see other python facets
    FacetManager facetManager = FacetManager.getInstance(module);
    final ModifiableFacetModel model = facetManager.createModifiableModel();
    BuildoutFacetType facetType = BuildoutFacetType.getInstance();
    BuildoutFacet facet = facetManager.createFacet(facetType, facetType.getDefaultFacetName(), config, null);
    model.addFacet(facet);
    new WriteAction() {

        protected void run(@NotNull final Result result) throws Throwable {
            model.commit();
        }
    }.execute();
    facet.updatePaths();
    BuildoutFacet.attachLibrary(module);
}
Also used : WriteAction(com.intellij.openapi.application.WriteAction) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) FacetManager(com.intellij.facet.FacetManager) ProjectFacetManager(com.intellij.facet.ProjectFacetManager) Result(com.intellij.openapi.application.Result)

Example 2 with FacetManager

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

the class PythonFrameworkSupportConfigurable method addSupport.

public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel model, @Nullable Library library) {
    final FacetManager facetManager = FacetManager.getInstance(module);
    ModifiableFacetModel facetModel = facetManager.createModifiableModel();
    PythonFacet facet = facetManager.createFacet(PythonFacetType.getInstance(), "Python", null);
    facet.getConfiguration().setSdk(mySdkComboBox.getSelectedSdk());
    facetModel.addFacet(facet);
    facetModel.commit();
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) FacetManager(com.intellij.facet.FacetManager)

Example 3 with FacetManager

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

the class AndroidUtils method addAndroidFacet.

@NotNull
public static AndroidFacet addAndroidFacet(final Module module, @NotNull VirtualFile contentRoot, boolean library) {
    final FacetManager facetManager = FacetManager.getInstance(module);
    ModifiableFacetModel model = facetManager.createModifiableModel();
    AndroidFacet facet = model.getFacetByType(AndroidFacet.ID);
    if (facet == null) {
        facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
        AndroidFacetConfiguration configuration = facet.getConfiguration();
        configuration.init(module, contentRoot);
        if (library) {
            facet.setProjectType(PROJECT_TYPE_LIBRARY);
        }
        model.addFacet(facet);
    }
    model.commit();
    return facet;
}
Also used : AndroidFacetConfiguration(org.jetbrains.android.facet.AndroidFacetConfiguration) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) ProjectFacetManager(com.intellij.facet.ProjectFacetManager) FacetManager(com.intellij.facet.FacetManager) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with FacetManager

use of com.intellij.facet.FacetManager 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 5 with FacetManager

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

the class KotlinAndroidTestCase method addAndroidFacet.

public AndroidFacet addAndroidFacet(Module module, String sdkPath, String platformDir, boolean addSdk) {
    FacetManager facetManager = FacetManager.getInstance(module);
    AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
    if (addSdk) {
        addAndroidSdk(module, sdkPath, platformDir);
    }
    final ModifiableFacetModel facetModel = facetManager.createModifiableModel();
    facetModel.addFacet(facet);
    ApplicationManager.getApplication().runWriteAction(new Runnable() {

        @Override
        public void run() {
            facetModel.commit();
        }
    });
    return facet;
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) 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