use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class FlashBuilderImporter method commit.
public List<Module> commit(final Project project, final ModifiableModuleModel model, final ModulesProvider modulesProvider, final ModifiableArtifactModel artifactModel) {
//FlexModuleBuilder.setupResourceFilePatterns(project);
final boolean needToCommit = model == null;
final ModifiableModuleModel moduleModel = model != null ? model : ModuleManager.getInstance(project).getModifiableModel();
final List<String> paths = getList();
final boolean isArchive = paths.size() == 1 && FlashBuilderProjectFinder.hasArchiveExtension(paths.get(0));
final List<String> dotProjectPaths = getDotProjectPaths(project);
final List<FlashBuilderProject> flashBuilderProjects = FlashBuilderProjectLoadUtil.loadProjects(dotProjectPaths, isArchive);
final Map<FlashBuilderProject, ModifiableRootModel> flashBuilderProjectToModifiableModelMap = new THashMap<>();
final Map<Module, ModifiableRootModel> moduleToModifiableModelMap = new THashMap<>();
final Set<String> moduleNames = new THashSet<>(flashBuilderProjects.size());
final FlexProjectConfigurationEditor currentFlexEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
assert needToCommit == (currentFlexEditor == null);
for (FlashBuilderProject flashBuilderProject : flashBuilderProjects) {
final String moduleName = makeUnique(flashBuilderProject.getName(), moduleNames);
moduleNames.add(moduleName);
final String moduleFilePath = flashBuilderProject.getProjectRootPath() + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
if (LocalFileSystem.getInstance().findFileByPath(moduleFilePath) != null) {
ApplicationManager.getApplication().runWriteAction(() -> ModuleBuilder.deleteModuleFile(moduleFilePath));
}
final Module module = moduleModel.newModule(moduleFilePath, FlexModuleType.getInstance().getId());
final ModifiableRootModel rootModel = currentFlexEditor != null ? currentFlexEditor.getModifiableRootModel(module) : ModuleRootManager.getInstance(module).getModifiableModel();
flashBuilderProjectToModifiableModelMap.put(flashBuilderProject, rootModel);
moduleToModifiableModelMap.put(module, rootModel);
}
final FlexProjectConfigurationEditor flexConfigEditor = currentFlexEditor != null ? currentFlexEditor : FlexProjectConfigurationEditor.createEditor(project, moduleToModifiableModelMap, null, null);
final FlashBuilderSdkFinder sdkFinder = new FlashBuilderSdkFinder(project, getParameters().myInitiallySelectedPath, flashBuilderProjects);
final FlashBuilderModuleImporter flashBuilderModuleImporter = new FlashBuilderModuleImporter(project, flexConfigEditor, flashBuilderProjects, sdkFinder);
for (final FlashBuilderProject flashBuilderProject : flashBuilderProjects) {
flashBuilderModuleImporter.setupModule(flashBuilderProjectToModifiableModelMap.get(flashBuilderProject), flashBuilderProject);
}
if (needToCommit) {
try {
flexConfigEditor.commit();
} catch (ConfigurationException e) {
Logger.getInstance(FlashBuilderImporter.class).error(e);
}
ApplicationManager.getApplication().runWriteAction(() -> {
ModifiableModelCommitter.multiCommit(moduleToModifiableModelMap.values(), moduleModel);
});
}
return new ArrayList<>(moduleToModifiableModelMap.keySet());
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class BuildConfigurationProjectStructureElement method checkIfBCOutputUsedAs3rdPartyLib.
private void checkIfBCOutputUsedAs3rdPartyLib(final ProjectStructureProblemsHolder problemsHolder, final FlexBCConfigurator configurator, final DependencyEntry entry, final VirtualFile[] classesRoots) {
for (VirtualFile libFile : classesRoots) {
final VirtualFile realFile = FlexCompilerHandler.getRealFile(libFile);
if (realFile != null && !realFile.isDirectory() && "swc".equalsIgnoreCase(realFile.getExtension())) {
final List<ModifiableFlexBuildConfiguration> bcs = configurator.getBCsByOutputPath(realFile.getPath());
if (bcs != null && !bcs.isEmpty()) {
final ModifiableFlexBuildConfiguration otherLibBC = bcs.get(0);
final FlexProjectConfigurationEditor editor = configurator.getConfigEditor();
assert editor != null;
final Module otherLibModule = editor.getModule(otherLibBC);
final String message = FlexBundle.message("own.lib.used.as.3rd.party", realFile.getName(), otherLibBC.getName(), otherLibModule.getName());
final Object location = entry instanceof ModuleLibraryEntry ? DependenciesConfigurable.Location.TableEntry.forModuleLibrary(((ModuleLibraryEntry) entry).getLibraryId()) : DependenciesConfigurable.Location.TableEntry.forSharedLibrary(((SharedLibraryEntry) entry).getLibraryLevel(), ((SharedLibraryEntry) entry).getLibraryName());
final PlaceInProjectStructure placeInPS = new PlaceInBuildConfiguration(this, DependenciesConfigurable.TAB_NAME, location);
final String quickFixName = FlexBundle.message("instead.setup.dependency.on.bc", otherLibBC.getName(), otherLibModule.getName());
final ConfigurationErrorQuickFix quickFix = new ConfigurationErrorQuickFix(quickFixName) {
public void performFix() {
final FlexBCConfigurable configurable = configurator.getBCConfigurable(myBc);
final DependenciesConfigurable dependenciesConfigurable = configurable.getDependenciesConfigurable();
final FlexBCConfigurable otherLibConfigurable = configurator.getBCConfigurable(otherLibBC);
final LinkageType linkageType = entry.getDependencyType().getLinkageType();
dependenciesConfigurable.addBCDependency(otherLibConfigurable, linkageType);
if (entry instanceof ModuleLibraryEntry) {
dependenciesConfigurable.removeDependency(((ModuleLibraryEntry) entry).getLibraryId());
} else {
dependenciesConfigurable.removeDependency(((SharedLibraryEntry) entry).getLibraryLevel(), ((SharedLibraryEntry) entry).getLibraryName());
}
final Place place = configurator.getPlaceFor(myModule, myBc.getName());
place.putPath(CompositeConfigurable.TAB_NAME, DependenciesConfigurable.TAB_NAME);
place.putPath(FlexBCConfigurable.LOCATION_ON_TAB, DependenciesConfigurable.Location.TableEntry.forBc(otherLibConfigurable));
ProjectStructureConfigurable.getInstance(myModule.getProject()).navigateTo(place, true);
}
};
final String errorId = entry instanceof ModuleLibraryEntry ? ((ModuleLibraryEntry) entry).getLibraryId() : ((SharedLibraryEntry) entry).getLibraryName();
problemsHolder.registerProblem(message, null, ProjectStructureProblemType.warning(errorId), placeInPS, quickFix);
}
}
}
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class FlexSdkStep method selectSdkUsedByOtherModules.
private static void selectSdkUsedByOtherModules(@Nullable final Project project, final FlexSdkComboBoxWithBrowseButton combo) {
if (project == null) {
return;
}
final FlexProjectConfigurationEditor currentEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
if (currentEditor != null) {
final Module[] modules = ModuleStructureConfigurable.getInstance(project).getModules();
for (Module module : modules) {
if (ModuleType.get(module) != FlexModuleType.getInstance()) {
continue;
}
for (ModifiableFlexBuildConfiguration c : currentEditor.getConfigurations(module)) {
SdkEntry sdkEntry = c.getDependencies().getSdkEntry();
Sdk sdk;
if (sdkEntry != null && (sdk = FlexSdkUtils.findFlexOrFlexmojosSdk(sdkEntry.getName())) != null && sdk.getSdkType() == FlexSdkType2.getInstance()) {
combo.setSelectedSdkRaw(sdk.getName());
return;
}
}
}
} else {
for (final Module module : ModuleManager.getInstance(project).getModules()) {
if (ModuleType.get(module) == FlexModuleType.getInstance()) {
for (FlexBuildConfiguration bc : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
Sdk sdk = bc.getSdk();
if (sdk != null) {
combo.setSelectedSdkRaw(sdk.getName());
return;
}
}
}
}
}
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class FlexModuleBuilder method setupRootModel.
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
final ContentEntry contentEntry = doAddContentEntry(modifiableRootModel);
if (contentEntry == null)
return;
final VirtualFile sourceRoot = createSourceRoot(contentEntry);
final Module module = modifiableRootModel.getModule();
final FlexProjectConfigurationEditor currentFlexEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
final boolean needToCommitFlexEditor = currentFlexEditor == null;
final FlexProjectConfigurationEditor flexConfigEditor;
flexConfigEditor = currentFlexEditor != null ? currentFlexEditor : FlexProjectConfigurationEditor.createEditor(module.getProject(), Collections.singletonMap(module, modifiableRootModel), null, null);
final ModifiableFlexBuildConfiguration[] configurations = flexConfigEditor.getConfigurations(module);
assert configurations.length == 1;
final ModifiableFlexBuildConfiguration bc = configurations[0];
setupBC(modifiableRootModel, bc);
if (bc.getOutputType() == OutputType.Application) {
createRunConfiguration(module, bc);
}
if (sourceRoot != null && myCreateSampleApp && myFlexSdk != null) {
try {
final boolean flex4 = !FlexSdkUtils.isAirSdkWithoutFlex(myFlexSdk) && StringUtil.compareVersionNumbers(myFlexSdk.getVersionString(), "4") >= 0;
FlexUtils.createSampleApp(module.getProject(), sourceRoot, mySampleAppName, myTargetPlatform, flex4);
} catch (IOException ex) {
throw new ConfigurationException(ex.getMessage());
}
}
if (myCreateHtmlWrapperTemplate && myFlexSdk != null) {
final String path = VfsUtilCore.urlToPath(contentEntry.getUrl()) + "/" + CreateHtmlWrapperTemplateDialog.HTML_TEMPLATE_FOLDER_NAME;
if (CreateHtmlWrapperTemplateDialog.createHtmlWrapperTemplate(module.getProject(), myFlexSdk, path, myEnableHistory, myCheckPlayerVersion, myExpressInstall)) {
bc.setUseHtmlWrapper(true);
bc.setWrapperTemplatePath(path);
}
}
if (needToCommitFlexEditor) {
flexConfigEditor.commit();
}
}
use of com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor in project intellij-plugins by JetBrains.
the class AddAsSwcLibDialog method doOKAction.
@Override
protected void doOKAction() {
final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCs = myBCTree.getSelectedBCs();
final Map<Module, ModifiableRootModel> moduleToModifiableModelMap = new THashMap<>();
for (Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCs) {
moduleToModifiableModelMap.put(moduleAndBC.first, ModuleRootManager.getInstance(moduleAndBC.first).getModifiableModel());
}
final LibraryTable.ModifiableModel projectLibsModel = ProjectLibraryTable.getInstance(myProject).getModifiableModel();
final LibraryTable.ModifiableModel globalLibsModel = ApplicationLibraryTable.getApplicationTable().getModifiableModel();
final FlexProjectConfigurationEditor flexConfigEditor = FlexProjectConfigurationEditor.createEditor(myProject, moduleToModifiableModelMap, projectLibsModel, globalLibsModel);
addLib(flexConfigEditor, modulesAndBCs, myRoots);
try {
flexConfigEditor.commit();
} catch (ConfigurationException e) {
Logger.getInstance(AddAsSwcLibDialog.class).error(e);
}
ApplicationManager.getApplication().runWriteAction(() -> {
globalLibsModel.commit();
projectLibsModel.commit();
for (ModifiableRootModel modifiableRootModel : moduleToModifiableModelMap.values()) {
modifiableRootModel.commit();
}
});
if (myOpenProjectStructureCheckBox.isSelected()) {
final Pair<Module, FlexBuildConfiguration> moduleAndBc = modulesAndBCs.iterator().next();
openProjectStructure(moduleAndBc.first, moduleAndBc.second);
}
super.doOKAction();
}
Aggregations