AnnotationAction.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 AnnotationAction() {}
  13. AnnotationAction.prototype = new CognosViewerAction();
  14. AnnotationAction.prototype.updateMenu = function(jsonSpec)
  15. {
  16. var viewerWidgetRef = this.m_oCV.getViewerWidget();
  17. var aAnnotations = this.m_oCV.aBuxAnnotations;
  18. var annItems = [];
  19. for (var annIndex=0; annIndex < aAnnotations.length; annIndex++)
  20. {
  21. var ann = eval("new " + aAnnotations[annIndex] + "()");
  22. ann.setCognosViewer(this.m_oCV);
  23. if (ann && ann.isEnabled(jsonSpec.placeType))
  24. {
  25. var newAnnItem = {};
  26. newAnnItem.name = aAnnotations[annIndex];
  27. newAnnItem.label = ann.getMenuItemString(viewerWidgetRef.getAttributeValue("itemName"));
  28. newAnnItem.action = {};
  29. newAnnItem.action.name = aAnnotations[annIndex];
  30. newAnnItem.action.payload = "";
  31. newAnnItem.items = null;
  32. newAnnItem.iconClass = ann.getMenuItemIconClass();// aAnnotations[annIndex];
  33. annItems.push(newAnnItem);
  34. }
  35. }
  36. jsonSpec.items = annItems;
  37. jsonSpec.disabled = !(jsonSpec.items && jsonSpec.items.length);
  38. if(jsonSpec.disabled) {
  39. jsonSpec.iconClass = "disabledAnnotation";
  40. } else {
  41. jsonSpec.iconClass = "annotation";
  42. }
  43. return jsonSpec;
  44. };
  45. AnnotationAction.prototype.execute = function()
  46. {
  47. var viewer = this.getCognosViewer();
  48. var selCon = viewer.getSelectionController();
  49. var selections = selCon.getSelections();
  50. if (selections && selections.length == 1) {
  51. var widget = viewer.getViewerWidget();
  52. if (widget) {
  53. this.executeAction(viewer, widget, selections[0]);
  54. }
  55. }
  56. };
  57. AnnotationAction.prototype.executeAction = function(viewer, widget, selection)
  58. {
  59. //Do nothing -- derived classes should override this method to perform the necessary action
  60. };