List of usage examples for com.intellij.openapi.ui Messages showYesNoDialog
@YesNoResult public static int showYesNoDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, String yesText, String noText, @Nullable Icon icon)
From source file:com.android.tools.idea.gradle.project.PreSyncChecks.java
License:Apache License
private static void checkHttpProxySettings(@NotNull Project project) { boolean performCheck = PropertiesComponent.getInstance() .getBoolean(SHOW_DO_NOT_ASK_TO_COPY_PROXY_SETTINGS_PROPERTY_NAME, true); if (!performCheck) { // User already checked the "do not ask me" option. return;//from w ww. ja v a2s .c o m } HttpConfigurable ideProxySettings = HttpConfigurable.getInstance(); if (ideProxySettings.USE_HTTP_PROXY && isNotEmpty(ideProxySettings.PROXY_HOST)) { GradleProperties properties; try { properties = new GradleProperties(project); } catch (IOException e) { LOG.info("Failed to read gradle.properties file", e); // Let sync continue, even though it may fail. return; } GradleProperties.ProxySettings proxySettings = properties.getProxySettings(); if (!ideProxySettings.PROXY_HOST.equals(proxySettings.getHost())) { String msg = "Android Studio is configured to use a HTTP proxy. " + "Gradle may need these proxy settings to access the Internet (e.g. for downloading dependencies.)\n\n" + "Would you like to have the IDE's proxy configuration be set in the project's gradle.properties file?"; DoNotAskOption doNotAskOption = new PropertyDoNotAskOption( SHOW_DO_NOT_ASK_TO_COPY_PROXY_SETTINGS_PROPERTY_NAME); int result = Messages.showYesNoDialog(project, msg, "Proxy Settings", Messages.getQuestionIcon(), doNotAskOption); if (result == YES) { proxySettings.copyFrom(ideProxySettings); properties.setProxySettings(proxySettings); try { properties.save(); } catch (IOException e) { //noinspection ThrowableResultOfMethodCallIgnored Throwable root = getRootCause(e); String cause = root.getMessage(); String errMsg = "Failed to save changes to gradle.properties file."; if (isNotEmpty(cause)) { if (!cause.endsWith(".")) { cause += "."; } errMsg += String.format("\nCause: %1$s", cause); } AndroidGradleNotification notification = AndroidGradleNotification.getInstance(project); notification.showBalloon("Proxy Settings", errMsg, NotificationType.ERROR); LOG.info("Failed to save changes to gradle.properties file", e); } } } } }
From source file:com.intellij.ide.plugins.PluginManagerConfigurable.java
License:Apache License
@Messages.YesNoResult private static int showShutDownIDEADialog(final String title) { String message = IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName()); return Messages.showYesNoDialog(message, title, "Shut Down", POSTPONE, Messages.getQuestionIcon()); }
From source file:com.intellij.ide.plugins.PluginManagerConfigurable.java
License:Apache License
@Messages.YesNoResult private static int showRestartIDEADialog(final String title) { String message = IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName()); return Messages.showYesNoDialog(message, title, "Restart", POSTPONE, Messages.getQuestionIcon()); }
From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.PluginManagerConfigurable_mbeddr.java
License:Apache License
@Messages.YesNoResult public static int showRestartDialog(@NotNull String title) { String action = IdeBundle/* w w w .j a va2 s. co m*/ .message(ApplicationManagerEx.getApplicationEx().isRestartCapable() ? "ide.restart.action" : "ide.shutdown.action"); String message = IdeBundle.message("ide.restart.required.message", action, ApplicationNamesInfo.getInstance().getFullProductName()); return Messages.showYesNoDialog(message, title, action, IdeBundle.message("ide.postpone.action"), Messages.getQuestionIcon()); }
From source file:com.theoryinpractice.testng.TestNGFramework.java
License:Apache License
@Override protected PsiMethod findOrCreateSetUpMethod(PsiClass clazz) throws IncorrectOperationException { PsiMethod method = findSetUpMethod(clazz); if (method != null) return method; final PsiManager manager = clazz.getManager(); final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory(); String setUpName = "setUp"; PsiMethod patternMethod = createSetUpPatternMethod(factory); PsiMethod inClass = clazz.findMethodBySignature(patternMethod, false); if (inClass != null) { int exit = ApplicationManager.getApplication().isUnitTestMode() ? DialogWrapper.OK_EXIT_CODE : Messages.showYesNoDialog( "Method \'" + setUpName + "\' already exist but is not annotated as @BeforeMethod.", CommonBundle.getWarningTitle(), "Annotate", "Create new method", Messages.getWarningIcon()); if (exit == DialogWrapper.OK_EXIT_CODE) { new AddAnnotationFix(BeforeMethod.class.getName(), inClass).invoke(inClass.getProject(), null, inClass.getContainingFile()); return inClass; } else if (exit == DialogWrapper.CANCEL_EXIT_CODE) { inClass = null;/*from w w w. j av a2 s . c om*/ int i = 0; while (clazz.findMethodBySignature(patternMethod, false) != null) { patternMethod.setName(setUpName + (++i)); } setUpName = patternMethod.getName(); } } final PsiClass superClass = clazz.getSuperClass(); if (superClass != null) { final PsiMethod[] methods = superClass.findMethodsBySignature(patternMethod, false); if (methods.length > 0) { final PsiModifierList modifierList = methods[0].getModifierList(); if (!modifierList.hasModifierProperty(PsiModifier.PRIVATE)) { //do not override private method @NonNls String pattern = "@" + BeforeMethod.class.getName() + "\n"; if (modifierList.hasModifierProperty(PsiModifier.PROTECTED)) { pattern += "protected "; } else if (modifierList.hasModifierProperty(PsiModifier.PUBLIC)) { pattern += "public "; } patternMethod = factory.createMethodFromText( pattern + "void " + setUpName + "() throws Exception {\nsuper." + setUpName + "();\n}", null); } } } final PsiMethod[] psiMethods = clazz.getMethods(); PsiMethod testMethod = null; for (PsiMethod psiMethod : psiMethods) { if (inClass == null && AnnotationUtil.isAnnotated(psiMethod, BeforeMethod.class.getName(), false)) { inClass = psiMethod; } if (testMethod == null && AnnotationUtil.isAnnotated(psiMethod, Test.class.getName(), false) && !psiMethod.hasModifierProperty(PsiModifier.PRIVATE)) { testMethod = psiMethod; } } if (inClass == null) { final PsiMethod psiMethod; if (testMethod != null) { psiMethod = (PsiMethod) clazz.addBefore(patternMethod, testMethod); } else { psiMethod = (PsiMethod) clazz.add(patternMethod); } JavaCodeStyleManager.getInstance(clazz.getProject()).shortenClassReferences(clazz); return psiMethod; } else if (inClass.getBody() == null) { return (PsiMethod) inClass.replace(patternMethod); } return inClass; }
From source file:com.urswolfer.intellij.plugin.gerrit.rest.SslSupport.java
License:Apache License
@CalledInAwt public boolean askIfShouldProceed(final String host) { int choice = Messages.showYesNoDialog( "The security certificate of " + host + " is not trusted. Do you want to proceed anyway?", "Not Trusted Certificate", "Proceed anyway", "No, I don't trust", Messages.getErrorIcon()); boolean trust = (choice == Messages.YES); if (trust) {/*w ww. j av a 2 s. c o m*/ saveToTrusted(host); } return trust; }
From source file:io.ballerina.plugins.idea.sdk.BallerinaSdkUtils.java
License:Open Source License
@Messages.YesNoResult public static void showRestartDialog(Project project) { ApplicationManager.getApplication().invokeLater(() -> { String action = project != null && ProjectManagerEx.getInstanceEx().canClose(project) ? "Reload Project" : "Restart IDE"; String message = "Project/IDE reloading action is required to apply changes. Do you wish to continue?"; if (Messages.showYesNoDialog(message, "Apply Changes", action, "Postpone", Messages.getQuestionIcon()) == Messages.YES) { if (action.equals("Reload Project")) { ProjectManagerEx.getInstanceEx().reloadProject(project); } else { ApplicationManagerEx.getApplicationEx().restart(true); }//from ww w. jav a 2 s .c o m } }); }
From source file:liveplugin.toolwindow.addplugin.git.jetbrains.plugins.github.util.GithubSslSupport.java
License:Apache License
@CalledInAwt public boolean askIfShouldProceed(final String url) { String host = GithubUrlUtil.getHostFromUrl(url); int choice = Messages.showYesNoDialog( "The security certificate of " + host + " is not trusted. Do you want to proceed anyway?", "Not Trusted Certificate", "Proceed anyway", "No, I don't trust", Messages.getErrorIcon()); boolean trust = (choice == Messages.YES); if (trust) {/*from w w w .j a v a 2s. c o m*/ saveToTrusted(host); } return trust; }
From source file:org.coding.git.util.CodingNetNotifications.java
License:Apache License
@Messages.YesNoResult public static boolean showYesNoDialog(@Nullable Project project, @NotNull String title, @NotNull String message, @NotNull DialogWrapper.DoNotAskOption doNotAskOption) { return Messages.YES == Messages.showYesNoDialog(project, message, title, Messages.getQuestionIcon(), doNotAskOption);/*ww w . java 2s .c om*/ }