void () { // invoke later because changing document inside undo/redo is not allowed Application application = ApplicationManager.getApplication(); application.invokeLater(undo, ModalityState.nonModal(), project.getDisposed()); }