CommandHandler.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * A command handler that may be registered with the
  3. * {@link CommandStack} via {@link CommandStack#registerHandler}.
  4. */
  5. export default function CommandHandler() {}
  6. /**
  7. * Execute changes described in the passed action context.
  8. *
  9. * @param {Object} context the execution context
  10. *
  11. * @return {Array<djs.model.Base>} list of touched (áka dirty) diagram elements
  12. */
  13. CommandHandler.prototype.execute = function(context) {};
  14. /**
  15. * Revert changes described in the passed action context.
  16. *
  17. * @param {Object} context the execution context
  18. *
  19. * @return {Array<djs.model.Base>} list of touched (áka dirty) diagram elements
  20. */
  21. CommandHandler.prototype.revert = function(context) {};
  22. /**
  23. * Return true if the handler may execute in the given context.
  24. *
  25. * @abstract
  26. *
  27. * @param {Object} context the execution context
  28. *
  29. * @return {Boolean} true if executing in the context is possible
  30. */
  31. CommandHandler.prototype.canExecute = function(context) {
  32. return true;
  33. };
  34. /**
  35. * Execute actions before the actual command execution but
  36. * grouped together (for undo/redo) with the action.
  37. *
  38. * @param {Object} context the execution context
  39. */
  40. CommandHandler.prototype.preExecute = function(context) {};
  41. /**
  42. * Execute actions after the actual command execution but
  43. * grouped together (for undo/redo) with the action.
  44. *
  45. * @param {Object} context the execution context
  46. */
  47. CommandHandler.prototype.postExecute = function(context) {};