TimingPageWidget.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*##############################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ############################################################################## */
  17. define([
  18. "dojo/_base/declare",
  19. "dijit/registry",
  20. "dijit/layout/_LayoutWidget",
  21. "dijit/_TemplatedMixin",
  22. "dijit/_WidgetsInTemplateMixin",
  23. "dijit/layout/BorderContainer",
  24. "hpcc/TimingGridWidget",
  25. "hpcc/TimingTreeMapWidget",
  26. "dojo/text!../templates/TimingPageWidget.html"
  27. ],
  28. function (declare,
  29. registry, _LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer,
  30. TimingGridWidget, TimingTreeMapWidget,
  31. template) {
  32. return declare("TimingPageWidget", [_LayoutWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
  33. templateString: template,
  34. baseClass: "TimingPageWidget",
  35. borderContainer: null,
  36. timingGrid: null,
  37. timingTreeMap: null,
  38. buildRendering: function (args) {
  39. this.inherited(arguments);
  40. },
  41. postCreate: function (args) {
  42. this.inherited(arguments);
  43. this.borderContainer = registry.byId(this.id + "BorderContainer");
  44. this.timingGrid = registry.byId(this.id + "Grid");
  45. this.timingTreeMap = registry.byId(this.id + "TreeMap");
  46. },
  47. startup: function (args) {
  48. this.inherited(arguments);
  49. },
  50. resize: function (args) {
  51. this.inherited(arguments);
  52. this.borderContainer.resize();
  53. },
  54. layout: function (args) {
  55. this.inherited(arguments);
  56. },
  57. // Plugin wrapper ---
  58. init: function (params) {
  59. if (this.initalized)
  60. return;
  61. this.initalized = true;
  62. var context = this;
  63. this.timingGrid.init(params);
  64. this.timingGrid.onClick = function (items) {
  65. context.syncSelectionFrom(context.timingGrid);
  66. };
  67. this.timingTreeMap.init(params);
  68. this.timingTreeMap.onClick = function (value) {
  69. context.syncSelectionFrom(context.timingTreeMap);
  70. }
  71. },
  72. syncSelectionFrom: function (sourceControl) {
  73. var selItems = [];
  74. // Get Selected Items ---
  75. if (sourceControl == this.timingGrid || sourceControl == this.timingTreeMap) {
  76. var items = sourceControl.getSelected();
  77. for (var i = 0; i < items.length; ++i) {
  78. if (items[i].SubGraphId) {
  79. selItems.push(items[i].SubGraphId);
  80. }
  81. }
  82. }
  83. // Set Selected Items ---
  84. if (sourceControl != this.timingGrid) {
  85. this.timingGrid.setSelected(selItems);
  86. }
  87. if (sourceControl != this.timingTreeMap) {
  88. this.timingTreeMap.setSelected(selItems);
  89. }
  90. }
  91. });
  92. });