OpenReportFromClipboardAction.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2012
  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. /**
  13. * This is the base class for generating request to re-run the report.
  14. * Classes derived from this will add to it their specific options.
  15. */
  16. function OpenReportFromClipboardAction()
  17. {
  18. this.m_action = 'bux';
  19. this.m_cv = this.getCognosViewer();
  20. }
  21. OpenReportFromClipboardAction.prototype = new CognosViewerAction();
  22. OpenReportFromClipboardAction.prototype.reuseQuery =function() { return false; };
  23. OpenReportFromClipboardAction.prototype.reuseGetParameter =function() { return false; };
  24. OpenReportFromClipboardAction.prototype.keepRAPCache = function() {return false; };
  25. OpenReportFromClipboardAction.prototype.reuseConversation = function() {return false; };
  26. OpenReportFromClipboardAction.prototype.runReport = function() {return true;};
  27. OpenReportFromClipboardAction.prototype.isUndoable = function() {return true; };
  28. OpenReportFromClipboardAction.prototype.execute = function()
  29. {
  30. if( window.clipboardData )
  31. {
  32. this.openReportForIE();
  33. }
  34. else
  35. {
  36. this.openReportForNonIE();
  37. }
  38. };
  39. OpenReportFromClipboardAction.prototype.openReportForNonIE = function()
  40. {
  41. var openReportFromClipboardActionObj = this;
  42. var clipboardDialog = new viewer.dialogs.ClipboardDialog({
  43. sTitle: RV_RES.IDS_JS_CLIPBOARD,
  44. okHandler: function(reportSpec)
  45. {
  46. openReportFromClipboardActionObj.executeAction(reportSpec);
  47. },
  48. cancelHandler: function() {}
  49. });
  50. clipboardDialog.startup();
  51. window.setTimeout(function () { clipboardDialog.show(); },0);
  52. };
  53. OpenReportFromClipboardAction.prototype.openReportForIE = function()
  54. {
  55. var reportSpec = window.clipboardData.getData( 'Text' );
  56. this.executeAction( reportSpec );
  57. };
  58. OpenReportFromClipboardAction.prototype.getDeleteEnvParamsList = function()
  59. {
  60. var deleteEnvParamsList = [
  61. 'modelPath',
  62. 'packageBase',
  63. 'rapReportInfo',
  64. 'rap.state'
  65. ];
  66. return deleteEnvParamsList;
  67. };
  68. OpenReportFromClipboardAction.prototype.deleteEnvParams = function()
  69. {
  70. var envParams = this.m_cv.envParams;
  71. var envParamsToBeDeleted = this.getDeleteEnvParamsList();
  72. for( var index in envParamsToBeDeleted )
  73. {
  74. if( envParams[ envParamsToBeDeleted[index] ] )
  75. {
  76. delete envParams[ envParamsToBeDeleted[index] ];
  77. }
  78. }
  79. };
  80. /**
  81. * Need to clean up CCognosViewer
  82. */
  83. OpenReportFromClipboardAction.prototype.cleanUpCognosViewer = function()
  84. {
  85. this.m_cv.setExecutionParameters( "" );
  86. this.m_cv.setConversation( "" );
  87. this.deleteEnvParams();
  88. };
  89. OpenReportFromClipboardAction.prototype.getRequestParams = function()
  90. {
  91. var requestParams = {
  92. 'run.outputFormat' : 'HTML' ,
  93. 'cv.id' : this.m_cv.getId(),
  94. 'widget.reloadToolbar' : 'true',
  95. 'openReportFromClipboard' : 'true',
  96. 'ui.reportDrop' : 'true'
  97. };
  98. var globalPrompts = this.m_cv.getViewerWidget().getGlobalPromptsInfo();
  99. if (globalPrompts != null ) {
  100. requestParams[ 'widget.globalPromptInfo' ] = globalPrompts;
  101. }
  102. if( this.m_filters != "" )
  103. {
  104. requestParams["cv.updateDataFilters"] = this.m_filters;
  105. }
  106. var envParamsNames = [
  107. 'cv.objectPermissions',
  108. 'limitedInteractiveMode'
  109. ];
  110. for( var index in envParamsNames )
  111. {
  112. var envParamName = envParamsNames[index];
  113. var envParamValue = this.m_cv.envParams[envParamName];
  114. if( envParamValue )
  115. {
  116. requestParams[ envParamName ] = envParamValue;
  117. }
  118. }
  119. return requestParams;
  120. };
  121. /**
  122. * Overrides the base class function
  123. */
  124. OpenReportFromClipboardAction.prototype.addAdditionalOptions = function( cognosViewerRequest )
  125. {
  126. var options = this.getRequestParams();
  127. for( var index in options ) {
  128. cognosViewerRequest.addFormField( index, options[index] );
  129. }
  130. };
  131. OpenReportFromClipboardAction.prototype.executeAction = function( reportSpec )
  132. {
  133. this.m_cv = this.getCognosViewer();
  134. this.m_cv.envParams["ui.spec"] = reportSpec;
  135. this.gatherFilterInfoBeforeAction("OpenReportFromClipboard");
  136. ChangePaletteAction.reset(this.getCognosViewer());
  137. }
  138. OpenReportFromClipboardAction.prototype.dispatchRequest = function( filters )
  139. {
  140. this.m_cv = this.getCognosViewer();
  141. var widget = this.m_cv.getViewerWidget();
  142. widget.reset();
  143. this.m_filters = filters;
  144. this.cleanUpCognosViewer();
  145. var cognosViewerRequest = this.createCognosViewerDispatcherEntry( this.m_action );
  146. this.m_cv.hideReportInfo();
  147. this.m_cv.dispatchRequest( cognosViewerRequest );
  148. //fire the modified event
  149. this.fireModifiedReportEvent();
  150. };
  151. OpenReportFromClipboardAction.prototype.doAddActionContext = function()
  152. {
  153. return false;
  154. };
  155. OpenReportFromClipboardAction.prototype.updateMenu = function(json)
  156. {
  157. json.visible = ( window.cognosViewerDebug === true );
  158. return json;
  159. };