Java 类com.intellij.ui.mac.MacMessages 实例源码

项目:intellij-ce-playground    文件:MessageDialogBuilder.java   
@Messages.YesNoCancelResult
public int show() {
  String yesText = ObjectUtils.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtils.chooseNotNull(myNoText, Messages.NO_BUTTON);
  String cancelText = ObjectUtils.chooseNotNull(myCancelText, Messages.CANCEL_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  }
  catch (Exception ignored) {}

  int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText, cancelText}, 0, myIcon, myDoNotAskOption);
  return buttonNumber == 0 ? Messages.YES : buttonNumber == 1 ? Messages.NO : Messages.CANCEL;

}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return number of button pressed: from 0 up to options.length-1 inclusive, or -1 for Cancel
 */
public static int showDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String[] options, int defaultOptionIndex, @Nullable Icon icon) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }
  else {
    try {
      if (canShowMacSheetPanel()) {
        return MacMessages.getInstance().showMessageDialog(title, message, options, false, SwingUtilities.getWindowAncestor(parent),
                                                           defaultOptionIndex, defaultOptionIndex, null);
      }
    }
    catch (MessageException ignored) {/*rollback the message and show a dialog*/}
    catch (Exception reportThis) {LOG.error(reportThis);}

    MessageDialog dialog = new MessageDialog(parent, message, title, options, defaultOptionIndex, defaultOptionIndex, icon, false);
    dialog.show();
    return dialog.getExitCode();
  }
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @see #showDialog(Project, String, String, String[], int, Icon, DialogWrapper.DoNotAskOption)
 * @see #showDialog(Component, String, String, String[], int, Icon)
 * @return number of button pressed: from 0 up to options.length-1 inclusive, or -1 for Cancel
 */
public static int showDialog(String message,
                             @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                             @NotNull String[] options,
                             int defaultOptionIndex,
                             int focusedOptionIndex,
                             @Nullable Icon icon,
                             @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showMessageDialog(title, message, options, false, null, defaultOptionIndex, focusedOptionIndex,
                                                         doNotAskOption);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  //what's it? if (application.isUnitTestMode()) throw new RuntimeException(message);
  MessageDialog dialog = new MessageDialog(message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption);
  dialog.show();
  return dialog.getExitCode();
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@Nullable Project project, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String yesText, @NotNull String noText, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance()
        .showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project));
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int result = showDialog(project, message, title, new String[]{yesText, noText}, 0, icon) == 0 ? YES : NO;
  //noinspection ConstantConditions
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@Nullable Project project,
                                  String message,
                                  @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                                  @NotNull String yesText,
                                  @NotNull String noText,
                                  @Nullable Icon icon,
                                  @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance()
        .showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project), doNotAskOption);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int result = showDialog(project, message, title, new String[]{yesText, noText}, 0, icon, doNotAskOption) == 0 ? YES : NO;
  //noinspection ConstantConditions
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@Nullable Project project, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON,
                                                       WindowManager.getInstance().suggestParentWindow(project));
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int result = showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon);

  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@Nullable Project project,
                                  String message,
                                  @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                                  @Nullable Icon icon,
                                  @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON,
                                                       WindowManager.getInstance().suggestParentWindow(project), doNotAskOption);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int result = showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon, doNotAskOption);

  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, SwingUtilities.getWindowAncestor(parent));
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int result = showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon) == 0 ? YES : NO;
  //noinspection ConstantConditions
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @see #showYesNoDialog(Project, String, String, Icon)
 * @see #showYesNoCancelDialog(Component, String, String, Icon)
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String yesText, @NotNull String noText, @Nullable Icon icon,
                                  @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, null, doNotAskOption);
    }
  }
  catch (MessageException messageException) {
    // just show a dialog instead
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  int result = showDialog(message, title, new String[]{yesText, noText}, 0, icon, doNotAskOption) == 0 ? YES : NO;
  //noinspection ConstantConditions
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #OK} if user pressed "Ok" or {@link #CANCEL} if user pressed "Cancel" button.
 */
@OkCancelResult
public static int showOkCancelDialog(Project project,
                                     String message,
                                     @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                                     @NotNull String okText,
                                     @NotNull String cancelText,
                                     Icon icon,
                                     DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      int result = MacMessages.getInstance()
        .showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project),
                         doNotAskOption);
      return result == YES ? OK : CANCEL;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption) == 0 ? OK : CANCEL;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No", or {@link #CANCEL} if user pressed "Cancel" button.
 */
@YesNoCancelResult
public static int showYesNoCancelDialog(Project project,
                                        String message,
                                        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                                        @NotNull String yes,
                                        @NotNull String no,
                                        @NotNull String cancel,
                                        @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel,
                                                             WindowManager.getInstance().suggestParentWindow(project), null);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int buttonNumber = showDialog(project, message, title, new String[]{yes, no, cancel}, 0, icon);
  return buttonNumber == 0 ? YES : buttonNumber == 1 ? NO : CANCEL;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No", or {@link #CANCEL} if user pressed "Cancel" button.
 */
@YesNoCancelResult
public static int showYesNoCancelDialog(@NotNull Component parent,
                                        String message,
                                        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                                        @NotNull String yes,
                                        @NotNull String no,
                                        @NotNull String cancel,
                                        Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel,
                                                             SwingUtilities.getWindowAncestor(parent), null);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int buttonNumber = showDialog(parent, message, title, new String[]{yes, no, cancel}, 0, icon);
  return buttonNumber == 0 ? YES : buttonNumber == 1 ? NO : CANCEL;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @see #showYesNoCancelDialog(Project, String, String, String, String, String, Icon)
 * @see #showYesNoCancelDialog(Component, String, String, String, String, String, Icon)
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No", or {@link #CANCEL} if user pressed "Cancel" button.
 */
@YesNoCancelResult
public static int showYesNoCancelDialog(String message,
                                        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                                        @NotNull String yes,
                                        @NotNull String no,
                                        @NotNull String cancel,
                                        Icon icon,
                                        @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel, null, doNotAskOption);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int buttonNumber = showDialog(message, title, new String[]{yes, no, cancel}, 0, icon, doNotAskOption);
  return buttonNumber == 0 ? YES : buttonNumber == 1 ? NO : CANCEL;
}
项目:tools-idea    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @see #showDialog(Project, String, String, String[], int, Icon, DialogWrapper.DoNotAskOption)
 * @see #showDialog(Component, String, String, String[], int, Icon)
 */
public static int showDialog(String message, String title, String[] options, int defaultOptionIndex, int focusedOptionIndex, @Nullable Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }
  else {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showMessageDialog(title, message, options, false, null, defaultOptionIndex, focusedOptionIndex, doNotAskOption);
    }

    //what's it? if (application.isUnitTestMode()) throw new RuntimeException(message);
    MessageDialog dialog = new MessageDialog(message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption);
    dialog.show();
    return dialog.getExitCode();
  }
}
项目:consulo    文件:MessageDialogBuilder.java   
@Messages.YesNoCancelResult
public int show() {
  String yesText = ObjectUtil.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtil.chooseNotNull(myNoText, Messages.NO_BUTTON);
  String cancelText = ObjectUtil.chooseNotNull(myCancelText, Messages.CANCEL_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  }
  catch (Exception ignored) {}

  int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText, cancelText}, 0, myIcon, myDoNotAskOption);
  return buttonNumber == 0 ? Messages.YES : buttonNumber == 1 ? Messages.NO : Messages.CANCEL;

}
项目:consulo    文件:Messages.java   
/**
 * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)!
 *
 * @return number of button pressed: from 0 up to options.length-1 inclusive, or -1 for Cancel
 */
public static int showDialog(@Nullable Project project,
                             String message,
                             @Nonnull String title,
                             @Nonnull String[] options,
                             int defaultOptionIndex,
                             @Nullable Icon icon,
                             @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }

  try {
    if (canShowMacSheetPanel()) {
      Window parentWindow = WindowManager.getInstance().suggestParentWindow(project);
      return MacMessages.getInstance()
              .showMessageDialog(title, message, options, false, parentWindow, defaultOptionIndex, defaultOptionIndex, doNotAskOption);
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  return showIdeaMessageDialog(project, message, title, options, defaultOptionIndex, icon, doNotAskOption);
}
项目:consulo    文件:Messages.java   
/**
 * @return number of button pressed: from 0 up to options.length-1 inclusive, or -1 for Cancel
 */
public static int showDialog(@Nonnull Component parent,
                             String message,
                             @Nonnull String title,
                             @Nonnull String[] options,
                             int defaultOptionIndex,
                             @Nullable Icon icon) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }
  else {
    try {
      if (canShowMacSheetPanel()) {
        return MacMessages.getInstance()
                .showMessageDialog(title, message, options, false, SwingUtilities.getWindowAncestor(parent), defaultOptionIndex, defaultOptionIndex, null);
      }
    }
    catch (Exception exception) {
      LOG.error(exception);
    }

    MessageDialog dialog = new MessageDialog(parent, message, title, options, defaultOptionIndex, defaultOptionIndex, icon, false);
    dialog.show();
    return dialog.getExitCode();
  }
}
项目:consulo    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @return number of button pressed: from 0 up to options.length-1 inclusive, or -1 for Cancel
 * @see #showDialog(Project, String, String, String[], int, Icon, DialogWrapper.DoNotAskOption)
 * @see #showDialog(Component, String, String, String[], int, Icon)
 */
public static int showDialog(String message,
                             @Nonnull String title,
                             @Nonnull String[] options,
                             int defaultOptionIndex,
                             int focusedOptionIndex,
                             @Nullable Icon icon,
                             @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showMessageDialog(title, message, options, false, null, defaultOptionIndex, focusedOptionIndex, doNotAskOption);
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  //what's it? if (application.isUnitTestMode()) throw new RuntimeException(message);
  MessageDialog dialog = new MessageDialog(message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption);
  dialog.show();
  return dialog.getExitCode();
}
项目:consulo    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@Nullable Project project,
                                  String message,
                                  @Nonnull String title,
                                  @Nonnull String yesText,
                                  @Nonnull String noText,
                                  @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project));
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  int result = showDialog(project, message, title, new String[]{yesText, noText}, 0, icon) == 0 ? YES : NO;
  //noinspection ConstantConditions
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:consulo    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@Nullable Project project, String message, @Nonnull String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  int result = showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon);

  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:consulo    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(@Nonnull Component parent, String message, @Nonnull String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, SwingUtilities.getWindowAncestor(parent));
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  int result = showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon) == 0 ? YES : NO;
  //noinspection ConstantConditions
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:consulo    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 * @see #showYesNoDialog(com.intellij.openapi.project.Project, String, String, javax.swing.Icon)
 * @see #showYesNoCancelDialog(java.awt.Component, String, String, javax.swing.Icon)
 */
@YesNoResult
public static int showYesNoDialog(String message,
                                  @Nonnull String title,
                                  @Nonnull String yesText,
                                  @Nonnull String noText,
                                  @Nullable Icon icon,
                                  @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, null, doNotAskOption);
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  int result = showDialog(message, title, new String[]{yesText, noText}, 0, icon, doNotAskOption) == 0 ? YES : NO;
  //noinspection ConstantConditions
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:consulo    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 * @see #showYesNoDialog(Project, String, String, Icon)
 * @see #showYesNoDialog(Component, String, String, Icon)
 */
@YesNoResult
public static int showYesNoDialog(String message, @Nonnull String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, null);
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  int result = showYesNoDialog(message, title, YES_BUTTON, NO_BUTTON, icon);
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:consulo    文件:Messages.java   
/**
 * @return {@link #OK} if user pressed "Ok" or {@link #CANCEL} if user pressed "Cancel" button.
 */
@OkCancelResult
public static int showOkCancelDialog(Project project,
                                     String message,
                                     @Nonnull String title,
                                     @Nonnull String okText,
                                     @Nonnull String cancelText,
                                     Icon icon,
                                     DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      int result = MacMessages.getInstance()
              .showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project), doNotAskOption);
      return result == YES ? OK : CANCEL;
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption) == 0 ? OK : CANCEL;
}
项目:consulo    文件:Messages.java   
/**
 * @return {@link #OK} if user pressed "Ok" or {@link #CANCEL} if user pressed "Cancel" button.
 */
@OkCancelResult
public static int showOkCancelDialog(@Nonnull Component parent,
                                     String message,
                                     @Nonnull String title,
                                     @Nonnull String okText,
                                     @Nonnull String cancelText,
                                     Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      int result = MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, SwingUtilities.getWindowAncestor(parent));
      return result == YES ? OK : CANCEL;
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  return showDialog(parent, message, title, new String[]{okText, cancelText}, 0, icon) == 0 ? OK : CANCEL;
}
项目:consulo    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @return {@link #OK} if user pressed "Ok" or {@link #CANCEL} if user pressed "Cancel" button.
 * @see #showOkCancelDialog(Project, String, String, String, String, Icon, DialogWrapper.DoNotAskOption)
 * @see #showOkCancelDialog(Component, String, String, String, String, Icon)
 */
@OkCancelResult
public static int showOkCancelDialog(String message,
                                     @Nonnull String title,
                                     @Nonnull String okText,
                                     @Nonnull String cancelText,
                                     Icon icon,
                                     @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      int result = MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, null, doNotAskOption);
      return result == YES ? OK : CANCEL;
    }
  }
  catch (Exception exception) {
    LOG.error(exception);
  }

  return showDialog(message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption) == 0 ? OK : CANCEL;
}
项目:consulo    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No", or {@link #CANCEL} if user pressed "Cancel" button.
 */
@YesNoCancelResult
public static int showYesNoCancelDialog(Project project,
                                        String message,
                                        @Nonnull String title,
                                        @Nonnull String yes,
                                        @Nonnull String no,
                                        @Nonnull String cancel,
                                        @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel, WindowManager.getInstance().suggestParentWindow(project), null);
    }
  }
  catch (Exception exception) {
  }

  int buttonNumber = showDialog(project, message, title, new String[]{yes, no, cancel}, 0, icon);
  return buttonNumber == 0 ? YES : buttonNumber == 1 ? NO : CANCEL;
}
项目:consulo    文件:Messages.java   
/**
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No", or {@link #CANCEL} if user pressed "Cancel" button.
 */
@YesNoCancelResult
public static int showYesNoCancelDialog(@Nonnull Component parent,
                                        String message,
                                        @Nonnull String title,
                                        @Nonnull String yes,
                                        @Nonnull String no,
                                        @Nonnull String cancel,
                                        Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel, SwingUtilities.getWindowAncestor(parent), null);
    }
  }
  catch (Exception exception) {
  }

  int buttonNumber = showDialog(parent, message, title, new String[]{yes, no, cancel}, 0, icon);
  return buttonNumber == 0 ? YES : buttonNumber == 1 ? NO : CANCEL;
}
项目:consulo    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No", or {@link #CANCEL} if user pressed "Cancel" button.
 * @see #showYesNoCancelDialog(Project, String, String, String, String, String, Icon)
 * @see #showYesNoCancelDialog(Component, String, String, String, String, String, Icon)
 */
@YesNoCancelResult
public static int showYesNoCancelDialog(String message,
                                        @Nonnull String title,
                                        @Nonnull String yes,
                                        @Nonnull String no,
                                        @Nonnull String cancel,
                                        Icon icon,
                                        @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel, null, doNotAskOption);
    }
  }
  catch (Exception exception) {
  }

  int buttonNumber = showDialog(message, title, new String[]{yes, no, cancel}, 0, icon, doNotAskOption);
  return buttonNumber == 0 ? YES : buttonNumber == 1 ? NO : CANCEL;
}
项目:intellij-ce-playground    文件:MessageDialogBuilder.java   
@Messages.YesNoResult
public int show() {
  String yesText = ObjectUtils.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtils.chooseNotNull(myNoText, Messages.NO_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  } catch (Exception ignored) {}

  return Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText}, 0, myIcon, myDoNotAskOption) == 0 ? Messages.YES : Messages.NO;

}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)!
 * @return number of button pressed: from 0 up to options.length-1 inclusive, or -1 for Cancel
 */
public static int showDialog(@Nullable Project project,
                             String message,
                             @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                             @NotNull String[] options,
                             int defaultOptionIndex,
                             @Nullable Icon icon,
                             @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }

  try {
    if (canShowMacSheetPanel()) {
      WindowManager windowManager = WindowManager.getInstance();
      if (windowManager != null) {
        Window parentWindow = windowManager.suggestParentWindow(project);
        return MacMessages.getInstance()
          .showMessageDialog(title, message, options, false, parentWindow, defaultOptionIndex, defaultOptionIndex, doNotAskOption);
      }
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  return showIdeaMessageDialog(project, message, title, options, defaultOptionIndex, icon, doNotAskOption);
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return number of button pressed: from 0 up to options.length-1 inclusive, or -1 for Cancel
 */
public static int showDialog(Project project,
                             String message,
                             @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title,
                             @Nullable String moreInfo,
                             @NotNull String[] options,
                             int defaultOptionIndex,
                             int focusedOptionIndex,
                             Icon icon) {
  if (isApplicationInUnitTestOrHeadless()) {
    return ourTestImplementation.show(message);
  }

  try {
    if (canShowMacSheetPanel() && moreInfo == null) {
      return MacMessages.getInstance()
        .showMessageDialog(title, message, options, false, WindowManager.getInstance().suggestParentWindow(project), defaultOptionIndex,
                           focusedOptionIndex, null);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  MessageDialog dialog = new MoreInfoMessageDialog(project, message, title, moreInfo, options, defaultOptionIndex, focusedOptionIndex, icon);
  dialog.show();
  return dialog.getExitCode();
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @see DialogWrapper#DialogWrapper(Project,boolean)
 */
public static void showMessageDialog(@Nullable Project project, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
      return;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  showDialog(project, message, title, new String[]{OK_BUTTON}, 0, icon);
}
项目:intellij-ce-playground    文件:Messages.java   
public static void showMessageDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(parent));
      return;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  showDialog(parent, message, title, new String[]{OK_BUTTON}, 0, icon);
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @see #showMessageDialog(Project, String, String, Icon)
 * @see #showMessageDialog(Component, String, String, Icon)
 */
public static void showMessageDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON);
      return;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  showDialog(message, title, new String[]{OK_BUTTON}, 0, icon);
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @see #showYesNoDialog(Project, String, String, Icon)
 * @see #showYesNoDialog(Component, String, String, Icon)
 * @return {@link #YES} if user pressed "Yes" or {@link #NO} if user pressed "No" button.
 */
@YesNoResult
public static int showYesNoDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, null);
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  int result = showYesNoDialog(message, title, YES_BUTTON, NO_BUTTON, icon);
  LOG.assertTrue(result == YES || result == NO, result);
  return result;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * @return {@link #OK} if user pressed "Ok" or {@link #CANCEL} if user pressed "Cancel" button.
 */
@OkCancelResult
public static int showOkCancelDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String okText, @NotNull String cancelText, Icon icon) {
  try {
    if (canShowMacSheetPanel()) {
      int result =
        MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, SwingUtilities.getWindowAncestor(parent));
      return result == YES ? OK : CANCEL;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  return showDialog(parent, message, title, new String[]{okText, cancelText}, 0, icon) == 0 ? OK : CANCEL;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Use this method only if you do not know project or component
 *
 * @see #showOkCancelDialog(Project, String, String, String, String, Icon, DialogWrapper.DoNotAskOption)
 * @see #showOkCancelDialog(Component, String, String, String, String, Icon)
 * @return {@link #OK} if user pressed "Ok" or {@link #CANCEL} if user pressed "Cancel" button.
 */
@OkCancelResult
public static int showOkCancelDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String okText, @NotNull String cancelText, Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) {
  try {
    if (canShowMacSheetPanel()) {
      int result = MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, null, doNotAskOption);
      return result == YES ? OK : CANCEL;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  return showDialog(message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption) == 0 ? OK : CANCEL;
}
项目:intellij-ce-playground    文件:Messages.java   
public static void showErrorDialog(@Nullable Project project, @Nls String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) {
  try {
    if (canShowMacSheetPanel()) {
      MacMessages.getInstance().showErrorDialog(title, message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
      return;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  showDialog(project, message, title, new String[]{OK_BUTTON}, 0, getErrorIcon());
}
项目:intellij-ce-playground    文件:Messages.java   
public static void showErrorDialog(@NotNull Component component, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) {
  try {
    if (canShowMacSheetPanel()) {
      MacMessages.getInstance().showErrorDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(component));
      return;
    }
  }
  catch (MessageException ignored) {/*rollback the message and show a dialog*/}
  catch (Exception reportThis) {LOG.error(reportThis);}

  showDialog(component, message, title, new String[]{OK_BUTTON}, 0, getErrorIcon());
}