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;
}
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();
}
}
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();
}
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());
}
});
}
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");
}
}
}
Aggregations