Search in sources :

Example 6 with ModifiableFlexBuildConfiguration

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

the class ActionScriptHighlightingTest method testCorrectScopeForSuperclassCheck3.

public void testCorrectScopeForSuperclassCheck3() throws Exception {
    // IDEA-91539
    final Sdk sdk46 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.6"), null, false);
    FlexTestUtils.modifyConfigs(myProject, e -> {
        ModifiableFlexBuildConfiguration bc1 = e.getConfigurations(myModule)[0];
        bc1.setTargetPlatform(TargetPlatform.Desktop);
        FlexTestUtils.setSdk(e.getConfigurations(myModule)[0], sdk46);
    });
    doTestFor(true, getTestName(false) + ".js2", getTestName(false) + "_2.mxml");
}
Also used : Sdk(com.intellij.openapi.projectRoots.Sdk) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 7 with ModifiableFlexBuildConfiguration

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

the class Flexmojos3GenerateConfigTask method updateMainClass.

public static void updateMainClass(final Module module, final VirtualFile configFile) {
    // Project Structure open
    if (FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor() != null)
        return;
    try {
        final String mainClassPath = FlexUtils.findXMLElement(configFile.getInputStream(), "<flex-config><file-specs><path-element>");
        final VirtualFile mainClassFile = mainClassPath == null ? null : LocalFileSystem.getInstance().findFileByPath(mainClassPath);
        if (mainClassFile == null || mainClassFile.isDirectory())
            return;
        final VirtualFile sourceRoot = ProjectRootManager.getInstance(module.getProject()).getFileIndex().getSourceRootForFile(mainClassFile);
        final String relativePath = sourceRoot == null ? null : VfsUtilCore.getRelativePath(mainClassFile, sourceRoot, '/');
        final String mainClass = relativePath == null ? mainClassFile.getNameWithoutExtension() : FileUtil.getNameWithoutExtension(relativePath).replace('/', '.');
        final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
        final LibraryTable.ModifiableModel librariesModel = ProjectLibraryTable.getInstance(module.getProject()).getModifiableModel();
        final FlexProjectConfigurationEditor flexEditor = FlexProjectConfigurationEditor.createEditor(module.getProject(), Collections.singletonMap(module, modifiableModel), librariesModel, null);
        final ModifiableFlexBuildConfiguration[] bcs = flexEditor.getConfigurations(module);
        final ModifiableFlexBuildConfiguration mainBC = ContainerUtil.find(bcs, bc -> bc.getOutputType() == OutputType.Application && module.getName().equals(bc.getName()));
        if (mainBC != null) {
            mainBC.setMainClass(mainClass);
        }
        flexEditor.commit();
        Disposer.dispose(librariesModel);
        modifiableModel.dispose();
    } catch (IOException ignore) {
    /**/
    } catch (ConfigurationException ignore) {
    /**/
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) ConfigurationException(com.intellij.openapi.options.ConfigurationException) IOException(java.io.IOException) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 8 with ModifiableFlexBuildConfiguration

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

the class FlexBCConfigurator method canBeRemoved.

public boolean canBeRemoved(ModifiableFlexBuildConfiguration[] configurations) {
    Map<Module, Integer> module2ConfigCount = new HashMap<>();
    for (ModifiableFlexBuildConfiguration bc : configurations) {
        Module module = myConfigEditor.getModule(bc);
        Integer count = module2ConfigCount.get(module);
        module2ConfigCount.put(module, count != null ? count + 1 : 1);
    }
    for (Map.Entry<Module, Integer> entry : module2ConfigCount.entrySet()) {
        Module module = entry.getKey();
        if (myConfigEditor.getConfigurations(module).length == entry.getValue()) {
            return false;
        }
    }
    return true;
}
Also used : HashMap(com.intellij.util.containers.HashMap) Module(com.intellij.openapi.module.Module) HashMap(com.intellij.util.containers.HashMap) BidirectionalMap(com.intellij.util.containers.BidirectionalMap) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 9 with ModifiableFlexBuildConfiguration

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

the class FlexBCConfigurator method addConfiguration.

public void addConfiguration(final Module module, final Runnable treeNodeNameUpdater) {
    if (module == null) {
        return;
    }
    final String title = FlexBundle.message("add.build.configuration.title", module.getName());
    final AddBuildConfigurationDialog dialog = new AddBuildConfigurationDialog(module.getProject(), title, getUsedNames(module), BuildConfigurationNature.DEFAULT, true);
    if (!dialog.showAndGet()) {
        return;
    }
    final ModifiableFlexBuildConfiguration bc = myConfigEditor.createConfiguration(module);
    final String bcName = dialog.getBCName();
    final String fileName = PathUtil.suggestFileName(bcName);
    final BuildConfigurationNature nature = dialog.getNature();
    bc.setName(bcName);
    bc.setNature(nature);
    final ModifiableFlexBuildConfiguration someExistingConfig = myConfigEditor.getConfigurations(module)[0];
    bc.setOutputFileName(fileName + (bc.getOutputType() == OutputType.Library ? ".swc" : ".swf"));
    bc.setOutputFolder(someExistingConfig.getOutputFolder());
    updatePackageFileName(bc, fileName);
    if (nature.isApp() && nature.isMobilePlatform()) {
        bc.getAndroidPackagingOptions().setEnabled(dialog.isAndroidEnabled());
        bc.getIosPackagingOptions().setEnabled(dialog.isIOSEnabled());
    }
    final SdkEntry sdkEntry = someExistingConfig.getDependencies().getSdkEntry();
    final SdkEntry newSdkEntry;
    if (sdkEntry != null && FlexSdkUtils.findFlexOrFlexmojosSdk(sdkEntry.getName()) != null) {
        newSdkEntry = Factory.createSdkEntry(sdkEntry.getName());
    } else {
        newSdkEntry = findAnySdk();
    }
    bc.getDependencies().setSdkEntry(newSdkEntry);
    createConfigurableNode(bc, module, treeNodeNameUpdater);
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) AddBuildConfigurationDialog(com.intellij.lang.javascript.flex.projectStructure.ui.AddBuildConfigurationDialog) SdkEntry(com.intellij.lang.javascript.flex.projectStructure.model.SdkEntry)

Example 10 with ModifiableFlexBuildConfiguration

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

the class FlexBCConfigurator method moduleRemoved.

public void moduleRemoved(final Module module) {
    if (ModuleType.get(module) != FlexModuleType.getInstance()) {
        return;
    }
    // config editor will handle event and update modifiable model on its own, we just need to update configurables
    Collection<ModifiableFlexBuildConfiguration> configsToRemove = ContainerUtil.findAll(myConfigurablesMap.keySet(), bc -> myConfigEditor.getModule(bc) == module);
    final ProjectStructureDaemonAnalyzer daemonAnalyzer = ProjectStructureConfigurable.getInstance(myConfigEditor.getProject()).getContext().getDaemonAnalyzer();
    for (ModifiableFlexBuildConfiguration bc : configsToRemove) {
        CompositeConfigurable configurable = myConfigurablesMap.remove(bc);
        myBCToOutputPathMap.remove(bc);
        daemonAnalyzer.removeElement(configurable.getProjectStructureElement());
        daemonAnalyzer.queueUpdateForAllElementsWithErrors();
        configurable.disposeUIResources();
    }
    myEventDispatcher.getMulticaster().moduleRemoved(module);
}
Also used : ProjectStructureDaemonAnalyzer(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer) CompositeConfigurable(com.intellij.lang.javascript.flex.projectStructure.ui.CompositeConfigurable) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Aggregations

ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)31 Sdk (com.intellij.openapi.projectRoots.Sdk)16 Module (com.intellij.openapi.module.Module)8 FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)5 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)4 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 LookupElement (com.intellij.codeInsight.lookup.LookupElement)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 IOException (java.io.IOException)3 FlexTestUtils (com.intellij.flex.util.FlexTestUtils)2 FlexStylesIndexableSetContributor (com.intellij.javascript.flex.css.FlexStylesIndexableSetContributor)2 FlexSchemaHandler (com.intellij.javascript.flex.mxml.schema.FlexSchemaHandler)2 FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)2 SdkEntry (com.intellij.lang.javascript.flex.projectStructure.model.SdkEntry)2 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)2 ModuleType (com.intellij.openapi.module.ModuleType)2