use of com.intellij.openapi.options.ConfigurationException in project intellij-plugins by JetBrains.
the class TsLintConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
super.apply();
final TsLintState state = getExtendedState(TsLintConfiguration.class).getState();
if (!StringUtil.isEmptyOrSpaces(state.getPackagePath()) && state.isAllowJs()) {
if (!checkPackageVersionForJs(state.getPackagePath()))
throw new ConfigurationException("Linting JavaScript is not supported for this version of TSLint.");
}
final TsLintLanguageService service = TsLintLanguageService.getService(myProject);
service.terminateStartedProcess(false);
}
use of com.intellij.openapi.options.ConfigurationException in project liferay-ide by liferay.
the class LiferayModuleFragmentBuilder method setupRootModel.
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
VirtualFile projectRoot = _createAndGetContentEntry();
Project project = rootModel.getProject();
ProjectType liferayProjectType = LiferayProjectTypeService.getProjectType(project);
_createProject(projectRoot, liferayProjectType.getId());
File hostBundle = new File(LiferayIdeaUI.USER_BUNDLES_DIR, _fragmentHost.substring(0, _fragmentHost.lastIndexOf(".jar")));
SwitchConsumerBuilder<File> switch_ = SwitchConsumer.newBuilder();
SwitchConsumer<File> switchConsumer = switch_.addCase(f -> f.getName().equals("portlet.properties"), f -> _copyPortletExtProperties(projectRoot, f)).addCase(f -> f.getName().contains("default.xml"), f -> _createDefaultExtXmlFile(projectRoot, f)).setDefault(f -> _copyOtherResource(projectRoot, f)).build();
Stream<String> stream = Stream.of(_overrideFiles);
stream.map(overrideFile -> new File(hostBundle, overrideFile)).filter(file -> file.exists()).forEach(switchConsumer);
rootModel.addContentEntry(projectRoot);
if (myJdk != null) {
rootModel.setSdk(myJdk);
} else {
rootModel.inheritSdk();
}
}
use of com.intellij.openapi.options.ConfigurationException in project liferay-ide by liferay.
the class LiferayModuleNameLocationComponent method _validateExistingModuleName.
private void _validateExistingModuleName() throws ConfigurationException {
Project project = _context.getProject();
if (project == null) {
return;
}
String moduleName = _getModuleName();
Module module;
ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(project);
if (fromConfigurable != null) {
ModuleStructureConfigurable moduleStructureConfigurable = fromConfigurable.getModulesConfig();
module = moduleStructureConfigurable.getModule(moduleName);
} else {
ModuleManager moduleManager = ModuleManager.getInstance(project);
module = moduleManager.findModuleByName(moduleName);
}
if (module != null) {
String msg = "Module \'" + moduleName + "\' already exists in project. Please specify another name.";
throw new ConfigurationException(msg);
}
}
use of com.intellij.openapi.options.ConfigurationException in project liferay-ide by liferay.
the class LiferayModuleWizardStep method validate.
@Override
public boolean validate() throws ConfigurationException {
String validationTitle = "Validation Error";
if (CoreUtil.isNullOrEmpty(getSelectedType())) {
throw new ConfigurationException("Please click one of the items to select a template", validationTitle);
}
ProjectManager projectManager = ProjectManager.getInstance();
Project workspaceProject = projectManager.getOpenProjects()[0];
String packageNameValue = getPackageName();
String classNameValue = getClassName();
PsiDirectoryFactory psiDirectoryFactory = PsiDirectoryFactory.getInstance(workspaceProject);
PsiNameHelper psiNameHelper = PsiNameHelper.getInstance(workspaceProject);
if (!CoreUtil.isNullOrEmpty(packageNameValue) && !psiDirectoryFactory.isValidPackageName(packageNameValue)) {
throw new ConfigurationException(packageNameValue + " is not a valid package name", validationTitle);
}
if (!CoreUtil.isNullOrEmpty(classNameValue) && !psiNameHelper.isQualifiedName(classNameValue)) {
throw new ConfigurationException(classNameValue + " is not a valid java class name", validationTitle);
}
return true;
}
use of com.intellij.openapi.options.ConfigurationException in project liferay-ide by liferay.
the class LiferayNamePathComponent method validateNameAndPath.
public boolean validateNameAndPath(WizardContext context, boolean defaultFormat) throws ConfigurationException {
String name = getNameValue();
if (StringUtil.isEmptyOrSpaces(name)) {
ApplicationInfo applicationInfo = ApplicationInfo.getInstance();
throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name", applicationInfo.getVersionName(), context.getPresentationName()));
}
String projectDirectory = getPath();
if (StringUtil.isEmptyOrSpaces(projectDirectory)) {
throw new ConfigurationException(IdeBundle.message("prompt.enter.project.file.location", context.getPresentationName()));
}
if (_shouldBeAbsolute && !new File(projectDirectory).isAbsolute()) {
throw new ConfigurationException(StringUtil.capitalize(IdeBundle.message("file.location.should.be.absolute", context.getPresentationName())));
}
String message = IdeBundle.message("directory.project.file.directory", context.getPresentationName());
if (!ProjectWizardUtil.createDirectoryIfNotExists(message, projectDirectory, isPathChangedByUser())) {
return false;
}
File file = new File(projectDirectory);
if (file.exists() && !file.canWrite()) {
String msg = String.format("Directory '%s' is not seem to be writable. Please consider another location.", projectDirectory);
throw new ConfigurationException(msg);
}
ProjectManager projectManager = ProjectManager.getInstance();
for (Project project : projectManager.getOpenProjects()) {
if (ProjectUtil.isSameProject(projectDirectory, project)) {
String msg = String.format("Directory '%s' is already taken by the project '%s'. Please consider another location.", projectDirectory, project.getName());
throw new ConfigurationException(msg);
}
}
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