List of usage examples for com.intellij.openapi.ui MessageDialogBuilder yesNo
@NotNull public static YesNo yesNo(@NotNull String title, @NotNull String message)
From source file:com.android.tools.idea.gradle.project.SdkSync.java
License:Apache License
@VisibleForTesting static void syncIdeAndProjectAndroidSdks(@NotNull final LocalProperties localProperties, @NotNull FindValidSdkPathTask findSdkPathTask) { if (localProperties.hasAndroidDirProperty()) { // if android.dir is specified, we don't sync SDKs. User is working with SDK sources. return;/*ww w . j a va 2 s . co m*/ } final File ideAndroidSdkPath = IdeSdks.getAndroidSdkPath(); final File projectAndroidSdkPath = localProperties.getAndroidSdkPath(); if (ideAndroidSdkPath != null) { if (projectAndroidSdkPath == null) { // If we have the IDE default SDK and we don't have a project SDK, update local.properties with default SDK path and exit. setProjectSdk(localProperties, ideAndroidSdkPath); return; } final ValidationResult validationResult = validateAndroidSdk(projectAndroidSdkPath, true); if (!validationResult.success) { // If we have the IDE default SDK and we don't have a valid project SDK, update local.properties with default SDK path and exit. invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { if (!ApplicationManager.getApplication().isUnitTestMode()) { String error = validationResult.message; if (isEmpty(error)) { error = String.format( "The path \n'%1$s'\n" + "does not refer to a valid Android SDK.", projectAndroidSdkPath.getPath()); } String format = "%1$s\n\nAndroid Studio will use this Android SDK instead:\n'%2$s'\nand will modify the project's local.properties file."; Messages.showErrorDialog(String.format(format, error, ideAndroidSdkPath.getPath()), ERROR_DIALOG_TITLE); } setProjectSdk(localProperties, ideAndroidSdkPath); } }); return; } } else { if (projectAndroidSdkPath == null || !isValidAndroidSdkPath(projectAndroidSdkPath)) { // We don't have any SDK (IDE or project.) File selectedPath = findSdkPathTask.selectValidSdkPath(); if (selectedPath == null) { throw new ExternalSystemException("Unable to continue until an Android SDK is specified"); } setIdeSdk(localProperties, selectedPath); return; } // If we have a valid project SDK but we don't have IDE default SDK, update IDE with project SDK path and exit. setIdeSdk(localProperties, projectAndroidSdkPath); return; } if (!filesEqual(ideAndroidSdkPath, projectAndroidSdkPath)) { final String msg = String.format("The project and Android Studio point to different Android SDKs.\n\n" + "Android Studio's default SDK is in:\n" + "%1$s\n\n" + "The project's SDK (specified in local.properties) is in:\n" + "%2$s\n\n" + "To keep results consistent between IDE and command line builds, only one path can be used. " + "Do you want to:\n\n" + "[1] Use Android Studio's default SDK (modifies the project's local.properties file.)\n\n" + "[2] Use the project's SDK (modifies Android Studio's default.)\n\n" + "Note that switching SDKs could cause compile errors if the selected SDK doesn't have the " + "necessary Android platforms or build tools.", ideAndroidSdkPath.getPath(), projectAndroidSdkPath.getPath()); invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { int result = MessageDialogBuilder.yesNo("Android SDK Manager", msg) .yesText("Use Android Studio's SDK").noText("Use Project's SDK").show(); if (result == Messages.YES) { // Use Android Studio's SDK setProjectSdk(localProperties, ideAndroidSdkPath); } else { // Use project's SDK setIdeSdk(localProperties, projectAndroidSdkPath); } if (isGuiTestingMode() && !getGuiTestSuiteState().isSkipSdkMerge()) { mergeIfNeeded(projectAndroidSdkPath, ideAndroidSdkPath); } } }); } }
From source file:com.android.tools.idea.gradle.project.SdkSync.java
License:Apache License
private static void mergeIfNeeded(@NotNull final File sourceSdk, @NotNull final File destSdk) { if (SdkMerger.hasMergeableContent(sourceSdk, destSdk)) { String msg = String.format( "The Android SDK at\n\n%1$s\n\nhas packages not in your project's SDK at\n\n%2$s\n\n" + "Would you like to copy into the project SDK?", sourceSdk.getPath(), destSdk.getPath()); int result = MessageDialogBuilder.yesNo("Merge SDKs", msg).yesText("Copy").noText("Do not copy").show(); if (result == Messages.YES) { new Task.Backgroundable(null, "Merging Android SDKs", false) { @Override//from w ww . j ava 2s . c o m public void run(@NotNull ProgressIndicator indicator) { SdkMerger.mergeSdks(sourceSdk, destSdk, indicator); } }.queue(); } } }
From source file:com.android.tools.idea.gradle.project.sync.SdkSync.java
License:Apache License
@VisibleForTesting void syncIdeAndProjectAndroidSdk(@NotNull LocalProperties localProperties, @NotNull FindValidSdkPathTask findSdkPathTask, @Nullable Project project) { if (localProperties.hasAndroidDirProperty()) { // if android.dir is specified, we don't sync SDKs. User is working with SDK sources. return;/*w w w .j a v a 2s .c o m*/ } File ideAndroidSdkPath = myIdeSdks.getAndroidSdkPath(); File projectAndroidSdkPath = localProperties.getAndroidSdkPath(); if (ideAndroidSdkPath != null) { if (projectAndroidSdkPath == null) { // If we have the IDE default SDK and we don't have a project SDK, update local.properties with default SDK path and exit. setProjectSdk(localProperties, ideAndroidSdkPath); return; } ValidationResult validationResult = validateAndroidSdk(projectAndroidSdkPath, true); if (!validationResult.success) { // If we have the IDE default SDK and we don't have a valid project SDK, update local.properties with default SDK path and exit. invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { if (!ApplicationManager.getApplication().isUnitTestMode()) { String error = validationResult.message; if (isEmpty(error)) { error = String.format( "The path \n'%1$s'\n" + "does not refer to a valid Android SDK.", projectAndroidSdkPath.getPath()); } String format = "%1$s\n\nAndroid Studio will use this Android SDK instead:\n'%2$s'\nand will modify the project's local.properties file."; Messages.showErrorDialog(String.format(format, error, ideAndroidSdkPath.getPath()), ERROR_DIALOG_TITLE); } setProjectSdk(localProperties, ideAndroidSdkPath); } }); return; } } else { if (projectAndroidSdkPath == null || !myIdeSdks.isValidAndroidSdkPath(projectAndroidSdkPath)) { // We don't have any SDK (IDE or project.) File selectedPath = findSdkPathTask.selectValidSdkPath(); if (selectedPath == null) { throw new ExternalSystemException("Unable to continue until an Android SDK is specified"); } setIdeSdk(localProperties, selectedPath); return; } // If we have a valid project SDK but we don't have IDE default SDK, update IDE with project SDK path and exit. setIdeSdk(localProperties, projectAndroidSdkPath); return; } if (!filesEqual(ideAndroidSdkPath, projectAndroidSdkPath)) { String msg = String.format("The project and Android Studio point to different Android SDKs.\n\n" + "Android Studio's default SDK is in:\n" + "%1$s\n\n" + "The project's SDK (specified in local.properties) is in:\n" + "%2$s\n\n" + "To keep results consistent between IDE and command line builds, only one path can be used. " + "Do you want to:\n\n" + "[1] Use Android Studio's default SDK (modifies the project's local.properties file.)\n\n" + "[2] Use the project's SDK (modifies Android Studio's default.)\n\n" + "Note that switching SDKs could cause compile errors if the selected SDK doesn't have the " + "necessary Android platforms or build tools.", ideAndroidSdkPath.getPath(), projectAndroidSdkPath.getPath()); invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { // We need to pass the project, so on Mac, the "Mac sheet" showing this message shows inside the IDE during UI tests, otherwise // it will show outside and the UI testing infrastructure cannot see it. It is overall a good practice to pass the project when // showing a message, to ensure that the message shows in the IDE instance containing the project. int result = MessageDialogBuilder.yesNo("Android SDK Manager", msg) .yesText("Use Android Studio's SDK").noText("Use Project's SDK").project(project) .show(); if (result == Messages.YES) { // Use Android Studio's SDK setProjectSdk(localProperties, ideAndroidSdkPath); } else { // Use project's SDK setIdeSdk(localProperties, projectAndroidSdkPath); } if (isGuiTestingMode() && !getGuiTestSuiteState().isSkipSdkMerge()) { mergeIfNeeded(projectAndroidSdkPath, ideAndroidSdkPath); } } }); } }
From source file:com.android.tools.idea.gradle.project.sync.SdkSync.java
License:Apache License
private static void mergeIfNeeded(@NotNull File sourceSdk, @NotNull File destSdk) { if (SdkMerger.hasMergeableContent(sourceSdk, destSdk)) { String msg = String.format( "The Android SDK at\n\n%1$s\n\nhas packages not in your project's SDK at\n\n%2$s\n\n" + "Would you like to copy into the project SDK?", sourceSdk.getPath(), destSdk.getPath()); int result = MessageDialogBuilder.yesNo("Merge SDKs", msg).yesText("Copy").noText("Do not copy").show(); if (result == Messages.YES) { new Task.Backgroundable(null, "Merging Android SDKs", false) { @Override//from w ww . j a v a 2 s .com public void run(@NotNull ProgressIndicator indicator) { SdkMerger.mergeSdks(sourceSdk, destSdk, indicator); } }.queue(); } } }
From source file:org.jetbrains.idea.svn.treeConflict.MergeFromTheirsResolver.java
License:Apache License
private boolean getAddedFilesPlaceOption() { final SvnConfiguration configuration = SvnConfiguration.getInstance(myVcs.getProject()); boolean add = Boolean.TRUE.equals(configuration.isKeepNewFilesAsIsForTreeConflictMerge()); if (configuration.isKeepNewFilesAsIsForTreeConflictMerge() != null) { return add; }/*from ww w . j ava 2s.c o m*/ if (!containAdditions(myTheirsChanges) && !containAdditions(myTheirsBinaryChanges)) { return false; } return Messages.YES == MessageDialogBuilder .yesNo(TreeConflictRefreshablePanel.TITLE, "Keep newly created file(s) in their original place?") .yesText("Keep").noText("Move").doNotAsk(new DialogWrapper.DoNotAskOption() { @Override public boolean isToBeShown() { return true; } @Override public void setToBeShown(boolean value, int exitCode) { if (!value) { if (exitCode == 0) { // yes configuration.setKeepNewFilesAsIsForTreeConflictMerge(true); } else { configuration.setKeepNewFilesAsIsForTreeConflictMerge(false); } } } @Override public boolean canBeHidden() { return true; } @Override public boolean shouldSaveOptionsOnCancel() { return true; } @Override public String getDoNotShowMessage() { return CommonBundle.message("dialog.options.do.not.ask"); } }).show(); }
From source file:org.mustbe.consulo.csharp.ide.refactoring.rename.CSharpOverrideElementProcessor.java
License:Apache License
@Override public void prepareRenaming(PsiElement element, String newName, Map<PsiElement, String> allRenames, SearchScope scope) {/* ww w . j a v a 2 s. c om*/ // if name is empty that mean start rename if (StringUtil.isEmpty(newName)) { myLastResult = -1; } if (myLastResult == -1) { Set<DotNetVirtualImplementOwner> allElements = getAllElements(element); if (!allElements.isEmpty()) { MessageDialogBuilder.YesNo builder = MessageDialogBuilder.yesNo("Rename", "Rename all override/implement methods or this method?"); builder = builder.yesText("All Methods"); builder = builder.noText("This Method"); if ((myLastResult = builder.show()) == Messages.YES) { for (DotNetVirtualImplementOwner tempElement : allElements) { allRenames.put(tempElement, newName); } } } } else if (myLastResult == Messages.YES) { Set<DotNetVirtualImplementOwner> allElements = getAllElements(element); for (DotNetVirtualImplementOwner tempElement : allElements) { allRenames.put(tempElement, newName); } } }