Search in sources :

Example 36 with ConfigurationException

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;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 37 with ConfigurationException

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());
}
Also used : THashSet(gnu.trove.THashSet) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) THashMap(gnu.trove.THashMap) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module)

Example 38 with ConfigurationException

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() + "'");
            }
        }
    }
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module) THashSet(gnu.trove.THashSet)

Example 39 with ConfigurationException

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*/
            }
        }
    }
}
Also used : ZipFile(java.util.zip.ZipFile) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 40 with ConfigurationException

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);
}
Also used : TsLintState(com.intellij.lang.javascript.linter.tslint.config.TsLintState) ConfigurationException(com.intellij.openapi.options.ConfigurationException) TsLintLanguageService(com.intellij.lang.javascript.linter.tslint.service.TsLintLanguageService) TsLintConfiguration(com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration)

Aggregations

ConfigurationException (com.intellij.openapi.options.ConfigurationException)86 VirtualFile (com.intellij.openapi.vfs.VirtualFile)20 File (java.io.File)17 Module (com.intellij.openapi.module.Module)16 Project (com.intellij.openapi.project.Project)15 IOException (java.io.IOException)12 NotNull (org.jetbrains.annotations.NotNull)9 Nullable (org.jetbrains.annotations.Nullable)8 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)7 Sdk (com.intellij.openapi.projectRoots.Sdk)6 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)5 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)4 Pair (com.intellij.openapi.util.Pair)4 GradleProjectImporter (com.android.tools.idea.gradle.project.importing.GradleProjectImporter)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)3 FlexBCConfigurable (com.intellij.lang.javascript.flex.projectStructure.ui.FlexBCConfigurable)3 Disposable (com.intellij.openapi.Disposable)3 Library (com.intellij.openapi.roots.libraries.Library)3