List of usage examples for com.intellij.openapi.ui Messages showYesNoDialog
@YesNoResult public static int showYesNoDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
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 w w w. j a v a2s . 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
@Override public void actionPerformed(AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); assert project != null; CompilerManager.getInstance(project).make(new CompileStatusNotification() { @Override/* w ww. ja v a 2s . c o m*/ public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { if (aborted) return; final Project project = compileContext.getProject(); if (errors == 0 || Messages.showYesNoDialog(project, "Compilation failed with errors. Do you want to run " + getTitle() + " anyway?", getTitle(), JetgroovyIcons.Groovy.Groovy_32x32) == Messages.YES) { runGroovyShell(project); } } }); }
From source file:org.jetbrains.plugins.groovy.intentions.conversions.ConvertMapToClassIntention.java
License:Apache License
public static boolean checkForReturnFromMethod(GrExpression replacedNewExpression) { final PsiElement parent = PsiUtil.skipParentheses(replacedNewExpression.getParent(), true); final GrMethod method = PsiTreeUtil.getParentOfType(replacedNewExpression, GrMethod.class, true, GrClosableBlock.class); if (method == null) return false; if (!(parent instanceof GrReturnStatement)) { //check for return expression final List<GrStatement> returns = ControlFlowUtils.collectReturns(method.getBlock()); final PsiElement expr = PsiUtil.skipParentheses(replacedNewExpression, true); if (!(returns.contains(expr))) return false; }/*from w w w. jav a 2s . co m*/ return !(!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog(replacedNewExpression.getProject(), GroovyIntentionsBundle.message("do.you.want.to.change.method.return.type", method.getName()), GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) != 0); }
From source file:org.jetbrains.plugins.groovy.intentions.conversions.ConvertMapToClassIntention.java
License:Apache License
public static boolean checkForVariableDeclaration(GrExpression replacedNewExpression) { final PsiElement parent = PsiUtil.skipParentheses(replacedNewExpression.getParent(), true); if (parent instanceof GrVariable && !(parent instanceof GrField) && !(parent instanceof GrParameter) && ((GrVariable) parent).getDeclaredType() != null && replacedNewExpression.getType() != null) { if (ApplicationManager.getApplication().isUnitTestMode() || Messages.showYesNoDialog(replacedNewExpression.getProject(), GroovyIntentionsBundle.message("do.you.want.to.change.variable.type", ((GrVariable) parent).getName()), GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) == 0) { return true; }/*from w w w .j a v a 2 s. c o m*/ } return false; }
From source file:org.jetbrains.plugins.groovy.intentions.conversions.ConvertMapToClassIntention.java
License:Apache License
@Nullable public static GrParameter checkForMethodParameter(GrExpression map) { final GrParameter parameter = getParameterByArgument(map); if (parameter == null) return null; final PsiElement parent = parameter.getParent().getParent(); if (!(parent instanceof PsiMethod)) return null; final PsiMethod method = (PsiMethod) parent; if (ApplicationManager.getApplication().isUnitTestMode() || Messages.showYesNoDialog(map.getProject(), GroovyIntentionsBundle.message("do.you.want.to.change.type.of.parameter.in.method", parameter.getName(), method.getName()), GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) == 0) { return parameter; }//from w w w .j av a 2 s .com return null; }
From source file:org.jetbrains.plugins.groovy.mvc.MvcFramework.java
License:Apache License
public void createApplicationIfNeeded(@NotNull final Module module) { if (findAppRoot(module) == null && module.getUserData(CREATE_APP_STRUCTURE) == Boolean.TRUE) { while (ModuleUtilCore.getSdk(module, JavaModuleExtensionImpl.class) == null) { if (Messages.showYesNoDialog(module.getProject(), "Cannot generate " + getDisplayName() + " project structure because JDK is not specified for module \"" + module.getName() + "\".\n" + getDisplayName() + " project will not be created if you don't specify JDK.\nDo you want to specify JDK?", "Error", Messages.getErrorIcon()) == 1) { return; }//from w w w .jav a2 s . com ProjectSettingsService.getInstance(module.getProject()) .showModuleConfigurationDialog(module.getName(), ClasspathEditor.NAME); } module.putUserData(CREATE_APP_STRUCTURE, null); final GeneralCommandLine commandLine = getCreationCommandLine(module); if (commandLine == null) return; MvcConsole.executeProcess(module, commandLine, new Runnable() { public void run() { VirtualFile root = findAppRoot(module); if (root == null) return; PsiDirectory psiDir = PsiManager.getInstance(module.getProject()).findDirectory(root); IdeView ide = LangDataKeys.IDE_VIEW.getData(DataManager.getInstance().getDataContext()); if (ide != null) ide.selectElement(psiDir); //also here comes fileCreated(application.properties) which manages roots and run configuration } }, true); } }
From source file:org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantProcessor.java
License:Apache License
protected boolean checkErrors(@NotNull PsiClass targetClass) { String fieldName = settings.getName(); String errorString = check(targetClass, fieldName); if (errorString != null) { String message = RefactoringBundle.getCannotRefactorMessage(errorString); CommonRefactoringUtil.showErrorMessage(GrIntroduceConstantHandler.REFACTORING_NAME, message, HelpID.INTRODUCE_CONSTANT, context.getProject()); return true; }/*from w w w.j a v a2s . c o m*/ PsiField oldField = targetClass.findFieldByName(fieldName, true); if (oldField != null) { String message = RefactoringBundle.message("field.exists", fieldName, oldField.getContainingClass().getQualifiedName()); int answer = Messages.showYesNoDialog(context.getProject(), message, GrIntroduceConstantHandler.REFACTORING_NAME, Messages.getWarningIcon()); if (answer != 0) { return true; } } return false; }
From source file:org.jetbrains.plugins.ruby.rails.facet.BaseRailsFacetBuilder.java
License:Apache License
private static void generateRailsApplication(final Module module, @NotNull final Sdk sdk, final RunContentDescriptorFactory descriptorFactory, @NotNull final RailsWizardSettingsHolder settings, @NotNull final String applicationHomePath, @Nullable final Runnable onDone) { if (settings.getAppGenerateWay() == RailsWizardSettingsHolder.Generate.NEW) { final String preconfigureForDBName = settings.getDBNameToPreconfigure(); // if directory for rails application home already exists // then try to find Rails Application in it final VirtualFile appHomeDir = VirtualFileUtil.findFileByLocalPath(applicationHomePath); // If rails application already exists ask user overwrite existing files or not? final boolean toOverwrite; if (appHomeDir != null && appHomeDir.isDirectory() && RailsUtil.containsRailsApp(applicationHomePath)) { final int dialogResult = Messages.showYesNoDialog(module.getProject(), RBundle.message("module.rails.generateapp.rails.new.overwrite.message", applicationHomePath), RBundle.message("module.rails.generateapp.rails.new.overwrite.title"), Messages.getQuestionIcon()); toOverwrite = dialogResult == DialogWrapper.OK_EXIT_CODE; } else {//from www .j a v a 2 s . c om toOverwrite = false; } RailsUtil.generateRailsApp(module, sdk, applicationHomePath, toOverwrite, preconfigureForDBName, descriptorFactory, onDone); } }
From source file:org.jetbrains.plugins.ruby.ruby.module.wizard.ui.rspec.RubyRSpecInstallComponentsStep.java
License:Apache License
@Override public boolean validate() throws ConfigurationException { final Sdk sdk = myBuilder.getSdk(); if (!RSpecUtil.checkIfRSpecGemExists(sdk)) { final String msg = RBundle .message("module.settings.dialog.select.test.spec.ruby.please.install.rspec.gem.text"); final String title = RBundle .message("module.settings.dialog.select.test.spec.ruby.please.install.rspec.gem.title"); return Messages.showYesNoDialog(myProject, msg, title, UIUtil.getWarningIcon()) == DialogWrapper.OK_EXIT_CODE; }/* w w w . j a v a 2s . c o m*/ return true; }
From source file:org.jetbrains.plugins.ruby.settings.GeneralSettingsTab.java
License:Apache License
@Override public void apply() throws ConfigurationException { final RApplicationSettings settings = RApplicationSettings.getInstance(); settings.useConsoleOutputOtherFilters = otherFiltersCheckBox.isSelected(); settings.useConsoleOutputRubyStacktraceFilter = rubyStacktraceFilterCheckBox.isSelected(); settings.useConsoleColorMode = colorModeCheckBox.isSelected(); settings.additionalEnvPATH = myTFAdditioanlPath.getText().trim(); final boolean isProjectViewStyleChanged = isProjectViewStyleChanged(); settings.useRubySpecificProjectView = useRubyProjectViewBox.isSelected(); if (isProjectViewStyleChanged) { final int result = Messages.showYesNoDialog(myContentPane.getParent(), RBundle.message("settings.plugin.general.tab.use.ruby.project.view.changed.message"), RBundle.message("settings.plugin.general.tab.use.ruby.project.view.changed.title"), Messages.getQuestionIcon()); if (result == DialogWrapper.OK_EXIT_CODE) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override//from w ww . j a v a 2 s . c o m public void run() { // reload all projects for (Project project : ProjectManager.getInstance().getOpenProjects()) { ProjectManager.getInstance().reloadProject(project); } } }, ModalityState.NON_MODAL); } } }