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);
}
}
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;
}
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));
}
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) {
/**/
}
}
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;
}
Aggregations