use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class IntroduceParameterObjectDialog method canRun.
@Override
protected void canRun() throws ConfigurationException {
super.canRun();
final Project project = mySourceMethod.getProject();
final PsiNameHelper nameHelper = PsiNameHelper.getInstance(project);
if (myCreateInnerClassRadioButton.isSelected()) {
final String innerClassName = getInnerClassName();
if (!nameHelper.isIdentifier(innerClassName))
throw new ConfigurationException("\'" + innerClassName + "\' is invalid inner class name");
if (mySourceMethod.getContainingClass().findInnerClassByName(innerClassName, false) != null)
throw new ConfigurationException("Inner class with name \'" + innerClassName + "\' already exist");
} else if (!useExistingClass()) {
final String className = getClassName();
if (className.length() == 0 || !nameHelper.isIdentifier(className)) {
throw new ConfigurationException("\'" + className + "\' is invalid parameter class name");
}
final String packageName = getPackageName();
if (packageName.length() == 0 || !nameHelper.isQualifiedName(packageName)) {
throw new ConfigurationException("\'" + packageName + "\' is invalid parameter class package name");
}
} else {
final String className = getExistingClassName();
if (className.length() == 0 || !nameHelper.isQualifiedName(className)) {
throw new ConfigurationException("\'" + className + "\' is invalid qualified parameter class name");
}
if (JavaPsiFacade.getInstance(getProject()).findClass(className, GlobalSearchScope.allScope(getProject())) == null) {
throw new ConfigurationException("\'" + className + "\' does not exist");
}
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class JsonSchemaConfigurable method doValidation.
private void doValidation() throws ConfigurationException {
final File file = new File(myProject.getBasePath(), myView.getSchemaSubPath());
VirtualFile vFile = null;
if (!file.exists() || (vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file)) == null) {
throw new ConfigurationException((!StringUtil.isEmptyOrSpaces(myDisplayName) ? (myDisplayName + ": ") : "") + "Schema file does not exist");
}
final String filename = file.getName();
if (StringUtil.isEmptyOrSpaces(myDisplayName))
throw new ConfigurationException(filename + ": Schema name is empty");
if (StringUtil.isEmptyOrSpaces(myView.getSchemaSubPath()))
throw new ConfigurationException(filename + ": Schema path is empty");
final CollectConsumer<String> collectConsumer = new CollectConsumer<>();
final JsonSchemaService service = JsonSchemaService.Impl.get(myProject);
if (service != null && !service.isSchemaFile(vFile, collectConsumer)) {
final String message;
if (collectConsumer.getResult().isEmpty())
message = filename + ": Can not read JSON schema from file (Unknown reason)";
else
message = filename + ": Can not read JSON schema from file: " + StringUtil.join(collectConsumer.getResult(), "; ");
logErrorForUser(message);
throw new RuntimeConfigurationWarning(message);
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class VcsConfigurationsDialog method doOKAction.
protected void doOKAction() {
for (String vcsName : myVcsNameToConfigurableMap.keySet()) {
UnnamedConfigurable configurable = myVcsNameToConfigurableMap.get(vcsName);
if (configurable != null && configurable.isModified()) {
try {
configurable.apply();
} catch (ConfigurationException e) {
Messages.showErrorDialog(VcsBundle.message("message.text.unable.to.save.settings", e.getMessage()), VcsBundle.message("message.title.unable.to.save.settings"));
}
}
}
final JComboBox vcsesToUpdate = myVcsesToUpdate;
if (vcsesToUpdate != null) {
final VcsDescriptor wrapper = (VcsDescriptor) myVcses.getSelectedValue();
vcsesToUpdate.setSelectedItem(wrapper);
final ComboBoxModel model = vcsesToUpdate.getModel();
for (int i = 0; i < model.getSize(); i++) {
final Object vcsWrapper = model.getElementAt(i);
if (vcsWrapper instanceof VcsDescriptor) {
final VcsDescriptor defaultVcsWrapper = (VcsDescriptor) vcsWrapper;
if (defaultVcsWrapper.equals(wrapper)) {
vcsesToUpdate.setSelectedIndex(i);
break;
}
}
}
}
super.doOKAction();
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class GradleModuleBuilder method saveFile.
private static void saveFile(@NotNull VirtualFile file, @NotNull String templateName, @Nullable Map templateAttributes) throws ConfigurationException {
FileTemplateManager manager = FileTemplateManager.getDefaultInstance();
FileTemplate template = manager.getInternalTemplate(templateName);
try {
appendToFile(file, templateAttributes != null ? template.getText(templateAttributes) : template.getText());
} catch (IOException e) {
LOG.warn(String.format("Unexpected exception on applying template %s config", GradleConstants.SYSTEM_ID.getReadableName()), e);
throw new ConfigurationException(e.getMessage(), String.format("Can't apply %s template config text", GradleConstants.SYSTEM_ID.getReadableName()));
}
}
use of com.intellij.openapi.options.ConfigurationException in project intellij-community by JetBrains.
the class GradleModuleBuilder method appendToFile.
private static void appendToFile(@NotNull VirtualFile file, @NotNull String templateName, @Nullable Map templateAttributes) throws ConfigurationException {
FileTemplateManager manager = FileTemplateManager.getDefaultInstance();
FileTemplate template = manager.getInternalTemplate(templateName);
try {
appendToFile(file, templateAttributes != null ? template.getText(templateAttributes) : template.getText());
} catch (IOException e) {
LOG.warn(String.format("Unexpected exception on appending template %s config", GradleConstants.SYSTEM_ID.getReadableName()), e);
throw new ConfigurationException(e.getMessage(), String.format("Can't append %s template config text", GradleConstants.SYSTEM_ID.getReadableName()));
}
}
Aggregations