Search in sources :

Example 71 with ConfigurationException

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

the class SingleConfigurationConfigurable method getValidationResult.

@Nullable
private ValidationResult getValidationResult() {
    if (!myValidationResultValid) {
        myLastValidationResult = null;
        RunnerAndConfigurationSettings snapshot = null;
        try {
            snapshot = getSnapshot();
            if (snapshot != null) {
                snapshot.setName(getNameText());
                snapshot.checkSettings(myExecutor);
                for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
                    ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), snapshot.getConfiguration());
                    if (runner != null) {
                        checkConfiguration(runner, snapshot);
                    }
                }
            }
        } catch (RuntimeConfigurationException exception) {
            final Runnable quickFix = exception.getQuickFix();
            Runnable resultQuickFix;
            if (quickFix != null && snapshot != null) {
                final RunnerAndConfigurationSettings fixedSettings = snapshot;
                resultQuickFix = () -> {
                    quickFix.run();
                    getEditor().resetFrom(fixedSettings);
                };
            } else {
                resultQuickFix = quickFix;
            }
            myLastValidationResult = new ValidationResult(exception.getLocalizedMessage(), exception.getTitle(), resultQuickFix);
        } catch (ConfigurationException e) {
            myLastValidationResult = new ValidationResult(e.getLocalizedMessage(), ExecutionBundle.message("invalid.data.dialog.title"), null);
        }
        myValidationResultValid = true;
    }
    return myLastValidationResult;
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) ProgramRunner(com.intellij.execution.runners.ProgramRunner) Nullable(org.jetbrains.annotations.Nullable)

Example 72 with ConfigurationException

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

the class ProjectJdksConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    final Ref<ConfigurationException> exceptionRef = Ref.create();
    try {
        super.apply();
        boolean modifiedJdks = false;
        for (int i = 0; i < myRoot.getChildCount(); i++) {
            final NamedConfigurable configurable = ((MyNode) myRoot.getChildAt(i)).getConfigurable();
            if (configurable.isModified()) {
                configurable.apply();
                modifiedJdks = true;
            }
        }
        if (myProjectJdksModel.isModified() || modifiedJdks) {
            myProjectJdksModel.apply(this);
        }
        myProjectJdksModel.setProjectSdk(getSelectedJdk());
    } catch (ConfigurationException e) {
        exceptionRef.set(e);
    }
    if (!exceptionRef.isNull()) {
        throw exceptionRef.get();
    }
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable)

Example 73 with ConfigurationException

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

the class ProjectStructureConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    LOG.assertTrue(TransactionGuard.getInstance().getContextTransaction() != null, "Project Structure should be shown in a transaction, see AnAction#startInTransaction");
    for (Configurable each : myName2Config) {
        if (each instanceof BaseStructureConfigurable && each.isModified()) {
            ((BaseStructureConfigurable) each).checkCanApply();
        }
    }
    final Ref<ConfigurationException> exceptionRef = Ref.create();
    try {
        for (Configurable each : myName2Config) {
            if (each.isModified()) {
                each.apply();
            }
        }
    } catch (ConfigurationException e) {
        exceptionRef.set(e);
    }
    if (!exceptionRef.isNull()) {
        throw exceptionRef.get();
    }
    myContext.getDaemonAnalyzer().clearCaches();
    BuildManager.getInstance().scheduleAutoMake();
}
Also used : ConfigurationException(com.intellij.openapi.options.ConfigurationException) Configurable(com.intellij.openapi.options.Configurable) BaseConfigurable(com.intellij.openapi.options.BaseConfigurable) ArtifactsStructureConfigurable(com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable)

Example 74 with ConfigurationException

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

the class ProjectConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    final CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(myProject);
    assert compilerProjectExtension != null : myProject;
    if (myProjectName != null && StringUtil.isEmptyOrSpaces(myProjectName.getText())) {
        throw new ConfigurationException("Please, specify project name!");
    }
    ApplicationManager.getApplication().runWriteAction(() -> {
        // set the output path first so that handlers of RootsChanged event sent after JDK is set
        // would see the updated path
        String canonicalPath = myProjectCompilerOutput.getText();
        if (canonicalPath != null && canonicalPath.length() > 0) {
            try {
                canonicalPath = FileUtil.resolveShortWindowsName(canonicalPath);
            } catch (IOException e) {
            //file doesn't exist yet
            }
            canonicalPath = FileUtil.toSystemIndependentName(canonicalPath);
            compilerProjectExtension.setCompilerOutputUrl(VfsUtilCore.pathToUrl(canonicalPath));
        } else {
            compilerProjectExtension.setCompilerOutputPointer(null);
        }
        LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(myProject);
        LanguageLevel level = myLanguageLevelCombo.getSelectedLevel();
        if (level != null) {
            extension.setLanguageLevel(level);
        }
        extension.setDefault(myLanguageLevelCombo.isDefault());
        myProjectJdkConfigurable.apply();
        if (myProjectName != null) {
            ((ProjectEx) myProject).setProjectName(getProjectName());
            if (myDetailsComponent != null)
                myDetailsComponent.setText(getBannerSlogan());
        }
    });
}
Also used : ProjectEx(com.intellij.openapi.project.ex.ProjectEx) ConfigurationException(com.intellij.openapi.options.ConfigurationException) LanguageLevel(com.intellij.pom.java.LanguageLevel) CompilerProjectExtension(com.intellij.openapi.roots.CompilerProjectExtension) IOException(java.io.IOException) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 75 with ConfigurationException

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

the class ExtractClassDialog method canRun.

@Override
protected void canRun() throws ConfigurationException {
    final Project project = sourceClass.getProject();
    final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
    final List<PsiMethod> methods = getMethodsToExtract();
    final List<PsiField> fields = getFieldsToExtract();
    final List<PsiClass> innerClasses = getClassesToExtract();
    if (methods.isEmpty() && fields.isEmpty() && innerClasses.isEmpty()) {
        throw new ConfigurationException("Nothing found to extract");
    }
    final String className = getClassName();
    if (className.length() == 0 || !nameHelper.isIdentifier(className)) {
        throw new ConfigurationException("\'" + className + "\' is invalid extracted class name");
    }
    /*final String packageName = getPackageName();
    if (packageName.length() == 0 || !nameHelper.isQualifiedName(packageName)) {
      throw new ConfigurationException("\'" + packageName + "\' is invalid extracted class package name");
    }*/
    for (PsiClass innerClass : innerClasses) {
        if (className.equals(innerClass.getName())) {
            throw new ConfigurationException("Extracted class should have unique name. Name " + "\'" + className + "\' is already in use by one of the inner classes");
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) 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