Search in sources :

Example 1 with DeviceInfo

use of com.intellij.lang.javascript.flex.actions.airpackage.DeviceInfo in project intellij-plugins by JetBrains.

the class FlexDebugRunner method launchFlexConfig.

protected RunContentDescriptor launchFlexConfig(final Module module, final FlexBuildConfiguration bc, final FlashRunnerParameters runnerParameters, final RunProfileState state, final RunContentDescriptor contentToReuse, final ExecutionEnvironment env) throws ExecutionException {
    final Project project = module.getProject();
    if (bc.getTargetPlatform() == TargetPlatform.Mobile) {
        final Sdk sdk = bc.getSdk();
        switch(runnerParameters.getMobileRunTarget()) {
            case Emulator:
                break;
            case AndroidDevice:
                final String androidDescriptorPath = getAirDescriptorPath(bc, bc.getAndroidPackagingOptions());
                final String androidAppId = getApplicationId(androidDescriptorPath);
                if (androidAppId == null) {
                    Messages.showErrorDialog(project, FlexBundle.message("failed.to.read.app.id", FileUtil.toSystemDependentName(androidDescriptorPath)), FlexBundle.message("error.title"));
                    return null;
                }
                if (!packAndInstallToAndroidDevice(module, bc, runnerParameters, androidAppId, true)) {
                    return null;
                }
                if (runnerParameters.getDebugTransport() == AirMobileDebugTransport.USB) {
                    if (!AirPackageUtil.androidForwardTcpPort(project, sdk, runnerParameters.getDeviceInfo(), runnerParameters.getUsbDebugPort())) {
                        return null;
                    }
                }
                break;
            case iOSSimulator:
                final String adtVersionSimulator = AirPackageUtil.getAdtVersion(module.getProject(), bc.getSdk());
                final String iosSimulatorDescriptorPath = getAirDescriptorPath(bc, bc.getIosPackagingOptions());
                final String iosSimulatorAppId = getApplicationId(iosSimulatorDescriptorPath);
                if (iosSimulatorAppId == null) {
                    Messages.showErrorDialog(project, FlexBundle.message("failed.to.read.app.id", FileUtil.toSystemDependentName(iosSimulatorDescriptorPath)), FlexBundle.message("error.title"));
                    return null;
                }
                if (!packAndInstallToIOSSimulator(module, bc, runnerParameters, adtVersionSimulator, iosSimulatorAppId, true)) {
                    return null;
                }
                break;
            case iOSDevice:
                final String adtVersion = AirPackageUtil.getAdtVersion(module.getProject(), bc.getSdk());
                if (StringUtil.compareVersionNumbers(adtVersion, "3.4") >= 0) {
                    if (!packAndInstallToIOSDevice(module, bc, runnerParameters, adtVersion, true)) {
                        return null;
                    }
                    if (runnerParameters.getDebugTransport() == AirMobileDebugTransport.USB) {
                        final DeviceInfo device = runnerParameters.getDeviceInfo();
                        final int deviceHandle = device == null ? -1 : device.IOS_HANDLE;
                        if (deviceHandle < 0) {
                            return null;
                        }
                        if (!AirPackageUtil.iosForwardTcpPort(project, sdk, runnerParameters.getUsbDebugPort(), deviceHandle)) {
                            return null;
                        }
                    }
                } else {
                    if (!AirPackageUtil.packageIpaForDevice(module, bc, runnerParameters, adtVersion, true)) {
                        return null;
                    }
                }
                break;
        }
    }
    return launchDebugProcess(module, bc, runnerParameters, env);
}
Also used : Project(com.intellij.openapi.project.Project) DeviceInfo(com.intellij.lang.javascript.flex.actions.airpackage.DeviceInfo) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 2 with DeviceInfo

use of com.intellij.lang.javascript.flex.actions.airpackage.DeviceInfo in project intellij-plugins by JetBrains.

the class FlexBaseRunner method doExecute.

@Override
@Nullable
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    final RunProfile runProfile = env.getRunProfile();
    final boolean isDebug = this instanceof FlexDebugRunner;
    try {
        if (runProfile instanceof RunProfileWithCompileBeforeLaunchOption) {
            checkMakeBeforeRunEnabled(env.getProject(), runProfile);
        }
        if (runProfile instanceof RemoteFlashRunConfiguration) {
            final RemoteFlashRunnerParameters params = ((RemoteFlashRunConfiguration) runProfile).getRunnerParameters();
            final Pair<Module, FlexBuildConfiguration> moduleAndBC = params.checkAndGetModuleAndBC(env.getProject());
            if (params.getDebugTransport() == FlashRunnerParameters.AirMobileDebugTransport.USB) {
                final Sdk sdk = moduleAndBC.second.getSdk();
                assert sdk != null;
                if (params.getRemoteDebugTarget() == RemoteDebugTarget.AndroidDevice) {
                    if (!AirPackageUtil.startAdbServer(env.getProject(), sdk) || !AirPackageUtil.scanAndroidDevices(env.getProject(), sdk, params) || !AirPackageUtil.androidForwardTcpPort(env.getProject(), sdk, params.getDeviceInfo(), params.getUsbDebugPort())) {
                        return null;
                    }
                } else if (params.getRemoteDebugTarget() == RemoteDebugTarget.iOSDevice) {
                    final String adtVersion = AirPackageUtil.getAdtVersion(env.getProject(), sdk);
                    if (!AirPackageUtil.checkAdtVersionForPackaging(env.getProject(), adtVersion, "3.4", sdk.getName(), FlexBundle.message("air.ios.debug.via.usb.requires.3.4"))) {
                        return null;
                    }
                    if (!AirPackageUtil.scanIosDevices(env.getProject(), sdk, params)) {
                        return null;
                    }
                    final DeviceInfo device = params.getDeviceInfo();
                    final int deviceHandle = device == null ? -1 : device.IOS_HANDLE;
                    if (deviceHandle < 0) {
                        return null;
                    }
                    if (!AirPackageUtil.iosForwardTcpPort(env.getProject(), sdk, params.getUsbDebugPort(), deviceHandle)) {
                        return null;
                    }
                }
            }
            return launchDebugProcess(moduleAndBC.first, moduleAndBC.second, params, env);
        }
        if (runProfile instanceof FlexUnitRunConfiguration) {
            final FlexUnitRunnerParameters params = ((FlexUnitRunConfiguration) runProfile).getRunnerParameters();
            final Pair<Module, FlexBuildConfiguration> moduleAndConfig = params.checkAndGetModuleAndBC(env.getProject());
            final Module module = moduleAndConfig.first;
            final FlexBuildConfiguration bc = moduleAndConfig.second;
            if (bc.getTargetPlatform() == TargetPlatform.Web) {
                FlashPlayerTrustUtil.updateTrustedStatus(module, bc, isDebug, params.isTrusted());
                return launchWebFlexUnit(env.getProject(), env.getContentToReuse(), env, params, bc.getActualOutputFilePath());
            } else {
                return launchAirFlexUnit(env.getProject(), state, env.getContentToReuse(), env, params);
            }
        }
        if (runProfile instanceof FlashRunConfiguration) {
            final FlashRunnerParameters params = ((FlashRunConfiguration) runProfile).getRunnerParameters();
            params.setDeviceInfo(null);
            final Pair<Module, FlexBuildConfiguration> moduleAndConfig = params.checkAndGetModuleAndBC(env.getProject());
            final Module module = moduleAndConfig.first;
            final FlexBuildConfiguration bc = moduleAndConfig.second;
            if (bc.isSkipCompile()) {
                showBCCompilationSkippedWarning(module, bc);
            }
            if (isDebug && SystemInfo.isMac && bc.getTargetPlatform() == TargetPlatform.Web) {
                checkDebuggerFromSdk4(env.getProject(), runProfile, params, bc);
            }
            if (bc.getTargetPlatform() == TargetPlatform.Web && !params.isLaunchUrl()) {
                FlashPlayerTrustUtil.updateTrustedStatus(module, bc, isDebug, params.isRunTrusted());
            }
            return launchFlexConfig(module, bc, params, state, env.getContentToReuse(), env);
        }
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e.getMessage());
    }
    return null;
}
Also used : FlexDebugRunner(com.intellij.lang.javascript.flex.debug.FlexDebugRunner) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) DeviceInfo(com.intellij.lang.javascript.flex.actions.airpackage.DeviceInfo) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DeviceInfo (com.intellij.lang.javascript.flex.actions.airpackage.DeviceInfo)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 FlexDebugRunner (com.intellij.lang.javascript.flex.debug.FlexDebugRunner)1 FlexUnitRunConfiguration (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration)1 FlexUnitRunnerParameters (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters)1 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 Nullable (org.jetbrains.annotations.Nullable)1