UndoRedoAction.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2011
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. function UndoRedoAction(){}
  13. UndoRedoAction.prototype = new CognosViewerAction();
  14. UndoRedoAction.prototype.dispatchRequest = function(filters, action)
  15. {
  16. var cognosViewerRequest = null;
  17. var undoObj = null;
  18. var undoRedoQueue = this.getUndoRedoQueue();
  19. if (action == "Undo")
  20. {
  21. undoObj = undoRedoQueue.moveBack();
  22. }
  23. else
  24. {
  25. undoObj = undoRedoQueue.moveForward();
  26. }
  27. if (action == "Undo" && undoObj && undoObj.undoCallback) {
  28. undoObj.undoCallback();
  29. this.getCognosViewer().getViewerWidget().updateToolbar();
  30. }
  31. else if (action == "Redo" && undoObj && undoObj.redoCallback) {
  32. undoObj.redoCallback();
  33. this.getCognosViewer().getViewerWidget().updateToolbar();
  34. }
  35. else
  36. {
  37. var widgetProperties = this.getCognosViewer().getViewerWidget().getProperties();
  38. if (widgetProperties && undoObj.widgetProperties)
  39. {
  40. widgetProperties.doUndo(undoObj.widgetProperties);
  41. }
  42. var cognosViewerRequest = new ViewerDispatcherEntry(this.getCognosViewer());
  43. if (typeof undoObj.spec != "undefined")
  44. {
  45. cognosViewerRequest.addFormField("ui.action", "undoRedo");
  46. cognosViewerRequest.addFormField("ui.spec", undoObj.spec);
  47. cognosViewerRequest.addFormField("executionParameters", undoObj.parameters);
  48. }
  49. else
  50. {
  51. cognosViewerRequest.addFormField("ui.action", "undoRedo");
  52. cognosViewerRequest.addFormField("ui.conversation", undoObj.conversation);
  53. }
  54. if (typeof undoObj.hasAVSChart != "undefined")
  55. {
  56. cognosViewerRequest.addFormField("hasAVSChart", undoObj.hasAVSChart);
  57. }
  58. if (widgetProperties && widgetProperties.getRowsPerPage() != null) {
  59. cognosViewerRequest.addFormField( "run.verticalElements", widgetProperties.getRowsPerPage() );
  60. }
  61. if(filters != "")
  62. {
  63. cognosViewerRequest.addFormField("cv.updateDataFilters", filters);
  64. }
  65. if (typeof undoObj.infoBar == "string")
  66. {
  67. cognosViewerRequest.addFormField("rap.reportInfo", undoObj.infoBar);
  68. }
  69. else
  70. {
  71. cognosViewerRequest.addFormField("rap.reportInfo", "{}");
  72. }
  73. cognosViewerRequest.addFormField("run.prompt", "false");
  74. cognosViewerRequest.setCallbacks( {
  75. "closeErrorDlg" : {"object" : undoRedoQueue, "method" : undoRedoQueue.handleCancel}
  76. });
  77. this.getCognosViewer().dispatchRequest(cognosViewerRequest);
  78. }
  79. this.fireModifiedReportEvent();
  80. };
  81. UndoRedoAction.prototype.execute = function()
  82. {
  83. this.gatherFilterInfoBeforeAction(this.m_sAction);
  84. };