use of com.intellij.ui.popup.mock.MockConfirmation in project intellij-community by JetBrains.
the class PopupFactoryImpl method createConfirmation.
@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);
}
Aggregations