ActionFactory.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. function ActionFactory(cognosViewer)
  13. {
  14. this.m_cognosViewer = cognosViewer;
  15. }
  16. ActionFactory.prototype.load = function(sAction)
  17. {
  18. this.m_cognosViewer.loadExtra();
  19. var action = null;
  20. try
  21. {
  22. var sClass = sAction + "Action";
  23. action = eval("(typeof "+ sClass + "=='function'? new " + sClass + "():null);");
  24. if (action) {
  25. action.setCognosViewer(this.m_cognosViewer);
  26. }
  27. }
  28. catch(exception)
  29. {
  30. action = null;
  31. }
  32. return action;
  33. };
  34. function ActionFactory_loadActionHandler(evt, cognosViewer)
  35. {
  36. var ctxNode = getCtxNodeFromEvent(evt);
  37. var selectionController = cognosViewer.getSelectionController();
  38. var action = null;
  39. if(ctxNode !== null)
  40. {
  41. var ctxValue = ctxNode.getAttribute("ctx");
  42. ctxValue = ctxValue.split("::")[0].split(":")[0];
  43. var descriptionNode = ctxNode.getAttribute("type") != null ? ctxNode : ctxNode.parentNode;
  44. var type = descriptionNode.getAttribute("type");
  45. switch(type)
  46. {
  47. case "columnTitle":
  48. var hasAuthoredDrillTargets = (ctxNode.getAttribute("dttargets")!=null);
  49. //List titles and Measure/calculation-on-edge crosstabs/charts (no muns) aren't drillable.
  50. var canDrillUpDown = (descriptionNode.getAttribute("CTNM") != null && selectionController.getMun(ctxValue) != ""
  51. && selectionController.getUsageInfo(ctxValue)!='2');
  52. if (hasAuthoredDrillTargets || canDrillUpDown) {
  53. action = cognosViewer.getAction("DrillUpDownOrThrough");
  54. action.init(hasAuthoredDrillTargets, canDrillUpDown);
  55. action.updateDrillabilityInfo(cognosViewer, ctxNode);
  56. }
  57. else
  58. {
  59. action = cognosViewer.getAction("RenameDataItem");
  60. }
  61. break;
  62. case "datavalue":
  63. case "chartElement":
  64. case "ordinalAxisLabel":
  65. case "legendLabel":
  66. case "legendTitle":
  67. case "ordinalAxisTitle":
  68. var hasAuthoredDrillTargets = (ctxNode.getAttribute("dttargets")!=null);
  69. //All dimensional data value selections (even measures/calcs) should be considered for drillability since they
  70. //are proxies to the inner edges (other entities aren't renamable or drillable)
  71. var canDrillUpDown = (selectionController.getHun(ctxValue) != "");
  72. if (hasAuthoredDrillTargets || canDrillUpDown) {
  73. action = cognosViewer.getAction("DrillUpDownOrThrough");
  74. action.init(hasAuthoredDrillTargets, canDrillUpDown);
  75. action.updateDrillabilityInfo(cognosViewer, ctxNode);
  76. }
  77. break;
  78. }
  79. }
  80. if(action === null)
  81. {
  82. action = cognosViewer.getAction("Selection");
  83. }
  84. action.setCognosViewer(cognosViewer);
  85. return action;
  86. }
  87. ActionFactory.prototype.destroy = function()
  88. {
  89. delete this.m_cognosViewer;
  90. }