Search in sources :

Example 81 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.

the class ModuleNameLocationComponent method validateModulePaths.

private boolean validateModulePaths() throws ConfigurationException {
    final String moduleName = getModuleName();
    final String moduleFileDirectory = myModuleFileLocation.getText();
    if (moduleFileDirectory.length() == 0) {
        throw new ConfigurationException("Enter module file location");
    }
    if (moduleName.length() == 0) {
        throw new ConfigurationException("Enter a module name");
    }
    if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.file"), moduleFileDirectory, myImlLocationChangedByUser)) {
        return false;
    }
    if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.content.root"), myModuleContentRoot.getText(), myContentRootChangedByUser)) {
        return false;
    }
    File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
    if (moduleFile.exists()) {
        int answer = Messages.showYesNoDialog(IdeBundle.message("prompt.overwrite.project.file", moduleFile.getAbsolutePath(), IdeBundle.message("project.new.wizard.module.identification")), IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
        if (answer != Messages.YES) {
            return false;
        }
    }
    return true;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 82 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.

the class ProjectNameStep method validate.

public boolean validate() throws ConfigurationException {
    String name = myNamePathComponent.getNameValue();
    if (name.length() == 0) {
        final ApplicationInfo info = ApplicationInfo.getInstance();
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name", info.getVersionName(), myWizardContext.getPresentationName()));
    }
    final String projectFileDirectory = getProjectFileDirectory();
    if (projectFileDirectory.length() == 0) {
        throw new ConfigurationException(IdeBundle.message("prompt.enter.project.file.location", myWizardContext.getPresentationName()));
    }
    final boolean shouldPromptCreation = myNamePathComponent.isPathChangedByUser();
    String prefix = IdeBundle.message("directory.project.file.directory", myWizardContext.getPresentationName());
    if (!ProjectWizardUtil.createDirectoryIfNotExists(prefix, projectFileDirectory, shouldPromptCreation)) {
        return false;
    }
    boolean shouldContinue = true;
    final String path = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED ? getProjectFileDirectory() + "/" + Project.DIRECTORY_STORE_FOLDER : getProjectFilePath();
    final File projectFile = new File(path);
    if (projectFile.exists()) {
        final String title = myWizardContext.isCreatingNewProject() ? IdeBundle.message("title.new.project") : IdeBundle.message("title.add.module");
        final String message = myWizardContext.isCreatingNewProject() && myWizardContext.getProjectStorageFormat() == DIRECTORY_BASED ? IdeBundle.message("prompt.overwrite.project.folder", Project.DIRECTORY_STORE_FOLDER, projectFile.getParentFile().getAbsolutePath()) : IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(), myWizardContext.getPresentationName());
        int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
        shouldContinue = answer == Messages.YES;
    }
    return shouldContinue;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) File(java.io.File)

Example 83 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.

the class AbstractExternalProjectImportBuilder method ensureProjectIsDefined.

/**
   * Asks current builder to ensure that target external project is defined.
   *
   * @param wizardContext             current wizard context
   * @throws ConfigurationException   if external project is not defined and can't be constructed
   */
@SuppressWarnings("unchecked")
public void ensureProjectIsDefined(@NotNull WizardContext wizardContext) throws ConfigurationException {
    final String externalSystemName = myExternalSystemId.getReadableName();
    File projectFile = getProjectFile();
    if (projectFile == null) {
        throw new ConfigurationException(ExternalSystemBundle.message("error.project.undefined"));
    }
    projectFile = getExternalProjectConfigToUse(projectFile);
    final Ref<ConfigurationException> error = new Ref<>();
    final ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {

        @Override
        public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
            myExternalProjectNode = externalProject;
        }

        @Override
        public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
            if (!StringUtil.isEmpty(errorDetails)) {
                LOG.warn(errorDetails);
            }
            error.set(new ConfigurationException(ExternalSystemBundle.message("error.resolve.with.log_link", errorMessage, PathManager.getLogPath()), ExternalSystemBundle.message("error.resolve.generic")));
        }
    };
    final Project project = getProject(wizardContext);
    final File finalProjectFile = projectFile;
    final String externalProjectPath = FileUtil.toCanonicalPath(finalProjectFile.getAbsolutePath());
    final Ref<ConfigurationException> exRef = new Ref<>();
    executeAndRestoreDefaultProjectSettings(project, () -> {
        try {
            ExternalSystemUtil.refreshProject(project, myExternalSystemId, externalProjectPath, callback, true, ProgressExecutionMode.MODAL_SYNC);
        } catch (IllegalArgumentException e) {
            exRef.set(new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName)));
        }
    });
    ConfigurationException ex = exRef.get();
    if (ex != null) {
        throw ex;
    }
    if (myExternalProjectNode == null) {
        ConfigurationException exception = error.get();
        if (exception != null) {
            throw exception;
        }
    } else {
        applyProjectSettings(wizardContext);
    }
}
Also used : Project(com.intellij.openapi.project.Project) Ref(com.intellij.openapi.util.Ref) ConfigurationException(com.intellij.openapi.options.ConfigurationException) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ExternalProjectRefreshCallback(com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Example 84 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.

the class JsonSchemaMappingsConfigurable method updateWarningText.

private void updateWarningText() {
    final MultiMap<String, JsonSchemaMappingsConfigurationBase.Item> patternsMap = new MultiMap<>();
    final StringBuilder sb = new StringBuilder();
    final List<JsonSchemaMappingsConfigurationBase.SchemaInfo> list;
    try {
        list = getUiList(false);
    } catch (ConfigurationException e) {
        // will not happen
        return;
    }
    for (JsonSchemaMappingsConfigurationBase.SchemaInfo info : list) {
        final JsonSchemaPatternComparator comparator = new JsonSchemaPatternComparator(myProject);
        final List<JsonSchemaMappingsConfigurationBase.Item> patterns = info.getPatterns();
        for (JsonSchemaMappingsConfigurationBase.Item pattern : patterns) {
            for (Map.Entry<String, Collection<JsonSchemaMappingsConfigurationBase.Item>> entry : patternsMap.entrySet()) {
                for (JsonSchemaMappingsConfigurationBase.Item item : entry.getValue()) {
                    final ThreeState similar = comparator.isSimilar(pattern, item);
                    if (ThreeState.NO.equals(similar))
                        continue;
                    if (sb.length() > 0)
                        sb.append('\n');
                    sb.append("'").append(pattern.getPresentation()).append("' for schema '").append(info.getName()).append("' and '").append(item.getPresentation()).append("' for schema '").append(entry.getKey()).append("'");
                }
            }
        }
        patternsMap.put(info.getName(), patterns);
    }
    if (sb.length() > 0) {
        myError = "Conflicting mappings:\n" + sb.toString();
    } else {
        myError = null;
    }
    final Enumeration children = myRoot.children();
    while (children.hasMoreElements()) {
        Object o = children.nextElement();
        if (o instanceof MyNode && ((MyNode) o).getConfigurable() instanceof JsonSchemaConfigurable) {
            ((JsonSchemaConfigurable) ((MyNode) o).getConfigurable()).setError(myError);
        }
    }
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ThreeState(com.intellij.util.ThreeState) ConfigurationException(com.intellij.openapi.options.ConfigurationException) MultiMap(com.intellij.util.containers.MultiMap)

Example 85 with ConfigurationException

use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.

the class HectorComponent method onClose.

private void onClose() {
    if (isModified()) {
        for (HectorComponentPanel panel : myAdditionalPanels) {
            try {
                panel.apply();
            } catch (ConfigurationException e) {
            //shouldn't be
            }
        }
        forceDaemonRestart();
        DaemonListeners.getInstance(myFile.getProject()).updateStatusBar();
    }
}
Also used : HectorComponentPanel(com.intellij.openapi.editor.HectorComponentPanel) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Aggregations

ConfigurationException (com.intellij.openapi.options.ConfigurationException)102 File (java.io.File)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)24 Project (com.intellij.openapi.project.Project)22 Module (com.intellij.openapi.module.Module)18 IOException (java.io.IOException)14 NotNull (org.jetbrains.annotations.NotNull)11 Nullable (org.jetbrains.annotations.Nullable)8 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)7 Sdk (com.intellij.openapi.projectRoots.Sdk)7 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)6 Disposable (com.intellij.openapi.Disposable)4 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 ExecutionException (com.intellij.execution.ExecutionException)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)3