Search in sources :

Example 11 with ConfigurationException

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

the class CompoundRunConfigurationSettingsEditor method applyEditorTo.

@Override
protected void applyEditorTo(@NotNull CompoundRunConfiguration s) throws ConfigurationException {
    Set<RunConfiguration> checked = new HashSet<>();
    for (int i = 0; i < myModel.getSize(); i++) {
        RunConfiguration configuration = myModel.get(i);
        String message = LangBundle.message("compound.run.configuration.cycle", configuration.getType().getDisplayName(), configuration.getName());
        if (!canBeAdded(configuration, s))
            throw new ConfigurationException(message);
        checked.add(configuration);
    }
    Set<RunConfiguration> toRun = s.getSetToRun();
    toRun.clear();
    toRun.addAll(checked);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationException(com.intellij.openapi.options.ConfigurationException) HashSet(java.util.HashSet)

Example 12 with ConfigurationException

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

the class ProjectSdksModel method canApply.

private boolean canApply(String[] errorString, @Nullable MasterDetailsComponent rootConfigurable, boolean addedOnly) throws ConfigurationException {
    LinkedHashMap<Sdk, Sdk> sdks = new LinkedHashMap<>(myProjectSdks);
    if (addedOnly) {
        Sdk[] allJdks = ProjectJdkTable.getInstance().getAllJdks();
        for (Sdk jdk : allJdks) {
            sdks.remove(jdk);
        }
    }
    ArrayList<String> allNames = new ArrayList<>();
    Sdk itemWithError = null;
    for (Sdk currItem : sdks.values()) {
        String currName = currItem.getName();
        if (currName.isEmpty()) {
            itemWithError = currItem;
            errorString[0] = ProjectBundle.message("sdk.list.name.required.error");
            break;
        }
        if (allNames.contains(currName)) {
            itemWithError = currItem;
            errorString[0] = ProjectBundle.message("sdk.list.unique.name.required.error");
            break;
        }
        final SdkAdditionalData sdkAdditionalData = currItem.getSdkAdditionalData();
        if (sdkAdditionalData instanceof ValidatableSdkAdditionalData) {
            try {
                ((ValidatableSdkAdditionalData) sdkAdditionalData).checkValid(this);
            } catch (ConfigurationException e) {
                if (rootConfigurable != null) {
                    final Object projectJdk = rootConfigurable.getSelectedObject();
                    if (!(projectJdk instanceof Sdk) || !Comparing.strEqual(((Sdk) projectJdk).getName(), currName)) {
                        //do not leave current item with current name
                        rootConfigurable.selectNodeInTree(currName);
                    }
                }
                throw new ConfigurationException(ProjectBundle.message("sdk.configuration.exception", currName) + " " + e.getMessage());
            }
        }
        allNames.add(currName);
    }
    if (itemWithError == null)
        return true;
    if (rootConfigurable != null) {
        rootConfigurable.selectNodeInTree(itemWithError.getName());
    }
    return false;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with ConfigurationException

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

the class WebModuleBuilder method modifySettingsStep.

@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
    if (myTemplate == null) {
        return super.modifySettingsStep(settingsStep);
    }
    final WebProjectGenerator.GeneratorPeer peer = myTemplate.getPeer();
    peer.buildUI(settingsStep);
    return new ModuleWizardStep() {

        @Override
        public JComponent getComponent() {
            return null;
        }

        @Override
        public void updateDataModel() {
        }

        @Override
        public boolean validate() throws ConfigurationException {
            ValidationInfo info = peer.validate();
            if (info != null)
                throw new ConfigurationException(info.message);
            return true;
        }
    };
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo) WebProjectGenerator(com.intellij.platform.WebProjectGenerator) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with ConfigurationException

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

the class ModuleNameLocationComponent method validateExistingModuleName.

private void validateExistingModuleName() throws ConfigurationException {
    Project project = myWizardContext.getProject();
    if (project == null)
        return;
    final String moduleName = getModuleName();
    final Module module;
    final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(project);
    if (fromConfigurable != null) {
        module = fromConfigurable.getModulesConfig().getModule(moduleName);
    } else {
        module = ModuleManager.getInstance(project).findModuleByName(moduleName);
    }
    if (module != null) {
        throw new ConfigurationException("Module \'" + moduleName + "\' already exist in project. Please, specify another name.");
    }
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)

Example 15 with ConfigurationException

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

the class NamePathComponent method validateNameAndPath.

public boolean validateNameAndPath(WizardContext context, boolean defaultFormat) throws ConfigurationException {
    String name = getNameValue();
    if (StringUtil.isEmptyOrSpaces(name)) {
        ApplicationInfo info = ApplicationInfo.getInstance();
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name", info.getVersionName(), context.getPresentationName()));
    }
    String projectDirectory = getPath();
    if (StringUtil.isEmptyOrSpaces(projectDirectory)) {
        throw new ConfigurationException(IdeBundle.message("prompt.enter.project.file.location", context.getPresentationName()));
    }
    if (myShouldBeAbsolute && !new File(projectDirectory).isAbsolute()) {
        throw new ConfigurationException(StringUtil.capitalize(IdeBundle.message("file.location.should.be.absolute", context.getPresentationName())));
    }
    boolean shouldPromptCreation = isPathChangedByUser();
    String message = IdeBundle.message("directory.project.file.directory", context.getPresentationName());
    if (!ProjectWizardUtil.createDirectoryIfNotExists(message, projectDirectory, shouldPromptCreation)) {
        return false;
    }
    File file = new File(projectDirectory);
    if (file.exists() && !file.canWrite()) {
        throw new ConfigurationException(String.format("Directory '%s' is not seem to be writable. Please consider another location.", projectDirectory));
    }
    for (Project p : ProjectManager.getInstance().getOpenProjects()) {
        if (ProjectUtil.isSameProject(projectDirectory, p)) {
            throw new ConfigurationException(String.format("Directory '%s' is already taken by the project '%s'. Please consider another location.", projectDirectory, p.getName()));
        }
    }
    boolean shouldContinue = true;
    String fileName = defaultFormat ? name + ProjectFileType.DOT_DEFAULT_EXTENSION : Project.DIRECTORY_STORE_FOLDER;
    File projectFile = new File(file, fileName);
    if (projectFile.exists()) {
        message = IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(), context.getPresentationName());
        int answer = Messages.showYesNoDialog(message, IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
        shouldContinue = (answer == Messages.YES);
    }
    return shouldContinue;
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) File(java.io.File)

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