ChangePaletteAction.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 ChangePaletteAction()
  13. {
  14. this.m_sAction = "ChangePalette";
  15. this.m_palette = "";
  16. this.m_runReport = true;
  17. this.m_aPaletteNames = ["Flow", "Classic", "Contemporary",
  18. "Contrast", "Corporate", "Dynamic",
  19. "Excel", "Excel 2007", "Gradients",
  20. "Grey Scale", "Jazz", "Legacy",
  21. "Metro", "Mixed", "Modern",
  22. "Patterns"];
  23. this.m_aPaletteIcons = ["changePaletteFlow", "changePaletteClassic", "changePaletteContemporary",
  24. "changePaletteContrast", "changePaletteCorporate", "changePaletteDynamic",
  25. "changePaletteExcel", "changePaletteExcel2007", "changePaletteGradients",
  26. "changePaletteGreyScale", "changePaletteJazz", "changePaletteLegacy",
  27. "changePaletteMetro", "changePaletteMixed", "changePaletteModern",
  28. "changePalettePatterns"];
  29. }
  30. ChangePaletteAction.prototype = new ModifyReportAction();
  31. ChangePaletteAction.baseclass = ModifyReportAction.prototype;
  32. ChangePaletteAction.prototype.reuseQuery = function() { return true; };
  33. ChangePaletteAction.prototype.preProcess = function()
  34. {
  35. // check to see if the report only contains flash charts, if so, we don't need to hit the report service, we can change the palette locally
  36. this.updateRunReport();
  37. if (this.m_runReport==false) {
  38. var flashCharts = this.getLayoutComponents();
  39. for(var index = 0; index < flashCharts.length; ++index)
  40. {
  41. var flashChart = flashCharts[index];
  42. if(flashChart.getAttribute("flashChart") != null)
  43. {
  44. if(this.m_palette == "")
  45. {
  46. flashChart.setPalette("Flow");
  47. }
  48. else
  49. {
  50. flashChart.setPalette(this.m_palette);
  51. }
  52. }
  53. }
  54. }
  55. };
  56. ChangePaletteAction.prototype.updateRunReport = function()
  57. {
  58. this.m_runReport=true;
  59. var reportTable = document.getElementById("rt" + this.m_oCV.getId());
  60. if(reportTable != null) {
  61. var serverSideCharts = getElementsByAttribute(reportTable, "*", "chartcontainer", "true");
  62. if(serverSideCharts.length == 0) {
  63. this.m_runReport=false;
  64. }
  65. }
  66. };
  67. ChangePaletteAction.prototype.runReport = function()
  68. {
  69. return this.m_runReport;
  70. };
  71. ChangePaletteAction.prototype.updateInfoBar = function()
  72. {
  73. return false;
  74. };
  75. ChangePaletteAction.prototype.getUndoHint = function()
  76. {
  77. return RV_RES.IDS_JS_CHANGE_PALETTE;
  78. };
  79. ChangePaletteAction.prototype.setRequestParms = function(palette)
  80. {
  81. if(typeof palette == "string")
  82. {
  83. this.m_palette = palette;
  84. // Preserve the information on the selected palette in CCognosViewer object for latter retrieval
  85. // and use in ChangePaletteAction.prototype.updateMenu().
  86. if (this.m_oCV != null && typeof this.m_oCV != "undefined")
  87. {
  88. this.m_oCV.m_sPalette = palette;
  89. }
  90. }
  91. };
  92. ChangePaletteAction.prototype.addActionContextAdditionalParms = function()
  93. {
  94. if(this.m_palette != "")
  95. {
  96. return "<name>" + this.m_palette + "</name>";
  97. }
  98. return "";
  99. };
  100. ChangePaletteAction.prototype.updateMenu = function(jsonSpec)
  101. {
  102. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  103. if (! jsonSpec.visible)
  104. {
  105. return jsonSpec;
  106. }
  107. var reportInfo = this.getSelectedReportInfo();
  108. if (reportInfo != null && reportInfo.displayTypeId.indexOf("Chart") >= 0)
  109. {
  110. jsonSpec.disabled = false;
  111. return jsonSpec;
  112. }
  113. jsonSpec.disabled = true;
  114. return jsonSpec;
  115. };
  116. ChangePaletteAction.reset = function( oCV )
  117. {
  118. delete (oCV.m_sPalette);
  119. };