Search in sources :

Example 1 with SwfPolicyFileConnection

use of com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection in project intellij-plugins by JetBrains.

the class FlexRunner method launchWebFlexUnit.

protected RunContentDescriptor launchWebFlexUnit(final Project project, final RunContentDescriptor contentToReuse, final ExecutionEnvironment env, final FlexUnitRunnerParameters params, final String swfFilePath) throws ExecutionException {
    final SwfPolicyFileConnection policyFileConnection = new SwfPolicyFileConnection();
    policyFileConnection.open(params.getSocketPolicyPort());
    final FlexUnitConnection flexUnitConnection = new FlexUnitConnection();
    flexUnitConnection.open(params.getPort());
    final ProcessHandler processHandler = new DefaultDebugProcessHandler() {

        @Override
        protected void destroyProcessImpl() {
            flexUnitConnection.write("Finish");
            flexUnitConnection.close();
            policyFileConnection.close();
            super.destroyProcessImpl();
        }

        @Override
        public boolean detachIsDefault() {
            return false;
        }
    };
    final ExecutionConsole console = createFlexUnitRunnerConsole(project, env, processHandler);
    flexUnitConnection.addListener(new FlexUnitListener(processHandler));
    launchWithSelectedApplication(swfFilePath, params.getLauncherParameters());
    final RunContentBuilder contentBuilder = new RunContentBuilder(new DefaultExecutionResult(console, processHandler), env);
    Disposer.register(project, contentBuilder);
    return contentBuilder.showRunContent(contentToReuse);
}
Also used : SwfPolicyFileConnection(com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection) FlexUnitConnection(com.intellij.lang.javascript.flex.flexunit.FlexUnitConnection) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) DefaultDebugProcessHandler(com.intellij.xdebugger.DefaultDebugProcessHandler) DefaultDebugProcessHandler(com.intellij.xdebugger.DefaultDebugProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder)

Example 2 with SwfPolicyFileConnection

use of com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection in project intellij-plugins by JetBrains.

the class FlexDebugProcess method openFlexUnitConnections.

private void openFlexUnitConnections(final int socketPolicyPort, final int port) {
    try {
        myPolicyFileConnection = new SwfPolicyFileConnection();
        myPolicyFileConnection.open(socketPolicyPort);
        myFlexUnitConnection = new FlexUnitConnection();
        myFlexUnitConnection.addListener(new FlexUnitConnection.Listener() {

            @Override
            public void statusChanged(FlexUnitConnection.ConnectionStatus status) {
                if (status == FlexUnitConnection.ConnectionStatus.CONNECTION_FAILED) {
                    getSession().stop();
                }
            }

            @Override
            public void onData(String line) {
                getProcessHandler().notifyTextAvailable(line + "\n", ProcessOutputTypes.STDOUT);
            }

            @Override
            public void onFinish() {
                getProcessHandler().detachProcess();
            }
        });
        myFlexUnitConnection.open(port);
    } catch (ExecutionException e) {
        Notifications.Bus.notify(new Notification(DEBUGGER_GROUP_ID, FlexBundle.message("flex.debugger.startup.error"), FlexBundle.message("flexunit.startup.error", e.getMessage()), NotificationType.ERROR), getSession().getProject());
        myFlexUnitConnection = null;
        myPolicyFileConnection = null;
    }
}
Also used : SwfPolicyFileConnection(com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection) FlexUnitConnection(com.intellij.lang.javascript.flex.flexunit.FlexUnitConnection) ExecutionException(com.intellij.execution.ExecutionException) Notification(com.intellij.notification.Notification)

Example 3 with SwfPolicyFileConnection

use of com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection in project intellij-plugins by JetBrains.

the class FlexRunner method launchAirFlexUnit.

@Nullable
protected RunContentDescriptor launchAirFlexUnit(final Project project, final RunProfileState state, final RunContentDescriptor contentToReuse, final ExecutionEnvironment env, final FlexUnitRunnerParameters params) throws ExecutionException {
    final ExecutionResult executionResult;
    final SwfPolicyFileConnection policyFileConnection = new SwfPolicyFileConnection();
    policyFileConnection.open(params.getSocketPolicyPort());
    final FlexUnitConnection flexUnitConnection = new FlexUnitConnection();
    flexUnitConnection.open(params.getPort());
    executionResult = state.execute(env.getExecutor(), this);
    if (executionResult == null) {
        flexUnitConnection.close();
        policyFileConnection.close();
        return null;
    }
    flexUnitConnection.addListener(new FlexUnitListener(executionResult.getProcessHandler()));
    executionResult.getProcessHandler().addProcessListener(new ProcessAdapter() {

        @Override
        public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
            flexUnitConnection.write("Finish");
        }

        @Override
        public void processTerminated(ProcessEvent event) {
            flexUnitConnection.close();
            policyFileConnection.close();
        }
    });
    final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
    return contentBuilder.showRunContent(contentToReuse);
}
Also used : SwfPolicyFileConnection(com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection) FlexUnitConnection(com.intellij.lang.javascript.flex.flexunit.FlexUnitConnection) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ExecutionResult(com.intellij.execution.ExecutionResult) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FlexUnitConnection (com.intellij.lang.javascript.flex.flexunit.FlexUnitConnection)3 SwfPolicyFileConnection (com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection)3 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)2 RunContentBuilder (com.intellij.execution.runners.RunContentBuilder)2 ExecutionException (com.intellij.execution.ExecutionException)1 ExecutionResult (com.intellij.execution.ExecutionResult)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)1 Notification (com.intellij.notification.Notification)1 DefaultDebugProcessHandler (com.intellij.xdebugger.DefaultDebugProcessHandler)1 Nullable (org.jetbrains.annotations.Nullable)1