Search in sources :

Example 1 with MockConfirmation

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);
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) BaseListPopupStep(com.intellij.openapi.ui.popup.util.BaseListPopupStep) ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) MockConfirmation(com.intellij.ui.popup.mock.MockConfirmation) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)1 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)1 MockConfirmation (com.intellij.ui.popup.mock.MockConfirmation)1 NotNull (org.jetbrains.annotations.NotNull)1