DiagramNode.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * Licensed Materials - Property of IBM IBM Cognos Products: Modeling UI (C) Copyright IBM Corp. 2016, 2018 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP
  3. * Schedule Contract with IBM Corp.
  4. */
  5. define([
  6. 'underscore',
  7. 'bi/commons/ui/core/Class'
  8. ], function (_, Class) {
  9. var DiagramNode = Class.extend({
  10. contentProvider: null,
  11. identifier: null,
  12. label: null,
  13. tableRowCount: 0,
  14. x: 0,
  15. y: 0,
  16. adjacentLinks: null,
  17. statisticsLoading: false,
  18. init: function(options) {
  19. DiagramNode.inherited('init', this);
  20. _.extend(this, options);
  21. this.adjacentLinks = [];
  22. this.identifier = options.moserObject.getIdentifier();
  23. this.label = options.moserObject.getLabel();
  24. this.comment = options.moserObject.getComment();
  25. this.screenTip = options.moserObject.getScreenTip();
  26. this.hidden = options.moserObject.isHidden();
  27. this.displayTableInfo = options.isDetailsVisible;
  28. this.tableRowCount = options.tableRowCount;
  29. this.statisticsLoading = options.statisticsLoading;
  30. this.x = options.position.x;
  31. this.y = options.position.y;
  32. if (this.fixed) {
  33. this.fx = this.x;
  34. this.fy = this.y;
  35. } else {
  36. this.fx = null;
  37. this.fy = null;
  38. }
  39. },
  40. /**
  41. * Add a refernce by ID to an adjacent link on a node
  42. *
  43. * @param {string}
  44. * linkID - The identifier of a link
  45. */
  46. addAdjacentLink: function(linkID) {
  47. this.adjacentLinks = _.union(this.adjacentLinks, [
  48. linkID
  49. ]);
  50. },
  51. /**
  52. * Return a list of current adjacent links and empty the current list
  53. */
  54. pullAdjacentLinks: function() {
  55. return this.adjacentLinks.splice(0, this.adjacentLinks.length);
  56. },
  57. /**
  58. * Sets the label of the node
  59. *
  60. * @param {string}
  61. * newValue - The new label to pass to the node
  62. */
  63. setLabel: function(newValue) {
  64. this.label = newValue;
  65. },
  66. /**
  67. * Sets whether the node is visible or not
  68. *
  69. * @param {boolean}
  70. * isHidden - true if the object is to be hidden
  71. */
  72. setHidden: function(isHidden) {
  73. this.hidden = isHidden;
  74. },
  75. /**
  76. * Set the instanceType on the node.
  77. *
  78. * @param {String}
  79. * instanceType The instance type
  80. */
  81. setInstanceType: function(instanceType) {
  82. this.instanceType = instanceType;
  83. }
  84. });
  85. return DiagramNode;
  86. });