Search in sources :

Example 1 with FlexRunner

use of com.intellij.flex.uiDesigner.debug.FlexRunner in project intellij-plugins by JetBrains.

the class AdlUtil method runDebugger.

// http://kb2.adobe.com/cps/407/kb407625.html
public static void runDebugger(final Module module, final Runnable postTask) throws ExecutionException {
    final Project project = module.getProject();
    final RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createConfiguration("FlashUIDesigner", RemoteFlashRunConfigurationType.getFactory());
    final RemoteFlashRunConfiguration configuration = (RemoteFlashRunConfiguration) settings.getConfiguration();
    RunManagerEx.disableTasks(project, settings.getConfiguration(), CompileStepBeforeRun.ID, CompileStepBeforeRunNoErrorCheck.ID);
    final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
    ProgramRunner.Callback callback = new ProgramRunner.Callback() {

        @Override
        public void processStarted(final RunContentDescriptor descriptor) {
            final ProcessHandler processHandler = descriptor.getProcessHandler();
            assert processHandler != null;
            DesignerApplication application = DesignerApplicationManager.getApplication();
            if (application != null) {
                Disposer.register(application, new Disposable() {

                    @Override
                    public void dispose() {
                        if (!project.isDisposed()) {
                            ApplicationManager.getApplication().invokeLater(() -> ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, descriptor));
                        }
                        processHandler.destroyProcess();
                    }
                });
                postTask.run();
            }
        }
    };
    FlexBuildConfiguration buildConfiguration = FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration();
    configuration.getRunnerParameters().setModuleName(module.getName());
    configuration.getRunnerParameters().setBCName(buildConfiguration.getName());
    final FlexRunner runner = new FlexRunner(callback, buildConfiguration);
    runner.execute(new ExecutionEnvironment(executor, runner, settings, project));
}
Also used : Disposable(com.intellij.openapi.Disposable) FlexRunner(com.intellij.flex.uiDesigner.debug.FlexRunner) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Project(com.intellij.openapi.project.Project) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) RemoteFlashRunConfiguration(com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Aggregations

DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 ProgramRunner (com.intellij.execution.runners.ProgramRunner)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 FlexRunner (com.intellij.flex.uiDesigner.debug.FlexRunner)1 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)1 RemoteFlashRunConfiguration (com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration)1 Disposable (com.intellij.openapi.Disposable)1 Project (com.intellij.openapi.project.Project)1