Search in sources :

Example 1 with MergingCommandLineArgumentsProvider

use of org.jetbrains.plugins.ruby.ruby.run.MergingCommandLineArgumentsProvider in project intellij-plugins by JetBrains.

the class RubyMotionUtilImpl method generateApp.

public void generateApp(final VirtualFile dir, final Module module, Sdk sdk, final ProjectType projectType) {
    final Project project = module.getProject();
    final String applicationHomePath = dir.getPath();
    final File tempDirectory;
    try {
        tempDirectory = FileUtil.createTempDirectory("RubyMotion", ".RubyMine");
    } catch (IOException e) {
        throw new Error(e);
    }
    final File generatedApp = new File(tempDirectory, module.getName());
    final Filter[] filters = null;
    final ProcessAdapter processListener = new ProcessAdapter() {

        public void processTerminated(ProcessEvent event) {
            FileUtil.moveDirWithContent(generatedApp, VfsUtilCore.virtualToIoFile(dir));
            tempDirectory.delete();
            if (module.isDisposed()) {
                return;
            }
            RModuleUtil.getInstance().refreshRubyModuleTypeContent(module);
            GeneratorsUtil.openFileInEditor(project, "app/app_delegate.rb", applicationHomePath);
            GeneratorsUtil.openFileInEditor(project, RakeUtilBase.RAKE_FILE, applicationHomePath);
            GeneratorsUtil.openFileInEditor(project, BundlerUtil.GEMFILE, applicationHomePath);
        }
    };
    final MergingCommandLineArgumentsProvider resultProvider = new MergingCommandLineArgumentsProvider(new String[] { getRubyMotionPath() + "/bin/motion", "create", "--template=" + projectType.name().toLowerCase(Locale.US), module.getName() }, null, null, null, sdk);
    ConsoleRunner.run(module, null, processListener, filters, null, ConsoleRunner.ProcessLaunchMode.BACKGROUND_TASK_WITH_PROGRESS, "Generating RubyMotion Application '" + module.getName() + "'...", tempDirectory.getAbsolutePath(), resultProvider, null, false);
}
Also used : Project(com.intellij.openapi.project.Project) MergingCommandLineArgumentsProvider(org.jetbrains.plugins.ruby.ruby.run.MergingCommandLineArgumentsProvider) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) Filter(com.intellij.execution.filters.Filter) ProcessEvent(com.intellij.execution.process.ProcessEvent) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) RFile(org.jetbrains.plugins.ruby.ruby.lang.psi.RFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Aggregations

Filter (com.intellij.execution.filters.Filter)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 File (java.io.File)1 IOException (java.io.IOException)1 RFile (org.jetbrains.plugins.ruby.ruby.lang.psi.RFile)1 MergingCommandLineArgumentsProvider (org.jetbrains.plugins.ruby.ruby.run.MergingCommandLineArgumentsProvider)1