List of usage examples for com.intellij.openapi.ui Messages showErrorDialog
public static void showErrorDialog(@Nullable Component component, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:org.jetbrains.jet.plugin.versions.OutdatedKotlinRuntimeNotification.java
License:Apache License
@NotNull public static Runnable showRuntimeJarNotFoundDialog(@NotNull final Project project, final @NotNull String jarName) { return new Runnable() { @Override// ww w .java2 s . c o m public void run() { Messages.showErrorDialog(project, jarName + " is not found. Make sure plugin is properly installed.", "No Runtime Found"); } }; }
From source file:org.jetbrains.kotlin.idea.configuration.KotlinMavenConfigurator.java
License:Apache License
private static void showErrorMessage(@NotNull Project project, @Nullable String message) { Messages.showErrorDialog(project, "<html>Couldn't configure kotlin-maven plugin automatically.<br/>" + (message != null ? message : "") + "See manual installation instructions <a href=\"http://confluence.jetbrains.com/display/Kotlin/Kotlin+Build+Tools#KotlinBuildTools-Maven\">here</a></html>", "Configure Kotlin-Maven Plugin"); }
From source file:org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog.java
License:Apache License
@Nullable private KotlinMoveTarget selectMoveTarget() { String message = verifyBeforeRun(); if (message != null) { setErrorText(message);/* w w w . j ava 2s . c o m*/ return null; } setErrorText(null); List<KtFile> sourceFiles = getSourceFiles(getSelectedElementsToMove()); PsiDirectory sourceDirectory = getSourceDirectory(sourceFiles); if (isMoveToPackage()) { final MoveDestination moveDestination = selectPackageBasedMoveDestination(true); if (moveDestination == null) return null; final String targetFileName = sourceFiles.size() > 1 ? null : tfFileNameInPackage.getText(); if (targetFileName != null && !checkTargetFileName(targetFileName)) return null; PsiDirectory targetDirectory = moveDestination.getTargetIfExists(sourceDirectory); List<PsiFile> filesExistingInTargetDir = getFilesExistingInTargetDir(sourceFiles, targetFileName, targetDirectory); if (!filesExistingInTargetDir.isEmpty()) { if (!CollectionsKt.intersect(sourceFiles, filesExistingInTargetDir).isEmpty()) { setErrorText("Can't move to the original file(s)"); return null; } if (filesExistingInTargetDir.size() > 1) { String filePathsToReport = StringUtil.join(filesExistingInTargetDir, new Function<PsiFile, String>() { @Override public String fun(PsiFile file) { return file.getVirtualFile().getPath(); } }, "\n"); Messages.showErrorDialog(myProject, "Cannot perform refactoring since the following files already exist:\n\n" + filePathsToReport, RefactoringBundle.message("move.title")); return null; } String question = String.format( "File '%s' already exists. Do you want to move selected declarations to this file?", filesExistingInTargetDir.get(0).getVirtualFile().getPath()); int ret = Messages.showYesNoDialog(myProject, question, RefactoringBundle.message("move.title"), Messages.getQuestionIcon()); if (ret != Messages.YES) return null; } // All source files must be in the same directory return new KotlinMoveTargetForDeferredFile(new FqName(getTargetPackage()), moveDestination.getTargetIfExists(sourceFiles.get(0)), new Function1<KtFile, KtFile>() { @Override public KtFile invoke(@NotNull KtFile originalFile) { return JetRefactoringUtilKt.getOrCreateKotlinFile( targetFileName != null ? targetFileName : originalFile.getName(), moveDestination.getTargetDirectory(originalFile)); } }); } final File targetFile = new File(getTargetFilePath()); if (!checkTargetFileName(targetFile.getName())) return null; KtFile jetFile = (KtFile) JetRefactoringUtilKt.toPsiFile(targetFile, myProject); if (jetFile != null) { if (sourceFiles.size() == 1 && sourceFiles.contains(jetFile)) { setErrorText("Can't move to the original file"); return null; } return new KotlinMoveTargetForExistingElement(jetFile); } File targetDir = targetFile.getParentFile(); final PsiDirectory psiDirectory = targetDir != null ? JetRefactoringUtilKt.toPsiDirectory(targetDir, myProject) : null; if (psiDirectory == null) { setErrorText("No directory found for file: " + targetFile.getPath()); return null; } Set<FqName> sourcePackageFqNames = CollectionsKt.mapTo(sourceFiles, new LinkedHashSet<FqName>(), new Function1<KtFile, FqName>() { @Override public FqName invoke(KtFile file) { return file.getPackageFqName(); } }); FqName targetPackageFqName = CollectionsKt.singleOrNull(sourcePackageFqNames); if (targetPackageFqName == null) { PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory); if (psiPackage == null) { setErrorText("Could not find package corresponding to " + targetDir.getPath()); return null; } targetPackageFqName = new FqName(psiPackage.getQualifiedName()); } final String finalTargetPackageFqName = targetPackageFqName.asString(); return new KotlinMoveTargetForDeferredFile(targetPackageFqName, psiDirectory, new Function1<KtFile, KtFile>() { @Override public KtFile invoke(@NotNull KtFile originalFile) { return JetRefactoringUtilKt.getOrCreateKotlinFile(targetFile.getName(), psiDirectory, finalTargetPackageFqName); } }); }
From source file:org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog.java
License:Apache License
@Nullable private KotlinMoveTarget selectMoveTarget() { String message = verifyBeforeRun(); if (message != null) { setErrorText(message);/*ww w .j ava 2 s .co m*/ return null; } setErrorText(null); List<KtFile> sourceFiles = getSourceFiles(getSelectedElementsToMove()); PsiDirectory sourceDirectory = getSourceDirectory(sourceFiles); if (isMoveToPackage()) { final MoveDestination moveDestination = selectPackageBasedMoveDestination(true); if (moveDestination == null) return null; final String targetFileName = sourceFiles.size() > 1 ? null : tfFileNameInPackage.getText(); if (targetFileName != null && !checkTargetFileName(targetFileName)) return null; PsiDirectory targetDirectory = moveDestination.getTargetIfExists(sourceDirectory); List<PsiFile> filesExistingInTargetDir = getFilesExistingInTargetDir(sourceFiles, targetFileName, targetDirectory); if (!filesExistingInTargetDir.isEmpty()) { if (!CollectionsKt.intersect(sourceFiles, filesExistingInTargetDir).isEmpty()) { setErrorText("Can't move to the original file(s)"); return null; } if (filesExistingInTargetDir.size() > 1) { String filePathsToReport = StringUtil.join(filesExistingInTargetDir, new Function<PsiFile, String>() { @Override public String fun(PsiFile file) { return file.getVirtualFile().getPath(); } }, "\n"); Messages.showErrorDialog(myProject, "Cannot perform refactoring since the following files already exist:\n\n" + filePathsToReport, RefactoringBundle.message("move.title")); return null; } String question = String.format( "File '%s' already exists. Do you want to move selected declarations to this file?", filesExistingInTargetDir.get(0).getVirtualFile().getPath()); int ret = Messages.showYesNoDialog(myProject, question, RefactoringBundle.message("move.title"), Messages.getQuestionIcon()); if (ret != Messages.YES) return null; } return new DeferredJetFileKotlinMoveTarget(myProject, new FqName(getTargetPackage()), new Function1<KtFile, KtFile>() { @Override public KtFile invoke(@NotNull KtFile originalFile) { return JetRefactoringUtilKt.getOrCreateKotlinFile( targetFileName != null ? targetFileName : originalFile.getName(), moveDestination.getTargetDirectory(originalFile)); } }); } final File targetFile = new File(getTargetFilePath()); if (!checkTargetFileName(targetFile.getName())) return null; KtFile jetFile = (KtFile) JetRefactoringUtilKt.toPsiFile(targetFile, myProject); if (jetFile != null) { if (sourceFiles.size() == 1 && sourceFiles.contains(jetFile)) { setErrorText("Can't move to the original file"); return null; } return new JetFileKotlinMoveTarget(jetFile); } File targetDir = targetFile.getParentFile(); final PsiDirectory psiDirectory = JetRefactoringUtilKt.toPsiDirectory(targetDir, myProject); assert psiDirectory != null : "No directory found: " + targetDir.getPath(); PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory); if (psiPackage == null) { setErrorText("Could not find package corresponding to " + targetDir.getPath()); return null; } return new DeferredJetFileKotlinMoveTarget(myProject, new FqName(psiPackage.getQualifiedName()), new Function1<KtFile, KtFile>() { @Override public KtFile invoke(@NotNull KtFile originalFile) { return JetRefactoringUtilKt.getOrCreateKotlinFile(targetFile.getName(), psiDirectory); } }); }
From source file:org.jetbrains.plugins.clojure.runner.ClojureScriptRunConfiguration.java
License:Apache License
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException { final Module module = getModule(); if (module == null) { throw new ExecutionException("Module is not specified"); }/* w ww. j av a 2s . co m*/ final ModuleRootManager rootManager = ModuleRootManager.getInstance(module); final Sdk sdk = rootManager.getSdk(); if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType)) { throw CantRunException.noJdkForModule(getModule()); } final Project project = module.getProject(); if (!org.jetbrains.plugins.clojure.config.ClojureConfigUtil.isClojureConfigured(module)) { Messages.showErrorDialog(project, ClojureBundle.message("error.running.configuration.with.error.error.message", getName(), ClojureBundle.message("clojure.lib.is.not.attached")), ClojureBundle.message("run.error.message.title")); ModulesConfigurator.showDialog(project, module.getName(), ClasspathEditor.NAME); return null; } final ClojureConfigUtil.RunConfigurationParameters params = new ClojureConfigUtil.RunConfigurationParameters(); final JavaCommandLineState state = new JavaCommandLineState(environment) { protected JavaParameters createJavaParameters() throws ExecutionException { configureJavaParams(params, module); configureScript(params); return params; } }; final TextConsoleBuilderImpl builder = new TextConsoleBuilderImpl(project) { private final ArrayList<Filter> filters = new ArrayList<Filter>(); @Override public ConsoleView getConsole() { final ConsoleViewImpl view = new ConsoleViewImpl(project, false); view.setFileType(ClojureFileType.CLOJURE_FILE_TYPE); for (Filter filter : filters) { view.addMessageFilter(filter); } return view; } @Override public void addFilter(Filter filter) { filters.add(filter); } }; state.setConsoleBuilder(builder); if (params.isDefaultClojureJarUsed()) { ClojureConfigUtil.warningDefaultClojureJar(module); } return state; }
From source file:org.jetbrains.plugins.github.util.GithubNotifications.java
License:Apache License
public static void showErrorDialog(final @Nullable Project project, final @NotNull String title, final @NotNull String message) { LOG.info(title + "; " + message); Messages.showErrorDialog(project, message, title); }
From source file:org.jetbrains.plugins.github.util.GithubNotifications.java
License:Apache License
public static void showErrorDialog(final @Nullable Project project, final @NotNull String title, final @NotNull Exception e) { LOG.warn(title, e);//w ww . j ava2 s .co m Messages.showErrorDialog(project, getErrorTextFromException(e), title); }
From source file:org.jetbrains.plugins.github.util.GithubNotifications.java
License:Apache License
public static void showErrorDialog(final @NotNull Component component, final @NotNull String title, final @NotNull String message) { LOG.info(title + "; " + message); Messages.showErrorDialog(component, message, title); }
From source file:org.jetbrains.plugins.groovy.compiler.GroovyCompiler.java
License:Apache License
public boolean validateConfiguration(CompileScope compileScope) { VirtualFile[] files = compileScope.getFiles(GroovyFileType.GROOVY_FILE_TYPE, true); if (files.length == 0) return true; final Set<String> scriptExtensions = GroovyFileTypeLoader.getCustomGroovyScriptExtensions(); final CompilerManager compilerManager = CompilerManager.getInstance(myProject); Set<Module> modules = new HashSet<Module>(); for (VirtualFile file : files) { if (scriptExtensions.contains(file.getExtension()) || compilerManager.isExcludedFromCompilation(file) || ResourceCompilerConfiguration.getInstance(myProject).isResourceFile(file)) { continue; }//from ww w .j ava2 s.c om ProjectRootManager rootManager = ProjectRootManager.getInstance(myProject); Module module = rootManager.getFileIndex().getModuleForFile(file); if (module != null && ModuleUtilCore.getExtension(module, GroovyModuleExtension.class) != null) { modules.add(module); } } Set<Module> nojdkModules = new HashSet<Module>(); for (Module module : modules) { final Sdk sdk = ModuleUtilCore.getSdk(module, JavaModuleExtensionImpl.class); if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType)) { nojdkModules.add(module); continue; } if (!LibrariesUtil.hasGroovySdk(module)) { if (!GroovyConfigUtils.getInstance().tryToSetUpGroovyFacetOnTheFly(module)) { Messages.showErrorDialog(myProject, GroovyBundle.message("cannot.compile.groovy.files.no.facet", module.getName()), GroovyBundle.message("cannot.compile")); ModulesConfigurator.showDialog(module.getProject(), module.getName(), ClasspathEditor.NAME); return false; } } } if (!nojdkModules.isEmpty()) { final Module[] noJdkArray = nojdkModules.toArray(new Module[nojdkModules.size()]); if (noJdkArray.length == 1) { Messages.showErrorDialog(myProject, GroovyBundle.message("cannot.compile.groovy.files.no.sdk", noJdkArray[0].getName()), GroovyBundle.message("cannot.compile")); } else { StringBuilder modulesList = new StringBuilder(); for (int i = 0; i < noJdkArray.length; i++) { if (i > 0) modulesList.append(", "); modulesList.append(noJdkArray[i].getName()); } Messages.showErrorDialog(myProject, GroovyBundle.message("cannot.compile.groovy.files.no.sdk.mult", modulesList.toString()), GroovyBundle.message("cannot.compile")); } return false; } final GroovyCompilerConfiguration configuration = GroovyCompilerConfiguration.getInstance(myProject); if (!configuration.transformsOk && needTransformCopying(compileScope)) { final int result = Messages.showYesNoDialog(myProject, "You seem to have global Groovy AST transformations defined in your project,\n" + "but they won't be applied to your code because they are not marked as compiler resources.\n" + "Do you want to add them to compiler resource list?\n" + "(you can do it yourself later in Settings | Compiler | Resource patterns)", "AST Transformations Found", JetgroovyIcons.Groovy.Groovy_32x32); if (result == 0) { ResourceCompilerConfiguration.getInstance(myProject) .addResourceFilePattern(AST_TRANSFORM_FILE_NAME); } else { configuration.transformsOk = true; } } return true; }
From source file:org.jetbrains.plugins.groovy.console.GroovyShellActionBase.java
License:Apache License
protected void doRun(final Module module) { final GroovyShellRunner shellRunner = getRunner(module); if (shellRunner == null) return;/* ww w . jav a 2 s .c om*/ AbstractConsoleRunnerWithHistory<LanguageConsoleView> runner = new GroovyConsoleRunner(getTitle(), shellRunner, module, "Groovy.Shell.Execute"); try { runner.initAndRun(); } catch (ExecutionException e) { LOG.info(e); Messages.showErrorDialog(module.getProject(), e.getMessage(), "Cannot Run " + getTitle()); } }