Java 类com.intellij.ui.popup.mock.MockConfirmation 实例源码

项目:intellij-ce-playground    文件:PopupFactoryImpl.java   
@NotNull
@Override
public ListPopup createConfirmation(String title,
                                    final String yesText,
                                    String noText,
                                    final Runnable onYes,
                                    final Runnable onNo,
                                    int defaultOptionIndex)
{

  final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[]{yesText, noText}) {
    @Override
    public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
      if (selectedValue.equals(yesText)) {
        onYes.run();
      }
      else {
        onNo.run();
      }
      return FINAL_CHOICE;
    }

    @Override
    public void canceled() {
      onNo.run();
    }

    @Override
    public boolean isMnemonicsNavigationEnabled() {
      return true;
    }
  };
  step.setDefaultOptionIndex(defaultOptionIndex);

  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText);
}
项目:tools-idea    文件:PopupFactoryImpl.java   
@NotNull
@Override
public ListPopup createConfirmation(String title,
                                    final String yesText,
                                    String noText,
                                    final Runnable onYes,
                                    final Runnable onNo,
                                    int defaultOptionIndex)
{

  final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[]{yesText, noText}) {
    @Override
    public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
      if (selectedValue.equals(yesText)) {
        onYes.run();
      }
      else {
        onNo.run();
      }
      return FINAL_CHOICE;
    }

    @Override
    public void canceled() {
      onNo.run();
    }

    @Override
    public boolean isMnemonicsNavigationEnabled() {
      return true;
    }
  };
  step.setDefaultOptionIndex(defaultOptionIndex);

  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText);
}
项目:EclipseCodeFormatter    文件:ProjectSettingsForm.java   
public ListPopup createConfirmation(String title, final String yesText, String noText, final Runnable onYes,
        final Runnable onNo, int defaultOptionIndex) {

    final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, new String[] { yesText, noText }) {
        @Override
        public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
            if (selectedValue.equals(yesText)) {
                onYes.run();
            } else {
                onNo.run();
            }
            return FINAL_CHOICE;
        }

        @Override
        public void canceled() {
        }

        @Override
        public boolean isMnemonicsNavigationEnabled() {
            return true;
        }
    };
    step.setDefaultOptionIndex(defaultOptionIndex);

    final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText);
}
项目:consulo    文件:PopupFactoryImpl.java   
@Nonnull
@Override
public ListPopup createConfirmation(String title,
                                    final String yesText,
                                    String noText,
                                    final Runnable onYes,
                                    final Runnable onNo,
                                    int defaultOptionIndex)
{

  final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, yesText, noText) {
    @Override
    public PopupStep onChosen(String selectedValue, final boolean finalChoice) {
      return doFinalStep(selectedValue.equals(yesText) ? onYes : onNo);
    }

    @Override
    public void canceled() {
      onNo.run();
    }

    @Override
    public boolean isMnemonicsNavigationEnabled() {
      return true;
    }
  };
  step.setDefaultOptionIndex(defaultOptionIndex);

  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText);
}