split undo logic into a basic core and a part specific to Swing