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