Search in sources :

Example 6 with FlexBuildConfigurationManager

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

the class ActionScriptHighlightingTest method testCorrectScopeForSuperclassCheck2.

public void testCorrectScopeForSuperclassCheck2() throws Exception {
    //
    final Sdk sdk46 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.6"), null, false);
    FlexTestUtils.modifyConfigs(myProject, e -> {
        ModifiableFlexBuildConfiguration bc1 = e.getConfigurations(myModule)[0];
        bc1.setName("web");
        bc1.setTargetPlatform(TargetPlatform.Web);
        FlexTestUtils.setSdk(bc1, sdk46);
        ModifiableFlexBuildConfiguration bc2 = e.createConfiguration(myModule);
        bc2.setName("air");
        bc1.setTargetPlatform(TargetPlatform.Desktop);
        FlexTestUtils.setSdk(bc2, sdk46);
    });
    FlexBuildConfigurationManager m = FlexBuildConfigurationManager.getInstance(myModule);
    m.setActiveBuildConfiguration(m.findConfigurationByName("air"));
    defaultTest();
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) Sdk(com.intellij.openapi.projectRoots.Sdk) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 7 with FlexBuildConfigurationManager

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager 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 8 with FlexBuildConfigurationManager

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

the class ActionScriptCompletionInTextFieldTest method doTestCustomScope.

private void doTestCustomScope(String activeBcName, String selectedBcName, int numberOfVariants) throws Exception {
    String filename = getTestName(false).replaceAll("\\d+", "");
    configureByFiles(null, BASE_PATH + filename + "_2.mxml", BASE_PATH + filename + "_3.mxml");
    final Sdk sdk = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.5"), null, true);
    FlexTestUtils.modifyConfigs(myProject, e -> {
        {
            final ModifiableFlexBuildConfiguration bc = e.getConfigurations(myModule)[0];
            bc.setName("Flex");
            bc.setNature(new BuildConfigurationNature(TargetPlatform.Web, false, OutputType.Application));
            FlexTestUtils.setSdk(bc, sdk);
        }
        {
            final ModifiableFlexBuildConfiguration bc = e.createConfiguration(myModule);
            bc.setName("AIR");
            bc.setNature(new BuildConfigurationNature(TargetPlatform.Desktop, false, OutputType.Application));
            FlexTestUtils.setSdk(bc, sdk);
        }
    });
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(myModule);
    manager.setActiveBuildConfiguration(manager.findConfigurationByName(activeBcName));
    final ModuleWithDependenciesScope scope = FlexUtils.getModuleWithDependenciesAndLibrariesScope(myModule, manager.findConfigurationByName(selectedBcName), false);
    PublicInheritorFilter filter = new PublicInheritorFilter(myProject, FlashRunConfigurationForm.SPRITE_CLASS_NAME, scope, true);
    PsiFile fragment = JSReferenceEditor.forClassName("", myProject, null, GlobalSearchScope.moduleScope(myModule), null, filter, "").getPsiFile();
    doTestForEditorTextField((JSExpressionCodeFragment) fragment, "", "js2", BASE_PATH + filename + ".txt");
    if (numberOfVariants == 0) {
        assertNull(myItems);
    } else {
        assertEquals(numberOfVariants, myItems.length);
    }
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) PublicInheritorFilter(com.intellij.lang.javascript.psi.impl.PublicInheritorFilter) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) ModuleWithDependenciesScope(com.intellij.openapi.module.impl.scopes.ModuleWithDependenciesScope) PsiFile(com.intellij.psi.PsiFile) Sdk(com.intellij.openapi.projectRoots.Sdk) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 9 with FlexBuildConfigurationManager

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

the class ActionScriptCompletionTest method testTwoSdks.

public void testTwoSdks() throws Exception {
    final Sdk sdk45 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.5"), null, true);
    final Sdk sdk46 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.6"), null, false);
    FlexTestUtils.modifyConfigs(myProject, new Consumer<FlexProjectConfigurationEditor>() {

        public void consume(final FlexProjectConfigurationEditor editor) {
            ModifiableFlexBuildConfiguration bc1 = editor.getConfigurations(myModule)[0];
            bc1.setName("1");
            FlexTestUtils.setSdk(bc1, sdk45);
            ModifiableFlexBuildConfiguration bc2 = editor.createConfiguration(myModule);
            bc2.setName("2");
            FlexTestUtils.setSdk(bc2, sdk46);
        }
    });
    final FlexBuildConfigurationManager m = FlexBuildConfigurationManager.getInstance(myModule);
    class TestZZ implements ThrowableRunnable<Exception> {

        private final String myBcName;

        private final String myExpectedTypeText;

        TestZZ(final String bcName, final String expectedTypeText) {
            myBcName = bcName;
            myExpectedTypeText = expectedTypeText;
        }

        @Override
        public void run() throws Exception {
            m.setActiveBuildConfiguration(m.findConfigurationByName(myBcName));
            defaultTest();
            for (LookupElement item : myItems) {
                final LookupElementPresentation p = new LookupElementPresentation();
                item.renderElement(p);
                assertEquals(myExpectedTypeText, p.getTypeText());
            }
        }
    }
    new TestZZ("1", sdk45.getName()).run();
    new TestZZ("2", sdk46.getName()).run();
    new TestZZ("1", sdk45.getName()).run();
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) ThrowableRunnable(com.intellij.util.ThrowableRunnable) LookupElementPresentation(com.intellij.codeInsight.lookup.LookupElementPresentation) Sdk(com.intellij.openapi.projectRoots.Sdk) LookupElement(com.intellij.codeInsight.lookup.LookupElement) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Aggregations

FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)9 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)4 Sdk (com.intellij.openapi.projectRoots.Sdk)3 LookupElement (com.intellij.codeInsight.lookup.LookupElement)2 LookupElementPresentation (com.intellij.codeInsight.lookup.LookupElementPresentation)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)1 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)1 ModuleOrProjectCompilerOptions (com.intellij.lang.javascript.flex.projectStructure.model.ModuleOrProjectCompilerOptions)1 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)1 JSFunction (com.intellij.lang.javascript.psi.JSFunction)1 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 PublicInheritorFilter (com.intellij.lang.javascript.psi.impl.PublicInheritorFilter)1 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)1 ModuleWithDependenciesScope (com.intellij.openapi.module.impl.scopes.ModuleWithDependenciesScope)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiDirectoryContainer (com.intellij.psi.PsiDirectoryContainer)1 PsiFile (com.intellij.psi.PsiFile)1 RowIcon (com.intellij.ui.RowIcon)1