Search in sources :

Example 16 with FlexBuildConfiguration

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

the class FlexUnitRunConfigurationForm method updateControls.

private void updateControls() {
    if (myShowLogCheckBox.isSelected()) {
        myLogLevelCombo.setEnabled(true);
        if (myLogLevelCombo.getSelectedItem() == null) {
            myLogLevelCombo.setSelectedItem(FlexUnitRunnerParameters.OutputLogLevel.values()[0]);
        }
    } else {
        myLogLevelCombo.setEnabled(false);
    }
    final FlexBuildConfiguration bc = myBCCombo.getBC();
    final boolean webPlatform = bc != null && bc.getTargetPlatform() == TargetPlatform.Web;
    final boolean mobilePlatform = bc != null && bc.getTargetPlatform() == TargetPlatform.Mobile;
    final boolean app = bc != null && bc.getOutputType() == OutputType.Application;
    myLauncherParametersLabel.setVisible(webPlatform);
    myLauncherParametersTextWithBrowse.setVisible(webPlatform);
    myRunTrustedCheckBox.setVisible(webPlatform);
    myEmulatorAdlOptionsLabel.setVisible(mobilePlatform);
    myEmulatorAdlOptionsEditor.setVisible(mobilePlatform);
    myAppDescriptorForEmulatorLabel.setVisible(app && mobilePlatform);
    myAppDescriptorForEmulatorCombo.setVisible(app && mobilePlatform);
    if (webPlatform) {
        myLauncherParametersTextWithBrowse.getTextField().setText(myLauncherParameters.getPresentableText());
    }
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)

Example 17 with FlexBuildConfiguration

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

the class FlexUnitRuntimeConfigurationProducer method configureRunnerParameters.

private static boolean configureRunnerParameters(final FlexUnitRunnerParameters params, final Module module, final PsiElement element) {
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
    FlexUnitSupport support = null;
    FlexBuildConfiguration bc = null;
    if (module.getName().equals(params.getModuleName()) && !params.getBCName().isEmpty()) {
        bc = manager.findConfigurationByName(params.getBCName());
        if (bc != null) {
            support = FlexUnitSupport.getSupport(bc, module);
        }
    }
    if (support == null) {
        bc = manager.getActiveConfiguration();
        support = FlexUnitSupport.getSupport(bc, module);
    }
    if (support == null) {
        for (FlexBuildConfiguration anyBC : manager.getBuildConfigurations()) {
            bc = anyBC;
            support = FlexUnitSupport.getSupport(bc, module);
            if (support != null) {
                break;
            }
        }
    }
    if (support == null) {
        return false;
    }
    params.setModuleName(module.getName());
    params.setBCName(bc.getName());
    if (bc.getTargetPlatform() == TargetPlatform.Mobile) {
        if (bc.getAndroidPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.Android);
        } else if (bc.getIosPackagingOptions().isEnabled()) {
            params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.IOS);
        }
    }
    if (element instanceof JSClass) {
        final JSClass clazz = (JSClass) element;
        if (!support.isTestClass(clazz, true))
            return false;
        forClass(clazz, params);
    } else if (element instanceof JSFunction) {
        final JSFunction method = (JSFunction) element;
        final String methodName = method.getName();
        final JSClass clazz = (JSClass) element.getParent();
        if (!support.isTestClass(clazz, true))
            return false;
        if (methodName == null || !support.isTestMethod(method)) {
            forClass(clazz, params);
        } else {
            params.setClassName(clazz.getQualifiedName());
            params.setMethodName(methodName);
            params.setScope(FlexUnitRunnerParameters.Scope.Method);
        }
    } else if (element instanceof PsiDirectory) {
        if (!forDirectory((PsiDirectory) element, module, params))
            return false;
    } else if (element instanceof PsiDirectoryContainer) {
        if (!forPackage((PsiDirectoryContainer) element, module, params))
            return false;
    } else {
        return false;
    }
    return true;
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) JSFunction(com.intellij.lang.javascript.psi.JSFunction) PsiDirectory(com.intellij.psi.PsiDirectory) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) PsiDirectoryContainer(com.intellij.psi.PsiDirectoryContainer) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 18 with FlexBuildConfiguration

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

the class FlexOrderEnumerationHandler method addCustomRootsForLibrary.

@Override
public boolean addCustomRootsForLibrary(@NotNull final OrderEntry forOrderEntry, @NotNull final OrderRootType type, @NotNull final Collection<String> urls) {
    if (!(forOrderEntry instanceof JdkOrderEntry)) {
        return false;
    }
    if (myActiveConfigurations == null) {
        return false;
    }
    final Module forModule = forOrderEntry.getOwnerModule();
    final FlexBuildConfiguration bc = getActiveConfiguration(forModule);
    final Sdk sdk = bc.getSdk();
    if (sdk == null || sdk.getSdkType() != FlexSdkType2.getInstance()) {
        return false;
    }
    final String[] allUrls = sdk.getRootProvider().getUrls(type);
    if (type != OrderRootType.CLASSES) {
        urls.addAll(Arrays.asList(allUrls));
        return true;
    }
    final List<String> themePaths = BCUtils.getThemes(forModule, bc);
    final List<String> allAccessibleUrls = ContainerUtil.filter(allUrls, s -> {
        s = VirtualFileManager.extractPath(StringUtil.trimEnd(s, JarFileSystem.JAR_SEPARATOR));
        return BCUtils.getSdkEntryLinkageType(s, bc) != null || themePaths.contains(s);
    });
    urls.addAll(new HashSet<>(allAccessibleUrls));
    return true;
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Example 19 with FlexBuildConfiguration

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

the class FlexSdkStep method selectSdkUsedByOtherModules.

private static void selectSdkUsedByOtherModules(@Nullable final Project project, final FlexSdkComboBoxWithBrowseButton combo) {
    if (project == null) {
        return;
    }
    final FlexProjectConfigurationEditor currentEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
    if (currentEditor != null) {
        final Module[] modules = ModuleStructureConfigurable.getInstance(project).getModules();
        for (Module module : modules) {
            if (ModuleType.get(module) != FlexModuleType.getInstance()) {
                continue;
            }
            for (ModifiableFlexBuildConfiguration c : currentEditor.getConfigurations(module)) {
                SdkEntry sdkEntry = c.getDependencies().getSdkEntry();
                Sdk sdk;
                if (sdkEntry != null && (sdk = FlexSdkUtils.findFlexOrFlexmojosSdk(sdkEntry.getName())) != null && sdk.getSdkType() == FlexSdkType2.getInstance()) {
                    combo.setSelectedSdkRaw(sdk.getName());
                    return;
                }
            }
        }
    } else {
        for (final Module module : ModuleManager.getInstance(project).getModules()) {
            if (ModuleType.get(module) == FlexModuleType.getInstance()) {
                for (FlexBuildConfiguration bc : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
                    Sdk sdk = bc.getSdk();
                    if (sdk != null) {
                        combo.setSelectedSdkRaw(sdk.getName());
                        return;
                    }
                }
            }
        }
    }
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) SdkEntry(com.intellij.lang.javascript.flex.projectStructure.model.SdkEntry)

Example 20 with FlexBuildConfiguration

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

the class BCCombo method initCombo.

private void initCombo() {
    setMinimumSize(new Dimension(150, getMinimumSize().height));
    final Collection<FlexBuildConfiguration> allConfigs = new ArrayList<>();
    final Module[] modules = ModuleManager.getInstance(myProject).getModules();
    mySingleModuleProject = modules.length == 1;
    for (final Module module : modules) {
        if (ModuleType.get(module) instanceof FlexModuleType) {
            for (final FlexBuildConfiguration config : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
                allConfigs.add(config);
                myBCToModuleMap.put(config, module);
            }
        }
    }
    myAllConfigs = allConfigs.toArray(new FlexBuildConfiguration[allConfigs.size()]);
    setRenderer(new ColoredListCellRendererWrapper() {

        @Override
        protected void doCustomize(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) {
            if (value instanceof Pair) {
                final String moduleName = (String) ((Pair) value).first;
                final String configName = (String) ((Pair) value).second;
                //setIcon(PlatformIcons.ERROR_INTRODUCTION_ICON);
                if (moduleName.isEmpty() || configName.isEmpty()) {
                    append(new SimpleColoredText("[none]", SimpleTextAttributes.ERROR_ATTRIBUTES));
                } else {
                    append(BCUtils.renderMissingBuildConfiguration(configName, moduleName));
                }
            } else {
                assert value instanceof FlexBuildConfiguration : value;
                final FlexBuildConfiguration bc = (FlexBuildConfiguration) value;
                setIcon(bc.getIcon());
                append(BCUtils.renderBuildConfiguration(bc, mySingleModuleProject ? null : myBCToModuleMap.get(bc).getName()));
            }
        }
    });
    addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            // remove invalid entry
            final Object selectedItem = getSelectedItem();
            final Object firstItem = getItemAt(0);
            if (selectedItem instanceof FlexBuildConfiguration && !(firstItem instanceof FlexBuildConfiguration)) {
                setModel(new DefaultComboBoxModel(myAllConfigs));
                setSelectedItem(selectedItem);
            }
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) SimpleColoredText(com.intellij.ui.SimpleColoredText) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) ActionListener(java.awt.event.ActionListener) FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) Module(com.intellij.openapi.module.Module) ColoredListCellRendererWrapper(com.intellij.ui.ColoredListCellRendererWrapper) Pair(com.intellij.openapi.util.Pair)

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