How to run an undo action on a node in Jetbrains MPS?

71 views Asked by At

I am creating a plugin which will have two buttons to perform Undo and Redo operation on a particular node. I want to know if it is possible to execute the IDE undo and redo operation problematically?

1

There are 1 answers

0
Sanjit Kumar Mishra On BEST ANSWER

I found the below code performs the Undo and Redo operation in Jetbrain's MPS.

foreach editor in FileEditorManager.getInstance(project).getAllEditors() { 
  if (editor.getName() != null && editor.getName().equals("EDITER_TO_UPDATE")) { 
    SwingUtilities.invokeLater(new Runnable() { 
      @Override 
      public void run() { 
        if (operations.equals(Operations.UNDO)) { 
          UndoManagerImpl.getInstance(project).undo(editor); 
        } else if (operations.equals(Operations.REDO)) { 
          UndoManagerImpl.getInstance(project).redo(editor); 
        } 
      } 
    }); 
  } 
}