Search in sources :

Example 1 with RemoteFlashRunConfiguration

use of com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration 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)

Example 2 with RemoteFlashRunConfiguration

use of com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration in project intellij-plugins by JetBrains.

the class FlexRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final BCBasedRunnerParameters parameters = ((RemoteFlashRunConfiguration) env.getRunProfile()).getRunnerParameters();
    RunContentDescriptor runContentDescriptor = XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
            try {
                return DebugPathManager.IS_DEV ? new MyFlexDebugProcessAbleToResolveFileDebugId(callback, session, buildConfiguration, parameters) : new MyFlexDebugProcess(callback, session, buildConfiguration, parameters);
            } catch (IOException e) {
                throw new ExecutionException(e.getMessage(), e);
            } finally {
                buildConfiguration = null;
            }
        }
    }).getRunContentDescriptor();
    ProcessHandler processHandler = runContentDescriptor.getProcessHandler();
    assert processHandler != null;
    //noinspection deprecation
    processHandler.putUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE, true);
    return runContentDescriptor;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) BCBasedRunnerParameters(com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) RemoteFlashRunConfiguration(com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration) ProcessHandler(com.intellij.execution.process.ProcessHandler) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ProcessHandler (com.intellij.execution.process.ProcessHandler)2 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)2 RemoteFlashRunConfiguration (com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration)2 ExecutionException (com.intellij.execution.ExecutionException)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 ProgramRunner (com.intellij.execution.runners.ProgramRunner)1 FlexRunner (com.intellij.flex.uiDesigner.debug.FlexRunner)1 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)1 BCBasedRunnerParameters (com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters)1 Disposable (com.intellij.openapi.Disposable)1 Project (com.intellij.openapi.project.Project)1 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 IOException (java.io.IOException)1 NotNull (org.jetbrains.annotations.NotNull)1