Java 类com.intellij.openapi.ui.MessageDialogBuilder 实例源码

项目:intellij-ce-playground    文件:ShowDelayedMessageInternalAction.java   
@Override
public void actionPerformed(AnActionEvent e) {

  new Thread("show delayed msg") {
    @Override
    public void run() {
      super.run();

      //noinspection EmptyCatchBlock
      TimeoutUtil.sleep(3000);

      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          MessageDialogBuilder.yesNo("Nothing happens after that", "Some message goes here").yesText(
            ApplicationBundle.message("command.exit")).noText(
            CommonBundle.message("button.cancel")).show();
        }
      });
    }
  }.start();

}
项目:consulo-csharp    文件:CSharpFindUsageHandler.java   
@NotNull
@Override
@RequiredReadAction
public PsiElement[] getPrimaryElements()
{
    PsiElement psiElement = getPsiElement();
    if(OverrideUtil.isAllowForOverride(psiElement))
    {
        Collection<DotNetVirtualImplementOwner> members = OverrideUtil.collectOverridingMembers((DotNetVirtualImplementOwner) psiElement);
        if(!members.isEmpty())
        {
            MessageDialogBuilder.YesNo builder = MessageDialogBuilder.yesNo("Find Usage", "Search for base target ir current target?");
            builder = builder.yesText("Base Target");
            builder = builder.noText("This Target");

            if(builder.show() == Messages.OK)
            {
                return PsiUtilCore.toPsiElementArray(members);
            }
        }
    }
    return super.getPrimaryElements();
}
项目:SmartQQ4IntelliJ    文件:LoginAction.java   
@Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        SmartClient client = smartPanel.getClient();
        boolean ok = true;
        if (client.isLogin()) {
            ok = MessageDialogBuilder.yesNo("", "您已处于登录状态,确定要重新登录吗?").show() == 0;
        }
        if (ok) {
            client.setLoginCallback(new MyLoginCallback(client, smartPanel));
            new Thread() {
                @Override
                public void run() {
                    client.login();
                }
            }.start();
        } else {
            smartPanel.initContacts();
        }
//
//        LoginDialog dialog = new LoginDialog(client);
//        dialog.setSize(200, 240);
//        dialog.setLocationRelativeTo(null);
//        dialog.pack();
//        dialog.setVisible(true);
//        LOG.info("login : " + client.isLogin());
//        if (client.isLogin()) {
//            new LoadThread(client).start();
//        } else {
//            //fillTestData(client);
//        }
    }
项目:intellij-ce-playground    文件:DirDiffTableModel.java   
private boolean confirmDeletion(int count) {
  return MessageDialogBuilder.yesNo("Confirm Delete", "Delete " + count + " items?").project(myProject).yesText("Delete").noText(CommonBundle.message("button.cancel")).doNotAsk(
    new DialogWrapper.DoNotAskOption() {
      @Override
      public boolean isToBeShown() {
        return WarnOnDeletion.isWarnWhenDeleteItems();
      }

      @Override
      public void setToBeShown(boolean value, int exitCode) {
        WarnOnDeletion.setWarnWhenDeleteItems(value);
      }

      @Override
      public boolean canBeHidden() {
        return true;
      }

      @Override
      public boolean shouldSaveOptionsOnCancel() {
        return true;
      }

      @NotNull
      @Override
      public String getDoNotShowMessage() {
        return "Do not ask me again";
      }
    }).show() == Messages.YES;
}
项目:intellij-ce-playground    文件:SdkSync.java   
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
        public void run(@NotNull ProgressIndicator indicator) {
          SdkMerger.mergeSdks(sourceSdk, destSdk, indicator);
        }
      }.queue();
    }
  }
}
项目:google-cloud-intellij    文件:GoogleAccountPluginUninstaller.java   
public void uninstallIfPresent() {
  IdeaPluginDescriptor accountPlugin =
      PluginManager.getPlugin(PluginId.findId("com.google.gct.login"));
  if (accountPlugin != null) {
    UsageTrackerProvider.getInstance().trackEvent(GctTracking.ACCOUNT_PLUGIN_DETECTED).ping();
    LOGGER.info("legacy google account plugin found.");
    accountPlugin.setEnabled(false);
    PluginManagerConfigurable managerConfigurable =
        new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
    UninstallPluginAction.uninstall(managerConfigurable.getOrCreatePanel(), true, accountPlugin);
    UsageTrackerProvider.getInstance().trackEvent(GctTracking.ACCOUNT_PLUGIN_UNINSTALLED).ping();
    LOGGER.info(
        "legacy google account plugin has been disabled and uninstalled. This will take effect on"
            + " the next IDE restart.");
    if (MessageDialogBuilder.yesNo(
            GctBundle.message("account.plugin.removal.requires.restart.title"),
            GctBundle.message("account.plugin.removal.requires.restart.text"))
        .yesText(GctBundle.message("OK"))
        .noText(GctBundle.message("Cancel"))
        .isYes()) {
      UsageTrackerProvider.getInstance()
          .trackEvent(GctTracking.ACCOUNT_PLUGIN_RESTART_DIALOG_YES_ACTION)
          .ping();
      ApplicationManagerEx.getApplicationEx().restart(true);
    } else {
      UsageTrackerProvider.getInstance()
          .trackEvent(GctTracking.ACCOUNT_PLUGIN_RESTART_DIALOG_NO_ACTION)
          .ping();
    }
  }
}
项目:consulo    文件:DirDiffTableModel.java   
private boolean confirmDeletion(int count) {
  return MessageDialogBuilder.yesNo("Confirm Delete", "Delete " + count + " items?").project(myProject).yesText("Delete").noText(CommonBundle.message("button.cancel")).doNotAsk(
          new DialogWrapper.DoNotAskOption() {
            @Override
            public boolean isToBeShown() {
              return WarnOnDeletion.isWarnWhenDeleteItems();
            }

            @Override
            public void setToBeShown(boolean value, int exitCode) {
              WarnOnDeletion.setWarnWhenDeleteItems(value);
            }

            @Override
            public boolean canBeHidden() {
              return true;
            }

            @Override
            public boolean shouldSaveOptionsOnCancel() {
              return true;
            }

            @Nonnull
            @Override
            public String getDoNotShowMessage() {
              return "Do not ask me again";
            }
          }).show() == Messages.YES;
}
项目:intellij-ce-playground    文件:PopFrameAction.java   
static boolean evaluateFinallyBlocks(Project project,
                              String title,
                              JavaStackFrame stackFrame,
                              XDebuggerEvaluator.XEvaluationCallback callback) {
  if (!DebuggerSettings.EVALUATE_FINALLY_NEVER.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME)) {
    List<PsiStatement> statements = getFinallyStatements(stackFrame.getDescriptor().getSourcePosition());
    if (!statements.isEmpty()) {
      StringBuilder sb = new StringBuilder();
      for (PsiStatement statement : statements) {
        sb.append("\n").append(statement.getText());
      }
      if (DebuggerSettings.EVALUATE_FINALLY_ALWAYS.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME)) {
        evaluateAndAct(project, stackFrame, sb, callback);
        return true;
      }
      else {
        int res = MessageDialogBuilder
          .yesNoCancel(title,
                       DebuggerBundle.message("warning.finally.block.detected") + sb)
          .project(project)
          .icon(Messages.getWarningIcon())
          .yesText(DebuggerBundle.message("button.execute.finally"))
          .noText(DebuggerBundle.message("button.drop.anyway"))
          .cancelText(CommonBundle.message("button.cancel"))
          .doNotAsk(
            new DialogWrapper.DoNotAskOption() {
              @Override
              public boolean isToBeShown() {
                return !DebuggerSettings.EVALUATE_FINALLY_ALWAYS.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME) &&
                       !DebuggerSettings.EVALUATE_FINALLY_NEVER.equals(DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME);
              }

              @Override
              public void setToBeShown(boolean value, int exitCode) {
                if (!value) {
                  DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME =
                    exitCode == Messages.YES ? DebuggerSettings.EVALUATE_FINALLY_ALWAYS : DebuggerSettings.EVALUATE_FINALLY_NEVER;
                }
                else {
                  DebuggerSettings.getInstance().EVALUATE_FINALLY_ON_POP_FRAME = DebuggerSettings.EVALUATE_FINALLY_ASK;
                }
              }

              @Override
              public boolean canBeHidden() {
                return true;
              }

              @Override
              public boolean shouldSaveOptionsOnCancel() {
                return false;
              }

              @NotNull
              @Override
              public String getDoNotShowMessage() {
                return CommonBundle.message("dialog.options.do.not.show");
              }
            })
          .show();

        switch (res) {
          case Messages.CANCEL:
            return true;
          case Messages.NO:
            break;
          case Messages.YES: // evaluate finally
            evaluateAndAct(project, stackFrame, sb, callback);
            return true;
        }
      }
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:ApplicationImpl.java   
private static boolean confirmExitIfNeeded(boolean exitConfirmed) {
  final boolean hasUnsafeBgTasks = ProgressManager.getInstance().hasUnsafeProgressIndicator();
  if (exitConfirmed && !hasUnsafeBgTasks) {
    return true;
  }

  DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
    @Override
    public boolean isToBeShown() {
      return GeneralSettings.getInstance().isConfirmExit() && ProjectManager.getInstance().getOpenProjects().length > 0;
    }

    @Override
    public void setToBeShown(boolean value, int exitCode) {
      GeneralSettings.getInstance().setConfirmExit(value);
    }

    @Override
    public boolean canBeHidden() {
      return !hasUnsafeBgTasks;
    }

    @Override
    public boolean shouldSaveOptionsOnCancel() {
      return false;
    }

    @NotNull
    @Override
    public String getDoNotShowMessage() {
      return "Do not ask me again";
    }
  };

  if (hasUnsafeBgTasks || option.isToBeShown()) {
    String message = ApplicationBundle
      .message(hasUnsafeBgTasks ? "exit.confirm.prompt.tasks" : "exit.confirm.prompt",
               ApplicationNamesInfo.getInstance().getFullProductName());

    if (MessageDialogBuilder.yesNo(ApplicationBundle.message("exit.confirm.title"), message).yesText(ApplicationBundle.message("command.exit")).noText(CommonBundle.message("button.cancel"))
          .doNotAsk(option).show() != Messages.YES) {
      return false;
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:GitDeleteRemoteBranchOperation.java   
private DeleteRemoteBranchDecision confirmBranchDeletion(@NotNull String branchName, @NotNull Collection<String> trackingBranches,
                                                         boolean currentBranchTracksBranchToDelete,
                                                         @NotNull Collection<GitRepository> repositories) {
  String title = "Delete Remote Branch";
  String message = "Delete remote branch " + branchName;

  boolean delete;
  final boolean deleteTracking;
  if (trackingBranches.isEmpty()) {
    delete = Messages.showYesNoDialog(myProject, message, title, "Delete", "Cancel", Messages.getQuestionIcon()) == Messages.YES;
    deleteTracking = false;
  }
  else {
    if (currentBranchTracksBranchToDelete) {
      message += "\n\nCurrent branch " + GitBranchUtil.getCurrentBranchOrRev(repositories) + " tracks " + branchName + " but won't be deleted.";
    }
    final String checkboxMessage;
    if (trackingBranches.size() == 1) {
      checkboxMessage = "Delete tracking local branch " + trackingBranches.iterator().next() + " as well";
    }
    else {
      checkboxMessage = "Delete tracking local branches " + StringUtil.join(trackingBranches, ", ");
    }

    final AtomicBoolean deleteChoice = new AtomicBoolean();
    delete = MessageDialogBuilder.yesNo(title, message).project(myProject).yesText("Delete").noText("Cancel").doNotAsk(new DialogWrapper.DoNotAskOption() {
      @Override
      public boolean isToBeShown() {
        return true;
      }

      @Override
      public void setToBeShown(boolean value, int exitCode) {
        deleteChoice.set(!value);
      }

      @Override
      public boolean canBeHidden() {
        return true;
      }

      @Override
      public boolean shouldSaveOptionsOnCancel() {
        return false;
      }

      @NotNull
      @Override
      public String getDoNotShowMessage() {
        return checkboxMessage;
      }
    }).show() == Messages.YES;
    deleteTracking = deleteChoice.get();
  }
  return new DeleteRemoteBranchDecision(delete, deleteTracking);
}
项目:intellij-ce-playground    文件:MergeFromTheirsResolver.java   
private boolean getAddedFilesPlaceOption() {
  final SvnConfiguration configuration = SvnConfiguration.getInstance(myVcs.getProject());
  boolean add = Boolean.TRUE.equals(configuration.isKeepNewFilesAsIsForTreeConflictMerge());
  if (configuration.isKeepNewFilesAsIsForTreeConflictMerge() != null) {
    return add;
  }
  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;
      }

      @NotNull
      @Override
      public String getDoNotShowMessage() {
        return CommonBundle.message("dialog.options.do.not.ask");
      }
    }).show();
}
项目:consulo    文件:ApplicationImpl.java   
private static boolean confirmExitIfNeeded(boolean exitConfirmed) {
  final boolean hasUnsafeBgTasks = ProgressManager.getInstance().hasUnsafeProgressIndicator();
  if (exitConfirmed && !hasUnsafeBgTasks) {
    return true;
  }

  DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
    @Override
    public boolean isToBeShown() {
      return GeneralSettings.getInstance().isConfirmExit() && ProjectManager.getInstance().getOpenProjects().length > 0;
    }

    @Override
    public void setToBeShown(boolean value, int exitCode) {
      GeneralSettings.getInstance().setConfirmExit(value);
    }

    @Override
    public boolean canBeHidden() {
      return !hasUnsafeBgTasks;
    }

    @Override
    public boolean shouldSaveOptionsOnCancel() {
      return false;
    }

    @Nonnull
    @Override
    public String getDoNotShowMessage() {
      return "Do not ask me again";
    }
  };

  if (hasUnsafeBgTasks || option.isToBeShown()) {
    String message = ApplicationBundle.message(hasUnsafeBgTasks ? "exit.confirm.prompt.tasks" : "exit.confirm.prompt", ApplicationNamesInfo.getInstance().getFullProductName());

    if (MessageDialogBuilder.yesNo(ApplicationBundle.message("exit.confirm.title"), message).yesText(ApplicationBundle.message("command.exit")).noText(CommonBundle.message("button.cancel"))
                .doNotAsk(option).show() != Messages.YES) {
      return false;
    }
  }
  return true;
}