Search in sources :

Example 46 with FlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlexBuildTargetScopeProvider method getModulesAndBCsToCompile.

static Collection<Pair<Module, FlexBuildConfiguration>> getModulesAndBCsToCompile(final CompileScope scope) throws ConfigurationException {
    final Collection<Pair<Module, FlexBuildConfiguration>> result = new HashSet<>();
    final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile = FlexResourceBuildTargetScopeProvider.getBCsToCompileForPackaging(scope);
    final RunConfiguration runConfiguration = CompileStepBeforeRun.getRunConfiguration(scope);
    if (modulesAndBCsToCompile != null) {
        for (Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCsToCompile) {
            if (!moduleAndBC.second.isSkipCompile()) {
                final FlexBuildConfiguration bcWithForcedDebugStatus = forceDebugStatus(moduleAndBC.first.getProject(), moduleAndBC.second);
                result.add(Pair.create(moduleAndBC.first, bcWithForcedDebugStatus));
                appendBCDependencies(result, moduleAndBC.first, moduleAndBC.second);
            }
        }
    } else if (runConfiguration instanceof FlashRunConfiguration || runConfiguration instanceof FlexUnitRunConfiguration) {
        final BCBasedRunnerParameters params = runConfiguration instanceof FlashRunConfiguration ? ((FlashRunConfiguration) runConfiguration).getRunnerParameters() : ((FlexUnitRunConfiguration) runConfiguration).getRunnerParameters();
        final Pair<Module, FlexBuildConfiguration> moduleAndBC;
        final Ref<RuntimeConfigurationError> exceptionRef = new Ref<>();
        moduleAndBC = ApplicationManager.getApplication().runReadAction((NullableComputable<Pair<Module, FlexBuildConfiguration>>) () -> {
            try {
                return params.checkAndGetModuleAndBC(runConfiguration.getProject());
            } catch (RuntimeConfigurationError e) {
                exceptionRef.set(e);
                return null;
            }
        });
        if (!exceptionRef.isNull()) {
            throw new ConfigurationException(exceptionRef.get().getMessage(), FlexBundle.message("run.configuration.0", runConfiguration.getName()));
        }
        if (!moduleAndBC.second.isSkipCompile()) {
            result.add(moduleAndBC);
            appendBCDependencies(result, moduleAndBC.first, moduleAndBC.second);
        }
    } else {
        for (final Module module : scope.getAffectedModules()) {
            if (module.isDisposed() || ModuleType.get(module) != FlexModuleType.getInstance())
                continue;
            for (final FlexBuildConfiguration bc : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
                if (!bc.isSkipCompile()) {
                    result.add(Pair.create(module, bc));
                }
            }
        }
    }
    return result;
}
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) Ref(com.intellij.openapi.util.Ref) 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) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Pair(com.intellij.openapi.util.Pair)

Example 47 with FlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.

the class CompilerConfigGenerator method getOrCreateConfigFile.

public static VirtualFile getOrCreateConfigFile(final Module module, final FlexBuildConfiguration bc) throws IOException {
    final CompilerConfigGenerator generator = new CompilerConfigGenerator(module, bc, FlexBuildConfigurationManager.getInstance(module).getModuleLevelCompilerOptions(), FlexProjectLevelCompilerOptionsHolder.getInstance(module.getProject()).getProjectLevelCompilerOptions());
    String text = generator.generateConfigFileText();
    if (bc.isTempBCForCompilation()) {
        final FlexBuildConfiguration originalBC = FlexBuildConfigurationManager.getInstance(module).findConfigurationByName(bc.getName());
        final boolean makeExternalLibsMerged = BCUtils.isFlexUnitBC(bc) || (originalBC != null && originalBC.getOutputType() == OutputType.Library);
        final boolean makeIncludedLibsMerged = BCUtils.isRuntimeStyleSheetBC(bc);
        text = FlexCompilerConfigFileUtilBase.mergeWithCustomConfigFile(text, bc.getCompilerOptions().getAdditionalConfigFilePath(), makeExternalLibsMerged, makeIncludedLibsMerged);
    }
    final String name = getConfigFileName(module, bc.getName(), PlatformUtils.getPlatformPrefix().toLowerCase(), BCUtils.getBCSpecifier(bc));
    return getOrCreateConfigFile(name, text);
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)

Example 48 with FlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlashRunConfigurationForm method applyEditorTo.

@Override
protected void applyEditorTo(@NotNull final FlashRunConfiguration configuration) throws ConfigurationException {
    final FlashRunnerParameters params = configuration.getRunnerParameters();
    myBCCombo.applyTo(params);
    final boolean overrideMainClass = myOverrideMainClassCheckBox.isSelected();
    params.setOverrideMainClass(overrideMainClass);
    params.setOverriddenMainClass(overrideMainClass ? myMainClassComponent.getText().trim() : "");
    params.setOverriddenOutputFileName(overrideMainClass ? myOutputFileNameTextField.getText().trim() : "");
    params.setLaunchUrl(myUrlOrFileRadioButton.isSelected());
    final String url = myUrlOrFileTextWithBrowse.getText().trim();
    final boolean windowsLocalFile = SystemInfo.isWindows && url.length() >= 2 && Character.isLetter(url.charAt(0)) && ':' == url.charAt(1);
    params.setUrl(windowsLocalFile ? FileUtil.toSystemIndependentName(url) : url);
    params.setLauncherParameters(myLauncherParameters);
    params.setRunTrusted(myRunTrustedCheckBox.isSelected());
    params.setAdlOptions(myAdlOptionsEditor.getText().trim());
    params.setAirProgramParameters(myAirProgramParametersEditor.getText().trim());
    final AirMobileRunTarget mobileRunTarget = myOnEmulatorRadioButton.isSelected() ? AirMobileRunTarget.Emulator : myOnAndroidDeviceRadioButton.isSelected() ? AirMobileRunTarget.AndroidDevice : myOnIOSSimulatorRadioButton.isSelected() ? AirMobileRunTarget.iOSSimulator : AirMobileRunTarget.iOSDevice;
    params.setMobileRunTarget(mobileRunTarget);
    final Emulator emulator = (Emulator) myEmulatorCombo.getSelectedItem();
    params.setEmulator(emulator);
    if (emulator.adlAlias == null) {
        try {
            params.setScreenWidth(Integer.parseInt(myScreenWidth.getText().trim()));
            params.setScreenHeight(Integer.parseInt(myScreenHeight.getText().trim()));
            params.setFullScreenWidth(Integer.parseInt(myFullScreenWidth.getText().trim()));
            params.setFullScreenHeight(Integer.parseInt(myFullScreenHeight.getText().trim()));
        } catch (NumberFormatException e) {
        /**/
        }
        try {
            params.setScreenDpi(Integer.parseInt(myScreenDpi.getText().trim()));
        } catch (NumberFormatException e) {
            params.setScreenDpi(0);
        }
    }
    final FlexBuildConfiguration bc = myBCCombo.getBC();
    if (SystemInfo.isMac && bc != null && bc.getTargetPlatform() == TargetPlatform.Mobile && myOnIOSSimulatorRadioButton.isSelected()) {
        final String path = FileUtil.toSystemIndependentName(myIOSSimulatorSdkTextWithBrowse.getText().trim());
        if (!path.isEmpty()) {
            PropertiesComponent.getInstance().setValue(LATEST_SELECTED_IOS_SIMULATOR_SDK_PATH_KEY, path);
        }
    }
    params.setIOSSimulatorSdkPath(FileUtil.toSystemIndependentName(myIOSSimulatorSdkTextWithBrowse.getText().trim()));
    params.setFastPackaging(myFastPackagingCheckBox.isSelected());
    params.setDebugTransport(myDebugOverNetworkRadioButton.isSelected() ? AirMobileDebugTransport.Network : AirMobileDebugTransport.USB);
    try {
        final int port = Integer.parseInt(myUsbDebugPortTextField.getText().trim());
        if (port > 0 && port < 65535) {
            params.setUsbDebugPort(port);
        }
    } catch (NumberFormatException ignore) {
    /*ignore*/
    }
    params.setEmulatorAdlOptions(myEmulatorAdlOptionsEditor.getText().trim());
    params.setAppDescriptorForEmulator((AppDescriptorForEmulator) myAppDescriptorForEmulatorCombo.getSelectedItem());
    params.setDebuggerSdkRaw(mySdkForDebuggingCombo.getSelectedSdkRaw());
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 49 with FlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlashRunConfigurationProducer method findSuitableRunConfig.

@Nullable
private static RunConfiguration findSuitableRunConfig(final Module module, final String fqn, final List<RunConfiguration> existing) {
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
    RunConfiguration basedOnBC = null;
    RunConfiguration basedOnMainClass = null;
    RunConfiguration basedOnMainClassAndActiveBC = null;
    for (final RunConfiguration runConfig : existing) {
        final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
        if (module.getName().equals(params.getModuleName())) {
            final FlexBuildConfiguration bc = manager.findConfigurationByName(params.getBCName());
            if (bc == null)
                continue;
            if (params.isOverrideMainClass()) {
                if (fqn.equals(params.getOverriddenMainClass())) {
                    if (manager.getActiveConfiguration() == bc) {
                        basedOnMainClassAndActiveBC = runConfig;
                    }
                    basedOnMainClass = runConfig;
                }
            } else {
                if (bc.getOutputType() == OutputType.Application && fqn.equals(bc.getMainClass())) {
                    if (manager.getActiveConfiguration() == bc) {
                        // the best choice
                        return runConfig;
                    }
                    basedOnBC = runConfig;
                }
            }
        }
    }
    // forth - based on overridden main class and any bc
    return basedOnBC != null ? basedOnBC : basedOnMainClassAndActiveBC != null ? basedOnMainClassAndActiveBC : basedOnMainClass;
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 50 with FlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlashRunConfigurationProducer method getBCToBaseOn.

private static FlexBuildConfiguration getBCToBaseOn(final Module module, final String fqn) {
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
    FlexBuildConfiguration appWithSuitableMainClass = null;
    for (FlexBuildConfiguration bc : manager.getBuildConfigurations()) {
        if (bc.getOutputType() == OutputType.Application && fqn.equals(bc.getMainClass())) {
            if (manager.getActiveConfiguration() == bc) {
                // the best choice
                return bc;
            }
            appWithSuitableMainClass = bc;
        }
    }
    // if no apps with matching main class - take active bc and override main class
    return appWithSuitableMainClass != null ? appWithSuitableMainClass : manager.getActiveConfiguration();
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)

Aggregations

FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)52 Module (com.intellij.openapi.module.Module)30 Sdk (com.intellij.openapi.projectRoots.Sdk)9 Pair (com.intellij.openapi.util.Pair)7 ArrayList (java.util.ArrayList)7 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)6 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)5 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)5 FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)5 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)4 Project (com.intellij.openapi.project.Project)4 FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)3 FlexUnitRunConfiguration (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration)3 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)3 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)3 FlashRunnerParameters (com.intellij.lang.javascript.flex.run.FlashRunnerParameters)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 ProjectStructureConfigurable (com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)3 CheckedTreeNode (com.intellij.ui.CheckedTreeNode)3 Place (com.intellij.ui.navigation.Place)3