Search in sources :

Example 1 with RubyMotionFacetConfiguration

use of org.jetbrains.plugins.ruby.motion.facet.RubyMotionFacetConfiguration 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

FacetManager (com.intellij.facet.FacetManager)1 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)1 ProjectFacetManager (com.intellij.facet.ProjectFacetManager)1 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ActionRunner (com.intellij.util.ActionRunner)1 RubyMotionFacet (org.jetbrains.plugins.ruby.motion.facet.RubyMotionFacet)1 RubyMotionFacetConfiguration (org.jetbrains.plugins.ruby.motion.facet.RubyMotionFacetConfiguration)1 RubyMotionFacetType (org.jetbrains.plugins.ruby.motion.facet.RubyMotionFacetType)1