List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon
@NotNull public static Icon getQuestionIcon()
From source file:co.uk.mikedamay.MikeActionClass.java
License:Apache License
public void actionPerformed(AnActionEvent event) { Project project = event.getData(PlatformDataKeys.PROJECT); String txt = Messages.showInputDialog(project, "What is your name?", "Input your name", Messages.getQuestionIcon()); Messages.showMessageDialog(project, "Hello, " + txt + "!\n I am glad to see you.", "Information", Messages.getInformationIcon()); }
From source file:com.android.tools.idea.avdmanager.AccelerationErrorSolution.java
License:Apache License
private Runnable getAction() { switch (myError.getSolution()) { case DOWNLOAD_EMULATOR: case UPDATE_EMULATOR: return new Runnable() { @Override//from w w w . j av a2s . c om public void run() { try { showQuickFix(ImmutableList.of(SdkConstants.FD_TOOLS, SdkConstants.FD_PLATFORM_TOOLS)); } finally { reportBack(); } } }; case UPDATE_PLATFORM_TOOLS: return new Runnable() { @Override public void run() { try { showQuickFix(ImmutableList.of(SdkConstants.FD_PLATFORM_TOOLS)); } finally { reportBack(); } } }; case UPDATE_SYSTEM_IMAGES: return new Runnable() { @Override public void run() { try { AvdManagerConnection avdManager = AvdManagerConnection.getDefaultAvdManagerConnection(); showQuickFix(avdManager.getSystemImageUpdates()); } finally { reportBack(); } } }; case INSTALL_KVM: return new Runnable() { @Override public void run() { try { GeneralCommandLine install = createKvmInstallCommand(); if (install == null) { BrowserUtil.browse(KVM_INSTRUCTIONS, myProject); } else { String text = String.format( "Linux systems vary a great deal; the installation steps we will attempt may not work in your particular scenario.\n\n" + "The steps are:\n\n" + " %1$s\n\n" + "If you prefer, you can skip this step and perform the KVM installation steps on your own.\n\n" + "There might be more details at: %2$s\n", install.getCommandLineString(), KVM_INSTRUCTIONS); int response = Messages.showDialog(text, myError.getSolution().getDescription(), new String[] { "Skip", "Proceed" }, 1, Messages.getQuestionIcon()); if (response == 1) { try { execute(install); myChangesMade = true; } catch (ExecutionException ex) { LOG.error(ex); BrowserUtil.browse(KVM_INSTRUCTIONS, myProject); Messages.showWarningDialog(myProject, "Please install KVM on your own", "Installation Failed"); } } else { BrowserUtil.browse(KVM_INSTRUCTIONS, myProject); } } } finally { reportBack(); } } }; case INSTALL_HAXM: case REINSTALL_HAXM: return new Runnable() { @Override public void run() { try { HaxmWizard wizard = new HaxmWizard(false); wizard.init(); myChangesMade = wizard.showAndGet(); } finally { reportBack(); } } }; case TURNOFF_HYPER_V: return new Runnable() { @Override public void run() { try { GeneralCommandLine turnHyperVOff = new ElevatedCommandLine(); turnHyperVOff.setExePath("bcdedit"); turnHyperVOff.addParameters("/set", "hypervisorlaunchtype", "off"); turnHyperVOff.setWorkDirectory(FileUtilRt.getTempDirectory()); try { execute(turnHyperVOff); promptAndReboot(SOLUTION_REBOOT_AFTER_TURNING_HYPER_V_OFF); } catch (ExecutionException ex) { LOG.error(ex); Messages.showWarningDialog(myProject, SOLUTION_TURN_OFF_HYPER_V, "Operation Failed"); } } finally { reportBack(); } } }; default: return new Runnable() { @Override public void run() { try { Messages.showWarningDialog(myProject, myError.getSolutionMessage(), myError.getSolution().getDescription()); } finally { reportBack(); } } }; } }
From source file:com.android.tools.idea.avdmanager.AccelerationErrorSolution.java
License:Apache License
/** * Prompts the user to reboot now, and performs the reboot if accepted. * HAXM Installer may need a reboot only on Windows, so this method is intended to work only on Windows * and only for HAXM installer use case//from w ww .j a v a 2 s.co m * * @param prompt the message to display to the user * @exception ExecutionException if the shutdown command fails to execute * @return No return value */ public static void promptAndReboot(@NotNull String prompt) throws ExecutionException { int response = Messages.showOkCancelDialog((Project) null, prompt, "Reboot Now", Messages.getQuestionIcon()); if (response == Messages.OK) { GeneralCommandLine reboot = new ElevatedCommandLine(); reboot.setExePath("shutdown"); reboot.addParameters("/g", "/t", "10"); // shutdown & restart after a 10 sec delay reboot.setWorkDirectory(FileUtilRt.getTempDirectory()); execute(reboot); } }
From source file:com.android.tools.idea.avdmanager.InstallSystemImageAction.java
License:Apache License
@Override public void actionPerformed(ActionEvent actionEvent) { String path = getPackagePath(); assert path != null; List<String> requested = ImmutableList.of(path); int response = Messages.showOkCancelDialog("The corresponding system image is missing.\n\nDownload it now?", "Download System Image", Messages.getQuestionIcon()); if (response != Messages.OK) { return;/*www . j a va 2 s .c om*/ } ModelWizardDialog sdkQuickfixWizard = SdkQuickfixUtils.createDialogForPaths(getProject(), requested); if (sdkQuickfixWizard != null) { sdkQuickfixWizard.show(); refreshAvds(); } }
From source file:com.android.tools.idea.fd.actions.SubmitFeedback.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getProject();/*from ww w . jav a2s. co m*/ if (project == null) { Logger.getInstance(SubmitFeedback.class).info("Unable to identify current project"); return; } if (!InstantRunSettings.isInstantRunEnabled() || !InstantRunSettings.isRecorderEnabled()) { int result = Messages.showYesNoDialog(project, AndroidBundle.message("instant.run.flr.would.you.like.to.enable"), AndroidBundle.message("instant.run.flr.dialog.title"), "Yes, I'd like to help", "Cancel", Messages.getQuestionIcon()); if (result == Messages.NO) { return; } InstantRunSettings.setInstantRunEnabled(true); InstantRunSettings.setRecorderEnabled(true); Messages.showInfoMessage(project, AndroidBundle.message("instant.run.flr.howto"), AndroidBundle.message("instant.run.flr.dialog.title")); return; } InstantRunFeedbackDialog dialog = new InstantRunFeedbackDialog(project); boolean ok = dialog.showAndGet(); if (ok) { new Task.Backgroundable(project, "Submitting Instant Run Issue") { public CompletableFuture<String> myReport; @Override public void run(@NotNull ProgressIndicator indicator) { myReport = GoogleCrash.getInstance().submit(FlightRecorder.get(project), dialog.getIssueText(), dialog.getLogs()); while (!myReport.isDone()) { try { myReport.get(200, TimeUnit.MILLISECONDS); } catch (Exception ignored) { } if (indicator.isCanceled()) { return; } } } @Override public void onSuccess() { if (myReport.isDone()) { String reportId; try { reportId = myReport.getNow("00"); } catch (CancellationException e) { Logger.getInstance(SubmitFeedback.class) .info("Submission of flight recorder logs cancelled"); return; } catch (CompletionException e) { FLR_NOTIFICATION_GROUP.createNotification( "Unexpected error while submitting instant run logs: " + e.getMessage(), NotificationType.ERROR); Logger.getInstance(SubmitFeedback.class).info(e); return; } String message = String.format("<html>Thank you for submitting the bug report.<br>" + "If you would like to follow up on this report, please file a bug at <a href=\"bug\">b.android.com</a> and specify the report id '%1$s'<html>", reportId); FLR_NOTIFICATION_GROUP.createNotification("", message, NotificationType.INFORMATION, (notification, event) -> { Escaper escaper = UrlEscapers.urlFormParameterEscaper(); String comment = String.format("Build: %1$s\nInstant Run Report: %2$s", ApplicationInfo.getInstance().getFullVersion(), reportId); String url = String.format( "https://code.google.com/p/android/issues/entry?template=%1$s&comment=%2$s&status=New", escaper.escape("Android Studio Instant Run Bug"), escaper.escape(comment)); BrowserUtil.browse(url); }).notify(project); } } }.queue(); } }
From source file:com.android.tools.idea.gradle.eclipse.AdtImportLocationStep.java
License:Apache License
@Override public boolean validate() throws ConfigurationException { WizardContext context = getWizardContext(); GradleImport importer = AdtImportProvider.getImporter(context); if (importer != null) { List<String> errors = importer.getErrors(); if (!errors.isEmpty()) { throw new ConfigurationException(errors.get(0)); }/*ww w .j a v a2 s . co m*/ } // The following code is based on similar code in com.intellij.ide.util.newProjectWizard.ProjectNameStep String projectFileDirectory = getProjectFileDirectory(); if (projectFileDirectory.length() == 0) { throw new ConfigurationException( String.format("Enter %1$s file location", context.getPresentationName())); } boolean shouldPromptCreation = myIsPathChangedByUser; if (!ProjectWizardUtil.createDirectoryIfNotExists( String.format("The %1$s file directory\n", context.getPresentationName()), projectFileDirectory, shouldPromptCreation)) { return false; } boolean shouldContinue = true; File projectFile = new File(getProjectFileDirectory()); String title = "New Project"; if (projectFile.isFile()) { shouldContinue = false; String message = String.format("%s exists and is a file.\nPlease specify a different project location", projectFile.getAbsolutePath()); Messages.showErrorDialog(message, title); } else if (projectFile.isDirectory()) { File[] files = projectFile.listFiles(); if (files != null && files.length > 0) { String message = String.format( "%1$s folder already exists and is not empty.\nIts content may be overwritten.\nContinue?", projectFile.getAbsolutePath()); int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon()); shouldContinue = answer == 0; } } return shouldContinue; }
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;/* w ww.j a v a 2 s . 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.android.tools.idea.gradle.project.sync.hyperlink.StopGradleDaemonsHyperlink.java
License:Apache License
@Override protected void execute(@NotNull Project project) { String title = "Stop Gradle Daemons"; String message = "Stopping all Gradle daemons will terminate any running Gradle builds (e.g. from the command line).\n" + "This action will also restart the IDE.\n\n" + "Do you want to continue?"; int answer = Messages.showYesNoDialog(project, message, title, Messages.getQuestionIcon()); if (answer == Messages.YES) { stopAllGradleDaemonsAndRestart(); }/*from ww w . ja v a2s . c o m*/ }
From source file:com.android.tools.idea.gradle.refactoring.GradleRenameModuleHandler.java
License:Apache License
@Override public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, @NotNull DataContext dataContext) { Module module = getGradleModule(dataContext); assert module != null; Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.module.name"), IdeBundle.message("title.rename.module"), Messages.getQuestionIcon(), module.getName(), new MyInputValidator(module)); }
From source file:com.android.tools.idea.gradle.service.notification.hyperlink.StopGradleDaemonsAndSyncHyperlink.java
License:Apache License
@Override protected void execute(@NotNull Project project) { String title = "Stop Gradle Daemons"; String message = "Stopping all Gradle daemons will terminate any running Gradle builds (e.g. from the command line.)\n\n" + "Do you want to continue?"; int answer = Messages.showYesNoDialog(project, message, title, Messages.getQuestionIcon()); if (answer == Messages.YES) { try {/*w ww . j a va 2 s.co m*/ GradleUtil.stopAllGradleDaemons(true); GradleProjectImporter.getInstance().requestProjectSync(project, null); } catch (IOException error) { Messages.showErrorDialog( "Failed to stop Gradle daemons. Please run 'gradle --stop' from the command line.\n\n" + "Cause:\n" + error.getMessage(), title); } } }