Search in sources :

Example 36 with FlexBuildConfiguration

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

the class FlexBCTree method getBCNode.

private CheckedTreeNode getBCNode(final String moduleName, final String bcName) {
    final Enumeration moduleNodes = ((CheckedTreeNode) getModel().getRoot()).children();
    while (moduleNodes.hasMoreElements()) {
        final CheckedTreeNode moduleNode = (CheckedTreeNode) moduleNodes.nextElement();
        final Object userObject = moduleNode.getUserObject();
        if (userObject instanceof Module && ((Module) userObject).getName().equals(moduleName)) {
            final Enumeration bcNodes = moduleNode.children();
            while (bcNodes.hasMoreElements()) {
                final CheckedTreeNode bcNode = (CheckedTreeNode) bcNodes.nextElement();
                final Object bcUserObject = bcNode.getUserObject();
                if (bcUserObject instanceof FlexBuildConfiguration && ((FlexBuildConfiguration) bcUserObject).getName().equals(bcName)) {
                    return bcNode;
                }
            }
            return null;
        }
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) Module(com.intellij.openapi.module.Module)

Example 37 with FlexBuildConfiguration

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

the class AirPackageDialog method checkDisabledCompilation.

private static boolean checkDisabledCompilation(final Project project, final Collection<Pair<Module, FlexBuildConfiguration>> selectedBCs) {
    final Collection<FlexBuildConfiguration> bcsWithDisabledCompilation = new ArrayList<>();
    for (Pair<Module, FlexBuildConfiguration> moduleAndBC : selectedBCs) {
        if (moduleAndBC.second.isSkipCompile()) {
            bcsWithDisabledCompilation.add(moduleAndBC.second);
        }
    }
    if (!bcsWithDisabledCompilation.isEmpty()) {
        final StringBuilder bcs = new StringBuilder();
        for (FlexBuildConfiguration bc : bcsWithDisabledCompilation) {
            bcs.append("<b>").append(StringUtil.escapeXml(bc.getName())).append("</b><br>");
        }
        final String message = FlexBundle.message("package.bc.with.disabled.compilation", bcsWithDisabledCompilation.size(), bcs.toString());
        final int answer = Messages.showYesNoDialog(project, message, FlexBundle.message("package.air.application.title"), Messages.getWarningIcon());
        return answer == Messages.YES;
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module)

Example 38 with FlexBuildConfiguration

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

the class ChooseActiveBuildConfigurationAction method createPopup.

public static ListPopup createPopup(@NotNull Module module) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
    final FlexBuildConfiguration activeBc = manager.getActiveConfiguration();
    final FlexBuildConfiguration[] bcs = manager.getBuildConfigurations();
    Arrays.sort(bcs, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
    for (final FlexBuildConfiguration bc : bcs) {
        actionGroup.add(new SelectBcAction(bc, manager));
    }
    actionGroup.addSeparator();
    actionGroup.add(new EditBcsAction(module));
    final DataContext dataContext = SimpleDataContext.getProjectContext(module.getProject());
    return new PopupFactoryImpl.ActionGroupPopup(FlexBundle.message("choose.build.configuration.popup.title", module.getName()), actionGroup, dataContext, false, false, false, true, null, -1, anAction -> anAction instanceof SelectBcAction && ((SelectBcAction) anAction).getBC() == activeBc, null) {

        @Override
        protected ListCellRenderer getListElementRenderer() {
            return new PopupListElementRenderer(this) {

                {
                //myRendererComponent.setBorder(new EmptyBorder(5, 0, 5, 0));
                }

                @Override
                protected JComponent createItemComponent() {
                    return new MyPanel();
                }

                @Override
                public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
                    MyPanel p = (MyPanel) myComponent;
                    p.clear();
                    PopupFactoryImpl.ActionItem actionItem = (PopupFactoryImpl.ActionItem) value;
                    AnAction anAction = actionItem.getAction();
                    SimpleColoredText text;
                    Icon icon;
                    boolean isActive;
                    if (anAction instanceof SelectBcAction) {
                        FlexBuildConfiguration bc = ((SelectBcAction) anAction).getBC();
                        isActive = bc == activeBc;
                        text = BCUtils.renderBuildConfiguration(bc, null, isActive);
                        icon = bc.getIcon();
                    } else {
                        text = new SimpleColoredText(anAction.getTemplatePresentation().getText(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
                        icon = anAction.getTemplatePresentation().getIcon();
                        isActive = false;
                    }
                    RowIcon rowIcon = new RowIcon(2);
                    rowIcon.setIcon(isActive ? (isSelected ? ICON_ACTIVE_SELECTED : ICON_ACTIVE) : ICON_EMPTY, 0);
                    rowIcon.setIcon(icon, 1);
                    p.setIcon(rowIcon);
                    if (isSelected) {
                        text = text.derive(SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES, true);
                        setSelected(p);
                    } else {
                        setDeselected(p);
                    }
                    p.setText(text);
                    mySeparatorComponent.setVisible(actionItem.isPrependWithSeparator());
                    return myRendererComponent;
                }
            };
        }
    };
}
Also used : PopupFactoryImpl(com.intellij.ui.popup.PopupFactoryImpl) SimpleColoredText(com.intellij.ui.SimpleColoredText) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) RowIcon(com.intellij.ui.RowIcon) PopupListElementRenderer(com.intellij.ui.popup.list.PopupListElementRenderer) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) RowIcon(com.intellij.ui.RowIcon) EmptyIcon(com.intellij.util.ui.EmptyIcon)

Example 39 with FlexBuildConfiguration

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

the class FlexOrderEnumerationHandler method processModuleWithBuildConfiguration.

// configuration is null for root module (one for which scope is being computed)
private static void processModuleWithBuildConfiguration(@NotNull Module module, @Nullable FlexBuildConfiguration bc, Map<Module, ModuleData> modules2activeConfigurations, Set<FlexBuildConfiguration> processedConfigurations, boolean productionDependency) {
    if (ModuleType.get(module) != FlexModuleType.getInstance()) {
        return;
    }
    final boolean isRootModule = bc == null;
    if (isRootModule) {
        bc = getActiveConfiguration(module);
    }
    if (bc == null || !processedConfigurations.add(bc)) {
        return;
    }
    ModuleData moduleData = modules2activeConfigurations.get(module);
    if (moduleData == null) {
        modules2activeConfigurations.put(module, moduleData = new ModuleData());
    }
    moduleData.addBc(bc, productionDependency);
    for (DependencyEntry entry : bc.getDependencies().getEntries()) {
        if (!(entry instanceof BuildConfigurationEntry)) {
            continue;
        }
        final LinkageType linkageType = entry.getDependencyType().getLinkageType();
        if (linkageType == LinkageType.LoadInRuntime) {
            continue;
        }
        FlexBuildConfiguration dependencyBc = ((BuildConfigurationEntry) entry).findBuildConfiguration();
        if (dependencyBc == null || !FlexCommonUtils.checkDependencyType(bc.getOutputType(), dependencyBc.getOutputType(), linkageType)) {
            continue;
        }
        if (!isRootModule && !BCUtils.isTransitiveDependency(linkageType)) {
            continue;
        }
        Module dependencyModule = ((BuildConfigurationEntry) entry).findModule();
        if (dependencyModule == null || dependencyModule == module) {
            continue;
        }
        processModuleWithBuildConfiguration(dependencyModule, dependencyBc, modules2activeConfigurations, processedConfigurations, entry.getDependencyType().getLinkageType() != LinkageType.Test);
    }
}
Also used : BuildConfigurationEntry(com.intellij.lang.javascript.flex.projectStructure.model.BuildConfigurationEntry) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) DependencyEntry(com.intellij.lang.javascript.flex.projectStructure.model.DependencyEntry) Module(com.intellij.openapi.module.Module) LinkageType(com.intellij.flex.model.bc.LinkageType)

Example 40 with FlexBuildConfiguration

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

the class FlexOrderEnumerationHandler method shouldAddDependency.

@NotNull
@Override
public AddDependencyType shouldAddDependency(@NotNull OrderEntry orderEntry, @NotNull OrderEnumeratorSettings settings) {
    Module module = orderEntry.getOwnerModule();
    if (ModuleType.get(module) != FlexModuleType.getInstance()) {
        return super.shouldAddDependency(orderEntry, settings);
    }
    if (orderEntry instanceof ModuleSourceOrderEntry) {
        return AddDependencyType.DEFAULT;
    }
    if (orderEntry instanceof JdkOrderEntry) {
        if (module != myRootModule) {
            // never add transitive dependency to Flex SDK
            return AddDependencyType.DO_NOT_ADD;
        }
        if (myActiveConfigurations == null) {
            return AddDependencyType.DEFAULT;
        }
        ModuleData moduleData = myActiveConfigurations.get(module);
        for (FlexBuildConfiguration bc : moduleData.bcs) {
            if (bc.getSdk() != null) {
                return AddDependencyType.DEFAULT;
            }
        }
        return AddDependencyType.DO_NOT_ADD;
    }
    Collection<FlexBuildConfiguration> accessibleConfigurations;
    if (myActiveConfigurations != null) {
        ModuleData moduleData = myActiveConfigurations.get(module);
        accessibleConfigurations = moduleData != null ? moduleData.bcs : Collections.emptyList();
    } else {
        // let all configurations be accessible in ProjectOrderEnumerator
        accessibleConfigurations = Arrays.asList(FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations());
    }
    if (orderEntry instanceof LibraryOrderEntry) {
        final LibraryEx library = (LibraryEx) ((LibraryOrderEntry) orderEntry).getLibrary();
        if (library == null) {
            return AddDependencyType.DEFAULT;
        }
        if (library.getKind() == FlexLibraryType.FLEX_LIBRARY) {
            return FlexProjectRootsUtil.dependOnLibrary(accessibleConfigurations, library, module != myRootModule, settings.isProductionOnly()) ? AddDependencyType.DEFAULT : AddDependencyType.DO_NOT_ADD;
        } else {
            // foreign library
            return AddDependencyType.DO_NOT_ADD;
        }
    } else if (orderEntry instanceof ModuleOrderEntry) {
        final Module dependencyModule = ((ModuleOrderEntry) orderEntry).getModule();
        if (dependencyModule == null) {
            return AddDependencyType.DO_NOT_ADD;
        }
        if (myActiveConfigurations != null) {
            ModuleData moduleData = myActiveConfigurations.get(dependencyModule);
            return moduleData != null && (moduleData.accessibleInProduction || !settings.isProductionOnly()) ? AddDependencyType.DEFAULT : AddDependencyType.DO_NOT_ADD;
        } else {
            // let all modules dependencies be accessible in ProjectOrderEnumerator
            return AddDependencyType.DEFAULT;
        }
    } else {
        return AddDependencyType.DEFAULT;
    }
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

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