TM1WebCubeViewerWidget.js 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504
  1. dojo.provide("TM1WebCubeViewerWidget");
  2. dojo.require("bux.Helper");
  3. dojo.require("bux.iwidget.utilities.UtilityWidgetBase"); //For Bux Action Button issue, can't remove
  4. dojo.declare("TM1WebCubeViewerWidget", [tm1.iwidget.utilities.Filter], {
  5. iframeCtrl: null,
  6. iframeCtrlCantLoadDojo: null,
  7. dimensionNames: null,
  8. elementNames: null,
  9. elementNameCounter: 0,
  10. subscriptionHandle: null,
  11. cubeViewState: null,
  12. app: null,
  13. inDoMore: false,
  14. _Widget: null,
  15. cantLoadDojo: false,
  16. onbeforeunloadHandler: null,
  17. // Filter variable
  18. filterFieldName: "tm1Cube",
  19. // ====== Multilingual Support - Start ========
  20. _productLocale: null,
  21. _tm1messages: null,
  22. // ====== Multilingual Support - End ========
  23. onLoad: function () {
  24. // ====== Multilingual Support - Start ========
  25. // Remember where we were loaded from: this is our path for future AJAX calls and .js loads
  26. dojo.registerModulePath("TM1WebCubeViewerWidget", this.iContext.io.rewriteURI("js"));
  27. this.setLanguage().then(dojo.hitch(this, "getWidgetAttributes"));
  28. // ====== Multilingual Support - End ========
  29. },
  30. loadWithAttributes: function () {
  31. // load tm1web css file
  32. var element = document.createElement('link');
  33. element.href = this.tm1WebURL + "/css/cubeviewer.css";
  34. element.rel = 'stylesheet';
  35. element.type = 'text/css';
  36. document.body.appendChild(element);
  37. element = document.createElement('link');
  38. element.href = this.tm1WebURL + "/scripts/tm1web/themes/tm1web/tm1web.css";
  39. element.rel = 'stylesheet';
  40. element.type = 'text/css';
  41. document.body.appendChild(element);
  42. dojo.addClass(document.body, "tm1web");
  43. var scriptsPath = this.tm1WebURL + "/scripts/";
  44. require({
  45. packages: [
  46. {
  47. name: "tm1web",
  48. location: scriptsPath + "tm1web",
  49. packageMap: {
  50. dojo: "tm1webDojo",
  51. dijit: "tm1webDijit",
  52. dojox: "tm1webDojox",
  53. com: "tm1webCom"
  54. }
  55. }, {
  56. name: "tm1webCom",
  57. location: scriptsPath + "com",
  58. packageMap: {
  59. dojo: "tm1webDojo",
  60. dijit: "tm1webDijit",
  61. dojox: "tm1webDojox",
  62. com: "tm1webCom"
  63. }
  64. }, {
  65. name: "tm1webRave",
  66. location: scriptsPath + "com",
  67. packageMap: {
  68. dojo: "tm1webDojo",
  69. dijit: "tm1webDijit",
  70. dojox: "tm1webDojox",
  71. com: "tm1webCom"
  72. }
  73. }, {
  74. name: "tm1webDojo",
  75. location: scriptsPath + "dojo",
  76. packageMap: {
  77. dojo: "tm1webDojo",
  78. dijit: "tm1webDijit",
  79. dojox: "tm1webDojox"
  80. }
  81. }, {
  82. name: "tm1webDijit",
  83. location: scriptsPath + "dijit",
  84. packageMap: {
  85. dojo: "tm1webDojo",
  86. dijit: "tm1webDijit",
  87. dojox: "tm1webDojox"
  88. }
  89. }, {
  90. name: "tm1webDojox",
  91. location: scriptsPath + "dojox",
  92. packageMap: {
  93. dojo: "tm1webDojo",
  94. dijit: "tm1webDijit",
  95. dojox: "tm1webDojox"
  96. }
  97. }
  98. ]
  99. });
  100. //if (this.getCookie("tm1webcremote") != "" || (this.tm1Toolbar == "1")) {
  101. // this.cantLoadDojo = true;
  102. //} else {
  103. try {
  104. var self = this;
  105. require([
  106. "tm1web/cubeview/CubeViewer",
  107. "tm1web/utility/message-localizer"
  108. ], function(TM1Widget, MessageLocalizer) {
  109. window.MessageLocalizer = MessageLocalizer;
  110. self._Widget = TM1Widget;
  111. self.app = null;
  112. if (self.areTM1ParametersValid()) {
  113. self.refreshView();
  114. } else {
  115. self.onGetProperties(null, true);
  116. }
  117. });
  118. } catch (err) {
  119. self.cantLoadDojo = true;
  120. // document.cookie = "tm1webcremote=true; path=/";
  121. self.app = null;
  122. if (self.areTM1ParametersValid()) {
  123. self.refreshView();
  124. } else {
  125. self.onGetProperties(null, true);
  126. }
  127. }
  128. //}
  129. },
  130. // ====== Multilingual Support - Start ========
  131. updateView: function () {
  132. this.setLanguage();
  133. },
  134. getCookie: function (name) {
  135. if (document.cookie.length <= 0)
  136. return (""); // no cookies
  137. var search = name + "=";
  138. var offset = document.cookie.indexOf(search);
  139. if (offset == -1)
  140. return (""); // cookie does not exist
  141. offset += search.length;
  142. // set index of beginning of value
  143. var end = document.cookie.indexOf(";", offset);
  144. // set index of end of cookie value
  145. if (end == -1)
  146. end = document.cookie.length;
  147. return (unescape(document.cookie.substring(offset, end)));
  148. },
  149. setLanguage: function () {
  150. // Setup Localization tables - Use the BUX preferences for locale. Use Product locale for loading strings
  151. var curProductLocale = bux.Helper.getUserPreference("productLocale");
  152. if (this._productLocale != curProductLocale) {
  153. this._productLocale = curProductLocale;
  154. var deferred = new dojo.Deferred();
  155. var self = this;
  156. dojo.requireLocalization("TM1WebCubeViewerWidget", "tm1ContentCubeViewerWidget_msg", curProductLocale);
  157. dojo.ready(function() {
  158. self._tm1messages = dojo.i18n.getLocalization("TM1WebCubeViewerWidget", "tm1ContentCubeViewerWidget_msg", curProductLocale);
  159. deferred.resolve();
  160. });
  161. return deferred;
  162. }
  163. },
  164. createBasicWidgetToolbar: function () {
  165. var toolbarItems =
  166. [
  167. {
  168. _root:
  169. [
  170. { separator: true },
  171. { name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada" }
  172. ]
  173. }
  174. ];
  175. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems);
  176. },
  177. createWidgetToolbar: function () {
  178. var toolbarItems =
  179. [
  180. {
  181. _root:
  182. [
  183. { separator: true },
  184. { name: "Refresh", action: "IDM_RECALCULATE", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_REFRESH, showLabel: false, "iconClass": "bux-refresh-image" },
  185. { name: "Reset", action: "IDM_RESET", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESET, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada" },
  186. { name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada" }
  187. ]
  188. }
  189. ];
  190. toolbarItems = this.addToolbutton(toolbarItems, "IDM_COMMIT");
  191. //toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEVIEW");
  192. //toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEAS");
  193. toolbarItems = this.addToolbuttonWithSubmenu(toolbarItems, "IDM_EXPORT");
  194. toolbarItems = this.addSeparator(toolbarItems);
  195. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEDATACHANGES");
  196. //toolbarItems = this.addToolbutton(toolbarItems, "IDM_REVIEWDATACHANGES");
  197. toolbarItems = this.addSeparator(toolbarItems);
  198. toolbarItems = this.addToolbutton(toolbarItems, "IDM_RECALCULATE");
  199. toolbarItems = this.addToolbutton(toolbarItems, "IDM_TOGGLE_AUTOMATICRECALCULATE");
  200. toolbarItems = this.addToolbuttonWithSubmenu(toolbarItems, "IDM_SUPPRESS_ZEROS");
  201. toolbarItems = this.addSeparator(toolbarItems);
  202. toolbarItems = this.addToolbutton(toolbarItems, "IDM_CHART");
  203. toolbarItems = this.addToolbutton(toolbarItems, "IDM_CHARTANDGRID");
  204. toolbarItems = this.addToolbutton(toolbarItems, "IDM_GRID");
  205. toolbarItems = this.addToolbuttonWithSubmenu(toolbarItems, "IDM_CHART-SELECT");
  206. toolbarItems = this.addSeparator(toolbarItems);
  207. toolbarItems = this.addToolbutton(toolbarItems, "IDM_RESET_DATA");
  208. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_UNDO");
  209. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_REDO");
  210. toolbarItems = this.addSeparator(toolbarItems);
  211. toolbarItems = this.addToolbuttonWithSubmenu(toolbarItems, "IDM_SANDBOX");
  212. toolbarItems = this.addToolbuttonWithSubmenu(toolbarItems, "IDM_SANDBOXITEMS");
  213. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems);
  214. },
  215. addSeparator: function (toolbarItems) {
  216. var separator = { "separator": true };
  217. return toolbarItems.concat(separator);
  218. },
  219. addToolbutton: function (toolbarItems, toolbarAction) {
  220. if (this.isToolbuttonVisible(toolbarAction)) {
  221. return toolbarItems.concat(this.createSimpleToolbutton(toolbarAction));
  222. } else {
  223. return toolbarItems;
  224. }
  225. },
  226. addToolbuttonWithSubmenu: function (toolbarItems, toolbarAction) {
  227. if (this.isToolbuttonVisible(toolbarAction)) {
  228. return toolbarItems.concat(this.createToolbuttonWithSubmenu(toolbarAction));
  229. } else {
  230. return toolbarItems;
  231. }
  232. },
  233. createSimpleToolbutton: function (toolbarAction) {
  234. var toolbutton = {
  235. "name": toolbarAction,
  236. "action": toolbarAction,
  237. "label": this.getToolbuttonTooltip(toolbarAction),
  238. "iconClass": this.getToolbuttonImage(toolbarAction),
  239. "disabled": this.isToolbuttonDisabled(toolbarAction)
  240. }
  241. return toolbutton;
  242. },
  243. appendSandboxMenuChoice: function (menuItems, sandboxIndex, sandboxName, activeSandbox) {
  244. var toolbarAction = "SANDBOXCHOICE" + sandboxIndex;
  245. var toolbutton = {
  246. "name": toolbarAction,
  247. "action": toolbarAction,
  248. "label": sandboxName,
  249. "iconClass": (activeSandbox == sandboxName ? "tm1-menu-radioselection" : "tm1-menu-empty")
  250. }
  251. return menuItems.concat(toolbutton);
  252. },
  253. appendStrategyDiagramMenuChoice: function (menuItems, diagramIndex, diagramName) {
  254. var toolbarAction = "STRATEGYDIAGRAMCHOICE" + diagramIndex;
  255. var toolbutton = {
  256. "name": toolbarAction,
  257. "action": toolbarAction,
  258. "label": diagramName,
  259. "iconClass": this.getToolbuttonImage("IDM_METRICS_STRATEGY")
  260. }
  261. return menuItems.concat(toolbutton);
  262. },
  263. createToolbuttonWithSubmenu: function (toolbarAction) {
  264. var menuitems = null;
  265. if (toolbarAction == "IDM_EXPORT") {
  266. var menuItems = [];
  267. menuItems = this.addToolbutton(menuItems, "IDM_SLICE_TO_EXCEL");
  268. menuItems = this.addToolbutton(menuItems, "IDM_SNAPSHOT_TO_EXCEL");
  269. menuItems = this.addToolbutton(menuItems, "IDM_EXPORT_TO_PDF");
  270. var toolbutton = {
  271. "name": toolbarAction,
  272. "action": toolbarAction,
  273. "label": this.getToolbuttonTooltip(toolbarAction),
  274. "iconClass": this.getToolbuttonImage(toolbarAction),
  275. "disabled": this.isToolbuttonDisabled(toolbarAction),
  276. "items": menuItems
  277. }
  278. return toolbutton;
  279. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  280. var menuItems = [];
  281. menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS");
  282. menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_ROWS");
  283. menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_COLUMNS");
  284. var toolbutton = {
  285. "name": toolbarAction,
  286. "action": toolbarAction,
  287. "label": this.getToolbuttonTooltip(toolbarAction),
  288. "iconClass": this.getToolbuttonImage(toolbarAction),
  289. "disabled": this.isToolbuttonDisabled(toolbarAction),
  290. "items": menuItems
  291. }
  292. return toolbutton;
  293. } else if (toolbarAction == "IDM_CHART-SELECT") {
  294. var menuItems = [];
  295. menuItems = this.addToolbuttonWithSubmenu(menuItems, "IDM_CHARTTYPE");
  296. menuItems = this.addToolbuttonWithSubmenu(menuItems, "IDM_METRICS");
  297. var toolbutton = {
  298. "name": toolbarAction,
  299. "action": toolbarAction,
  300. "label": this.getToolbuttonTooltip(toolbarAction),
  301. "iconClass": this.getToolbuttonImage(toolbarAction),
  302. "disabled": this.isToolbuttonDisabled(toolbarAction),
  303. "items": menuItems
  304. }
  305. return toolbutton;
  306. } else if (toolbarAction == "IDM_METRICS") {
  307. var menuItems = [];
  308. menuItems = this.addToolbutton(menuItems, "IDM_METRICS_IMPACT");
  309. // menuItems = this.addToolbuttonWithSubmenu(menuItems, "IDM_METRICS_STRATEGY");
  310. if (this.cubeViewState != null && this.cubeViewState.strategyDiagramList != null && this.cubeViewState.strategyDiagramList.length > 0) {
  311. for (i = 0; i < this.cubeViewState.strategyDiagramList.length; i++) {
  312. menuItems = this.appendStrategyDiagramMenuChoice(menuItems, i, this.cubeViewState.strategyDiagramList[i].displayString);
  313. }
  314. }
  315. var toolbutton = {
  316. "name": toolbarAction,
  317. "action": toolbarAction,
  318. "label": this.getToolbuttonTooltip(toolbarAction),
  319. "iconClass": this.getToolbuttonImage(toolbarAction),
  320. "disabled": this.isToolbuttonDisabled(toolbarAction),
  321. "items": menuItems
  322. }
  323. return toolbutton;
  324. } else if (toolbarAction == "IDM_CHARTTYPE") {
  325. var menuItems = [];
  326. menuItems = this.addToolbutton(menuItems, "IDM_CHART_POINT");
  327. menuItems = this.addToolbutton(menuItems, "IDM_CHART_BUBBLE");
  328. menuItems = this.addToolbutton(menuItems, "IDM_CHART_LINE");
  329. menuItems = this.addToolbutton(menuItems, "IDM_CHART_SPLINE");
  330. menuItems = this.addToolbutton(menuItems, "IDM_CHART_STEPLINE");
  331. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_FASTLINE");
  332. menuItems = this.addToolbutton(menuItems, "IDM_CHART_BAR");
  333. menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDBAR");
  334. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDBAR100");
  335. menuItems = this.addToolbutton(menuItems, "IDM_CHART_COLUMN");
  336. menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDCOLUMN");
  337. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDCOLUMN100");
  338. menuItems = this.addToolbutton(menuItems, "IDM_CHART_AREA");
  339. menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDAREA");
  340. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDAREA100");
  341. menuItems = this.addToolbutton(menuItems, "IDM_CHART_PIE");
  342. menuItems = this.addToolbutton(menuItems, "IDM_CHART_DOUGHNUT");
  343. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STOCK");
  344. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_CANDLESTICK");
  345. menuItems = this.addToolbutton(menuItems, "IDM_CHART_RANGE");
  346. menuItems = this.addToolbutton(menuItems, "IDM_CHART_SPLINERANGE");
  347. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_GANTT");
  348. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_RANGECOLUMN");
  349. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_RADAR");
  350. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_POLAR");
  351. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_BOXPLOT");
  352. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_FUNNEL");
  353. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_PYRAMID");
  354. var toolbutton = {
  355. "name": toolbarAction,
  356. "action": toolbarAction,
  357. "label": this.getToolbuttonTooltip(toolbarAction),
  358. "iconClass": this.getToolbuttonImage(toolbarAction),
  359. "disabled": this.isToolbuttonDisabled(toolbarAction),
  360. "items": menuItems
  361. }
  362. return toolbutton;
  363. } else if (toolbarAction == "IDM_SANDBOX") {
  364. var menuItems = [];
  365. menuItems = this.addToolbutton(menuItems, "IDM_CREATE_SANDBOX");
  366. menuItems = this.addToolbutton(menuItems, "IDM_DELETE_SANDBOX");
  367. var toolbutton = {
  368. "name": toolbarAction,
  369. "action": toolbarAction,
  370. "label": this.getToolbuttonTooltip(toolbarAction),
  371. "iconClass": this.getToolbuttonImage(toolbarAction),
  372. "disabled": this.isToolbuttonDisabled(toolbarAction),
  373. "items": menuItems
  374. }
  375. return toolbutton;
  376. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  377. var menuItems = [];
  378. if (this.sandboxNames) {
  379. menuItems = this.appendSandboxMenuChoice(menuItems, 0, "[Base]", this.sandboxNames.currentSandbox);
  380. if (this.sandboxNames.sandboxes.length > 1) {
  381. for (i = 1; i < this.sandboxNames.sandboxes.length; i++) {
  382. menuItems = this.appendSandboxMenuChoice(menuItems, i, this.sandboxNames.sandboxes[i].name, this.sandboxNames.currentSandbox);
  383. }
  384. }
  385. } else {
  386. menuItems = this.appendSandboxMenuChoice(menuItems, 0, "[Base]", "[Base]");
  387. }
  388. var toolbutton = {
  389. "name": toolbarAction,
  390. "action": toolbarAction,
  391. "label": this.getToolbuttonTooltip(toolbarAction),
  392. "iconClass": this.getToolbuttonImage(toolbarAction),
  393. "disabled": this.isToolbuttonDisabled(toolbarAction),
  394. "items": menuItems
  395. }
  396. return toolbutton;
  397. } else if (toolbarAction == "IDM_METRICS_STRATEGY") {
  398. var menuItems = [];
  399. if (this.cubeViewState != null && this.cubeViewState.strategyDiagramList != null && this.cubeViewState.strategyDiagramList.length > 0) {
  400. for (i = 0; i < this.cubeViewState.strategyDiagramList.length; i++) {
  401. menuItems = this.appendStrategyDiagramMenuChoice(menuItems, i, this.cubeViewState.strategyDiagramList[i].displayString);
  402. }
  403. }
  404. var toolbutton = {
  405. "name": toolbarAction,
  406. "action": toolbarAction,
  407. "label": this.getToolbuttonTooltip(toolbarAction),
  408. "iconClass": this.getToolbuttonImage(toolbarAction),
  409. "disabled": this.isToolbuttonDisabled(toolbarAction),
  410. "items": menuItems
  411. }
  412. return toolbutton;
  413. }
  414. var toolbutton = {
  415. "name": toolbarAction,
  416. "action": toolbarAction,
  417. "label": this.getToolbuttonTooltip(toolbarAction),
  418. "iconClass": this.getToolbuttonImage(toolbarAction),
  419. "disabled": this.isToolbuttonDisabled(toolbarAction),
  420. "items": menuitems
  421. }
  422. return toolbutton;
  423. },
  424. isToolbuttonVisible: function (toolbarAction) {
  425. if (toolbarAction == "IDM_SANDBOXITEMS") {
  426. if (this.app != null) {
  427. if (this.cubeViewState == null) {
  428. return true;
  429. } else {
  430. return (this.cubeViewState.sandboxes.display);
  431. }
  432. }
  433. } else
  434. return true;
  435. },
  436. isToolbuttonDisabled: function (toolbarAction) {
  437. if (toolbarAction == "IDM_CHART-SELECT") {
  438. if (this.app != null) {
  439. if (this.cubeViewState == null) {
  440. return true;
  441. } else {
  442. return (this.cubeViewState.displayMode == "Grid");
  443. }
  444. }
  445. } else if (toolbarAction == "IDM_METRICS") {
  446. if (this.app != null) {
  447. if (this.cubeViewState == null) {
  448. return true;
  449. } else {
  450. return (this.cubeViewState.metricView == false);
  451. }
  452. }
  453. } else if (toolbarAction == "IDM_METRICS_IMPACT") {
  454. return false;
  455. } else if (toolbarAction == "IDM_METRICS_STRATEGY") {
  456. return false;
  457. } else if (toolbarAction == "IDM_COMMIT") {
  458. if (this.app != null) {
  459. if (this.cubeViewState == null) {
  460. return true;
  461. } else {
  462. return this.cubeViewState.baseSandbox;
  463. }
  464. }
  465. return true;
  466. } else if (toolbarAction == "IDM_SAVEVIEW") {
  467. return false;
  468. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  469. if (this.app != null) {
  470. if (this.cubeViewState == null) {
  471. return true;
  472. } else {
  473. return (this.cubeViewState.unsavedChanges == false);
  474. }
  475. }
  476. return true;
  477. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  478. if (this.app != null) {
  479. if (this.cubeViewState == null) {
  480. return true;
  481. } else {
  482. return (this.cubeViewState.unsavedChanges == false);
  483. }
  484. }
  485. return true;
  486. } else if (toolbarAction == "IDM_RESET_DATA") {
  487. if (this.app != null) {
  488. if (this.cubeViewState == null) {
  489. return true;
  490. } else {
  491. return this.cubeViewState.baseSandbox;
  492. }
  493. }
  494. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  495. if (this.app != null) {
  496. if (this.cubeViewState == null) {
  497. return true;
  498. } else {
  499. return (this.cubeViewState.redoUndoStatus.canUndo == false);
  500. }
  501. }
  502. return true;
  503. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  504. if (this.app != null) {
  505. if (this.cubeViewState == null) {
  506. return true;
  507. } else {
  508. return (this.cubeViewState.redoUndoStatus.canRedo == false);
  509. }
  510. }
  511. return true;
  512. } else if (toolbarAction == "IDM_SANDBOX") {
  513. return false;
  514. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  515. return false;
  516. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  517. return false;
  518. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  519. return false;
  520. } else {
  521. return false;
  522. }
  523. return "tm1-toolbar-empty";
  524. },
  525. getToolbuttonTooltip: function (toolbarAction) {
  526. if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  527. return window.MessageLocalizer.get("SUPPRESS_ZEROES_TOOLTIP_STR");
  528. } else if (toolbarAction == "IDM_COMMIT") {
  529. return window.MessageLocalizer.get("COMMIT_TOOLTIP_STR");
  530. } else if (toolbarAction == "IDM_SAVEVIEW") {
  531. return window.MessageLocalizer.get("SAVE_VIEW_TOOLTIP_STR");
  532. } else if (toolbarAction == "IDM_SAVEAS") {
  533. return window.MessageLocalizer.get("SAVE_AS_TOOLTIP_STR");
  534. } else if (toolbarAction == "IDM_EXPORT") {
  535. return window.MessageLocalizer.get("EXPORT_TOOLTIP_STR");
  536. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  537. return window.MessageLocalizer.get("SLICE_TO_EXCEL_STR");
  538. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  539. return window.MessageLocalizer.get("SNAP_TO_EXCEL_STR");
  540. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  541. return window.MessageLocalizer.get("EXPORT_TO_PDF_STR");
  542. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  543. return window.MessageLocalizer.get("SAVE_DATA_CHANGES_TOOLTIP_STR");
  544. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  545. return window.MessageLocalizer.get("REVIEW_DATA_CHANGES_TOOLTIP_STR");
  546. } else if (toolbarAction == "IDM_RECALCULATE") {
  547. return window.MessageLocalizer.get("RECALCULATE_TOOLTIP_STR");
  548. } else if (toolbarAction == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  549. if (this.app && this.cubeViewState && this.cubeViewState.automaticRecalculationEnabled) {
  550. return window.MessageLocalizer.get("AUTO_RECALCULATE_OFF_TOOLTIP_STR");
  551. } else {
  552. return window.MessageLocalizer.get("AUTO_RECALCULATE_ON_TOOLTIP_STR");
  553. }
  554. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  555. return window.MessageLocalizer.get("SUP_ZERO_ROW_COL_STR");
  556. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS") {
  557. return window.MessageLocalizer.get("SUP_ZERO_ROW_STR");
  558. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  559. return window.MessageLocalizer.get("SUP_ZERO_COL_STR");
  560. } else if (toolbarAction == "IDM_CHART") {
  561. return window.MessageLocalizer.get("VIEW_CHART_TOOLTIP_STR");
  562. } else if (toolbarAction == "IDM_CHARTANDGRID") {
  563. return window.MessageLocalizer.get("VIEW_CHARTGRID_TOOLTIP_STR");
  564. } else if (toolbarAction == "IDM_GRID") {
  565. return window.MessageLocalizer.get("VIEW_GRID_TOOLTIP_STR");
  566. } else if (toolbarAction == "IDM_CHART-SELECT") {
  567. return window.MessageLocalizer.get("CHART_PROP_TOOLTIP_STR");
  568. } else if (toolbarAction == "IDM_CHARTTYPE") {
  569. return window.MessageLocalizer.get("CHART_TYPE_STR");
  570. } else if (toolbarAction == "IDM_METRICS") {
  571. return window.MessageLocalizer.get("METRIC_DIAGRAM_STR");
  572. } else if (toolbarAction == "IDM_METRICS_IMPACT") {
  573. return window.MessageLocalizer.get("METRIC_IMPACT_DIAGRAM_STR");
  574. } else if (toolbarAction == "IDM_METRICS_STRATEGY") {
  575. return window.MessageLocalizer.get("METRIC_STRATEGY_DIAGRAMS_STR");
  576. } else if (toolbarAction == "IDM_CHART_POINT") {
  577. return window.MessageLocalizer.get("POINT_CHART_STR");
  578. } else if (toolbarAction == "IDM_CHART_BUBBLE") {
  579. return window.MessageLocalizer.get("BUBBLE_CHART_STR");
  580. } else if (toolbarAction == "IDM_CHART_LINE") {
  581. return window.MessageLocalizer.get("LINE_CHART_STR");
  582. } else if (toolbarAction == "IDM_CHART_SPLINE") {
  583. return window.MessageLocalizer.get("SPLINE_CHART_STR");
  584. } else if (toolbarAction == "IDM_CHART_STEPLINE") {
  585. return window.MessageLocalizer.get("STEP_LINE_CHART_STR");
  586. } else if (toolbarAction == "IDM_CHART_FASTLINE") {
  587. return window.MessageLocalizer.get("FAST_LINE_CHART_STR");
  588. } else if (toolbarAction == "IDM_CHART_BAR") {
  589. return window.MessageLocalizer.get("BAR_CHART_STR");
  590. } else if (toolbarAction == "IDM_CHART_STACKEDBAR") {
  591. return window.MessageLocalizer.get("STACKED_BAR_CHART_STR");
  592. } else if (toolbarAction == "IDM_CHART_STACKEDBAR100") {
  593. return window.MessageLocalizer.get("STACKED_BAR_100_CHART_STR");
  594. } else if (toolbarAction == "IDM_CHART_COLUMN") {
  595. return window.MessageLocalizer.get("COLUMN_CHART_STR");
  596. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN") {
  597. return window.MessageLocalizer.get("STACKED_COL_CHART_STR");
  598. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN100") {
  599. return window.MessageLocalizer.get("STACKED_COL_100_CHART_STR");
  600. } else if (toolbarAction == "IDM_CHART_AREA") {
  601. return window.MessageLocalizer.get("AREA_CHART_STR");
  602. } else if (toolbarAction == "IDM_CHART_SPLINEAREA") {
  603. return window.MessageLocalizer.get("SPLINE_AREA_CHART_STR");
  604. } else if (toolbarAction == "IDM_CHART_STACKEDAREA") {
  605. return window.MessageLocalizer.get("STACKED_AREA_CHART_STR");
  606. } else if (toolbarAction == "IDM_CHART_STACKEDAREA100") {
  607. return window.MessageLocalizer.get("STACKED_AREA_100_CHART_STR");
  608. } else if (toolbarAction == "IDM_CHART_PIE") {
  609. return window.MessageLocalizer.get("PIE_CHART_STR");
  610. } else if (toolbarAction == "IDM_CHART_DOUGHNUT") {
  611. return window.MessageLocalizer.get("DOUGHNUT_CHART_STR");
  612. } else if (toolbarAction == "IDM_CHART_STOCK") {
  613. return window.MessageLocalizer.get("STOCK_CHART_STR");
  614. } else if (toolbarAction == "IDM_CHART_CANDLESTICK") {
  615. return window.MessageLocalizer.get("CANDLE_STICK_CHART_STR");
  616. } else if (toolbarAction == "IDM_CHART_RANGE") {
  617. return window.MessageLocalizer.get("RANGE_CHART_STR");
  618. } else if (toolbarAction == "IDM_CHART_SPLINERANGE") {
  619. return window.MessageLocalizer.get("SPLINE_RANGE_CHART_STR");
  620. } else if (toolbarAction == "IDM_CHART_GANTT") {
  621. return window.MessageLocalizer.get("GANTT_CHART_STR");
  622. } else if (toolbarAction == "IDM_CHART_RANGECOLUMN") {
  623. return window.MessageLocalizer.get("RANGE_COLUMN_CHART_STR");
  624. } else if (toolbarAction == "IDM_CHART_RADAR") {
  625. return window.MessageLocalizer.get("RADAR_CHART_STR");
  626. } else if (toolbarAction == "IDM_CHART_POLAR") {
  627. return window.MessageLocalizer.get("POLAR_CHART_STR");
  628. } else if (toolbarAction == "IDM_CHART_BOXPLOT") {
  629. return window.MessageLocalizer.get("BOX_PLOT_CHART_STR");
  630. } else if (toolbarAction == "IDM_CHART_FUNNEL") {
  631. return window.MessageLocalizer.get("FUNNEL_CHART_STR");
  632. } else if (toolbarAction == "IDM_CHART_PYRAMID") {
  633. return window.MessageLocalizer.get("PYRAMID_CHART_STR");
  634. } else if (toolbarAction == "IDM_RESET_DATA") {
  635. return window.MessageLocalizer.get("RESET_DATA_STR");
  636. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  637. return window.MessageLocalizer.get("UNDO_TOOLTIP_STR");
  638. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  639. return window.MessageLocalizer.get("REDO_TOOLTIP_STR");
  640. } else if (toolbarAction == "IDM_SANDBOX") {
  641. return window.MessageLocalizer.get("SANDBOX_TOOLTIP_STR");
  642. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  643. return window.MessageLocalizer.get("CREATE_SANDBOX_STR");
  644. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  645. return window.MessageLocalizer.get("DELETE_SANDBOX_STR");
  646. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  647. if (this.sandboxNames) {
  648. return this.sandboxNames.currentSandbox;
  649. } else {
  650. return "[Base]";
  651. }
  652. }
  653. return "";
  654. },
  655. getToolbuttonImage: function (toolbarAction) {
  656. if (toolbarAction == "IDM_CHARTTYPE") {
  657. return "tm1-toolbar-chart-select";
  658. } else if (toolbarAction == "IDM_METRICS") {
  659. return "tm1-toolbar-metrics";
  660. } else if (toolbarAction == "IDM_METRICS_IMPACT") {
  661. return "tm1-toolbar-metrics-impact";
  662. } else if (toolbarAction == "IDM_METRICS_STRATEGY") {
  663. return "tm1-toolbar-metrics-strategy";
  664. } else if (toolbarAction == "IDM_CHART_POINT") {
  665. return "tm1-toolbar-chart-point";
  666. } else if (toolbarAction == "IDM_CHART_BUBBLE") {
  667. return "tm1-toolbar-chart-bubble";
  668. } else if (toolbarAction == "IDM_CHART_LINE") {
  669. return "tm1-toolbar-chart-line";
  670. } else if (toolbarAction == "IDM_CHART_SPLINE") {
  671. return "tm1-toolbar-chart-spline";
  672. } else if (toolbarAction == "IDM_CHART_STEPLINE") {
  673. return "tm1-toolbar-chart-stepline";
  674. } else if (toolbarAction == "IDM_CHART_FASTLINE") {
  675. return "tm1-toolbar-chart-fastline";
  676. } else if (toolbarAction == "IDM_CHART_BAR") {
  677. return "tm1-toolbar-chart-bar";
  678. } else if (toolbarAction == "IDM_CHART_STACKEDBAR") {
  679. return "tm1-toolbar-chart-stackedbar";
  680. } else if (toolbarAction == "IDM_CHART_STACKEDBAR100") {
  681. return "tm1-toolbar-chart-stackedbar100";
  682. } else if (toolbarAction == "IDM_CHART_COLUMN") {
  683. return "tm1-toolbar-chart-column";
  684. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN") {
  685. return "tm1-toolbar-chart-stackedcolumn";
  686. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN100") {
  687. return "tm1-toolbar-chart-stackedcolumn100";
  688. } else if (toolbarAction == "IDM_CHART_AREA") {
  689. return "tm1-toolbar-chart-area";
  690. } else if (toolbarAction == "IDM_CHART_SPLINEAREA") {
  691. return "tm1-toolbar-chart-splinearea";
  692. } else if (toolbarAction == "IDM_CHART_STACKEDAREA") {
  693. return "tm1-toolbar-chart-stackedarea";
  694. } else if (toolbarAction == "IDM_CHART_STACKEDAREA100") {
  695. return "tm1-toolbar-chart-stackedarea100";
  696. } else if (toolbarAction == "IDM_CHART_PIE") {
  697. return "tm1-toolbar-chart-pie";
  698. } else if (toolbarAction == "IDM_CHART_DOUGHNUT") {
  699. return "tm1-toolbar-chart-doughnut";
  700. } else if (toolbarAction == "IDM_CHART_STOCK") {
  701. return "tm1-toolbar-chart-stock";
  702. } else if (toolbarAction == "IDM_CHART_CANDLESTICK") {
  703. return "tm1-toolbar-chart-candlestick";
  704. } else if (toolbarAction == "IDM_CHART_RANGE") {
  705. return "tm1-toolbar-chart-range";
  706. } else if (toolbarAction == "IDM_CHART_SPLINERANGE") {
  707. return "tm1-toolbar-chart-splinerange";
  708. } else if (toolbarAction == "IDM_CHART_GANTT") {
  709. return "tm1-toolbar-chart-gantt";
  710. } else if (toolbarAction == "IDM_CHART_RANGECOLUMN") {
  711. return "tm1-toolbar-chart-rangecolumn";
  712. } else if (toolbarAction == "IDM_CHART_RADAR") {
  713. return "tm1-toolbar-chart-radar";
  714. } else if (toolbarAction == "IDM_CHART_POLAR") {
  715. return "tm1-toolbar-chart-polar";
  716. } else if (toolbarAction == "IDM_CHART_BOXPLOT") {
  717. return "tm1-toolbar-chart-boxplot";
  718. } else if (toolbarAction == "IDM_CHART_FUNNEL") {
  719. return "tm1-toolbar-chart-funnel";
  720. } else if (toolbarAction == "IDM_CHART_PYRAMID") {
  721. return "tm1-toolbar-chart-pyramid";
  722. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  723. return "tm1-toolbar-slice-excel2";
  724. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  725. return "tm1-toolbar-slice-snapshot";
  726. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  727. return "tm1-toolbar-slice-pdf";
  728. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  729. if (this.app._widget.GetSuppressZerosInfo().both == true) {
  730. return "tm1-toolbar-suppress-zeros dijitToggleButtonChecked";
  731. } else if (this.app._widget.GetSuppressZerosInfo().row == true) {
  732. return "tm1-toolbar-suppress-zeros-on-rows dijitToggleButtonChecked";
  733. } else if (this.app._widget.GetSuppressZerosInfo().column == true) {
  734. return "tm1-toolbar-suppress-zeros-on-columns dijitToggleButtonChecked";
  735. } else {
  736. return "tm1-toolbar-suppress-zeros";
  737. }
  738. } else if (toolbarAction == "IDM_COMMIT") {
  739. if (this.isToolbuttonDisabled("IDM_COMMIT")) {
  740. return "tm1-toolbar-apply disabled-toolbutton";
  741. } else {
  742. return "tm1-toolbar-apply";
  743. }
  744. } else if (toolbarAction == "IDM_SAVEVIEW") {
  745. if (this.isToolbuttonDisabled("IDM_SAVEVIEW")) {
  746. return "tm1-toolbar-save-view disabled-toolbutton";
  747. } else {
  748. return "tm1-toolbar-save-view";
  749. }
  750. } else if (toolbarAction == "IDM_SAVEAS") {
  751. if (this.isToolbuttonDisabled("IDM_SAVEAS")) {
  752. return "tm1-toolbar-save-view-as disabled-toolbutton";
  753. } else {
  754. return "tm1-toolbar-save-view-as";
  755. }
  756. } else if (toolbarAction == "IDM_EXPORT") {
  757. if (this.isToolbuttonDisabled("IDM_EXPORT")) {
  758. return "tm1-toolbar-export disabled-toolbutton";
  759. } else {
  760. return "tm1-toolbar-export";
  761. }
  762. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  763. if (this.isToolbuttonDisabled("IDM_SAVEDATACHANGES")) {
  764. return "tm1-toolbar-save_data_changes disabled-toolbutton";
  765. } else {
  766. return "tm1-toolbar-save_data_changes";
  767. }
  768. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  769. if (this.isToolbuttonDisabled("IDM_REVIEWDATACHANGES")) {
  770. return "tm1-toolbar-review_data_changes disabled-toolbutton";
  771. } else {
  772. return "tm1-toolbar-review_data_changes";
  773. }
  774. } else if (toolbarAction == "IDM_RECALCULATE") {
  775. if (this.isToolbuttonDisabled("IDM_RECALCULATE")) {
  776. return "tm1-toolbar-recalculate disabled-toolbutton";
  777. } else {
  778. return "tm1-toolbar-recalculate";
  779. }
  780. } else if (toolbarAction == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  781. if (this.app && this.cubeViewState && this.cubeViewState.automaticRecalculationEnabled) {
  782. return "tm1-toolbar-recalculation";
  783. } else {
  784. return "tm1-toolbar-recalculation dijitToggleButtonChecked";
  785. }
  786. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  787. if (this.app._widget.GetSuppressZerosInfo().both == true) {
  788. return "tm1-menu-radioselection";
  789. }
  790. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS") {
  791. if ((this.app._widget.GetSuppressZerosInfo().row == true) ||
  792. (this.app._widget.GetSuppressZerosInfo().both == true)) {
  793. return "tm1-menu-radioselection";
  794. }
  795. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  796. if ((this.app._widget.GetSuppressZerosInfo().column == true) ||
  797. (this.app._widget.GetSuppressZerosInfo().both == true)) {
  798. return "tm1-menu-radioselection";
  799. }
  800. } else if (toolbarAction == "IDM_CHART") {
  801. if (this.app && this.cubeViewState && this.cubeViewState.displayMode == "Chart") {
  802. return "tm1-toolbar-chart_only dijitToggleButtonChecked";
  803. } else {
  804. return "tm1-toolbar-chart_only";
  805. }
  806. } else if (toolbarAction == "IDM_CHARTANDGRID") {
  807. if (this.app && this.cubeViewState && this.cubeViewState.displayMode == "GridAndChart") {
  808. return "tm1-toolbar-chart-grid dijitToggleButtonChecked";
  809. } else {
  810. return "tm1-toolbar-chart-grid";
  811. }
  812. } else if (toolbarAction == "IDM_GRID") {
  813. if (this.app && this.cubeViewState && this.cubeViewState.displayMode == "Grid") {
  814. return "tm1-toolbar-grid_only dijitToggleButtonChecked";
  815. } else {
  816. return "tm1-toolbar-grid_only";
  817. }
  818. } else if (toolbarAction == "IDM_CHART-SELECT") {
  819. if (this.isToolbuttonDisabled("IDM_CHART-SELECT")) {
  820. return "tm1-toolbar-chart-select_type disabled-toolbutton";
  821. } else {
  822. return "tm1-toolbar-chart-select_type";
  823. }
  824. } else if (toolbarAction == "IDM_RESET_DATA") {
  825. if (this.isToolbuttonDisabled("IDM_RESET_DATA")) {
  826. return "tm1-toolbar-sandbox-reset disabled-toolbutton";
  827. } else {
  828. return "tm1-toolbar-sandbox-reset";
  829. }
  830. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  831. if (this.isToolbuttonDisabled("IDM_SANDBOX_UNDO")) {
  832. return "tm1-toolbar-sandbox-undo disabled-toolbutton";
  833. } else {
  834. return "tm1-toolbar-sandbox-undo";
  835. }
  836. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  837. if (this.isToolbuttonDisabled("IDM_SANDBOX_REDO")) {
  838. return "tm1-toolbar-sandbox-redo disabled-toolbutton";
  839. } else {
  840. return "tm1-toolbar-sandbox-redo";
  841. }
  842. } else if (toolbarAction == "IDM_SANDBOX") {
  843. if (this.isToolbuttonDisabled("IDM_SANDBOX")) {
  844. return "tm1-toolbar-sandbox-select disabled-toolbutton";
  845. } else {
  846. return "tm1-toolbar-sandbox-select";
  847. }
  848. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  849. return "tm1-toolbar-sandbox-new";
  850. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  851. return "tm1-toolbar-sandbox-delete";
  852. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  853. return null;
  854. }
  855. return "tm1-toolbar-empty";
  856. },
  857. //
  858. areTM1ParametersValid: function () {
  859. var bParametersAreValid = true;
  860. if (this.tm1Cube == "") {
  861. bParametersAreValid = false;
  862. } else if (this.tm1Host == "") {
  863. bParametersAreValid = false;
  864. } else if (this.tm1Server == "") {
  865. bParametersAreValid = false;
  866. } else if (this.tm1CubeView == "") {
  867. bParametersAreValid = false;
  868. }
  869. if (!bParametersAreValid) {
  870. console.log(this.tm1Cube);
  871. console.log(this.tm1Host);
  872. console.log(this.tm1Server);
  873. console.log(this.tm1CubeView);
  874. }
  875. return bParametersAreValid == true;
  876. },
  877. getWidgetAttributes: function () {
  878. this.tm1WebURL = this.iContext.getiWidgetAttributes().getItemValue("tm1WebURL");
  879. this.tm1Host = this.iContext.getiWidgetAttributes().getItemValue("tm1Host");
  880. this.tm1Server = this.iContext.getiWidgetAttributes().getItemValue("tm1Server");
  881. this.tm1Cube = this.iContext.getiWidgetAttributes().getItemValue("tm1Cube");
  882. this.tm1CubeView = this.iContext.getiWidgetAttributes().getItemValue("tm1CubeView");
  883. this.tm1UserName = this.iContext.getiWidgetAttributes().getItemValue("tm1UserName");
  884. this.tm1Password = this.iContext.getiWidgetAttributes().getItemValue("tm1Password");
  885. this.filterPackages = this.iContext.getiWidgetAttributes().getItemValue("FilterPackages");
  886. this.tm1AccessType = this.iContext.getiWidgetAttributes().getItemValue("AccessType");
  887. this.tm1HideDimBar = this.iContext.getiWidgetAttributes().getItemValue("TM1HideDimBar");
  888. this.tm1Toolbar = this.iContext.getiWidgetAttributes().getItemValue("TM1Toolbar");
  889. this.tm1Height = this.iContext.getiWidgetAttributes().getItemValue("tHeight");
  890. this.tm1Width = this.iContext.getiWidgetAttributes().getItemValue("tWidth");
  891. this.tm1FiltersToSetPayload = eval ("(" + this.iContext.getiWidgetAttributes().getItemValue("filtersToSetPayload") + ")");
  892. if (this.tm1UserName == null || this.tm1UserName.length == 0) {
  893. var cookieValue = dojo.cookie("cam_passport");
  894. if (cookieValue && cookieValue.length > 0) {
  895. this.camPassport = cookieValue;
  896. }
  897. }
  898. if (this.tm1AccessType == null || tm1.tm1AccessType == "") {
  899. if (this.tm1CubeView == null || this.tm1CubeView == "") {
  900. this.tm1ServerCubeView = this.iContext.getiWidgetAttributes().getItemValue("tm1ServerCubeView");
  901. if (this.tm1ServerCubeView != "") {
  902. var searchString = this.tm1ServerCubeView;
  903. var separatorIndex = searchString.indexOf('$$');
  904. this.tm1Server = searchString.substring(0, separatorIndex);
  905. searchString = searchString.substring(separatorIndex + 2, searchString.length);
  906. separatorIndex = searchString.indexOf('$$');
  907. this.tm1Cube = searchString.substring(0, separatorIndex);
  908. searchString = searchString.substring(separatorIndex + 2, searchString.length);
  909. separatorIndex = searchString.indexOf('$$');
  910. this.tm1CubeView = searchString;
  911. }
  912. }
  913. var separatorIndex = this.tm1CubeView.indexOf('$$');
  914. this.tm1AccessType = this.tm1CubeView.substring(separatorIndex + 2, this.tm1CubeView.length);
  915. this.tm1CubeView = this.tm1CubeView.substring(0, separatorIndex);
  916. this.upgradeWidget();
  917. } else {
  918. this.loadWithAttributes();
  919. }
  920. },
  921. upgradeWidget: function () {
  922. var attributes = this.iContext.getiWidgetAttributes();
  923. var _properties = {
  924. 'webLabel': this.tm1WebURL,
  925. 'label': this.tm1Host,
  926. 'serverLabel': this.tm1Server,
  927. 'cubeLabel': this.tm1Cube,
  928. 'cubeViewLabel': this.tm1CubeView,
  929. 'accessLabel': this.tm1AccessType,
  930. 'userNameLabel': this.tm1UserName,
  931. 'passwordLabel': ""
  932. };
  933. var propertiesDialog = new CubeViewPropertiesPane({
  934. properties: _properties,
  935. title: dojo.string.substitute(BUXMSG.WDG.IDS_WDG_PROPERTIES_DIALOG_TITLE, [attributes.getItemValue("widgetTitle")]),
  936. firstLine: "This dashboard was created for an earlier version of TM1. Please specify the new location including port of TM1Web, reenter the password if applicable, and make any other required changes.",
  937. sourceWidget: this,
  938. okPropertiesCallback: dojo.hitch(this, this.onSetProperties),
  939. cancelPropertiesCallback: dojo.hitch(this, this._onCancelProperties)
  940. });
  941. this._propertiesDialog = propertiesDialog;
  942. var _payload = { properties: _properties, propertiesDialogSpec: null, propertiesDialogTab: propertiesDialog };
  943. this.iContext.iEvents.fireEvent("com.ibm.bux.widget.properties.get.done", null, _payload);
  944. },
  945. refreshView: function () {
  946. if (this.cantLoadDojo) {
  947. if (this.iframeCtrlCantLoadDojo) {
  948. this.iframeCtrlCantLoadDojo.setUrl(this.getIFrameUrl()); //
  949. } else {
  950. var widgetTitle = "widgetTitle";
  951. var domObject = this.iContext.getElementById("_" + this.iContext.widgetId + "_" + "widgetFrame");
  952. this.iframeCtrlCantLoadDojo = new tm1.iwidget.utilities.IFrame({
  953. url: this.getIFrameUrl(), //
  954. frameTitle: widgetTitle
  955. }, domObject);
  956. this.iframeCtrlCantLoadDojo.startup();
  957. }
  958. this.createBasicWidgetToolbar();
  959. } else {
  960. var loadDeferred = new dojo.Deferred();
  961. this.app = new this._Widget({
  962. adminHost: this.tm1Host,
  963. tm1Server: this.tm1Server,
  964. camPassport: this.camPassport,
  965. sessionToken: this.sessionToken,
  966. username: !this.sessionToken ? (this.tm1UserName || undefined) : "",
  967. password: !this.sessionToken ? (this.tm1UserName ? (this.tm1Password ? this.tm1Password : "") : undefined) : "",
  968. cube: this.tm1Cube,
  969. view: this.tm1CubeView,
  970. isPublic: (this.tm1AccessType == "PUBLIC"),
  971. style: "width: 100%; height: 100%",
  972. onLoad: function() {
  973. loadDeferred.resolve();
  974. }
  975. }).placeAt(dojo.byId("_" + this.iContext.widgetId + "_" + "widgetFrame"));
  976. this.app.startup();
  977. loadDeferred.then(dojo.hitch(this, this.createCompleteCallback));
  978. }
  979. },
  980. refreshMore: function () {
  981. if (this.app != null) {
  982. if (this.subscriptionHandle) {
  983. this.app._widget.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  984. }
  985. this.app.destroy();
  986. this.app = null;
  987. }
  988. if (this.iframeCtrl) {
  989. this.iframeCtrl.setUrl(this.getIFrameUrl()); //
  990. } else {
  991. var widgetTitle = "widgetTitle";
  992. var domObject = this.iContext.getElementById("_" + this.iContext.widgetId + "_" + "widgetFrameA");
  993. this.iframeCtrl = new tm1.iwidget.utilities.IFrame({
  994. url: this.getIFrameUrl(), //
  995. frameTitle: widgetTitle
  996. }, domObject);
  997. this.iframeCtrl.startup();
  998. }
  999. },
  1000. getIFrameUrl: function () {
  1001. return this.tm1WebURL + "/UrlApi.jsp#Action=Open&Type=CubeViewer"
  1002. + "&Cube=" + this.tm1Cube + "&View=" + this.tm1CubeView + "&AccessType=" + this.tm1AccessType
  1003. + (!this.sessionToken ?
  1004. ("&TM1Server=" + this.tm1Server + "&AdminHost=" + this.tm1Host
  1005. + (this.camPassport ?
  1006. ("&CamPassport=" + this.camPassport) :
  1007. ("&UserName=" + this.tm1UserName + "&Password=" + (this.tm1Password ? this.tm1Password : "")))) :
  1008. ("&SessionToken=" + this.sessionToken));
  1009. },
  1010. createCompleteCallback: function (value) {
  1011. if (!this.inDoMore) {
  1012. if (this.tm1HideDimBar == "1") {
  1013. this.app._widget.toggleDimensionBar(true);
  1014. }
  1015. this.createWidgetToolbar();
  1016. if(this.onbeforeunloadHandler != null) {
  1017. window.onbeforeunload = this.onbeforeunloadHandler;
  1018. this.onbeforeunloadHandler = null;
  1019. }
  1020. this.sessionToken = this.app.sessionToken;
  1021. }
  1022. var dimensionNamePromise = this.app._widget.getDimensionNames();
  1023. dimensionNamePromise.promise.then(dojo.hitch(this, function (inDimensionNames) {
  1024. this.dimensionNames = inDimensionNames;
  1025. this.elementNameCounter = 0;
  1026. this.elementNames = [];
  1027. if (inDimensionNames != null && inDimensionNames.length > 0) {
  1028. var elementsPromise = this.app._widget.getElementNames(this.dimensionNames[0]);
  1029. elementsPromise.promise.then(dojo.hitch(this, this.getElementNamesCallback));
  1030. }
  1031. }));
  1032. if (this.subscriptionHandle) {
  1033. this.app._widget.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  1034. }
  1035. this.subscriptionHandle = this.app._widget.subscribeToStateChangeUpdates(dojo.hitch(this, this.getCubeViewStateCallback));
  1036. },
  1037. onView: function (iEvent) {
  1038. if (this.inDoMore) {
  1039. this.inDoMore = false;
  1040. if ((dojo.isIE || dojo.isTrident) && window.onbeforeunload != null) {
  1041. this.onbeforeunloadHandler = window.onbeforeunload;
  1042. window.onbeforeunload = null;
  1043. }
  1044. this.refreshView();
  1045. }
  1046. },
  1047. onEdit: function (iEvent) {
  1048. this.refreshView();
  1049. // example of a toolbar for edit mode
  1050. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, [{
  1051. label: "Edit action",
  1052. iconClass: "bux-toolbar-button-edit",
  1053. action: "action.edit"
  1054. }]);
  1055. },
  1056. onMore: function (iEvent) {
  1057. if (!this.inDoMore) {
  1058. this.inDoMore = true;
  1059. this.refreshMore();
  1060. }
  1061. // example of a toolbar for more mode (not supported by BUX right now)
  1062. // this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, [{
  1063. // label: "More action",
  1064. // iconClass: "bux-toolbar-button-more",
  1065. // action: "action.more"
  1066. // }]);
  1067. },
  1068. // ui actions
  1069. doMode: function (mode) {
  1070. // switch back to view mode
  1071. this.iContext.iEvents.fireEvent("onModeChanged", null, {
  1072. newMode: mode
  1073. });
  1074. },
  1075. onModeChanged: function (mode) {
  1076. },
  1077. onToolbarAction: function (evt) {
  1078. if (evt.payload == "IDM_RESTART") {
  1079. if (this.app != null) {
  1080. if (this.subscriptionHandle) {
  1081. this.app._widget.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  1082. }
  1083. this.app.destroy();
  1084. this.app = null;
  1085. }
  1086. this.refreshView();
  1087. } else if (this.app == null) {
  1088. return;
  1089. } else if (evt.payload == "IDM_RESET") {
  1090. this.app._widget.resetView();
  1091. } else if (evt.payload == "IDM_COMMIT") {
  1092. this.app._widget.commitSandbox();
  1093. } else if (evt.payload == "IDM_SAVEVIEW") {
  1094. alert("not implemented yet");
  1095. } else if (evt.payload == "IDM_SAVEAS") {
  1096. alert("not implemented yet");
  1097. } else if (evt.payload == "IDM_SAVEDATACHANGES") {
  1098. this.app._widget.saveData();
  1099. } else if (evt.payload == "IDM_REVIEWDATACHANGES") {
  1100. alert("not implemented yet");
  1101. } else if (evt.payload == "IDM_RECALCULATE") {
  1102. this.app.recalculate();
  1103. } else if (evt.payload == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  1104. if (this.app && this.cubeViewState && this.cubeViewState.automaticRecalculationEnabled) {
  1105. this.app._widget.setAutomaticRecalculation(false);
  1106. } else {
  1107. this.app._widget.setAutomaticRecalculation(true);
  1108. }
  1109. } else if (evt.payload == "IDM_SLICE_TO_EXCEL") {
  1110. this.app._widget.displayExportOptions("SLICE");
  1111. } else if (evt.payload == "IDM_SNAPSHOT_TO_EXCEL") {
  1112. this.app._widget.displayExportOptions("SNAPSHOT");
  1113. } else if (evt.payload == "IDM_EXPORT_TO_PDF") {
  1114. this.app._widget.displayExportOptions("PRINTTOPDF");
  1115. } else if (evt.payload == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  1116. this.app._widget.SuppressZerosBoth();
  1117. this.createWidgetToolbar();
  1118. } else if (evt.payload == "IDM_SUPPRESS_ZEROS_ROWS") {
  1119. this.app._widget.SuppressZerosRows();
  1120. this.createWidgetToolbar();
  1121. } else if (evt.payload == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  1122. this.app._widget.SuppressZerosCols();
  1123. this.createWidgetToolbar();
  1124. } else if (evt.payload == "IDM_CHART") {
  1125. this.app._widget.ChangeDisplayMode("Chart");
  1126. } else if (evt.payload == "IDM_CHARTANDGRID") {
  1127. this.app._widget.ChangeDisplayMode("GridAndChart");
  1128. } else if (evt.payload == "IDM_GRID") {
  1129. this.app._widget.ChangeDisplayMode("Grid");
  1130. } else if (evt.payload == "IDM_METRICS_IMPACT") {
  1131. this.app._widget.ChartTypeChanged(33);
  1132. } else if (evt.payload == "IDM_CHART_POINT") {
  1133. this.app._widget.ChartTypeChanged(0, "");
  1134. } else if (evt.payload == "IDM_CHART_BUBBLE") {
  1135. this.app._widget.ChartTypeChanged(1, "");
  1136. } else if (evt.payload == "IDM_CHART_LINE") {
  1137. this.app._widget.ChartTypeChanged(2, "");
  1138. } else if (evt.payload == "IDM_CHART_SPLINE") {
  1139. this.app._widget.ChartTypeChanged(3, "");
  1140. } else if (evt.payload == "IDM_CHART_STEPLINE") {
  1141. this.app._widget.ChartTypeChanged(4, "");
  1142. } else if (evt.payload == "IDM_CHART_FASTLINE") {
  1143. this.app._widget.ChartTypeChanged(5, "");
  1144. } else if (evt.payload == "IDM_CHART_BAR") {
  1145. this.app._widget.ChartTypeChanged(6, "");
  1146. } else if (evt.payload == "IDM_CHART_STACKEDBAR") {
  1147. this.app._widget.ChartTypeChanged(7, "");
  1148. } else if (evt.payload == "IDM_CHART_STACKEDBAR100") {
  1149. this.app._widget.ChartTypeChanged(8, "");
  1150. } else if (evt.payload == "IDM_CHART_COLUMN") {
  1151. this.app._widget.ChartTypeChanged(9, "");
  1152. } else if (evt.payload == "IDM_CHART_STACKEDCOLUMN") {
  1153. this.app._widget.ChartTypeChanged(10, "");
  1154. } else if (evt.payload == "IDM_CHART_STACKEDCOLUMN100") {
  1155. this.app._widget.ChartTypeChanged(11, "");
  1156. } else if (evt.payload == "IDM_CHART_AREA") {
  1157. this.app._widget.ChartTypeChanged(12, "");
  1158. } else if (evt.payload == "IDM_CHART_SPLINEAREA") {
  1159. this.app._widget.ChartTypeChanged(13, "");
  1160. } else if (evt.payload == "IDM_CHART_STACKEDAREA") {
  1161. this.app._widget.ChartTypeChanged(14, "");
  1162. } else if (evt.payload == "IDM_CHART_STACKEDAREA100") {
  1163. this.app._widget.ChartTypeChanged(15, "");
  1164. } else if (evt.payload == "IDM_CHART_PIE") {
  1165. this.app._widget.ChartTypeChanged(16, "");
  1166. } else if (evt.payload == "IDM_CHART_DOUGHNUT") {
  1167. this.app._widget.ChartTypeChanged(17, "");
  1168. } else if (evt.payload == "IDM_CHART_STOCK") {
  1169. this.app._widget.ChartTypeChanged(18, "");
  1170. } else if (evt.payload == "IDM_CHART_CANDLESTICK") {
  1171. this.app._widget.ChartTypeChanged(19, "");
  1172. } else if (evt.payload == "IDM_CHART_RANGE") {
  1173. this.app._widget.ChartTypeChanged(20, "");
  1174. } else if (evt.payload == "IDM_CHART_SPLINERANGE") {
  1175. this.app._widget.ChartTypeChanged(21, "");
  1176. } else if (evt.payload == "IDM_CHART_GANTT") {
  1177. this.app._widget.ChartTypeChanged(22, "");
  1178. } else if (evt.payload == "IDM_CHART_RANGECOLUMN") {
  1179. this.app._widget.ChartTypeChanged(23, "");
  1180. } else if (evt.payload == "IDM_CHART_RADAR") {
  1181. this.app._widget.ChartTypeChanged(24, "");
  1182. } else if (evt.payload == "IDM_CHART_POLAR") {
  1183. this.app._widget.ChartTypeChanged(25, "");
  1184. } else if (evt.payload == "IDM_CHART_BOXPLOT") {
  1185. this.app._widget.ChartTypeChanged(26, "");
  1186. } else if (evt.payload == "IDM_CHART_FUNNEL") {
  1187. this.app._widget.ChartTypeChanged(27, "");
  1188. } else if (evt.payload == "IDM_CHART_PYRAMID") {
  1189. this.app._widget.ChartTypeChanged(28, "");
  1190. } else if (evt.payload == "IDM_RESET_DATA") {
  1191. this.app._widget.resetData();
  1192. } else if (evt.payload == "IDM_SANDBOX_UNDO") {
  1193. this.app.undo();
  1194. } else if (evt.payload == "IDM_SANDBOX_REDO") {
  1195. this.app.redo();
  1196. } else if (evt.payload == "IDM_CREATE_SANDBOX") {
  1197. this.app._widget.createSandbox();
  1198. } else if (evt.payload == "IDM_DELETE_SANDBOX") {
  1199. this.app._widget.deleteSandboxes();
  1200. } else if (evt.payload.substring(0, 21) == "STRATEGYDIAGRAMCHOICE") {
  1201. var strategyDiagramId = evt.payload.substring(21, evt.payload.length);
  1202. var diagramId = parseInt(strategyDiagramId);
  1203. var StrategyId = 34 + diagramId;
  1204. this.app._widget.ChartTypeChanged(StrategyId, this.cubeViewState.strategyDiagramList[diagramId].name);
  1205. } else if (evt.payload.substring(0, 13) == "SANDBOXCHOICE") {
  1206. var sandBoxId = evt.payload.substring(13, evt.payload.length);
  1207. if (sandBoxId == 0) {
  1208. this.app._widget.setActiveSandbox("[Base]");
  1209. } else {
  1210. this.app._widget.setActiveSandbox(this.sandboxNames.sandboxes[sandBoxId].name);
  1211. }
  1212. }
  1213. },
  1214. getCubeViewStateCallback: function (inCubeViewState) {
  1215. this.cubeViewState = inCubeViewState;
  1216. var sandboxPromise = this.app._widget.getSandboxes();
  1217. sandboxPromise.then(dojo.hitch(this, this.getSandboxNamesCallback));
  1218. },
  1219. getSandboxNamesCallback: function (inSandboxNames) {
  1220. this.sandboxNames = inSandboxNames;
  1221. this.createWidgetToolbar();
  1222. },
  1223. onUnload: function (evt) {
  1224. if(this.recalPromise) {
  1225. this.recalPromise.then(dojo.hitch(this, this.doOnUnload));
  1226. } else {
  1227. this.doOnUnload();
  1228. }
  1229. this.unloaded = true;
  1230. },
  1231. doOnUnload: function() {
  1232. if (this.app) {
  1233. if (this.subscriptionHandle) {
  1234. this.app._widget.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  1235. }
  1236. this.app.destroy();
  1237. this.app.logout();
  1238. this.app = null;
  1239. this.sessionToken = null;
  1240. }
  1241. if (this.iframeCtrl != null) {
  1242. this.iframeCtrl.destroy();
  1243. }
  1244. if (this.iframeCtrlCantLoadDojo != null) {
  1245. this.iframeCtrlCantLoadDojo.destroy();
  1246. }
  1247. },
  1248. onSetVisible: function(evt)
  1249. {
  1250. if(!this.unloaded) {
  1251. if (evt.payload.isVisible) {
  1252. if (this.app != null) {
  1253. this.recalPromise = this.app.recalculate();
  1254. }
  1255. }
  1256. }
  1257. },
  1258. onWidgetRefresh: function (evt) // Invoked when User preferences get modified (Including locales)
  1259. {
  1260. if (this.app != null) {
  1261. this.app.recalculate();
  1262. }
  1263. return;
  1264. },
  1265. onWidgetSave: function() {
  1266. var saveDonePayload = {'status':true};
  1267. this.iContext.iEvents.fireEvent("com.ibm.bux.widget.save.done", null, saveDonePayload);
  1268. },
  1269. onWidgetResize: function (e) {
  1270. if (this.inDoMore) {
  1271. var newWidth = e.payload.resize.w;
  1272. var newHeight = e.payload.resize.h;
  1273. this.iframeCtrl.resize({
  1274. w: newWidth,
  1275. h: newHeight - 40
  1276. });
  1277. } else if (this.cantLoadDojo) {
  1278. var newWidth = e.payload.resize.w;
  1279. var newHeight = e.payload.resize.h;
  1280. this.iframeCtrlCantLoadDojo.resize({
  1281. w: newWidth,
  1282. h: newHeight
  1283. });
  1284. } else {
  1285. if (!this._preferredSizeSet) {
  1286. var attributes = this.iContext.getiWidgetAttributes();
  1287. var width = parseInt(((this.tm1Width != null) && (this.tm1Width > 0)) ? this.tm1Width : attributes.getItemValue("viewWidth"));
  1288. var height = parseInt(((this.tm1Height != null) && (this.tm1Height > 0)) ? this.tm1Height : attributes.getItemValue("viewHeight"));
  1289. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  1290. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  1291. chromeObject.setPreferredSize({ w: width, h: height });
  1292. this._preferredSizeSet = true;
  1293. chromeObject.doChromeAutoResize();
  1294. }
  1295. if (this.app != null) {
  1296. this.app.resize();
  1297. this.tm1Height = e.payload.resize.h;
  1298. this.tm1Width = e.payload.resize.w;
  1299. this.iContext.getiWidgetAttributes().setItemValue("tHeight", this.tm1Height);
  1300. this.iContext.getiWidgetAttributes().setItemValue("tWidth", this.tm1Width);
  1301. }
  1302. }
  1303. },
  1304. onGetProperties: function (evt, init) {
  1305. /*
  1306. var attributes = this.iContext.getiWidgetAttributes();
  1307. var _properties = {
  1308. 'label': this.iContext.getiWidgetAttributes().getItemValue("tm1Host"),
  1309. 'serverLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1Server"),
  1310. 'cubeLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1Cube"),
  1311. 'cubeViewLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1CubeView"),
  1312. 'userNameLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1UserName"),
  1313. 'passwordLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1Password")
  1314. };
  1315. var propertiesDialog = new CubeViewPropertiesPane({
  1316. properties: _properties,
  1317. title: dojo.string.substitute(BUXMSG.WDG.IDS_WDG_PROPERTIES_DIALOG_TITLE, [attributes.getItemValue("widgetTitle")]),
  1318. sourceWidget: this,
  1319. cancelPropertiesCallback: (init) ? dojo.hitch(this, this._onCancelProperties) : null
  1320. });
  1321. this._propertiesDialog = propertiesDialog;
  1322. var _payload = {properties: _properties, propertiesDialogSpec:null, propertiesDialogTab: propertiesDialog};
  1323. this.iContext.iEvents.fireEvent("com.ibm.bux.widget.properties.get.done", null, _payload);
  1324. */
  1325. },
  1326. _onCancelProperties: function () {
  1327. if (this._firstRender == true) {
  1328. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  1329. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  1330. chromeObject.widgetRemoveConfirmed();
  1331. }
  1332. },
  1333. saveTM1CubeViewerParams: function (inIContext) {
  1334. inIContext.getiWidgetAttributes().setItemValue("tm1WebURL", this.tm1WebURL);
  1335. inIContext.getiWidgetAttributes().setItemValue("tm1Host", this.tm1Host);
  1336. inIContext.getiWidgetAttributes().setItemValue("tm1Server", this.tm1Server);
  1337. inIContext.getiWidgetAttributes().setItemValue("tm1Cube", this.tm1Cube);
  1338. inIContext.getiWidgetAttributes().setItemValue("tm1CubeView", this.tm1CubeView);
  1339. inIContext.getiWidgetAttributes().setItemValue("tm1UserName", this.tm1UserName);
  1340. inIContext.getiWidgetAttributes().setItemValue("tm1Password", this.tm1Password);
  1341. inIContext.getiWidgetAttributes().setItemValue("AccessType", this.tm1AccessType);
  1342. // inIContext.getiWidgetAttributes().setItemValue("tHeight", this.tm1Height);
  1343. return;
  1344. },
  1345. onSetProperties: function () {
  1346. var attributes = this.iContext.getiWidgetAttributes();
  1347. var tm1WebUrl = this._propertiesDialog.webLabelInput.value;
  1348. var host = this._propertiesDialog.labelInput.value;
  1349. var server = this._propertiesDialog.serverLabelInput.value;
  1350. var cube = this._propertiesDialog.cubeLabelInput.value;
  1351. var cubeView = this._propertiesDialog.cubeViewLabelInput.value;
  1352. var access = this._propertiesDialog.accessLabelInput.value;
  1353. var userName = this._propertiesDialog.userNameLabelInput.value;
  1354. var password = this._propertiesDialog.passwordLabelInput.value;
  1355. if (host != attributes.getItemValue("tm1Host") ||
  1356. tm1WebUrl != attributes.getItemValue("tm1WebURL") ||
  1357. server != attributes.getItemValue("tm1Server") ||
  1358. cube != attributes.getItemValue("tm1Cube") ||
  1359. cubeView != attributes.getItemValue("tm1CubeView") ||
  1360. access != attributes.getItemValue("AccessType") ||
  1361. userName != attributes.getItemValue("tm1UserName") ||
  1362. password != attributes.getItemValue("tm1Password")) {
  1363. this.tm1WebURL = tm1WebUrl;
  1364. this.tm1Host = host;
  1365. this.tm1Server = server;
  1366. this.tm1Cube = cube;
  1367. this.tm1CubeView = cubeView;
  1368. this.tm1UserName = userName;
  1369. this.tm1Password = password;
  1370. this.tm1AccessType = access;
  1371. this.saveTM1CubeViewerParams(this.iContext);
  1372. this.loadWithAttributes();
  1373. }
  1374. return;
  1375. },
  1376. _onCancelProperties: function () {
  1377. if (this._firstRender == true) {
  1378. this.removeWidget();
  1379. }
  1380. },
  1381. removeWidget: function () {
  1382. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  1383. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  1384. chromeObject.widgetRemoveConfirmed();
  1385. },
  1386. _excludeList: ["copyright", "version"],
  1387. _getProps: function (asDialog) {
  1388. var results = {};
  1389. var names = this.iContext.getiWidgetAttributes().getAllNames();
  1390. for (var i = 0, l = names.length; i < l; i++) {
  1391. var name = names[i];
  1392. if (-1 != dojo.indexOf(this._excludeList, name)) {
  1393. // skip read-only attributes
  1394. // BUG: can't use enabler's isReadOnly() fails with a bizare javascript error.
  1395. continue;
  1396. }
  1397. var value = this.iContext.getiWidgetAttributes().getItemValue(name);
  1398. results[name] = (asDialog) ? {
  1399. value: value
  1400. } : value;
  1401. }
  1402. return results;
  1403. }
  1404. });