ActionCallback (@NotNull final String text) { final ActionCallback result = new ActionCallback(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { for (int i = 0; i < text.length(); i++) { if (!processKeyTyped(text.charAt(i))) { result.setRejected(); return; } } result.setDone(); } }); return result; }