Search in sources :

Example 1 with FlashRunConfiguration

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

the class FlexTestUtils method createFlashRunConfig.

public static void createFlashRunConfig(final RunManager runManager, final Module module, final String configName, final String className, boolean generatedName) {
    final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(configName, FlashRunConfigurationType.getFactory());
    runManager.addConfiguration(settings, false);
    final FlashRunnerParameters params = ((FlashRunConfiguration) settings.getConfiguration()).getRunnerParameters();
    params.setModuleName(module.getName());
    params.setBCName(FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration().getName());
    params.setOverrideMainClass(true);
    params.setOverriddenMainClass(className);
    if (generatedName) {
        ((FlashRunConfiguration) settings.getConfiguration()).setGeneratedName();
    }
}
Also used : FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 2 with FlashRunConfiguration

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

the class FlexTestUtils method checkFlashRunConfig.

public static void checkFlashRunConfig(final RunManager runManager, final Module module, final String configName, final String className) {
    final List<RunnerAndConfigurationSettings> settings = runManager.getConfigurationSettingsList(FlashRunConfigurationType.getInstance());
    RunnerAndConfigurationSettings settingsToCheck = null;
    for (RunnerAndConfigurationSettings setting : settings) {
        if (configName.equals(setting.getName())) {
            settingsToCheck = setting;
            break;
        }
    }
    Assert.assertNotNull("Run configuration not found: " + configName, settingsToCheck);
    final FlashRunnerParameters params = ((FlashRunConfiguration) settingsToCheck.getConfiguration()).getRunnerParameters();
    Assert.assertEquals(className, params.getOverriddenMainClass());
    Assert.assertEquals(FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration().getName(), params.getBCName());
}
Also used : FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 3 with FlashRunConfiguration

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

the class FlexModuleBuilder method createRunConfiguration.

public static void createRunConfiguration(final Module module, final FlexBuildConfiguration bc) {
    final RunManager runManager = RunManagerEx.getInstance(module.getProject());
    final List<RunConfiguration> existingConfigurations = runManager.getConfigurationsList(FlashRunConfigurationType.getInstance());
    for (RunConfiguration configuration : existingConfigurations) {
        final FlashRunnerParameters parameters = ((FlashRunConfiguration) configuration).getRunnerParameters();
        if (module.getName().equals(parameters.getModuleName()) && bc.getName().equals(parameters.getBCName())) {
            //already exists
            return;
        }
    }
    final RunnerAndConfigurationSettings settings = runManager.createConfiguration("", FlashRunConfigurationType.getFactory());
    final FlashRunConfiguration runConfiguration = (FlashRunConfiguration) settings.getConfiguration();
    final FlashRunnerParameters params = runConfiguration.getRunnerParameters();
    params.setModuleName(module.getName());
    params.setBCName(bc.getName());
    if (bc.getNature().isMobilePlatform()) {
        if (bc.getAndroidPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.Android);
        } else if (bc.getIosPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.IOS);
        }
    }
    settings.setName(params.suggestUniqueName(existingConfigurations));
    settings.setTemporary(false);
    runManager.addConfiguration(settings, false);
    runManager.setSelectedConfiguration(settings);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManager(com.intellij.execution.RunManager) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 4 with FlashRunConfiguration

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

the class ValidateFlashConfigurationsPrecompileTask method getProblems.

static Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> getProblems(final CompileScope scope, final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile) {
    final Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> problems = new ArrayList<>();
    for (final Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCsToCompile) {
        final Module module = moduleAndBC.first;
        final FlexBuildConfiguration bc = moduleAndBC.second;
        final Consumer<FlashProjectStructureProblem> errorConsumer = problem -> problems.add(Trinity.create(module, bc, problem));
        checkConfiguration(module, bc, false, errorConsumer);
        final RunConfiguration runConfig = CompileStepBeforeRun.getRunConfiguration(scope);
        if (bc.getNature().isApp() && runConfig instanceof FlashRunConfiguration) {
            final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
            if (module.getName().equals(params.getModuleName()) && bc.getName().equals(params.getBCName())) {
                if (bc.getNature().isDesktopPlatform()) {
                    FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAirDesktopPackagingOptions(), errorConsumer, false, "does not matter");
                } else if (bc.getNature().isMobilePlatform()) {
                    switch(params.getMobileRunTarget()) {
                        case Emulator:
                            switch(params.getAppDescriptorForEmulator()) {
                                case Android:
                                    FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAndroidPackagingOptions(), errorConsumer, false, "does not matter");
                                    break;
                                case IOS:
                                    FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getIosPackagingOptions(), errorConsumer, false, "does not matter");
                                    break;
                            }
                            break;
                        case AndroidDevice:
                            checkPackagingOptions(module, bc.getSdk(), bc.getAndroidPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
                            break;
                        case iOSSimulator:
                            checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), true, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
                            break;
                        case iOSDevice:
                            checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
                            break;
                    }
                }
            }
        }
    }
    checkSimilarOutputFiles(modulesAndBCsToCompile, trinity -> problems.add(trinity));
    return problems;
}
Also used : Trinity(com.intellij.openapi.util.Trinity) HyperlinkEvent(javax.swing.event.HyperlinkEvent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet) THashMap(gnu.trove.THashMap) TargetPlatform(com.intellij.flex.model.bc.TargetPlatform) ReadAction(com.intellij.openapi.application.ReadAction) FlexCommonUtils(com.intellij.flex.FlexCommonUtils) BCUtils(com.intellij.lang.javascript.flex.projectStructure.options.BCUtils) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType) Map(java.util.Map) FileUtil(com.intellij.openapi.util.io.FileUtil) Module(com.intellij.openapi.module.Module) ProjectStructureProblemType(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemType) FlexBuildConfigurationsExtension(com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension) com.intellij.openapi.compiler(com.intellij.openapi.compiler) Collection(java.util.Collection) Set(java.util.Set) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) NotificationListener(com.intellij.notification.NotificationListener) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) NotificationType(com.intellij.notification.NotificationType) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) CompilerWorkspaceConfiguration(com.intellij.compiler.CompilerWorkspaceConfiguration) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) FlexUtils(com.intellij.lang.javascript.flex.FlexUtils) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) OutputType(com.intellij.flex.model.bc.OutputType) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) CompileStepBeforeRun(com.intellij.compiler.options.CompileStepBeforeRun) ArrayList(java.util.ArrayList) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) com.intellij.lang.javascript.flex.projectStructure.ui(com.intellij.lang.javascript.flex.projectStructure.ui) Project(com.intellij.openapi.project.Project) FlexSdkUtils(com.intellij.lang.javascript.flex.sdk.FlexSdkUtils) FlexCommonBundle(com.intellij.flex.FlexCommonBundle) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) com.intellij.lang.javascript.flex.projectStructure.model(com.intellij.lang.javascript.flex.projectStructure.model) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters) Sdk(com.intellij.openapi.projectRoots.Sdk) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) Place(com.intellij.ui.navigation.Place) Pair(com.intellij.openapi.util.Pair) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) Navigatable(com.intellij.pom.Navigatable) PathUtil(com.intellij.util.PathUtil) Trinity(com.intellij.openapi.util.Trinity) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) ArrayList(java.util.ArrayList) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 5 with FlashRunConfiguration

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

the class FlexBuildTargetScopeProvider method getBuildTargetScopes.

@NotNull
public List<TargetTypeBuildScope> getBuildTargetScopes(@NotNull final CompileScope baseScope, @NotNull final CompilerFilter filter, @NotNull final Project project, boolean forceBuild) {
    final RunConfiguration runConfiguration = CompileStepBeforeRun.getRunConfiguration(baseScope);
    final Collection<Pair<Module, FlexBuildConfiguration>> bcsToCompileForPackaging = FlexResourceBuildTargetScopeProvider.getBCsToCompileForPackaging(baseScope);
    List<String> targetIds = new ArrayList<>();
    try {
        for (Pair<Module, FlexBuildConfiguration> moduleAndBC : getModulesAndBCsToCompile(baseScope)) {
            final Module module = moduleAndBC.first;
            final FlexBuildConfiguration bc = moduleAndBC.second;
            if (bcsToCompileForPackaging != null && contains(bcsToCompileForPackaging, module, bc)) {
                final boolean forcedDebugStatus = getForcedDebugStatus(project, bc);
                targetIds.add(FlexCommonUtils.getBuildTargetId(module.getName(), bc.getName(), forcedDebugStatus));
            } else if (bc.isTempBCForCompilation()) {
                LOG.assertTrue(runConfiguration instanceof FlashRunConfiguration || runConfiguration instanceof FlexUnitRunConfiguration, bc.getName());
                final BCBasedRunnerParameters params = runConfiguration instanceof FlashRunConfiguration ? ((FlashRunConfiguration) runConfiguration).getRunnerParameters() : ((FlexUnitRunConfiguration) runConfiguration).getRunnerParameters();
                LOG.assertTrue(params.getModuleName().equals(module.getName()), "Module name in run config: " + params.getModuleName() + ", expected: " + module.getName());
                LOG.assertTrue(params.getBCName().equals(bc.getName()), "BC name in run config: " + params.getBCName() + ", expected: " + bc.getName());
                targetIds.add(FlexCommonUtils.getBuildTargetIdForRunConfig(runConfiguration.getType().getId(), runConfiguration.getName()));
            } else {
                targetIds.add(FlexCommonUtils.getBuildTargetId(module.getName(), bc.getName(), null));
            }
        }
    } catch (ConfigurationException e) {
        // can't happen because checked in ValidateFlashConfigurationsPrecompileTask
        LOG.error(e);
    }
    if (targetIds.isEmpty()) {
        return Collections.emptyList();
    }
    return Collections.singletonList(CmdlineProtoUtil.createTargetsScope(FlexBuildTargetType.INSTANCE.getTypeId(), targetIds, forceBuild));
}
Also used : BCBasedRunnerParameters(com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)6 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)4 FlashRunnerParameters (com.intellij.lang.javascript.flex.run.FlashRunnerParameters)4 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 Module (com.intellij.openapi.module.Module)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 Pair (com.intellij.openapi.util.Pair)3 FlexUnitRunConfiguration (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration)2 BCBasedRunnerParameters (com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters)2 NotNull (org.jetbrains.annotations.NotNull)2 CompilerWorkspaceConfiguration (com.intellij.compiler.CompilerWorkspaceConfiguration)1 CompileStepBeforeRun (com.intellij.compiler.options.CompileStepBeforeRun)1 RunManager (com.intellij.execution.RunManager)1 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 FlexCommonBundle (com.intellij.flex.FlexCommonBundle)1 FlexCommonUtils (com.intellij.flex.FlexCommonUtils)1 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)1 OutputType (com.intellij.flex.model.bc.OutputType)1 TargetPlatform (com.intellij.flex.model.bc.TargetPlatform)1