List of usage examples for com.intellij.openapi.ui Messages showMessageDialog
public static void showMessageDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
From source file:com.intellij.codeInspection.MoveToPackageFix.java
License:Apache License
private void chooseDirectoryAndMove(Project project, PsiFile myFile) { try {//ww w .j av a 2s .c o m PsiDirectory directory = MoveClassesOrPackagesUtil.chooseDestinationPackage(project, myTargetPackage, myFile.getContainingDirectory()); if (directory == null) { return; } String error = RefactoringMessageUtil.checkCanCreateFile(directory, myFile.getName()); if (error != null) { Messages.showMessageDialog(project, error, CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return; } new MoveClassesOrPackagesProcessor(project, ((PsiJavaFile) myFile).getClasses(), new SingleSourceRootMoveDestination( PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(directory)), directory), false, false, null).run(); } catch (IncorrectOperationException e) { LOG.error(e); } }
From source file:com.intellij.compiler.impl.CompileDriver.java
License:Apache License
private boolean validateCompilerConfiguration(final CompileScope scope, boolean checkOutputAndSourceIntersection) { try {//w w w. ja va 2s .c o m final Module[] scopeModules = scope .getAffectedModules()/*ModuleManager.getInstance(myProject).getModules()*/; final List<String> modulesWithoutOutputPathSpecified = new ArrayList<String>(); boolean isProjectCompilePathSpecified = true; final Set<File> nonExistingOutputPaths = new HashSet<File>(); final CompilerManager compilerManager = CompilerManager.getInstance(myProject); for (final Module module : scopeModules) { if (!compilerManager.isValidationEnabled(module)) { continue; } boolean isEmpty = true; for (ContentFolderTypeProvider contentFolderType : ContentFolderTypeProvider .filter(ContentFolderScopes.productionAndTest())) { if (hasContent(module, contentFolderType)) { isEmpty = false; break; } } if (isEmpty) { continue; } for (ContentFolderTypeProvider contentFolderType : ContentFolderTypeProvider .filter(ContentFolderScopes.productionAndTest())) { if (hasContent(module, contentFolderType)) { final String outputPath = getModuleOutputPath(module, contentFolderType); if (outputPath != null) { final File file = new File(FileUtil.toSystemDependentName(outputPath)); if (!file.exists()) { nonExistingOutputPaths.add(file); } } else { modulesWithoutOutputPathSpecified.add(module.getName()); } } } for (AdditionalOutputDirectoriesProvider provider : AdditionalOutputDirectoriesProvider.EP_NAME .getExtensions()) { for (String path : provider.getOutputDirectories(myProject, module)) { if (path == null) { final CompilerConfiguration extension = CompilerConfiguration .getInstance(module.getProject()); if (extension.getCompilerOutputUrl() == null) { isProjectCompilePathSpecified = false; } else { modulesWithoutOutputPathSpecified.add(module.getName()); } } else { final File file = new File(path); if (!file.exists()) { nonExistingOutputPaths.add(file); } } } } } if (!isProjectCompilePathSpecified) { final String message = CompilerBundle.message("error.project.output.not.specified"); if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error(message); } Messages.showMessageDialog(myProject, message, CommonBundle.getErrorTitle(), Messages.getErrorIcon()); ProjectSettingsService.getInstance(myProject).openProjectSettings(); return false; } if (!modulesWithoutOutputPathSpecified.isEmpty()) { showNotSpecifiedError("error.output.not.specified", modulesWithoutOutputPathSpecified, ContentEntriesEditor.NAME); return false; } if (!nonExistingOutputPaths.isEmpty()) { for (File file : nonExistingOutputPaths) { final boolean succeeded = file.mkdirs(); if (!succeeded) { if (file.exists()) { // for overlapping paths, this one might have been created as an intermediate path on a previous iteration continue; } Messages.showMessageDialog(myProject, CompilerBundle.message("error.failed.to.create.directory", file.getPath()), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return false; } } final Boolean refreshSuccess = new WriteAction<Boolean>() { @Override protected void run(Result<Boolean> result) throws Throwable { LocalFileSystem.getInstance().refreshIoFiles(nonExistingOutputPaths); Boolean res = Boolean.TRUE; for (File file : nonExistingOutputPaths) { if (LocalFileSystem.getInstance().findFileByIoFile(file) == null) { res = Boolean.FALSE; break; } } result.setResult(res); } }.execute().getResultObject(); if (!refreshSuccess.booleanValue()) { return false; } dropScopesCaches(); } if (checkOutputAndSourceIntersection && myShouldClearOutputDirectory) { if (!validateOutputAndSourcePathsIntersection()) { return false; } // myShouldClearOutputDirectory may change in validateOutputAndSourcePathsIntersection() CompilerPathsEx.CLEAR_ALL_OUTPUTS_KEY.set(scope, myShouldClearOutputDirectory); } else { CompilerPathsEx.CLEAR_ALL_OUTPUTS_KEY.set(scope, false); } final Compiler[] allCompilers = compilerManager.getCompilers(Compiler.class); for (Compiler compiler : allCompilers) { if (!compiler.validateConfiguration(scope)) { LOG.info("Validation with compiler " + compiler.getDescription() + " is failed."); return false; } } return true; } catch (Throwable e) { LOG.info(e); return false; } }
From source file:com.intellij.compiler.impl.CompileDriver.java
License:Apache License
private void showNotSpecifiedError(@NonNls final String resourceId, List<String> modules, String editorNameToSelect) { String nameToSelect = null;/*from ww w. j a v a 2 s. co m*/ final StringBuilder names = StringBuilderSpinAllocator.alloc(); final String message; try { final int maxModulesToShow = 10; for (String name : modules.size() > maxModulesToShow ? modules.subList(0, maxModulesToShow) : modules) { if (nameToSelect == null) { nameToSelect = name; } if (names.length() > 0) { names.append(",\n"); } names.append("\""); names.append(name); names.append("\""); } if (modules.size() > maxModulesToShow) { names.append(",\n..."); } message = CompilerBundle.message(resourceId, modules.size(), names.toString()); } finally { StringBuilderSpinAllocator.dispose(names); } if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error(message); } Messages.showMessageDialog(myProject, message, CommonBundle.getErrorTitle(), Messages.getErrorIcon()); showConfigurationDialog(nameToSelect, editorNameToSelect); }
From source file:com.intellij.compiler.impl.javaCompiler.AnnotationProcessingCompiler.java
License:Apache License
private void showCyclesNotSupportedForAnnotationProcessors(Module[] modulesInChunk) { LOGGER.assertTrue(modulesInChunk.length > 0); String moduleNameToSelect = modulesInChunk[0].getName(); final String moduleNames = getModulesString(modulesInChunk); Messages.showMessageDialog(myProject, CompilerBundle.message("error.annotation.processing.not.supported.for.module.cycles", moduleNames), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); showConfigurationDialog(moduleNameToSelect, null); }
From source file:com.intellij.compiler.impl.javaCompiler.javac.JavacCompiler.java
License:Apache License
@Override public boolean checkCompiler(final CompileScope scope) { final Module[] modules = scope.getAffectedModules(); final Set<Sdk> checkedJdks = new HashSet<Sdk>(); for (final Module module : modules) { JavaModuleExtension extension = ModuleUtilCore.getExtension(module, JavaModuleExtension.class); if (extension == null) { continue; }//from w w w . j av a2 s .c om final Sdk javaSdk = JavaCompilerUtil.getSdkForCompilation(module); if (javaSdk == null) { Messages.showMessageDialog(myProject, JavaCompilerBundle.message("javac.error.jdk.is.not.set.for.module", module.getName()), JavaCompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()); return false; } if (checkedJdks.contains(javaSdk)) { continue; } checkedJdks.add(javaSdk); final SdkTypeId sdkType = javaSdk.getSdkType(); assert sdkType instanceof JavaSdkType; final VirtualFile homeDirectory = javaSdk.getHomeDirectory(); if (homeDirectory == null) { Messages.showMessageDialog(myProject, JavaCompilerBundle.message("javac.error.jdk.home.missing", javaSdk.getHomePath()), JavaCompilerBundle.message("compiler.javac" + ".name"), Messages.getErrorIcon()); return false; } final String toolsJarPath = ((JavaSdkType) sdkType).getToolsPath(javaSdk); if (toolsJarPath == null) { Messages.showMessageDialog(myProject, JavaCompilerBundle.message("javac.error.tools.jar.missing", javaSdk.getName()), JavaCompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()); return false; } final String versionString = javaSdk.getVersionString(); if (versionString == null) { Messages.showMessageDialog(myProject, JavaCompilerBundle.message("javac.error.unknown.jdk.version", javaSdk.getName()), JavaCompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()); return false; } if (CompilerUtil.isOfVersion(versionString, "1.0")) { Messages.showMessageDialog(myProject, JavaCompilerBundle.message("javac.error.1_0_compilation.not.supported"), JavaCompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()); return false; } } return true; }
From source file:com.intellij.debugger.actions.ExportThreadsAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) { return;/* w w w. j av a 2 s .c om*/ } DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext(); if (context.getDebuggerSession() != null) { String destinationDirectory = ""; final VirtualFile baseDir = project.getBaseDir(); if (baseDir != null) destinationDirectory = baseDir.getPresentableUrl(); ExportDialog dialog = new ExportDialog(context.getDebugProcess(), destinationDirectory); dialog.show(); if (dialog.isOK()) { try { File file = new File(dialog.getFilePath()); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); try { String text = StringUtil.convertLineSeparators(dialog.getTextToSave(), SystemProperties.getLineSeparator()); writer.write(text); } finally { writer.close(); } } catch (IOException ex) { Messages.showMessageDialog(project, ex.getMessage(), ActionsBundle.actionText(DebuggerActions.EXPORT_THREADS), Messages.getErrorIcon()); } } } }
From source file:com.intellij.debugger.actions.ForceEarlyReturnAction.java
License:Apache License
private static void showError(final Project project, final String message) { ApplicationManager.getApplication()/*w w w . j a va 2s . com*/ .invokeLater(() -> Messages.showMessageDialog(project, message, UIUtil.removeMnemonic(ActionsBundle.actionText("Debugger.ForceEarlyReturn")), Messages.getErrorIcon()), ModalityState.any()); }
From source file:com.intellij.debugger.actions.InspectAction.java
License:Apache License
private boolean canInspect(ValueDescriptorImpl descriptor, DebuggerContextImpl context) { DebuggerSession session = context.getDebuggerSession(); if (session == null || !session.isPaused()) return false; boolean isField = descriptor instanceof FieldDescriptorImpl; if (descriptor instanceof WatchItemDescriptor) { Modifier modifier = ((WatchItemDescriptor) descriptor).getModifier(); if (modifier == null || !modifier.canInspect()) return false; isField = modifier instanceof Field; }/*from w ww. j a va 2s . co m*/ if (isField) { // check if possible if (!context.getDebugProcess().canWatchFieldModification()) { Messages.showMessageDialog(context.getProject(), DebuggerBundle.message("error.modification.watchpoints.not.supported"), ActionsBundle.actionText(DebuggerActions.INSPECT), Messages.getInformationIcon()); return false; } } return true; }
From source file:com.intellij.debugger.actions.PopFrameAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); StackFrameProxyImpl stackFrame = getStackFrameProxy(e); if (stackFrame == null) { return;//from w w w. jav a 2 s.c o m } try { DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext()); DebugProcessImpl debugProcess = debuggerContext.getDebugProcess(); if (debugProcess == null) { return; } debugProcess.getManagerThread() .schedule(debugProcess.createPopFrameCommand(debuggerContext, stackFrame)); } catch (NativeMethodException e2) { Messages.showMessageDialog(project, DebuggerBundle.message("error.native.method.exception"), ActionsBundle.actionText(DebuggerActions.POP_FRAME), Messages.getErrorIcon()); } catch (InvalidStackFrameException ignored) { } catch (VMDisconnectedException vde) { } }
From source file:com.intellij.debugger.engine.DebugProcessImpl.java
License:Apache License
private void checkVirtualMachineVersion(VirtualMachine vm) { final String version = vm.version(); if ("1.4.0".equals(version)) { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w .ja va 2 s . com*/ public void run() { Messages.showMessageDialog(getProject(), DebuggerBundle.message("warning.jdk140.unstable"), DebuggerBundle.message("title.jdk140.unstable"), Messages.getWarningIcon()); } }); } }