Search in sources :

Example 1 with FlexProjectConfigurationEditor

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

the class FlexTestUtils method modifyConfigs.

public static void modifyConfigs(Project project, final Consumer<FlexProjectConfigurationEditor> modifier) {
    Module[] modules = ModuleManager.getInstance(project).getModules();
    final FlexProjectConfigurationEditor editor = createConfigEditor(modules);
    try {
        modifier.consume(editor);
        editor.commit();
    } catch (ConfigurationException ex) {
        throw new RuntimeException(ex);
    } finally {
        Disposer.dispose(editor);
    }
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module)

Example 2 with FlexProjectConfigurationEditor

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

the class FlashPackagingSourceItemsProvider method createFlashBCOutputSourceItems.

private static Collection<? extends PackagingSourceItem> createFlashBCOutputSourceItems(final Module module) {
    final List<PackagingSourceItem> result = new ArrayList<>();
    int orderNumber = 0;
    final FlexProjectConfigurationEditor configEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
    // because Project Structure is open
    assert configEditor != null;
    for (FlexBuildConfiguration bc : configEditor.getConfigurations(module)) {
        final String outputFilePath = bc.getActualOutputFilePath().toLowerCase();
        if (!outputFilePath.endsWith(".swf") && !outputFilePath.endsWith(".swc")) {
            // BC is not configured properly yet
            continue;
        }
        result.add(new FlashBCOutputSourceItem(bc, FlashBCOutputSourceItem.Type.OutputFile, orderNumber++));
        if (bc.getOutputType() == OutputType.Application && bc.getTargetPlatform() == TargetPlatform.Web && bc.isUseHtmlWrapper()) {
            result.add(new FlashBCOutputSourceItem(bc, FlashBCOutputSourceItem.Type.OutputFileAndHtmlWrapper, orderNumber++));
        }
        result.add(new FlashBCOutputSourceItem(bc, FlashBCOutputSourceItem.Type.OutputFolderContents, orderNumber++));
    }
    return result;
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ArrayList(java.util.ArrayList) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)

Example 3 with FlexProjectConfigurationEditor

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

the class FlashBuilderImportTest method importProject.

protected void importProject(final String dotProjectFileContent, final String dotActionScriptPropertiesFileContent, final Collection<String> otherProjectNames, @Nullable final String flashBuilderWorkspacePath) throws IOException, ConfigurationException {
    final VirtualFile dotProjectFile = addFileWithContent(FlashBuilderImporter.DOT_PROJECT, dotProjectFileContent, myFlashBuilderProjectDir);
    addFileWithContent(FlashBuilderImporter.DOT_ACTION_SCRIPT_PROPERTIES, dotActionScriptPropertiesFileContent, myFlashBuilderProjectDir);
    final FlashBuilderProject flashBuilderProject = FlashBuilderProjectLoadUtil.loadProject(dotProjectFile, false);
    final Collection<FlashBuilderProject> allFBProjects = new ArrayList<>();
    allFBProjects.add(flashBuilderProject);
    for (String name : otherProjectNames) {
        allFBProjects.add(FlashBuilderProjectLoadUtil.getDummyFBProject(name));
    }
    final String moduleFilePath = myFlashBuilderProjectDir.getPath() + "/" + flashBuilderProject.getName() + ModuleFileType.DOT_DEFAULT_EXTENSION;
    final ModifiableModuleModel moduleModel = ModuleManager.getInstance(myProject).getModifiableModel();
    myModule = moduleModel.newModule(moduleFilePath, FlexModuleType.getInstance().getId());
    final ModifiableRootModel rootModel = ModuleRootManager.getInstance(myModule).getModifiableModel();
    final FlashBuilderSdkFinder sdkFinder = new FlashBuilderSdkFinder(myProject, StringUtil.notNullize(flashBuilderWorkspacePath), Collections.singletonList(flashBuilderProject));
    final FlexProjectConfigurationEditor flexEditor = FlexProjectConfigurationEditor.createEditor(myProject, Collections.singletonMap(myModule, rootModel), null, null);
    new FlashBuilderModuleImporter(myProject, flexEditor, allFBProjects, sdkFinder).setupModule(rootModel, flashBuilderProject);
    flexEditor.commit();
    ApplicationManager.getApplication().runWriteAction(() -> ModifiableModelCommitter.multiCommit(Collections.singletonList(rootModel), moduleModel));
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel)

Example 4 with FlexProjectConfigurationEditor

use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor 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 5 with FlexProjectConfigurationEditor

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

the class FlexCompositeSdk method getSdks.

@NotNull
public Sdk[] getSdks() {
    if (mySdks != null) {
        return mySdks;
    }
    Sdk[] allSdks;
    boolean cache;
    final FlexProjectConfigurationEditor currentEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
    if (currentEditor == null) {
        allSdks = ProjectJdkTable.getInstance().getAllJdks();
        cache = true;
    } else {
        final Collection<Sdk> sdks = ProjectStructureConfigurable.getInstance(currentEditor.getProject()).getProjectJdksModel().getProjectSdks().values();
        allSdks = sdks.toArray(new Sdk[sdks.size()]);
        cache = false;
    }
    List<Sdk> result = ContainerUtil.findAll(allSdks, sdk -> ArrayUtil.contains(sdk.getName(), myNames));
    Sdk[] resultArray = result.toArray(new Sdk[result.size()]);
    if (cache) {
        mySdks = resultArray;
    }
    return resultArray;
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)15 Module (com.intellij.openapi.module.Module)9 ConfigurationException (com.intellij.openapi.options.ConfigurationException)7 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)4 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)4 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 FlexBCConfigurator (com.intellij.lang.javascript.flex.projectStructure.FlexBCConfigurator)3 Sdk (com.intellij.openapi.projectRoots.Sdk)3 ProjectLibraryTable (com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable)3 LinkageType (com.intellij.flex.model.bc.LinkageType)2 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)2 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)2 ApplicationLibraryTable (com.intellij.openapi.roots.impl.libraries.ApplicationLibraryTable)2 Library (com.intellij.openapi.roots.libraries.Library)2 Place (com.intellij.ui.navigation.Place)2 Nullable (org.jetbrains.annotations.Nullable)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 LookupElementPresentation (com.intellij.codeInsight.lookup.LookupElementPresentation)1 FlexCommonBundle (com.intellij.flex.FlexCommonBundle)1