GraphPageWidget.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. define([
  17. "dojo/_base/declare",
  18. "dojo/_base/lang",
  19. "dojo/_base/array",
  20. "dojo/_base/Deferred",
  21. "dojo/dom",
  22. "dojo/dom-construct",
  23. "dojo/on",
  24. "dojo/html",
  25. "dojo/store/Memory",
  26. "dojo/store/Observable",
  27. "dijit/layout/BorderContainer",
  28. "dijit/layout/TabContainer",
  29. "dijit/layout/ContentPane",
  30. "dijit/registry",
  31. "dijit/Dialog",
  32. "dojox/html/entities",
  33. "dgrid/OnDemandGrid",
  34. "dgrid/Keyboard",
  35. "dgrid/Selection",
  36. "dgrid/selector",
  37. "dgrid/extensions/ColumnResizer",
  38. "dgrid/extensions/DijitRegistry",
  39. "hpcc/_Widget",
  40. "hpcc/GraphWidget",
  41. "hpcc/ESPUtil",
  42. "hpcc/ESPWorkunit",
  43. "hpcc/TimingGridWidget",
  44. "hpcc/TimingTreeMapWidget",
  45. "hpcc/WsWorkunits",
  46. "dojo/text!../templates/GraphPageWidget.html",
  47. "dijit/PopupMenuItem",
  48. "dijit/Menu",
  49. "dijit/MenuItem",
  50. "dijit/MenuSeparator",
  51. "dijit/Dialog",
  52. "dijit/form/TextBox",
  53. "dijit/form/SimpleTextarea",
  54. "dijit/form/NumberSpinner",
  55. "dijit/form/DropDownButton"
  56. ], function (declare, lang, arrayUtil, Deferred, dom, domConstruct, on, html, Memory, Observable,
  57. BorderContainer, TabContainer, ContentPane, registry, Dialog,
  58. entities,
  59. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  60. _Widget, GraphWidget, ESPUtil, ESPWorkunit, TimingGridWidget, TimingTreeMapWidget, WsWorkunits,
  61. template) {
  62. return declare("GraphPageWidget", [_Widget], {
  63. templateString: template,
  64. baseClass: "GraphPageWidget",
  65. borderContainer: null,
  66. rightBorderContainer: null,
  67. graphName: "",
  68. wu: null,
  69. editorControl: null,
  70. global: null,
  71. main: null,
  72. overview: null,
  73. local: null,
  74. timingGrid: null,
  75. timingTreeMap: null,
  76. subgraphsGrid: null,
  77. verticesGrid: null,
  78. edgesGrid: null,
  79. xgmmlDialog: null,
  80. infoDialog: null,
  81. findField: null,
  82. findText: "",
  83. found: [],
  84. foundIndex: 0,
  85. overviewDepth: null,
  86. localDepth: null,
  87. localDistance: null,
  88. buildRendering: function (args) {
  89. this.inherited(arguments);
  90. },
  91. postCreate: function (args) {
  92. this.inherited(arguments);
  93. this.borderContainer = registry.byId(this.id + "BorderContainer");
  94. this.rightBorderContainer = registry.byId(this.id + "RightBorderContainer");
  95. this.findField = registry.byId(this.id + "FindField");
  96. this.mainDepth = registry.byId(this.id + "MainDepth");
  97. this.overviewDepth = registry.byId(this.id + "OverviewDepth");
  98. this.localDepth = registry.byId(this.id + "LocalDepth");
  99. this.localDistance = registry.byId(this.id + "LocalDistance");
  100. this._initGraphControls();
  101. this._initTimings();
  102. this._initDialogs();
  103. },
  104. startup: function (args) {
  105. this.inherited(arguments);
  106. this._initSubgraphs();
  107. this._initVertices();
  108. this._initEdges();
  109. var splitter = this.borderContainer.getSplitter("right");
  110. this.main.watchSplitter(splitter);
  111. this.overview.watchSplitter(splitter);
  112. this.local.watchSplitter(splitter);
  113. splitter = this.rightBorderContainer.getSplitter("bottom");
  114. this.main.watchSplitter(splitter);
  115. this.overview.watchSplitter(splitter);
  116. this.local.watchSplitter(splitter);
  117. this.main.watchSelect(registry.byId(this.id + "AdvancedMenu"));
  118. },
  119. resize: function (args) {
  120. this.inherited(arguments);
  121. this.borderContainer.resize();
  122. },
  123. layout: function (args) {
  124. this.inherited(arguments);
  125. },
  126. destroy: function (args) {
  127. this.xgmmlDialog.destroyRecursive();
  128. this.infoDialog.destroyRecursive();
  129. this.inherited(arguments);
  130. },
  131. // Implementation ---
  132. _initGraphControls: function () {
  133. var context = this;
  134. this.global = registry.byId(this.id + "GlobalGraphWidget");
  135. this.main = registry.byId(this.id + "MainGraphWidget");
  136. this.main.onSelectionChanged = function (items) {
  137. context.syncSelectionFrom(context.main);
  138. };
  139. this.main.onLayoutFinished = function () {
  140. // TODO: Could be too expensive ---
  141. //context.wu.setGraphSvg(context.graphName, context.main.svg);
  142. };
  143. this.main.onDoubleClick = function (globalID) {
  144. var mainItem = context.main.getItem(globalID);
  145. context.main.centerOnItem(mainItem, true);
  146. };
  147. this.overview = registry.byId(this.id + "MiniGraphWidget");
  148. this.overview.onSelectionChanged = function (items) {
  149. context.syncSelectionFrom(context.overview);
  150. };
  151. this.overview.onDoubleClick = function (globalID) {
  152. var mainItem = context.main.getItem(globalID);
  153. context.main.centerOnItem(mainItem, true);
  154. };
  155. this.local = registry.byId(this.id + "LocalGraphWidget");
  156. this.local.onSelectionChanged = function (items) {
  157. context.syncSelectionFrom(context.local);
  158. };
  159. this.local.onDoubleClick = function (globalID) {
  160. var mainItem = context.main.getItem(globalID);
  161. context._onLocalRefresh();
  162. context.main.centerOnItem(mainItem, true);
  163. context.syncSelectionFrom(context.local);
  164. };
  165. },
  166. _initTimings: function () {
  167. this.timingGrid = registry.byId(this.id + "TimingsGrid");
  168. var context = this;
  169. this.timingGrid.onClick = function (items) {
  170. context.syncSelectionFrom(context.timingGrid);
  171. };
  172. this.timingGrid.onDblClick = function (item) {
  173. var subgraphID = item.SubGraphId;
  174. var mainItem = context.main.getItem(subgraphID);
  175. context.main.centerOnItem(mainItem, true);
  176. };
  177. this.timingTreeMap = registry.byId(this.id + "TimingsTreeMap");
  178. this.timingTreeMap.onClick = function (value) {
  179. context.syncSelectionFrom(context.timingTreeMap);
  180. }
  181. this.timingTreeMap.onDblClick = function (value) {
  182. var mainItem = context.main.getItem(value.SubGraphId);
  183. context.main.centerOnItem(mainItem, true);
  184. }
  185. },
  186. _initDialogs: function () {
  187. var context = this;
  188. this.infoDialog = registry.byId(this.id + "InfoDialog");
  189. on(dom.byId(this.id + "InfoDialogCancel"), "click", function (event) {
  190. context.infoDialog.hide();
  191. });
  192. this.xgmmlDialog = registry.byId(this.id + "XGMMLDialog");
  193. this.xgmmlTextArea = registry.byId(this.id + "XGMMLTextArea");
  194. on(dom.byId(this.id + "XGMMLDialogApply"), "click", function (event) {
  195. context.xgmmlDialog.hide();
  196. if (context.xgmmlDialog.get("hpccMode") === "XGMML") {
  197. var xgmml = context.xgmmlTextArea.get("value");
  198. context.loadGraphFromXGMML(xgmml);
  199. } else if (context.xgmmlDialog.get("hpccMode") === "DOT") {
  200. var dot = context.xgmmlTextArea.get("value");
  201. context.loadGraphFromDOT(dot);
  202. } else if (context.xgmmlDialog.get("hpccMode") === "DOTATTRS") {
  203. var dotAttrs = context.xgmmlTextArea.get("value");
  204. context.global.setDotMetaAttributes(dotAttrs);
  205. context.main.setDotMetaAttributes(dotAttrs);
  206. context.overview.setDotMetaAttributes(dotAttrs);
  207. context.local.setDotMetaAttributes(dotAttrs);
  208. context._onMainRefresh();
  209. }
  210. });
  211. on(dom.byId(this.id + "XGMMLDialogCancel"), "click", function (event) {
  212. context.xgmmlDialog.hide();
  213. });
  214. },
  215. _initItemGrid: function (grid) {
  216. var context = this;
  217. grid.on(".dgrid-row:click", function (evt) {
  218. context.syncSelectionFrom(grid);
  219. });
  220. grid.on(".dgrid-row:dblclick", function (evt) {
  221. var item = grid.row(evt).data;
  222. if (item._globalID) {
  223. var mainItem = context.main.getItem(item._globalID);
  224. context.main.centerOnItem(mainItem, true);
  225. }
  226. });
  227. },
  228. _initSubgraphs: function () {
  229. var store = new Memory({
  230. idProperty: "id",
  231. data: []
  232. });
  233. this.subgraphsStore = Observable(store);
  234. this.subgraphsGrid = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  235. store: this.subgraphsStore
  236. }, this.id + "SubgraphsGrid");
  237. this._initItemGrid(this.subgraphsGrid);
  238. },
  239. _initVertices: function () {
  240. var store = new Memory({
  241. idProperty: "id",
  242. data: []
  243. });
  244. this.verticesStore = Observable(store);
  245. this.verticesGrid = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  246. store: this.verticesStore
  247. }, this.id + "VerticesGrid");
  248. this._initItemGrid(this.verticesGrid);
  249. },
  250. _initEdges: function () {
  251. var store = new Memory({
  252. idProperty: "id",
  253. data: []
  254. });
  255. this.edgesStore = Observable(store);
  256. this.edgesGrid = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  257. store: this.edgesStore
  258. }, this.id + "EdgesGrid");
  259. this._initItemGrid(this.edgesGrid);
  260. },
  261. _onMainRefresh: function () {
  262. this.main.setMessage("Performing Layout...");
  263. this.main.startLayout("dot");
  264. },
  265. _onLocalRefresh: function () {
  266. this.refreshLocal(this.local.getSelectionAsGlobalID());
  267. },
  268. _doFind: function (prev) {
  269. if (this.findText != this.findField.value) {
  270. this.findText = this.findField.value;
  271. this.found = this.global.findAsGlobalID(this.findText);
  272. this.global.setSelectedAsGlobalID(this.found);
  273. this.syncSelectionFrom(this.global);
  274. this.foundIndex = -1;
  275. }
  276. this.foundIndex += prev ? -1 : +1;
  277. if (this.foundIndex < 0) {
  278. this.foundIndex = this.found.length - 1;
  279. } else if (this.foundIndex >= this.found.length) {
  280. this.foundIndex = 0;
  281. }
  282. if (this.found.length) {
  283. this.main.centerOnGlobalID(this.found[this.foundIndex], true);
  284. this.local.centerOnGlobalID(this.found[this.foundIndex], true);
  285. }
  286. },
  287. _onFind: function (prev) {
  288. this.findText = "";
  289. this._doFind(false);
  290. },
  291. _onFindNext: function () {
  292. this._doFind(false);
  293. },
  294. _onFindPrevious: function () {
  295. this._doFind(true);
  296. },
  297. _onAbout: function () {
  298. html.set(dom.byId(this.id + "InfoDialogContent"), "<div style='width: 320px; height: 120px; text-align: center;'><p>Version: " + this.main.getVersion() + "</p><p>" + this.main.getResourceLinks() + "</p>");
  299. this.infoDialog.set("title", "About HPCC Systems Graph Control");
  300. this.infoDialog.show();
  301. },
  302. _onGetSVG: function () {
  303. html.set(dom.byId(this.id + "InfoDialogContent"), "<textarea rows='25' cols='80'>" + entities.encode(this.main.getSVG()) + "</textarea>");
  304. this.infoDialog.set("title", "SVG Source");
  305. this.infoDialog.show();
  306. },
  307. _onRenderSVG: function () {
  308. var context = this
  309. this.main.localLayout(function (svg) {
  310. html.set(dom.byId(context.id + "InfoDialogContent"), "<div style='border: 1px inset grey; width: 640px; height: 480px; overflow : auto; '>" + svg + "</div>");
  311. context.infoDialog.set("title", "Rendered SVG");
  312. context.infoDialog.show();
  313. });
  314. },
  315. _onGetXGMML: function () {
  316. this.xgmmlDialog.set("title", "XGMML");
  317. this.xgmmlDialog.set("hpccMode", "XGMML");
  318. this.xgmmlTextArea.set("value", this.main.getXGMML());
  319. this.xgmmlDialog.show();
  320. },
  321. _onEditDOT: function () {
  322. this.xgmmlDialog.set("title", "DOT");
  323. this.xgmmlDialog.set("hpccMode", "DOT");
  324. this.xgmmlTextArea.set("value", this.main.getDOT());
  325. this.xgmmlDialog.show();
  326. },
  327. _onGetGraphAttributes: function () {
  328. this.xgmmlDialog.set("title", "DOT Attributes");
  329. this.xgmmlDialog.set("hpccMode", "DOTATTRS");
  330. this.xgmmlTextArea.set("value", this.global.getDotMetaAttributes());
  331. this.xgmmlDialog.show();
  332. },
  333. _onMainDepthChange: function (value) {
  334. this.refreshMain();
  335. },
  336. _onOverviewDepthChange: function (value) {
  337. this.refreshOverview();
  338. },
  339. _onLocalDepthChange: function (value) {
  340. this._onLocalRefresh();
  341. },
  342. _onLocalDistanceChange: function (value) {
  343. this._onLocalRefresh();
  344. },
  345. init: function (params) {
  346. if (this.inherited(arguments))
  347. return;
  348. if (params.SafeMode && params.SafeMode != "false") {
  349. this.overviewDepth.set("value", 0)
  350. this.mainDepth.set("value", 1)
  351. this.localDepth.set("value", 2)
  352. var dotAttrs = this.global.getDotMetaAttributes();
  353. dotAttrs += "\r\ngraph[splines=\"line\"];";
  354. this.global.setDotMetaAttributes(dotAttrs);
  355. }
  356. if (params.Wuid) {
  357. this.graphName = params.GraphName;
  358. this.wu = ESPWorkunit.Get(params.Wuid);
  359. var firstLoad = true;
  360. var context = this;
  361. this.wu.monitor(function () {
  362. context.wu.getInfo({
  363. onGetApplicationValues: function (applicationValues) {
  364. },
  365. onGetGraphs: function (graphs) {
  366. if (firstLoad == true) {
  367. firstLoad = false;
  368. context.loadGraphFromWu(context.wu, context.graphName).then(function (response) {
  369. context.refresh(params);
  370. });
  371. } else {
  372. context.refreshGraph(context.wu, context.graphName);
  373. }
  374. }
  375. });
  376. });
  377. } else if (params.QueryId) {
  378. this.targetQuery = params.Target;
  379. this.queryId = params.QueryId;
  380. this.graphName = params.GraphName;
  381. this.loadGraphFromQuery(this.targetQuery, this.queryId, this.graphName);
  382. }
  383. this.timingGrid.init(lang.mixin({
  384. query: this.graphName
  385. }, params));
  386. this.timingTreeMap.init(lang.mixin({
  387. query: this.graphName,
  388. hideHelp: true
  389. }, params));
  390. },
  391. refresh: function (params) {
  392. if (params && params.SubGraphId) {
  393. this.global.setSelectedAsGlobalID([params.SubGraphId]);
  394. this.syncSelectionFrom(this.global);
  395. }
  396. },
  397. loadGraphFromXGMML: function (xgmml) {
  398. this.global.loadXGMML(xgmml, false);
  399. this.refreshMain();
  400. this.refreshOverview();
  401. this.loadSubgraphs();
  402. this.loadVertices();
  403. this.loadEdges();
  404. },
  405. loadGraphFromDOT: function (dot) {
  406. this.global.loadDOT(dot);
  407. this.refreshMain();
  408. this.refreshOverview();
  409. this.loadSubgraphs();
  410. this.loadVertices();
  411. this.loadEdges();
  412. },
  413. loadGraphFromWu: function (wu, graphName) {
  414. var deferred = new Deferred();
  415. this.overview.setMessage("Fetching Data...");
  416. this.main.setMessage("Fetching Data...");
  417. this.local.setMessage("Fetching Data...");
  418. var context = this;
  419. wu.fetchGraphXgmmlByName(graphName, function (xgmml, svg) {
  420. context.overview.setMessage("");
  421. context.main.setMessage("");
  422. context.local.setMessage("");
  423. context.loadGraphFromXGMML(xgmml, svg);
  424. deferred.resolve();
  425. });
  426. return deferred.promise;
  427. },
  428. loadGraphFromQuery: function (targetQuery, queryId, graphName) {
  429. this.overview.setMessage("Fetching Data...");
  430. this.main.setMessage("Fetching Data...");
  431. this.local.setMessage("Fetching Data...");
  432. var context = this;
  433. WsWorkunits.WUQueryGetGraph({
  434. request: {
  435. Target: targetQuery,
  436. QueryId: queryId,
  437. GraphName: graphName
  438. }
  439. }).then(function(response){
  440. context.overview.setMessage("");
  441. context.main.setMessage("");
  442. context.local.setMessage("");
  443. if(lang.exists("WUQueryGetGraphResponse.Graphs.ECLGraphEx", response)){
  444. if(response.WUQueryGetGraphResponse.Graphs.ECLGraphEx.length > 0){
  445. context.loadGraphFromXGMML(response.WUQueryGetGraphResponse.Graphs.ECLGraphEx[0].Graph, "");
  446. }
  447. }
  448. });
  449. },
  450. refreshGraph: function (wu, graphName) {
  451. var context = this;
  452. wu.fetchGraphXgmmlByName(graphName, function (xgmml) {
  453. context.main.mergeXGMML(xgmml);
  454. context.loadSubgraphs();
  455. context.loadVertices();
  456. context.loadEdges();
  457. });
  458. },
  459. isNumber: function(n) {
  460. return !isNaN(parseFloat(n)) && isFinite(n);
  461. },
  462. loadSubgraphs: function () {
  463. var subgraphs = this.main.getSubgraphsWithProperties();
  464. var layoutMap = [];
  465. for (var i = 0; i < subgraphs.length; ++i) {
  466. for (var key in subgraphs[i]) {
  467. if (key != "id" && key.substring(0, 1) != "_") {
  468. layoutMap[key] = true;
  469. }
  470. if (this.isNumber(subgraphs[i][key])) {
  471. subgraphs[i][key] = parseFloat(subgraphs[i][key]);
  472. }
  473. }
  474. }
  475. var layout = [
  476. { label: "ID", field: "id", width: 50 }
  477. ];
  478. for (var key in layoutMap) {
  479. layout.push({ label: key, field: key, width: 100 });
  480. }
  481. this.subgraphsStore.setData(subgraphs);
  482. this.subgraphsGrid.set("columns", layout);
  483. this.subgraphsGrid.refresh();
  484. },
  485. loadVertices: function () {
  486. var vertices = this.main.getVerticesWithProperties();
  487. var layoutMap = [];
  488. for (var i = 0; i < vertices.length; ++i) {
  489. for (var key in vertices[i]) {
  490. if (key != "id" && key != "ecl" && key != "label" && key.substring(0, 1) != "_") {
  491. layoutMap[key] = true;
  492. }
  493. if (this.isNumber(vertices[i][key])) {
  494. vertices[i][key] = parseFloat(vertices[i][key]);
  495. }
  496. }
  497. }
  498. var layout = [
  499. { label: "ID", field: "id", width: 50 },
  500. { label: "Label", field: "label", width: 150 }
  501. ];
  502. for (var key in layoutMap) {
  503. layout.push({ label: key, field: key, width: 200 });
  504. }
  505. layout.push({ label: "ECL", field: "ecl", width: 1024 });
  506. this.verticesStore.setData(vertices);
  507. this.verticesGrid.set("columns", layout);
  508. this.verticesGrid.refresh();
  509. },
  510. loadEdges: function () {
  511. var edges = this.main.getEdgesWithProperties();
  512. var layoutMap = [];
  513. for (var i = 0; i < edges.length; ++i) {
  514. for (var key in edges[i]) {
  515. if (key != "id" && key.substring(0, 1) != "_") {
  516. layoutMap[key] = true;
  517. }
  518. if (this.isNumber(edges[i][key])) {
  519. edges[i][key] = parseFloat(edges[i][key]);
  520. }
  521. }
  522. }
  523. var layout = [
  524. { label: "ID", field: "id", width: 50 }
  525. ];
  526. for (var key in layoutMap) {
  527. layout.push({ label: key, field: key, width: 100 });
  528. }
  529. this.edgesStore.setData(edges);
  530. this.edgesGrid.set("columns", layout);
  531. this.edgesGrid.refresh();
  532. },
  533. syncSelectionFrom: function (sourceControl) {
  534. var selectedGlobalIDs = [];
  535. // Get Selected Items ---
  536. if (sourceControl == this.timingGrid || sourceControl == this.timingTreeMap) {
  537. var items = sourceControl.getSelected();
  538. for (var i = 0; i < items.length; ++i) {
  539. if (items[i].SubGraphId) {
  540. selectedGlobalIDs.push(items[i].SubGraphId);
  541. }
  542. }
  543. } else if (sourceControl == this.verticesGrid || sourceControl == this.edgesGrid || sourceControl == this.subgraphsGrid) {
  544. var items = sourceControl.getSelected();
  545. for (var i = 0; i < items.length; ++i) {
  546. if (items[i]._globalID) {
  547. selectedGlobalIDs.push(items[i]._globalID);
  548. }
  549. }
  550. } else {
  551. selectedGlobalIDs = sourceControl.getSelectionAsGlobalID();
  552. }
  553. // Set Selected Items ---
  554. if (sourceControl != this.timingGrid) {
  555. this.timingGrid.setSelectedAsGlobalID(selectedGlobalIDs);
  556. }
  557. if (sourceControl != this.timingTreeMap) {
  558. this.timingTreeMap.setSelectedAsGlobalID(selectedGlobalIDs);
  559. }
  560. if (sourceControl != this.subgraphsGrid && this.subgraphsGrid.store) {
  561. this.subgraphsGrid.setSelection(selectedGlobalIDs);
  562. }
  563. if (sourceControl != this.verticesGrid && this.verticesGrid.store) {
  564. this.verticesGrid.setSelection(selectedGlobalIDs);
  565. }
  566. if (sourceControl != this.edgesGrid && this.edgesGrid.store) {
  567. this.edgesGrid.setSelection(selectedGlobalIDs);
  568. }
  569. if (sourceControl != this.main) {
  570. this.main.setSelectedAsGlobalID(selectedGlobalIDs);
  571. }
  572. if (sourceControl != this.overview) {
  573. this.overview.setSelectedAsGlobalID(selectedGlobalIDs);
  574. }
  575. if (sourceControl != this.local) {
  576. this.refreshLocal(selectedGlobalIDs);
  577. }
  578. var propertiesDom = dom.byId(this.id + "Properties");
  579. propertiesDom.innerHTML = "";
  580. for (var i = 0; i < selectedGlobalIDs.length; ++i) {
  581. this.global.displayProperties(selectedGlobalIDs[i], propertiesDom);
  582. }
  583. },
  584. resetPage: function () {
  585. this.main.clear();
  586. },
  587. refreshMain: function () {
  588. var xgmml = this.global.getLocalisedXGMML([0], this.mainDepth.get("value"));
  589. this.main.loadXGMML(xgmml);
  590. },
  591. refreshOverview: function () {
  592. var xgmml = this.global.getLocalisedXGMML([0], this.overviewDepth.get("value"));
  593. this.overview.loadXGMML(xgmml);
  594. },
  595. refreshLocal: function (selectedGlobalIDs) {
  596. var globalItems = [];
  597. for (var i = 0; i < selectedGlobalIDs.length; ++i) {
  598. globalItems.push(this.global.getItem(selectedGlobalIDs[i]));
  599. }
  600. var xgmml = this.global.getLocalisedXGMML(globalItems, this.localDepth.get("value"), this.localDistance.get("value"));
  601. this.local.loadXGMML(xgmml);
  602. this.local.setSelectedAsGlobalID(selectedGlobalIDs);
  603. },
  604. displayGraphs: function (graphs) {
  605. for (var i = 0; i < graphs.length; ++i) {
  606. this.wu.fetchGraphXgmml(i, function (xgmml) {
  607. this.main.loadXGMML(xgmml, true);
  608. });
  609. }
  610. }
  611. });
  612. });