use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlexModuleWizardForm method validate.
public boolean validate() throws ConfigurationException {
final Sdk sdk = mySdkCombo.getSelectedSdk();
if (sdk != null) {
if (myTargetPlatformCombo.getSelectedItem() == TargetPlatform.Mobile && !FlexSdkUtils.isAirSdkWithoutFlex(sdk) && StringUtil.compareVersionNumbers(sdk.getVersionString(), "4.5") < 0) {
throw new ConfigurationException(FlexBundle.message("sdk.does.not.support.air.mobile", sdk.getVersionString()));
}
if (FlexSdkUtils.isAirSdkWithoutFlex(sdk) && !myPureActionScriptCheckBox.isSelected()) {
throw new ConfigurationException(StringUtil.capitalize(FlexBundle.message("air.sdk.requires.pure.as", sdk.getName())));
}
if (mySampleAppCheckBox.isSelected()) {
final String fileName = mySampleAppTextField.getText().trim();
if (fileName.isEmpty()) {
throw new ConfigurationException(FlexBundle.message("sample.app.name.empty"));
}
final String extension = FileUtilRt.getExtension(fileName).toLowerCase();
if (!"mxml".equals(extension) && !"as".equals(extension)) {
throw new ConfigurationException(FlexBundle.message("sample.app.incorrect.extension"));
}
}
}
return true;
}
use of com.intellij.openapi.options.ConfigurationException 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.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlexProjectConfigurationEditor method checkCanCommit.
public void checkCanCommit() throws ConfigurationException {
for (Module module : myModule2Editors.keySet()) {
List<Editor> editors = myModule2Editors.get(module);
Set<String> names = new HashSet<>();
for (Editor editor : editors) {
if (!names.add(editor.getName())) {
throw new ConfigurationException("Duplicate build configuration name '" + editor.getName() + "' in module '" + module.getName() + "'");
}
}
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class FlashBuilderProjectFinder method _isMultiProjectArchive.
private static boolean _isMultiProjectArchive(final String archiveFilePath) throws ConfigurationException {
boolean containsDotProjectFile = false;
boolean containsDotActionScriptFile = false;
boolean containsNestedProjects = false;
ZipFile zipFile = null;
try {
zipFile = new ZipFile(archiveFilePath);
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
final String entryName = entries.nextElement().getName();
if (FlashBuilderImporter.DOT_PROJECT.equals(entryName))
containsDotProjectFile = true;
if (FlashBuilderImporter.DOT_ACTION_SCRIPT_PROPERTIES.equals(entryName))
containsDotActionScriptFile = true;
if (entryName.endsWith(FlashBuilderImporter.DOT_FXP) || entryName.endsWith(FlashBuilderImporter.DOT_FXPL)) {
containsNestedProjects = true;
}
if (containsDotProjectFile && containsDotActionScriptFile && containsNestedProjects)
break;
}
if (!containsDotProjectFile || !containsDotActionScriptFile) {
throw new ConfigurationException(FlexBundle.message("does.not.contain.flash.builder.projects"), CommonBundle.getErrorTitle());
}
return containsNestedProjects;
} catch (IOException e) {
throw new ConfigurationException(FlexBundle.message("does.not.contain.flash.builder.projects"), CommonBundle.getErrorTitle());
} finally {
if (zipFile != null) {
try {
zipFile.close();
} catch (IOException ignore) {
/*ignore*/
}
}
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class TsLintConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
super.apply();
final TsLintState state = getExtendedState(TsLintConfiguration.class).getState();
if (!StringUtil.isEmptyOrSpaces(state.getPackagePath()) && state.isAllowJs()) {
if (!checkPackageVersionForJs(state.getPackagePath()))
throw new ConfigurationException("Linting JavaScript is not supported for this version of TSLint.");
}
final TsLintLanguageService service = TsLintLanguageService.getService(myProject);
service.terminateStartedProcess(false);
}
Aggregations