TimingPageWidget.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/BorderContainer",
  21. "hpcc/_Widget",
  22. "hpcc/TimingGridWidget",
  23. "hpcc/TimingTreeMapWidget",
  24. "dojo/text!../templates/TimingPageWidget.html"
  25. ],
  26. function (declare,
  27. registry, BorderContainer,
  28. _Widget, TimingGridWidget, TimingTreeMapWidget,
  29. template) {
  30. return declare("TimingPageWidget", [_Widget], {
  31. templateString: template,
  32. baseClass: "TimingPageWidget",
  33. borderContainer: null,
  34. timingGrid: null,
  35. timingTreeMap: null,
  36. buildRendering: function (args) {
  37. this.inherited(arguments);
  38. },
  39. postCreate: function (args) {
  40. this.inherited(arguments);
  41. this.borderContainer = registry.byId(this.id + "BorderContainer");
  42. this.timingGrid = registry.byId(this.id + "Grid");
  43. this.timingTreeMap = registry.byId(this.id + "TreeMap");
  44. },
  45. startup: function (args) {
  46. this.inherited(arguments);
  47. },
  48. resize: function (args) {
  49. this.inherited(arguments);
  50. this.borderContainer.resize();
  51. },
  52. layout: function (args) {
  53. this.inherited(arguments);
  54. },
  55. // Plugin wrapper ---
  56. init: function (params) {
  57. if (this.inherited(arguments))
  58. return;
  59. var context = this;
  60. this.timingGrid.init(params);
  61. this.timingGrid.onClick = function (items) {
  62. context.syncSelectionFrom(context.timingGrid);
  63. };
  64. this.timingTreeMap.init(params);
  65. this.timingTreeMap.onClick = function (value) {
  66. context.syncSelectionFrom(context.timingTreeMap);
  67. }
  68. },
  69. syncSelectionFrom: function (sourceControl) {
  70. var items = [];
  71. // Get Selected Items ---
  72. if (sourceControl == this.timingGrid || sourceControl == this.timingTreeMap) {
  73. items = sourceControl.getSelected();
  74. }
  75. // Set Selected Items ---
  76. if (sourceControl != this.timingGrid) {
  77. this.timingGrid.setSelected(items);
  78. }
  79. if (sourceControl != this.timingTreeMap) {
  80. this.timingTreeMap.setSelected(items);
  81. }
  82. }
  83. });
  84. });