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