void (@NotNull Runnable modalAction) { if (!isModalEntity()) { modalAction.run(); return; } if (myModalityEntered) { throw new IllegalStateException("Modality already entered: " + getModalityState()); } LaterInvocator.enterModal(this, (ModalityStateEx)getModalityState()); myModalityEntered = true; try { modalAction.run(); } finally { LaterInvocator.leaveModal(this); } }