Search in sources :

Example 1 with FlexModuleType

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

the class AirPackageAction method update.

public void update(final AnActionEvent e) {
    final Project project = e.getProject();
    boolean flexModulePresent = false;
    boolean airAppPresent = false;
    if (project != null) {
        final FlexModuleType flexModuleType = FlexModuleType.getInstance();
        MODULES_LOOP: for (Module module : ModuleManager.getInstance(project).getModules()) {
            if (ModuleType.get(module) == flexModuleType) {
                flexModulePresent = true;
                for (FlexBuildConfiguration bc : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
                    final BuildConfigurationNature nature = bc.getNature();
                    if (nature.isApp() && !nature.isWebPlatform()) {
                        airAppPresent = true;
                        break MODULES_LOOP;
                    }
                }
            }
        }
    }
    e.getPresentation().setVisible(flexModulePresent);
    e.getPresentation().setEnabled(airAppPresent && !CompilerManager.getInstance(project).isCompilationActive() && !AirPackageProjectParameters.getInstance(project).isPackagingInProgress());
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) Project(com.intellij.openapi.project.Project) FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) Module(com.intellij.openapi.module.Module)

Example 2 with FlexModuleType

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

the class FlexBuildConfigurationsExtension method getFlexModuleForNode.

@Nullable
private static Module getFlexModuleForNode(@Nullable MasterDetailsComponent.MyNode node) {
    while (node != null) {
        final NamedConfigurable configurable = node.getConfigurable();
        final Object editableObject = configurable == null ? null : configurable.getEditableObject();
        if (editableObject instanceof Module && ModuleType.get((Module) editableObject) instanceof FlexModuleType) {
            return (Module) editableObject;
        }
        final TreeNode parent = node.getParent();
        node = parent instanceof MasterDetailsComponent.MyNode ? (MasterDetailsComponent.MyNode) parent : null;
    }
    return null;
}
Also used : FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) TreeNode(javax.swing.tree.TreeNode) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with FlexModuleType

use of com.intellij.lang.javascript.flex.FlexModuleType 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)

Example 4 with FlexModuleType

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

the class BCBasedRunnerParameters method checkAndGetModuleAndBC.

public Pair<Module, FlexBuildConfiguration> checkAndGetModuleAndBC(final Project project) throws RuntimeConfigurationError {
    if (myModuleName.isEmpty() || myBCName.isEmpty()) {
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }
    final Module module = ModuleManager.getInstance(project).findModuleByName(myModuleName);
    if (module == null || !(ModuleType.get(module) instanceof FlexModuleType)) {
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }
    final FlexBuildConfiguration bc = FlexBuildConfigurationManager.getInstance(module).findConfigurationByName(myBCName);
    if (bc == null) {
        throw new RuntimeConfigurationError(FlexBundle.message("module.does.not.contain.bc", myModuleName, myBCName));
    }
    final Sdk sdk = bc.getSdk();
    if (sdk == null) {
        throw new RuntimeConfigurationError(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), module.getName()));
    }
    return Pair.create(module, bc);
}
Also used : FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 5 with FlexModuleType

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

the class BCCombo method resetFrom.

public void resetFrom(final BCBasedRunnerParameters params) {
    final Module module = ModuleManager.getInstance(myProject).findModuleByName(params.getModuleName());
    final FlexBuildConfiguration config = module != null && (ModuleType.get(module) instanceof FlexModuleType) ? FlexBuildConfigurationManager.getInstance(module).findConfigurationByName(params.getBCName()) : null;
    if (config == null) {
        final Object[] model = new Object[myAllConfigs.length + 1];
        model[0] = Pair.create(params.getModuleName(), params.getBCName());
        System.arraycopy(myAllConfigs, 0, model, 1, myAllConfigs.length);
        setModel(new DefaultComboBoxModel(model));
        setSelectedIndex(0);
    } else {
        setModel(new DefaultComboBoxModel(myAllConfigs));
        setSelectedItem(config);
    }
}
Also used : FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module)

Aggregations

FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)5 Module (com.intellij.openapi.module.Module)5 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)1 Pair (com.intellij.openapi.util.Pair)1 ColoredListCellRendererWrapper (com.intellij.ui.ColoredListCellRendererWrapper)1 SimpleColoredText (com.intellij.ui.SimpleColoredText)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 TreeNode (javax.swing.tree.TreeNode)1 Nullable (org.jetbrains.annotations.Nullable)1