Search in sources :

Example 16 with FacetManager

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

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

the class AbstractAndroidQuickFixMultiFileTest method addAndroidFacet.

private void addAndroidFacet() {
    FacetManager facetManager = FacetManager.getInstance(myModule);
    AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), "Android", null);
    final ModifiableFacetModel facetModel = facetManager.createModifiableModel();
    facetModel.addFacet(facet);
    ApplicationManager.getApplication().runWriteAction(new Runnable() {

        @Override
        public void run() {
            facetModel.commit();
        }
    });
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) FacetManager(com.intellij.facet.FacetManager) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 18 with FacetManager

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

Example 19 with FacetManager

use of com.intellij.facet.FacetManager in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineUtil method createModuleDeploymentSources.

/**
 * Creates a list of module deployment sources available for deployment to App Engine:
 *
 * <p>Maven based deployment sources are included for both flexible and standard projects if
 * applicable.
 *
 * <p>User browsable jar/war deployment sources are included only if there are no App Engine
 * standard modules.
 *
 * @return a list of {@link ModuleDeploymentSource}'s
 */
public static List<ModuleDeploymentSource> createModuleDeploymentSources(@NotNull Project project) {
    AppEngineProjectService projectService = AppEngineProjectService.getInstance();
    List<ModuleDeploymentSource> moduleDeploymentSources = Lists.newArrayList();
    boolean hasStandardModules = false;
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        FacetManager facetManager = FacetManager.getInstance(module);
        if (facetManager.getFacetByType(AppEngineStandardFacetType.ID) != null || facetManager.getFacetByType(AppEngineFlexibleFacetType.ID) != null) {
            AppEngineEnvironment environment = projectService.getModuleAppEngineEnvironment(module).orElseThrow(() -> new RuntimeException("No environment."));
            if (ModuleType.is(module, JavaModuleType.getModuleType()) && projectService.isJarOrWarMavenBuild(module)) {
                moduleDeploymentSources.add(createMavenBuildDeploymentSource(project, module, environment));
            }
            if (environment.isStandard() || environment.isFlexCompat()) {
                hasStandardModules = true;
            }
        }
    }
    if (!hasStandardModules) {
        moduleDeploymentSources.add(createUserSpecifiedPathDeploymentSource(project));
    }
    return moduleDeploymentSources;
}
Also used : ModuleDeploymentSource(com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource) AppEngineProjectService(com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService) AppEngineEnvironment(com.google.cloud.tools.intellij.appengine.cloud.AppEngineEnvironment) Module(com.intellij.openapi.module.Module) FacetManager(com.intellij.facet.FacetManager)

Example 20 with FacetManager

use of com.intellij.facet.FacetManager in project intellij by bazelbuild.

the class BlazePythonSyncPlugin method removeFacet.

private static void removeFacet(Module workspaceModule) {
    FacetManager manager = FacetManager.getInstance(workspaceModule);
    ModifiableFacetModel facetModel = manager.createModifiableModel();
    LibraryContributingFacet<?> facet = manager.findFacet(PythonFacetUtil.getFacetId(), "Python");
    if (facet != null) {
        facetModel.removeFacet(facet);
        facetModel.commit();
    }
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) FacetManager(com.intellij.facet.FacetManager)

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