reportSelection.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** BI and PM: qs
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2015
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *****************************************************************/
  11. // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
  12. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  13. function selectReportElement(evt, sId, sType)
  14. {
  15. var el, newSelection, i;
  16. var selectionController = g_reportSelectionController;
  17. if (sId.indexOf("reportFilter") === 0)
  18. {
  19. var iFilterLinesCount = 0;
  20. var iSortLinesCount = 0;
  21. var combinedFilters = getConfigFrame().getCombinedFilter();
  22. if (typeof combinedFilters == "undefined")
  23. {
  24. var ColFilterIdxSize = getConfigFrame().cfgSize("ColFilterIdx");
  25. for(i = 0; i < ColFilterIdxSize; i++)
  26. {
  27. var aFilterIdx = getConfigFrame().cfgGetAt("ColFilterIdx", i);
  28. if (aFilterIdx && aFilterIdx.length)
  29. {
  30. iFilterLinesCount++;
  31. }
  32. }
  33. }
  34. else
  35. {
  36. if (typeof combinedFilters.getRawFilter == "function" && combinedFilters.getRawFilter().getSize() > 0)
  37. {
  38. iFilterLinesCount++;
  39. }
  40. if (typeof combinedFilters.getSummaryFilter == "function" && combinedFilters.getSummaryFilter().getSize() > 0)
  41. {
  42. iFilterLinesCount++;
  43. }
  44. }
  45. var oMQMgr = goWindowManager.getMiniQueryManager();
  46. var aSortColumns = oMQMgr.getElementsByAttribute("sort");
  47. if (aSortColumns.length > 0)
  48. {
  49. iSortLinesCount = 1;
  50. }
  51. var bFilterSelected = false;
  52. for (i = 0; i < selectionController.getSelections().length; i++)
  53. {
  54. if (selectionController.getSelections()[i].getType() == sType)
  55. {
  56. bFilterSelected = true;
  57. break;
  58. }
  59. }
  60. if (evt !== null && evt.shiftKey === false && evt.ctrlKey === false)
  61. {
  62. selectionController.clearSelections();
  63. }
  64. for (i = 0; i < (iFilterLinesCount + iSortLinesCount); i++)
  65. {
  66. el = getReportFrame().document.getElementById("reportFilter" + i);
  67. if (el !== null)
  68. {
  69. newSelection = new CReportSelectionObject(sType, el);
  70. if (!bFilterSelected)
  71. {
  72. selectionController.select(newSelection, null);
  73. }
  74. else
  75. {
  76. selectionController.deselect(newSelection);
  77. }
  78. }
  79. }
  80. }
  81. else
  82. {
  83. el = getReportFrame().document.getElementById (sId);
  84. if (el !== null)
  85. {
  86. newSelection = new CReportSelectionObject(sType, el);
  87. selectionController.select(newSelection, evt);
  88. }
  89. }
  90. };
  91. function reselectReportSelections()
  92. {
  93. var cf = getConfigFrame();
  94. var previousSelections = new Array();
  95. var i;
  96. for (i = 0; i < cf.cfgSize("reselectReportElements"); i++)
  97. {
  98. previousSelections[previousSelections.length] = cf.cfgGetAt("reselectReportElements", i);
  99. }
  100. for (i = 0; i < previousSelections.length; i++)
  101. {
  102. if (previousSelections[i] == TITLE_STYLE && document.getElementById('reportTitle') !== null)
  103. {
  104. selectReportElement(null, 'reportTitle', TITLE_STYLE);
  105. }
  106. else if (previousSelections[i] == SUBTITLE_STYLE && document.getElementById('reportSubtitle') !== null)
  107. {
  108. selectReportElement(null, 'reportSubtitle', SUBTITLE_STYLE);
  109. }
  110. else if (previousSelections[i] == FILTER_STYLE && document.getElementById('reportFilter0') !== null)
  111. {
  112. selectReportElement(null, 'reportFilter', FILTER_STYLE);
  113. }
  114. }
  115. cf.cfgRemove("reselectReportElements");
  116. g_reportSelectionController.reselect();
  117. };
  118. function addReportElementsForReselection()
  119. {
  120. var cf = getConfigFrame();
  121. var selections = g_reportSelectionController.getSelections();
  122. var bFilterFlag = false;
  123. cf.cfgRemove("reselectReportElements");
  124. for (var i = 0; i < selections.length; i++)
  125. {
  126. var sType = selections[i].getType();
  127. if (sType != FILTER_STYLE || bFilterFlag === false)
  128. {
  129. cf.cfgSetAt("reselectReportElements", cf.cfgSize("reselectReportElements"), sType);
  130. }
  131. if (sType == FILTER_STYLE)
  132. {
  133. bFilterFlag = true;
  134. }
  135. }
  136. };
  137. function pageDoubleClicked(e)
  138. {
  139. var node = null;
  140. if (goWindowManager != "undefined" && goWindowManager && typeof goWindowManager.getReportManager == "function")
  141. {
  142. if (typeof getNodeFromEvent == "function")
  143. {
  144. node = getNodeFromEvent(e);
  145. }
  146. }
  147. if (node === null)
  148. {
  149. return false;
  150. }
  151. if(typeof node.selectedCell != "undefined")
  152. {
  153. var divRegion = node;
  154. node = node.selectedCell;
  155. divRegion.removeAttribute("selectedCell");
  156. }
  157. while (node.nodeType == 3)
  158. {
  159. node = node.parentNode;
  160. }
  161. var ctx = node.getAttribute("ctx");
  162. var uid = node.getAttribute("uid");
  163. if ((ctx != null && node.firstChild && node.firstChild.className && node.firstChild.className.indexOf("textItem") < 0) ||
  164. (node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") != null))
  165. {
  166. node = node.parentNode;
  167. if(node.className.toUpperCase() == "BLOCK" && node.nodeName.toUpperCase() == "DIV") {
  168. node = node.parentNode;
  169. }
  170. uid = node.getAttribute("uid");
  171. }
  172. if (uid != null && node.firstChild != null && (node.getAttribute("type") == "columnTitle" || node.getAttribute("type") == "section"))
  173. {
  174. if (typeof goWindowManager != "undefined" && goWindowManager && typeof goWindowManager.getApplicationFrame == "function")
  175. {
  176. goWindowManager.getFeatureManager().launchFeature('Rename');
  177. }
  178. }
  179. if (typeof g_reportSelectionController != "undefined") {
  180. g_reportSelectionController.clearSelections();
  181. }
  182. };
  183. var TITLE_STYLE = "TitleStyle";
  184. var SUBTITLE_STYLE = "SubtitleStyle";
  185. var FILTER_STYLE = "FilterStyle";