Search in sources :

Example 91 with ConfigurationException

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);
}
Also used : TsLintState(com.intellij.lang.javascript.linter.tslint.config.TsLintState) ConfigurationException(com.intellij.openapi.options.ConfigurationException) TsLintLanguageService(com.intellij.lang.javascript.linter.tslint.service.TsLintLanguageService) TsLintConfiguration(com.intellij.lang.javascript.linter.tslint.config.TsLintConfiguration)

Example 92 with ConfigurationException

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();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileUtilRt(com.intellij.openapi.util.io.FileUtilRt) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) FileUtil(com.liferay.ide.idea.util.FileUtil) Project(com.intellij.openapi.project.Project) ModuleType(com.intellij.openapi.module.ModuleType) LiferayIdeaUI(com.liferay.ide.idea.ui.LiferayIdeaUI) LiferayProjectTypeService(com.liferay.ide.idea.core.LiferayProjectTypeService) Path(java.nio.file.Path) StdModuleTypes(com.intellij.openapi.module.StdModuleTypes) ProjectType(com.intellij.openapi.project.ProjectType) SwitchConsumer(com.liferay.ide.idea.util.SwitchConsumer) Icon(javax.swing.Icon) FileSystem(java.nio.file.FileSystem) Disposable(com.intellij.openapi.Disposable) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) SwitchConsumerBuilder(com.liferay.ide.idea.util.SwitchConsumer.SwitchConsumerBuilder) Stream(java.util.stream.Stream) BladeCLI(com.liferay.ide.idea.util.BladeCLI) ConfigurationException(com.intellij.openapi.options.ConfigurationException) FileSystems(java.nio.file.FileSystems) Project(com.intellij.openapi.project.Project) ProjectType(com.intellij.openapi.project.ProjectType) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 93 with ConfigurationException

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);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ModuleStructureConfigurable(com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module) ModuleManager(com.intellij.openapi.module.ModuleManager) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)

Example 94 with ConfigurationException

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;
}
Also used : PsiNameHelper(com.intellij.psi.PsiNameHelper) Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) PsiDirectoryFactory(com.intellij.psi.impl.file.PsiDirectoryFactory) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 95 with ConfigurationException

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;
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) File(java.io.File) ProjectManager(com.intellij.openapi.project.ProjectManager)

Aggregations

ConfigurationException (com.intellij.openapi.options.ConfigurationException)102 File (java.io.File)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)24 Project (com.intellij.openapi.project.Project)22 Module (com.intellij.openapi.module.Module)18 IOException (java.io.IOException)14 NotNull (org.jetbrains.annotations.NotNull)11 Nullable (org.jetbrains.annotations.Nullable)8 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)7 Sdk (com.intellij.openapi.projectRoots.Sdk)7 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)6 Disposable (com.intellij.openapi.Disposable)4 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)4 Pair (com.intellij.openapi.util.Pair)4 GradleProjectImporter (com.android.tools.idea.gradle.project.importing.GradleProjectImporter)3 ExecutionException (com.intellij.execution.ExecutionException)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)3