dimTree.js 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2017
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. /*******************************************************
  9. Dimension Tree
  10. A dimension tree can be created within any HTML container. The data for
  11. the dimension tree is taken from the dimCache (which will load the data if it is not there)
  12. The steps to creating a dimension tree are as follows:
  13. - Create a dimTree instance and pass in a reference to the HTML container.
  14. - Set the behaviours of the dimtree wich include:
  15. - Multi Select/Single Select: Allow only 1 selection or allow many
  16. - Wide Select/ Narrow Select: Select box style selection or windows explorer style selection
  17. - Must select (On/Off): Sets whether or not no selection is allowed.
  18. - Drag and Drop (On/Off): Sets whether categories can be dragged from the tree to other areas of the display.
  19. - Hiearchy Roots Selectable (On/Off): Sets whether hierarchy (Alternate Hierarchies, Custom Subsets) roots are selectable.
  20. - Measure Placeholders Disabled (On/Off): Sets whether the measure placeholders appear disabled and are not selectable.
  21. - Leaves Selectable (On/Off): Sets whether leaves can be selected.
  22. - Show Alternate Hierarchies (On/Off): Sets whether alternate hierarchies appear in the tree or not.
  23. - Show Custom subsets (On/Off): Sets whether custom subsets appear in the tree or not.
  24. - Tree selection type (can be changed while tree is displayed): Sets the selection display type
  25. - TREE_SELECTION_ITEM_ONLY: Only the selected item is highlighted, in dark blue.
  26. - TREE_SELECTION_CHILDREN: The selected item is highlighted in dark blue, and the immediate children are highlighted in light blue.
  27. - TREE_SELECTION_ALL_DESCENDANTS: The selected item is highlighted in dark blue, and all descendents are highlighted in light blue.
  28. - TREE_SELECTION_DESCENDENT_LEAVES: The selected item is highlighted in dark blue, and all leaves under the selected item are highlighted in light blue.
  29. - top item closable: Does the top item have a +/- control.
  30. - Call an initalization method to draw the tree. Initialization methods include:
  31. initCubeDimTree(): Creates a cube tree. The root of the tree is the cube, and the
  32. dimensions are children of the cube. The cube node is unselectable.
  33. initDimTree(dimIdx,isTopNodeActive): Creates a dimension tree where the top nod is the
  34. root of a particular dimension specified by dimIdx.
  35. isTopNodeActive specifies whether the dimension root is selectable.
  36. initDimSubTree(dimIdx, catCode, isTopNodeActive): Creates a dimension tree with the specified category with
  37. code catCode, as the root of the tree.
  38. The tree will be created with the following HTML structure:
  39. Each node in the tree has the following structure:
  40. <div>
  41. <img> //
  42. ... // Pre images for indenting and vertical lines
  43. <img> //
  44. <img> // Joint image (+,-)
  45. <img> // Data type image (Folder, File)
  46. <A>
  47. text Node //Text
  48. </A>
  49. </div>
  50. <div> //child div
  51. </div>
  52. Directly following each node's div is another div that contains all of the child
  53. nodes of this node, as well as their child divs. (Even leaves have child divs, which are
  54. empty, therefore node divs are always the even numbered children of a containing div and
  55. their child divs are always the odd numbered divs. Like so:
  56. <container>
  57. node div
  58. child div
  59. niode div
  60. child div
  61. ...
  62. node div
  63. child div
  64. </container>
  65. The only exception to this rule are temporary nodes (Loading..., More...) which have no child divs
  66. but always appear as the last child of the container.
  67. *******************************************************/
  68. var images = new Array();
  69. var dimCache = topparent.getGlobal("dimCache");
  70. var dimTrees = new Array();
  71. //Constants
  72. var IMAGE_BLANK = 0;
  73. var IMAGE_T = 1;
  74. var IMAGE_T_MINUS = 2;
  75. var IMAGE_T_PLUS = 3;
  76. var IMAGE_L = 4;
  77. var IMAGE_L_MINUS = 5;
  78. var IMAGE_L_PLUS = 6;
  79. var IMAGE_I = 7;
  80. var IMAGE_FOLDER = 8;
  81. var IMAGE_FOLDER_OPEN = 9;
  82. var IMAGE_FOLDER_DISABLED = 10;
  83. var IMAGE_FOLDER_DISABLED_OPEN = 11;
  84. var IMAGE_ALT_FOLDER = 12;
  85. var IMAGE_ALT_FOLDER_OPEN = 13;
  86. var IMAGE_ALT_FOLDER_DISABLED = 14;
  87. var IMAGE_ALT_FOLDER_DISABLED_OPEN = 15;
  88. var IMAGE_FILE = 16;
  89. var IMAGE_FILE_DISABLED = 17;
  90. var IMAGE_CALCULATED_FILE = 18;
  91. var IMAGE_CALCULATED_FILE_DISABLED = 19;
  92. var IMAGE_NONSEL_FOLDER = 20;
  93. var IMAGE_NONSEL_FOLDER_OPEN = 21;
  94. var IMAGE_NONSEL_FOLDER_DISABLED = 22;
  95. var IMAGE_NONSEL_FOLDER_DISABLED_OPEN = 23;
  96. var IMAGE_CS_FOLDER = 24;
  97. var IMAGE_CS_FOLDER_OPEN = 25;
  98. var IMAGE_CS_FOLDER_DISABLED = 26;
  99. var IMAGE_CS_FOLDER_DISABLED_OPEN = 27;
  100. var IMAGE_ALT_NONSEL_FOLDER = 28;
  101. var IMAGE_ALT_NONSEL_FOLDER_OPEN = 29;
  102. var IMAGE_ALT_NONSEL_FOLDER_DISABLED = 30;
  103. var IMAGE_ALT_NONSEL_FOLDER_DISABLED_OPEN = 31;
  104. var IMAGE_SEARCH_FOLDER = 32;
  105. var IMAGE_SEARCH_FOLDER_DISABLED = 33;
  106. var IMAGE_SEARCH_ALT_FOLDER = 34;
  107. var IMAGE_SEARCH_ALT_FOLDER_DISABLED = 35;
  108. var IMAGE_SEARCH_FILE = 36;
  109. var IMAGE_SEARCH_FILE_DISABLED = 37;
  110. var IMAGE_SEARCH_CALCULATED_FILE = 38;
  111. var IMAGE_SEARCH_CALCULATED_FILE_DISABLED = 39;
  112. var IMAGE_SEARCH_NONSEL_FOLDER = 40;
  113. var IMAGE_SEARCH_NONSEL_FOLDER_DISABLED = 41;
  114. var IMAGE_SEARCH_ALT_NONSEL_FOLDER = 42;
  115. var IMAGE_SEARCH_ALT_NONSEL_FOLDER_DIABLED = 43;
  116. var IMAGE_PACKAGE = 44;
  117. var IMAGE_LOADING = 45;
  118. var JOINT_T = 0;
  119. var JOINT_L = 1;
  120. var EXPAND_NONE = 0;
  121. var EXPAND_CLOSED = 2;
  122. var EXPAND_OPEN = 1;
  123. var FILE_REGULAR = 0;
  124. var FILE_CALCULATED = 1;
  125. var PARENT_TOP = 2;
  126. var PARENT_MAIN = 3;
  127. var PARENT_ALT = 4;
  128. var PARENT_NONSEL = 5;
  129. var PARENT_CS = 6;
  130. var PARENT_ALT_NONSEL = 7;
  131. var LOAD_ICON = 8;
  132. var DIMTREE_LOAD_DELAY = 100;
  133. var TREE_SELECTION_ITEM_ONLY = 0;
  134. var TREE_SELECTION_CHILDREN = 1;
  135. var TREE_SELECTION_ALL_DESCENDANTS = 2;
  136. var TREE_SELECTION_DESCENDENT_LEAVES = 3;
  137. var TREE_SELECTION_DESCENDENT_NON_LEAVES = 4;
  138. var SUBTREE_EMPTY = 0;
  139. var SUBTREE_LOADING = 1;
  140. var SUBTREE_NOT_EMPTY = 2;
  141. function initDimtree() {
  142. dTree = new dimTree(document.getElementById("dimTreeContainer"));
  143. dTree.setTreeDragAndDrop(true);
  144. dTree.initCubeDimTree();
  145. }
  146. function cleanupDimTree() {
  147. if (dTree)
  148. dTree.clearTreeContainer();
  149. }
  150. function deselectAll() {
  151. for (var i = 0; i < dimTrees.length;i++) {
  152. dimTrees[i].deselectAll();
  153. }
  154. }
  155. function preloadImages() {
  156. var path = topparent.getGlobal("sharedImgPath");
  157. images[IMAGE_BLANK] = new Image();
  158. images[IMAGE_BLANK].src = path + "blank.png";
  159. images[IMAGE_T] = new Image();
  160. images[IMAGE_T].src = path + "T.png";
  161. images[IMAGE_T_MINUS] = new Image();
  162. images[IMAGE_T_MINUS].src = path + "Tminus.png";
  163. images[IMAGE_T_PLUS] = new Image();
  164. images[IMAGE_T_PLUS].src = path + "Tplus.png";
  165. images[IMAGE_L] = new Image();
  166. images[IMAGE_L].src = path + "L.png";
  167. images[IMAGE_L_MINUS] = new Image();
  168. images[IMAGE_L_MINUS].src = path + "Lminus.png";
  169. images[IMAGE_L_PLUS] = new Image();
  170. images[IMAGE_L_PLUS].src = path + "Lplus.png";
  171. images[IMAGE_I] = new Image();
  172. images[IMAGE_I].src = path + "I.png";
  173. images[IMAGE_FOLDER] = new Image();
  174. images[IMAGE_FOLDER].src = path + "foldericon.png";
  175. images[IMAGE_FOLDER_OPEN] = new Image();
  176. images[IMAGE_FOLDER_OPEN].src = path + "openfoldericon.png";
  177. images[IMAGE_FOLDER_DISABLED] = new Image();
  178. images[IMAGE_FOLDER_DISABLED].src = path + "foldericon_no.png";
  179. images[IMAGE_FOLDER_DISABLED_OPEN] = new Image();
  180. images[IMAGE_FOLDER_DISABLED_OPEN].src = path + "openfoldericon_no.png";
  181. images[IMAGE_ALT_FOLDER] = new Image();
  182. images[IMAGE_ALT_FOLDER].src = path + "alternate_drill.png";
  183. images[IMAGE_ALT_FOLDER_OPEN] = new Image();
  184. images[IMAGE_ALT_FOLDER_OPEN].src = path + "alternate_drill_open.png";
  185. images[IMAGE_ALT_FOLDER_DISABLED] = new Image();
  186. images[IMAGE_ALT_FOLDER_DISABLED].src = path + "alternate_drill_no.png";
  187. images[IMAGE_ALT_FOLDER_DISABLED_OPEN] = new Image();
  188. images[IMAGE_ALT_FOLDER_DISABLED_OPEN].src = path + "alternate_drill_open_no.png";
  189. images[IMAGE_FILE] = new Image();
  190. images[IMAGE_FILE].src = path + "file.png";
  191. images[IMAGE_FILE_DISABLED] = new Image();
  192. images[IMAGE_FILE_DISABLED].src = path + "file_no.png";
  193. images[IMAGE_CALCULATED_FILE] = new Image();
  194. images[IMAGE_CALCULATED_FILE].src = path + "calculated.gif";
  195. images[IMAGE_CALCULATED_FILE_DISABLED] = new Image();
  196. images[IMAGE_CALCULATED_FILE_DISABLED].src = path + "calculate_no.gif";
  197. images[IMAGE_NONSEL_FOLDER] = new Image();
  198. images[IMAGE_NONSEL_FOLDER].src = path + "scenario.gif";
  199. images[IMAGE_NONSEL_FOLDER_OPEN] = new Image();
  200. images[IMAGE_NONSEL_FOLDER_OPEN].src = path + "scenario_open.gif";
  201. images[IMAGE_NONSEL_FOLDER_DISABLED] = new Image();
  202. images[IMAGE_NONSEL_FOLDER_DISABLED].src = path + "scenario_no.gif";
  203. images[IMAGE_NONSEL_FOLDER_DISABLED_OPEN] = new Image();
  204. images[IMAGE_NONSEL_FOLDER_DISABLED_OPEN].src = path + "scenario_open_no.gif";
  205. images[IMAGE_CS_FOLDER] = new Image();
  206. images[IMAGE_CS_FOLDER].src = path + "custom_subset_folder.gif";
  207. images[IMAGE_CS_FOLDER_OPEN] = new Image();
  208. images[IMAGE_CS_FOLDER_OPEN].src = path + "custom_subset_folder_open.gif";
  209. images[IMAGE_CS_FOLDER_DISABLED] = new Image();
  210. images[IMAGE_CS_FOLDER_DISABLED].src = path + "custom_subset_folder_no.gif";
  211. images[IMAGE_CS_FOLDER_DISABLED_OPEN] = new Image();
  212. images[IMAGE_CS_FOLDER_DISABLED_OPEN].src = path + "custom_subset_folder_open_no.gif";
  213. images[IMAGE_ALT_NONSEL_FOLDER] = new Image();
  214. images[IMAGE_ALT_NONSEL_FOLDER].src = path + "alternate_scenario.gif";
  215. images[IMAGE_ALT_NONSEL_FOLDER_OPEN] = new Image();
  216. images[IMAGE_ALT_NONSEL_FOLDER_OPEN].src = path + "alternate_scenario_open.gif";
  217. images[IMAGE_ALT_NONSEL_FOLDER_DISABLED] = new Image();
  218. images[IMAGE_ALT_NONSEL_FOLDER_DISABLED].src = path + "alternate_scenario_dis.gif";
  219. images[IMAGE_ALT_NONSEL_FOLDER_DISABLED_OPEN] = new Image();
  220. images[IMAGE_ALT_NONSEL_FOLDER_DISABLED_OPEN].src = path + "alternate_scenario_open_dis.gif";
  221. images[IMAGE_SEARCH_FOLDER] = new Image();
  222. images[IMAGE_SEARCH_FOLDER].src = path + "search_folder.gif";
  223. images[IMAGE_SEARCH_FOLDER_DISABLED] = new Image();
  224. images[IMAGE_SEARCH_FOLDER_DISABLED].src = path + "search_folder_no.gif";
  225. // images[IMAGE_SEARCH_ALT_FOLDER] = new Image();
  226. // images[IMAGE_SEARCH_ALT_FOLDER].src = path + "search_alternate_drill.gif";
  227. // images[IMAGE_SEARCH_ALT_FOLDER_DISABLED] = new Image();
  228. // images[IMAGE_SEARCH_ALT_FOLDER_DISABLED].src = path + "search_alternate_drill_no.gif";
  229. images[IMAGE_SEARCH_FILE] = new Image();
  230. images[IMAGE_SEARCH_FILE].src = path + "search_categories.gif";
  231. images[IMAGE_SEARCH_FILE_DISABLED] = new Image();
  232. images[IMAGE_SEARCH_FILE_DISABLED].src = path + "search_categories_no.gif";
  233. images[IMAGE_SEARCH_CALCULATED_FILE] = new Image();
  234. images[IMAGE_SEARCH_CALCULATED_FILE].src = path + "search_calculated.gif";
  235. images[IMAGE_SEARCH_CALCULATED_FILE_DISABLED] = new Image();
  236. images[IMAGE_SEARCH_CALCULATED_FILE_DISABLED].src = path + "search_calculated_no.gif";
  237. images[IMAGE_SEARCH_NONSEL_FOLDER] = new Image();
  238. images[IMAGE_SEARCH_NONSEL_FOLDER].src = path + "search_scenario.gif";
  239. images[IMAGE_SEARCH_NONSEL_FOLDER_DISABLED] = new Image();
  240. images[IMAGE_SEARCH_NONSEL_FOLDER_DISABLED].src = path + "search_scenario_no.gif";
  241. // images[IMAGE_SEARCH_ALT_NONSEL_FOLDER] = new Image();
  242. // images[IMAGE_SEARCH_ALT_NONSEL_FOLDER].src = path + "alternate_scenario_search.gif";
  243. // images[IMAGE_SEARCH_ALT_NONSEL_FOLDER_DIABLED] = new Image();
  244. // images[IMAGE_SEARCH_ALT_NONSEL_FOLDER_DIABLED].src = path + "alternate_scenario_search_dis.gif";
  245. images[IMAGE_PACKAGE] = new Image();
  246. images[IMAGE_PACKAGE].src = path + "package.gif";
  247. images[IMAGE_LOADING] = new Image();
  248. images[IMAGE_LOADING].src = path + "tree_loading.gif";
  249. }
  250. //Dimtree Class
  251. function dimTree(treeContainer) {
  252. preloadImages();
  253. var topNodeActive = false;
  254. var enabledRootPath = null;
  255. //Options
  256. var treemultiSelect = false;
  257. this.setTreeMultiSelect = function(val) {
  258. treemultiSelect = val;
  259. }
  260. this.getTreeMultiSelect = function() {
  261. return treemultiSelect;
  262. }
  263. var treeWideSelect = false;
  264. this.setTreeWideSelect = function(val) {
  265. treeWideSelect = val;
  266. }
  267. this.getTreeWideSelect = function() {
  268. return treeWideSelect;
  269. }
  270. var treeMustSelect = false;
  271. this.setTreeMustSelect = function(val) {
  272. treeMustSelect = val;
  273. }
  274. this.getTreeMustSelect = function() {
  275. return treeMustSelect;
  276. }
  277. var treeDragAndDrop = false;
  278. this.setTreeDragAndDrop = function(val) {
  279. treeDragAndDrop = val;
  280. }
  281. this.getTreeDragAndDrop = function() {
  282. return treeDragAndDrop;
  283. }
  284. var treeHierRootsSelectable = true;
  285. this.setTreeHierRootsSelectable = function(val) {
  286. treeHierRootsSelectable = val;
  287. }
  288. this.getTreeHierRootsSelectable = function() {
  289. return treeHierRootsSelectable;
  290. }
  291. var treeMeasurePlaceholdersGrayText = false;
  292. this.setMeasurePlaceholdersGrayText = function(val) {
  293. treeMeasurePlaceholdersGrayText = val;
  294. }
  295. this.getMeasurePlaceholdersGrayText = function() {
  296. return treeMeasurePlaceholdersGrayText;
  297. }
  298. var leavesSelectable = true;
  299. this.setLeavesSelectable = function(val) {
  300. leavesSelectable = val;
  301. }
  302. this.getLeavesSelectable = function() {
  303. return leavesSelectable;
  304. }
  305. var treeShowAlternateHierarchies = true;
  306. this.setTreeShowAlternateHierarchies = function(val) {
  307. treeShowAlternateHierarchies = val;
  308. }
  309. this.getTreeShowAlternateHierarchies = function() {
  310. return treeShowAlternateHierarchies;
  311. }
  312. var treeShowCustomSubsets = true;
  313. this.setTreeShowCustomSubsets = function(val) {
  314. treeShowCustomSubsets = val;
  315. }
  316. this.getTreeShowCustomSubsets = function() {
  317. return treeShowCustomSubsets;
  318. }
  319. var treeSelectionType = TREE_SELECTION_ITEM_ONLY;
  320. this.setTreeSelectionType = function(val) {
  321. treeSelectionType = val;
  322. updateTreeSelection();
  323. }
  324. this.getTreeSelectionType = function() {
  325. return treeSelectionType;
  326. }
  327. var topItemClosable = false;
  328. this.setTopItemClosable = function(val) {
  329. topItemClosable = val;
  330. }
  331. this.getTopItemClosable = function() {
  332. return topItemClosable;
  333. }
  334. //Private Variables
  335. var timers = new Array();
  336. var loadingContainers = new Array();
  337. var itemCache = new Array();
  338. var numSubtreesLoading = 0;
  339. var selectedItems = new Array();
  340. var numSelected = 0;
  341. var treeContainer = treeContainer;
  342. var treeNum = 0;
  343. //Constructor***
  344. //add this as an entry in the dimTrees array, and record its index
  345. treeNum = dimTrees.length;
  346. dimTrees[treeNum] = this;
  347. //***
  348. //Methods
  349. function initCubeDimTree() {
  350. var childBox = createCubeNodeContent(treeContainer,cubeName);
  351. for (var i = 0; i < topparent.getGlobal("gDimensionInfo").length; i++) {
  352. createNodeContent(childBox,dimCache.getDimTopNode(i).getCode(),i,(i == (topparent.getGlobal("gDimensionInfo").length - 1)),true,true);
  353. }
  354. treeContainer.firstChild.setAttribute("topNode","true");
  355. }
  356. this.initCubeDimTree = initCubeDimTree;
  357. function initDimTree(dimIdx,isTopNodeActive) {
  358. topNodeActive = isTopNodeActive;
  359. createNodeContent(treeContainer,dimCache.getDimTopNode(dimIdx).getCode(),dimIdx,true,topNodeActive,true);
  360. expandItem(treeContainer.firstChild.firstChild);
  361. treeContainer.firstChild.setAttribute("topNode","true");
  362. }
  363. this.initDimTree = initDimTree;
  364. function initDimSubTree(dimIdx, catCode, isTopNodeActive) {
  365. //Assumes that the catCode given exists in the dimcache.
  366. topNodeActive = isTopNodeActive;
  367. createNodeContent(treeContainer,catCode,dimIdx,true,topNodeActive,true);
  368. expandItem(treeContainer.firstChild.firstChild);
  369. treeContainer.firstChild.setAttribute("topNode","true");
  370. }
  371. this.initDimSubTree = initDimSubTree;
  372. function clearTreeContainer() {
  373. //This method can be used to clean out the container to display a new tree.
  374. //Or, it can and should be used to destruct the tree and prevent IE memory leaks.
  375. deselectAll();
  376. while(treeContainer.childNodes.length) {
  377. clearEventHandlers(treeContainer.childNodes[treeContainer.childNodes.length - 1]);
  378. treeContainer.removeChild(treeContainer.childNodes[treeContainer.childNodes.length - 1]);
  379. }
  380. }
  381. this.clearTreeContainer = clearTreeContainer;
  382. function clearEventHandlers(domNode) {
  383. if (domNode.ondragstart)
  384. domNode.ondragstart = null;
  385. if (domNode.onclick)
  386. domNode.onclick = null;
  387. if (domNode.onmouseover)
  388. domNode.onmouseover = null;
  389. if (domNode.onmouseout)
  390. domNode.onmouseout = null;
  391. if (domNode.oncontextmenu)
  392. domNode.oncontextmenu = null;
  393. for (var i = 0; i < domNode.childNodes.length; i++)
  394. clearEventHandlers(domNode.childNodes[i]);
  395. }
  396. /*****************************/
  397. /* Node creation Functions */
  398. function createCubeNodeContent(container,cubeName) {
  399. var div = document.createElement("DIV");
  400. div.className = "dimtree_item_div";
  401. //In IE, we need to force the DIV to 0 height to compress the white space
  402. if (document.all) {
  403. div.style.height = 0;
  404. }
  405. if (topItemClosable) {
  406. div.appendChild(createJoint(JOINT_L, EXPAND_OPEN));
  407. }
  408. div.appendChild(createIcon(PARENT_TOP, EXPAND_OPEN, true));
  409. div.appendChild(createTextNode(cubeName),true);
  410. div.setAttribute("expand",EXPAND_OPEN);
  411. container.appendChild(div);
  412. var childPreString = "";
  413. if (topItemClosable)
  414. childPreString = "0";
  415. var childBox = createChildrenBox(childPreString);
  416. childBox.className = "dimtree_content_div";
  417. childBox.setAttribute("subtree",SUBTREE_NOT_EMPTY);
  418. container.appendChild(childBox);
  419. return childBox;
  420. }
  421. function createNodeContent(parentDiv, code, dimIdx, last, active, enabled) {
  422. var catNode = dimCache.getCategory(dimIdx, code);
  423. var measurePlaceholder = (treeMeasurePlaceholdersGrayText && catNode.isMeasurePlaceholder());
  424. var div = document.createElement("DIV");
  425. if (treeSelectionType == TREE_SELECTION_ITEM_ONLY || !catNode.isAlternateParent())
  426. div.className = "dimtree_item_div";
  427. else
  428. div.className = "dimtree_item_div_notTransparent";
  429. //In IE, we need to force the DIV to 0 height to compress the white space
  430. if (document.all) {
  431. div.style.height = 0;
  432. }
  433. div.setAttribute("code",code);
  434. div.setAttribute("dimIdx",dimIdx);
  435. div.setAttribute("ppdsId",catNode.getPPDSID());
  436. div.setAttribute("level",1);
  437. div.setAttribute("page",0);
  438. div.setAttribute("type","cm");
  439. if (catNode.isAlternateParent())
  440. div.setAttribute("isHierRoot","true");
  441. else
  442. div.setAttribute("isHierRoot","false");
  443. if (catNode.isCustomSubset())
  444. div.setAttribute("customSubset","true");
  445. else
  446. div.setAttribute("customSubset","false");
  447. if (catNode.isMeasurePlaceholder())
  448. div.setAttribute("measurePlaceholder","true");
  449. else
  450. div.setAttribute("measurePlaceholder","false");
  451. if (enabled)
  452. div.setAttribute("tndisabled","false");
  453. else
  454. div.setAttribute("tndisabled","true");
  455. var selectable = (active && !measurePlaceholder);
  456. if (!treeHierRootsSelectable && (catNode.isTopNode() || catNode.isAlternateParent()))
  457. selectable = false;
  458. if (!leavesSelectable && (catNode.isLeaf()))
  459. selectable = false;
  460. if (selectable)
  461. div.setAttribute("selectable","true");
  462. else
  463. div.setAttribute("selectable","false");
  464. var prevCode = "";
  465. if (parentDiv.getAttribute("prevCode") != null)
  466. prevCode = parentDiv.getAttribute("prevCode");
  467. addNodePreImages(prevCode, div);
  468. var expand = catNode.isLeaf()? EXPAND_NONE : EXPAND_CLOSED;
  469. div.setAttribute("expand",expand);
  470. var joint = last? JOINT_L : JOINT_T;
  471. var itemtype;
  472. if (catNode.isCustomSubset())
  473. itemtype = PARENT_CS;
  474. else if (catNode.isLeaf())
  475. if (catNode.isCalculated())
  476. itemtype = FILE_CALCULATED;
  477. else
  478. itemtype = FILE_REGULAR;
  479. else
  480. if (catNode.isAlternateParent()) {
  481. if (catNode.isNonSelectable())
  482. itemtype = PARENT_ALT_NONSEL
  483. else
  484. itemtype = PARENT_ALT;
  485. } else {
  486. if (catNode.isNonSelectable())
  487. itemtype = PARENT_NONSEL;
  488. else
  489. itemtype = PARENT_MAIN;
  490. }
  491. div.appendChild(createJoint(joint, expand));
  492. var showenabled = enabled || catNode.isTopNode() || catNode.isAlternateParent();
  493. var icon = createIcon(itemtype, expand, showenabled);
  494. if (active && treeDragAndDrop) {
  495. icon.ondragstart = function(event) {
  496. dragStart(event, this, treeNum);
  497. }
  498. icon.onclick = function(event) {
  499. click(event, this.nextSibling, treeNum);
  500. }
  501. }
  502. if (selectable && !treeWideSelect) {
  503. icon.onmouseover = function() {
  504. return mouseover(this.nextSibling, treeNum);
  505. }
  506. icon.onmouseout = function() {
  507. return mouseout(this.nextSibling, treeNum);
  508. }
  509. if ( !topparent.getGlobal("safari") )
  510. {
  511. icon.oncontextmenu = function(event) {
  512. contextmenu(event, this.nextSibling, treeNum);
  513. }
  514. }
  515. else
  516. {
  517. if ( icon.onclick != null )
  518. icon.onclick = function(event) {
  519. ctrlclickPlusClick(event, this.nextSibling, treeNum);
  520. }
  521. else
  522. icon.onclick = function(event) {
  523. ctrlclickNOclick(event, this.nextSibling, treeNum);
  524. }
  525. }
  526. }
  527. div.appendChild(icon);
  528. var hiddenForm;
  529. if (topparent.getXtabFrame())
  530. hiddenForm = topparent.getXtabFrame().document.fhidden;
  531. var nodeText = catNode.getLabel();
  532. if( hiddenForm && hiddenForm.SHN != "undefined" && hiddenForm.SHN != null && hiddenForm.SHN.value == 1)
  533. nodeText = catNode.getFullName();
  534. var textNode = createTextNode(nodeText,(showenabled && !measurePlaceholder));
  535. if (selectable && !treeWideSelect) {
  536. textNode.onmouseover = function() {
  537. return mouseover(this, treeNum);
  538. }
  539. textNode.onmouseout = function() {
  540. return mouseout(this, treeNum);
  541. }
  542. textNode.onclick = function(event) {
  543. click(event, this, treeNum);
  544. }
  545. }
  546. if (active && treeDragAndDrop) {
  547. textNode.ondragstart = function(event) {
  548. dragStart(event, this, treeNum);
  549. }
  550. if ( !topparent.getGlobal("safari") )
  551. {
  552. textNode.oncontextmenu = function(event) {
  553. contextmenu(event, this, treeNum);
  554. }
  555. }
  556. else
  557. {
  558. if ( icon.onclick != null )
  559. textNode.onclick = function(event) {
  560. ctrlclickPlusClick(event, this, treeNum);
  561. }
  562. else
  563. textNode.onclick = function(event) {
  564. ctrlclickNOclick(event, this, treeNum);
  565. }
  566. }
  567. }
  568. if (selectable && treeWideSelect) {
  569. div.onmouseover = function() {
  570. return mouseover(this, treeNum);
  571. }
  572. div.onmouseout = function() {
  573. return mouseout(this, treeNum);
  574. }
  575. div.onclick = function(event) {
  576. click(event, this, treeNum);
  577. }
  578. }
  579. div.appendChild(textNode);
  580. parentDiv.appendChild(div);
  581. prevCode += last? "0" : "1";
  582. parentDiv.appendChild(createChildrenBox(prevCode, dimIdx));
  583. }
  584. function createLoadNode(parentDiv) {
  585. var div = document.createElement("DIV");
  586. div.className = "dimtree_item_div_notTransparent";
  587. addNodePreImages(parentDiv.getAttribute("prevCode"), div);
  588. div.appendChild(createJoint(JOINT_L, EXPAND_NONE));
  589. div.appendChild(createIcon(LOAD_ICON, EXPAND_NONE, true));
  590. div.appendChild(createTextNode(topparent.getGlobal("gLoadingText"),true));
  591. div.setAttribute("textNode","true");
  592. parentDiv.appendChild(div);
  593. }
  594. function createMoreNode(parentDiv, dimIdx, code, nextItem) {
  595. var div = document.createElement("DIV");
  596. div.className = "dimtree_item_div_notTransparent";
  597. div.setAttribute("nextItem",nextItem);
  598. div.setAttribute("code",code);
  599. div.setAttribute("dimIdx",dimIdx);
  600. div.setAttribute("more","true");
  601. div.setAttribute("textNode","true");
  602. addNodePreImages(parentDiv.getAttribute("prevCode"), div);
  603. div.appendChild(createJoint(JOINT_L, EXPAND_CLOSED));
  604. div.appendChild(createTextNode(topparent.getGlobal("gMoreText"),true));
  605. parentDiv.appendChild(div);
  606. }
  607. function addNodePreImages(prevCode, div) {
  608. //Adds either blank images or I nodes before the content according to the prevCode (0 = blank, 1 = I node).
  609. var pCode = prevCode;
  610. for (var i = 0; i < pCode.length; i++) {
  611. var imgSrc = images[IMAGE_BLANK].src;
  612. if (pCode.charAt(i) == "1")
  613. imgSrc = images[IMAGE_I].src;
  614. insertIMGNode(div, imgSrc, "dimtree_icon", []);
  615. }
  616. }
  617. function createIcon(type, expand, enabled) {
  618. var span = document.createElement("SPAN");
  619. span.setAttribute("iconType",type);
  620. span.setAttribute("enabled",(enabled)? "true" :"false");
  621. if (type == PARENT_TOP)
  622. insertIMGNode(span, images[getIconImageIdx(type, expand, enabled)].src, "dimtree_package_item", []);
  623. else
  624. insertIMGNode(span, images[getIconImageIdx(type, expand, enabled)].src, "dimtree_folder_icon", []);
  625. return span;
  626. }
  627. function getIconImageIdx(type, expand, enabled) {
  628. var imgIdx;
  629. switch (type) {
  630. case FILE_REGULAR: imgIdx = IMAGE_FILE; break;
  631. case FILE_CALCULATED: imgIdx = IMAGE_CALCULATED_FILE; break;
  632. case PARENT_TOP: imgIdx = IMAGE_PACKAGE; break;
  633. case PARENT_MAIN: imgIdx = IMAGE_FOLDER; break;
  634. case PARENT_ALT: imgIdx = IMAGE_ALT_FOLDER; break;
  635. case PARENT_CS: imgIdx = IMAGE_CS_FOLDER; break;
  636. case PARENT_NONSEL: imgIdx = IMAGE_NONSEL_FOLDER; break;
  637. case PARENT_ALT_NONSEL: imgIdx = IMAGE_ALT_NONSEL_FOLDER; break;
  638. case LOAD_ICON: imgIdx = IMAGE_LOADING; break;
  639. }
  640. if ((type == PARENT_MAIN || type == PARENT_ALT || type == PARENT_CS|| type == PARENT_NONSEL || type == PARENT_ALT_NONSEL) && expand == EXPAND_OPEN)
  641. imgIdx++;
  642. if (!enabled)
  643. if (type == FILE_REGULAR || type == FILE_CALCULATED)
  644. imgIdx++;
  645. else
  646. imgIdx += 2;
  647. return imgIdx;
  648. }
  649. function createJoint(type, expand) {
  650. var span = document.createElement("SPAN");
  651. span.setAttribute("jointType",type);
  652. if (expand == EXPAND_OPEN)
  653. span.onclick = function(event) {
  654. colapseNode(event, treeNum);
  655. }
  656. if (expand == EXPAND_CLOSED)
  657. span.onclick = function(event) {
  658. expandNode(event, treeNum);
  659. }
  660. insertIMGNode(span, images[getJointImageIdx(type, expand)].src, "dimtree_icon", []);
  661. return span;
  662. }
  663. function getJointImageIdx(type, expand) {
  664. var imgIdx = (type == JOINT_T)? IMAGE_T: IMAGE_L;
  665. imgIdx += expand;
  666. return imgIdx;
  667. }
  668. function createTextNode(text,enabled) {
  669. var link = document.createElement("A");
  670. if (enabled != false)
  671. link.className = "dimtree_text";
  672. else
  673. link.className = "dimtree_text_disabled";
  674. link.href = "#";
  675. link.appendChild(document.createTextNode(text));
  676. return link;
  677. }
  678. function createChildrenBox(prevCode, dimIdx) {
  679. var div = document.createElement("DIV");
  680. div.className = "dimtree_content_div_hidden";
  681. //In IE, we need to force the DIV to 0 height to compress the white space
  682. if (document.all) {
  683. div.style.height = 0;
  684. }
  685. div.setAttribute("prevCode",prevCode);
  686. div.setAttribute("subtree",SUBTREE_EMPTY);
  687. return div;
  688. }
  689. /*****************************/
  690. /* Node Action Functions */
  691. function expandItem(item) {
  692. var hasMore = (item.parentNode.getAttribute("more") == "true");
  693. if (hasMore) {
  694. loadItemChildren(item);
  695. } else {
  696. loadChildren(item);
  697. setJointType(item);
  698. setFolderIcon(item);
  699. setJointActions(item);
  700. setChildClass(item);
  701. }
  702. }
  703. this.expandItem = expandItem;
  704. function loadChildren(item) {
  705. var childDiv = getChildDiv(item);
  706. if (parseInt(childDiv.getAttribute("subtree")) == SUBTREE_EMPTY) {
  707. loadTreeChildren(item, childDiv, parseInt(item.parentNode.getAttribute("dimIdx")), item.parentNode.getAttribute("code"), 0);
  708. }
  709. }
  710. function setChildClass(item) {
  711. var childDiv = getChildDiv(item);
  712. if (childDiv.children.length > 0) {
  713. if (notSelectAllDescendents() || notSelected(item)) {
  714. if ( selectItemsOnly() || parentIsNotHierarchyRoot(item)) {
  715. childDiv.className = "dimtree_content_div";
  716. } else {
  717. childDiv.className = "dimtree_content_div_notTransparent";
  718. }
  719. } else {
  720. childDiv.className = "dimtree_content_div_childselect";
  721. }
  722. } else {
  723. childDiv.className = "dimtree_content_div_hidden";
  724. }
  725. }
  726. function parentIsNotHierarchyRoot(item) {
  727. return (item.parentNode.getAttribute("isHierRoot") != "true");
  728. }
  729. function selectItemsOnly() {
  730. return (treeSelectionType == TREE_SELECTION_ITEM_ONLY);
  731. }
  732. function notSelected(item) {
  733. return (item.parentNode.getAttribute("selected") != "true");
  734. }
  735. function notSelectAllDescendents() {
  736. return (treeSelectionType != TREE_SELECTION_ALL_DESCENDANTS);
  737. }
  738. function getChildDiv(item) {
  739. return item.parentNode.nextSibling;
  740. }
  741. function loadItemChildren(item) {
  742. var moreDiv = item.parentNode;
  743. var moreDivParent = moreDiv.parentNode;
  744. var dimIdx = moreDiv.getAttribute("dimIdx");
  745. var code = moreDiv.getAttribute("code");
  746. var nextItem = moreDiv.getAttribute("nextItem");
  747. loadTreeChildren( item, moreDivParent, parseInt(dimIdx), code, parseInt(nextItem));
  748. }
  749. function setJointType(item) {
  750. var childDiv = getChildDiv(item);
  751. var jointImgIdx;
  752. if (childDiv.children.length > 0) {
  753. jointImgIdx = getJointImageIdx(parseInt(item.getAttribute("jointType")),EXPAND_OPEN);
  754. } else {
  755. jointImgIdx = getJointImageIdx(parseInt(item.getAttribute("jointType")),EXPAND_NONE); // No children = nothing to expand!
  756. }
  757. var theSrc = images[jointImgIdx].src;
  758. if (item.firstChild.src) {
  759. item.firstChild.src = theSrc;
  760. } else {
  761. item.firstChild.setAttribute("theSrc", theSrc);
  762. }
  763. }
  764. function setFolderIcon(item) {
  765. var nextObj = item.nextSibling;
  766. var iconType = nextObj.getAttribute("iconType");
  767. var isEnabled = (nextObj.getAttribute("enabled") == "true");
  768. var iconImageIdx = getIconImageIdx(parseInt(iconType),EXPAND_OPEN, isEnabled);
  769. var theSrc = images[iconImageIdx].src;
  770. if (nextObj.firstChild.src) {
  771. nextObj.firstChild.src = theSrc;
  772. } else {
  773. nextObj.firstChild.setAttribute("theSrc", theSrc);
  774. }
  775. }
  776. function setJointActions(item) {
  777. var childDiv = getChildDiv(item);
  778. if (childDiv.children.length > 0) {
  779. item.onclick = function(event) { colapseNode(event, treeNum); }
  780. item.parentNode.setAttribute("expand", EXPAND_OPEN);
  781. } else {
  782. item.onclick = function(event) {}
  783. item.parentNode.setAttribute("expand", EXPAND_NONE);
  784. }
  785. }
  786. function colapseItem(item) {
  787. nextObj = item.nextSibling;
  788. item.parentNode.setAttribute("expand",EXPAND_CLOSED);
  789. item.firstChild.src = images[getJointImageIdx(parseInt(item.getAttribute("jointType")),EXPAND_CLOSED)].src;
  790. nextObj.firstChild.src = images[getIconImageIdx(parseInt(nextObj.getAttribute("iconType")),EXPAND_CLOSED,nextObj.getAttribute("enabled") == "true")].src;
  791. item.onclick = function(event) { expandNode(event, treeNum); }
  792. var childDiv = item.parentNode.nextSibling;
  793. childDiv.className = "dimtree_content_div_hidden";
  794. }
  795. this.colapseItem = colapseItem;
  796. function loadTreeChildren(item, div, dimIdx, code, firstItem) {
  797. var catNode = dimCache.getCategory(dimIdx, code);
  798. if (firstItem) {
  799. //remove the more...
  800. removeLastText(div);
  801. var node = div.childNodes[div.childNodes.length - 2];
  802. changeJointType(node, JOINT_T, node.getAttribute("expand"));
  803. }
  804. itemCache[code] = item;
  805. if (catNode.childrenLoaded(firstItem)) {
  806. populateTreeChildren(div, dimIdx, code, firstItem);
  807. } else {
  808. div.setAttribute("subtree",SUBTREE_LOADING);
  809. createLoadNode(div);
  810. loadingContainers[code] = div;
  811. timers[code] = setInterval("dimTrees[" + treeNum + "].checkTreeLoaded(" + dimIdx + ",'" + code + "'," + firstItem + ")",DIMTREE_LOAD_DELAY);
  812. numSubtreesLoading++;
  813. catNode.loadChildren();
  814. }
  815. }
  816. function populateTreeChildren(div, dimIdx, code, firstItem) {
  817. var catNode = dimCache.getCategory(dimIdx, code);
  818. var more;
  819. if (treeShowCustomSubsets)
  820. more = (catNode.getNumChildrenLoaded() > firstItem + parseInt(topparent.getGlobal("childLimit")) || !catNode.allChildrenLoaded());
  821. else
  822. more = (catNode.getNumChildrenLoaded() > firstItem + parseInt(topparent.getGlobal("childLimit")) || !catNode.allNonCustomSubsetsLoaded());
  823. var catNodes = catNode.getChildren();
  824. if (catNodes.length > 0) {
  825. for (var i = firstItem; i < (firstItem + parseInt(topparent.getGlobal("childLimit"))) && i < catNodes.length; i++) {
  826. if ((treeShowAlternateHierarchies || !dimCache.getCategory(dimIdx, catNodes[i]).isAlternateParent()) &&
  827. (treeShowCustomSubsets || !dimCache.getCategory(dimIdx, catNodes[i]).isCustomSubset())) {
  828. //Check to see if the parent is enabled or is the root of the enabled hierarchy
  829. var enabled = ((enabledRootPath == null) || matchPaths(createPath(div.previousSibling),enabledRootPath) || (div.previousSibling.getAttribute("tndisabled") == "false"));
  830. createNodeContent(div,catNodes[i],dimIdx,((i == catNodes.length - 1) && !more),true,enabled);
  831. } else if ((i == catNodes.length - 1) && !more && div.childNodes.length) {
  832. //we don't show this one, so we have to update the last shown node's joint type to an L.
  833. var node = div.childNodes[div.childNodes.length - 2];
  834. changeJointType(node, JOINT_L, node.getAttribute("expand"));
  835. }
  836. }
  837. div.setAttribute("subtree",SUBTREE_NOT_EMPTY);
  838. updateTreeSelection();
  839. if (more) {
  840. createMoreNode(div, dimIdx, code, firstItem + parseInt(topparent.getGlobal("childLimit")));
  841. }
  842. } else {
  843. var item = itemCache[code];
  844. setJointType(item);
  845. setFolderIcon(item);
  846. setJointActions(item);
  847. setChildClass(item);
  848. itemCache[code] = null;
  849. }
  850. }
  851. function checkTreeLoaded(dimIdx, code, firstItem) {
  852. if (dimCache.getCategory(dimIdx, code).childrenLoaded(firstItem)) {
  853. clearInterval(timers[code]);
  854. if (loadingContainers[code]) {
  855. removeLastText(loadingContainers[code]);
  856. populateTreeChildren(loadingContainers[code], dimIdx, code, firstItem);
  857. loadingContainers[code] = null;
  858. numSubtreesLoading--;
  859. }
  860. }
  861. }
  862. this.checkTreeLoaded = checkTreeLoaded;
  863. function removeLastText(container) {
  864. if (container.lastChild.getAttribute("textNode") == "true")
  865. container.removeChild(container.lastChild);
  866. }
  867. function selectItem(item, ctrlPressed) {
  868. if (item.parentNode.getAttribute("selected") == "true" && ctrlPressed && (!treeMustSelect || numSelected > 1)) {
  869. setItemUnselected(item);
  870. if (treeDragAndDrop)
  871. topparent.getGlobal("dndManager").cancelDrag();
  872. } else {
  873. if ((!treemultiSelect || !ctrlPressed) && numSelected)
  874. deselectAll();
  875. setItemSelected(item);
  876. if (treeDragAndDrop)
  877. topparent.getGlobal("dndManager").setCarry(item.parentNode);
  878. }
  879. }
  880. this.selectItem = selectItem;
  881. function setItemOnlySelected(item) {
  882. if (treeWideSelect)
  883. item.parentNode.className = "dimtree_item_div_selected";
  884. else
  885. if (item.className == "dimtree_text dimtree_text_rollover")
  886. item.className = "dimtree_text_selected dimtree_text_rollover";
  887. else
  888. item.className = "dimtree_text_selected";
  889. }
  890. function setItemOnlyUnselected(item) {
  891. if (treeWideSelect)
  892. item.parentNode.className = "dimtree_item_div";
  893. else
  894. if (item.className == "dimtree_text_selected dimtree_text_rollover")
  895. item.className = "dimtree_text dimtree_text_rollover";
  896. else
  897. item.className = "dimtree_text";
  898. }
  899. function setItemChildrenSelected(item) {
  900. setItemOnlySelected(item);
  901. if (item.parentNode.nextSibling.className != "dimtree_content_div_hidden")
  902. item.parentNode.nextSibling.className = "dimtree_content_div";
  903. //Assume that this option is only on when there is wide selection.
  904. var childDiv = item.parentNode.nextSibling;
  905. for (var i = 0; i < childDiv.childNodes.length; i += 2) {
  906. if (childDiv.childNodes[i].getAttribute("textNode") != "true") {
  907. if (childDiv.childNodes[i].getAttribute("selected") == "true")
  908. childDiv.childNodes[i].className = "dimtree_item_div_selected";
  909. else if (childDiv.childNodes[i].getAttribute("isHierRoot") != "true") {
  910. childDiv.childNodes[i].className = "dimtree_item_div_childselect";
  911. } else
  912. childDiv.childNodes[i].className = "dimtree_item_div_notTransparent";
  913. }
  914. }
  915. }
  916. function setItemChildrenUnselected(item) {
  917. setItemOnlyUnselected(item);
  918. //Assume that this option is only on when there is wide selection.
  919. var childDiv = item.parentNode.nextSibling;
  920. for (var i = 0; i < childDiv.childNodes.length; i += 2) {
  921. if (childDiv.childNodes[i].getAttribute("textNode") != "true") {
  922. if (childDiv.childNodes[i].getAttribute("selected") == "true")
  923. childDiv.childNodes[i].className = "dimtree_item_div_selected";
  924. else if (childDiv.childNodes[i].getAttribute("isHierRoot") != "true")
  925. childDiv.childNodes[i].className = "dimtree_item_div";
  926. else
  927. childDiv.childNodes[i].className = "dimtree_item_div_notTransparent";
  928. }
  929. }
  930. unselectChildDiv(item);
  931. }
  932. function setItemLeavesSelected(item) {
  933. setItemOnlySelected(item);
  934. if (item.parentNode.nextSibling.className != "dimtree_content_div_hidden")
  935. item.parentNode.nextSibling.className = "dimtree_content_div";
  936. //Assume that this option is only on when there is wide selection.
  937. setItemLeavesSelection(item.parentNode,true,false);
  938. }
  939. function setItemLeavesUnselected(item) {
  940. setItemOnlyUnselected(item);
  941. //Assume that this option is only on when there is wide selection.
  942. unselectChildDiv(item);
  943. setItemLeavesSelection(item.parentNode,false,false);
  944. }
  945. function setItemLeavesSelection(item, select, blankout) {
  946. var childDiv = item.nextSibling;
  947. for (var i = 0; i < childDiv.childNodes.length; i += 2) {
  948. if (childDiv.childNodes[i].getAttribute("textNode") != "true") {
  949. if (childDiv.childNodes[i].getAttribute("selected") == "true")
  950. childDiv.childNodes[i].className = "dimtree_item_div_selected";
  951. else if (childDiv.childNodes[i].getAttribute("isHierRoot") != "true") {
  952. if (childDiv.childNodes[i].getAttribute("expand") != EXPAND_NONE) { //Not a leaf
  953. if (parseInt(childDiv.childNodes[i + 1].getAttribute("subtree")) == SUBTREE_NOT_EMPTY) //There are children loaded
  954. setItemLeavesSelection(childDiv.childNodes[i], select, blankout);
  955. } else if (select) {
  956. if (blankout)
  957. childDiv.childNodes[i].className = "dimtree_item_div_notTransparent";
  958. else
  959. childDiv.childNodes[i].className = "dimtree_item_div_childselect";
  960. } else {
  961. childDiv.childNodes[i].className = "dimtree_item_div";
  962. }
  963. }
  964. }
  965. }
  966. }
  967. function setItemNonLeavesSelected(item) {
  968. setItemOnlySelected(item);
  969. if (item.parentNode.nextSibling.className != "dimtree_content_div_hidden")
  970. item.parentNode.nextSibling.className = "dimtree_content_div_childselect";
  971. setItemLeavesSelection(item.parentNode,true,true);
  972. }
  973. function setItemNonLeavesUnselected(item) {
  974. setItemOnlyUnselected(item);
  975. unselectChildDiv(item);
  976. setItemLeavesSelection(item.parentNode,false,true);
  977. }
  978. function setItemAllDescendentsSelected(item) {
  979. setItemOnlySelected(item);
  980. if (item.parentNode.nextSibling.className != "dimtree_content_div_hidden")
  981. item.parentNode.nextSibling.className = "dimtree_content_div_childselect";
  982. }
  983. function setItemAllDescendentsUnselected(item) {
  984. setItemOnlyUnselected(item);
  985. unselectChildDiv(item);
  986. }
  987. function unselectChildDiv(item) {
  988. if (item.parentNode.nextSibling.className != "dimtree_content_div_hidden") {
  989. if (item.parentNode.getAttribute("isHierRoot") != "true")
  990. item.parentNode.nextSibling.className = "dimtree_content_div";
  991. else {
  992. item.parentNode.nextSibling.className = "dimtree_content_div_notTransparent";
  993. }
  994. }
  995. }
  996. function removeItemFromSelectionList(item) {
  997. var found = false;
  998. for (var i = 0; i < numSelected; i++) {
  999. if (!found && selectedItems[i] == item)
  1000. found = true;
  1001. if (found) {
  1002. if (i == numSelected - 1) {
  1003. numSelected--;
  1004. } else
  1005. selectedItems[i] = selectedItems[i + 1];
  1006. }
  1007. }
  1008. }
  1009. function deselectAll() {
  1010. for (var i = numSelected - 1; i >= 0; i--) {
  1011. setItemUnselected(selectedItems[i]);
  1012. }
  1013. if (topparent.getGlobal("dndManager") && topparent.getGlobal("dndManager").isCarrying)
  1014. topparent.getGlobal("dndManager").cancelDrag();
  1015. }
  1016. this.deselectAll = deselectAll;
  1017. this.numTreeItemsSelected = function() {
  1018. return numSelected;
  1019. }
  1020. this.getTreeSelectedItem = function(idx) {
  1021. if (idx == null)
  1022. return selectedItems[0];
  1023. else if (idx >= 0 && idx < numSelected)
  1024. return selectedItems[idx];
  1025. else
  1026. return null;
  1027. }
  1028. function updateTreeSelection() {
  1029. for (var i = 0; i < numSelected; i++) {
  1030. setItemSelected(selectedItems[i]);
  1031. }
  1032. }
  1033. function setItemSelected(item) {
  1034. //if the item is not selected, add it to the array.
  1035. if (item.parentNode.getAttribute("selected") != "true") {
  1036. item.parentNode.setAttribute("selected","true");
  1037. selectedItems[numSelected] = item;
  1038. numSelected++;
  1039. }
  1040. var needUpdate = (parseInt(item.parentNode.getAttribute("selectionType")) != treeSelectionType);
  1041. if (needUpdate) {
  1042. switch (parseInt(item.parentNode.getAttribute("selectionType"))) {
  1043. case TREE_SELECTION_ITEM_ONLY: setItemOnlyUnselected(item); break;
  1044. case TREE_SELECTION_CHILDREN: setItemChildrenUnselected(item); break;
  1045. case TREE_SELECTION_ALL_DESCENDANTS: setItemAllDescendentsUnselected(item); break;
  1046. case TREE_SELECTION_DESCENDENT_LEAVES: setItemLeavesUnselected(item); break;
  1047. case TREE_SELECTION_DESCENDENT_NON_LEAVES: setItemNonLeavesUnselected(item); break;
  1048. }
  1049. }
  1050. switch (treeSelectionType) {
  1051. case TREE_SELECTION_ITEM_ONLY: setItemOnlySelected(item); break;
  1052. case TREE_SELECTION_CHILDREN: setItemChildrenSelected(item); break;
  1053. case TREE_SELECTION_ALL_DESCENDANTS: setItemAllDescendentsSelected(item); break;
  1054. case TREE_SELECTION_DESCENDENT_LEAVES: setItemLeavesSelected(item); break;
  1055. case TREE_SELECTION_DESCENDENT_NON_LEAVES: setItemNonLeavesSelected(item); break;
  1056. }
  1057. item.parentNode.setAttribute("selectionType",treeSelectionType);
  1058. }
  1059. function setItemUnselected(item) {
  1060. if (item.parentNode.getAttribute("selected") == "true") {
  1061. item.parentNode.setAttribute("selected","false");
  1062. removeItemFromSelectionList(item);
  1063. }
  1064. switch (parseInt(item.parentNode.getAttribute("selectionType"))) {
  1065. case TREE_SELECTION_ITEM_ONLY: setItemOnlyUnselected(item); break;
  1066. case TREE_SELECTION_CHILDREN: setItemChildrenUnselected(item); break;
  1067. case TREE_SELECTION_ALL_DESCENDANTS: setItemAllDescendentsUnselected(item); break;
  1068. case TREE_SELECTION_DESCENDENT_LEAVES: setItemLeavesUnselected(item); break;
  1069. case TREE_SELECTION_DESCENDENT_NON_LEAVES: setItemNonLeavesUnselected(item); break;
  1070. }
  1071. item.parentNode.setAttribute("selectionType",-1);
  1072. }
  1073. function resetTreeToTop() {
  1074. deselectAll();
  1075. var dimIdx = treeContainer.firstChild.getAttribute("dimIdx");
  1076. clearTreeContainer();
  1077. if (dimIdx == null) {
  1078. initCubeDimTree();
  1079. } else {
  1080. initDimTree(dimIdx,topNodeActive);
  1081. }
  1082. }
  1083. this.resetTreeToTop = resetTreeToTop;
  1084. function resetTree() {
  1085. deselectAll();
  1086. var dimIdx = treeContainer.firstChild.getAttribute("dimIdx");
  1087. var code = treeContainer.firstChild.getAttribute("code");
  1088. clearTreeContainer();
  1089. if (dimIdx == null) {
  1090. initCubeDimTree();
  1091. } else {
  1092. initDimSubTree(dimIdx,code,topNodeActive);
  1093. }
  1094. }
  1095. this.resetTree = resetTree;
  1096. this.setTreeToCat = function(dimIdx, catCode) {
  1097. //First Construct the path back to the root of the tree using the dimcache.
  1098. //The path will be constructed as a list of codes working backwards from the selected node.
  1099. //if the dimcache is currently loading, then we will wait until it is done
  1100. if (dimCache.isLoading() || numSubtreesLoading) {
  1101. setTimeout("dimTrees[" + treeNum + "].setTreeToCat(" + dimIdx + ",\"" + catCode + "\");",DIMTREE_LOAD_DELAY);
  1102. return;
  1103. }
  1104. //Assumes that this category is in the cache
  1105. var cat = dimCache.getCategory(dimIdx ,catCode);
  1106. deselectAll();
  1107. var path = new Array();
  1108. var parent;
  1109. var siblings;
  1110. var idx;
  1111. while (!cat.isTopNode() && cat.getCode() != treeContainer.firstChild.getAttribute("code")) {
  1112. path[path.length] = cat.getCode();
  1113. cat = dimCache.getCategory(dimIdx ,cat.getParent());
  1114. }
  1115. //Start at the root and loop
  1116. var div = treeContainer.firstChild;
  1117. if (div.getAttribute("dimIdx") == null) {
  1118. //Cube node so find the next node, it will be the dimension node that matches the last node in the path
  1119. var dims = div.nextSibling.childNodes;
  1120. for (var i = 0; i < dims.length; i += 2) {
  1121. if (dims[i].getAttribute("dimIdx") == dimIdx)
  1122. div = dims[i];
  1123. }
  1124. }
  1125. var ctr = path.length - 1;
  1126. //Loop through the path and expand the node at each step.
  1127. while (ctr != -1) {
  1128. expandItem(div.childNodes[div.childNodes.length - 3]);
  1129. var dims = div.nextSibling.childNodes;
  1130. for (var i = 0; i < dims.length; i += 2) {
  1131. if (dims[i].getAttribute("code") == path[ctr])
  1132. div = dims[i];
  1133. }
  1134. ctr--;
  1135. }
  1136. //Select the last one.
  1137. selectItem(div.childNodes[div.childNodes.length - 1],null);
  1138. }
  1139. this.selectFirstChildOfRoot = function() {
  1140. var RETRY_TIMEOUT = 100;
  1141. var topNode = treeContainer.firstChild;
  1142. if (parseInt(topNode.nextSibling.getAttribute("subtree")) != SUBTREE_NOT_EMPTY) {
  1143. setTimeout("dimTrees[" + treeNum + "].selectFirstChildOfRoot();", RETRY_TIMEOUT);
  1144. return;
  1145. }
  1146. selectItem(topNode.nextSibling.firstChild.childNodes[3],false);
  1147. }
  1148. this.selectRoot = function() {
  1149. selectItem(treeContainer.firstChild.childNodes[2],false);
  1150. }
  1151. this.selectionInSameHierarchy = function() {
  1152. if (selectedItems.length) {
  1153. var path = getHierarchyRootsPath(selectedItems[0].parentNode);
  1154. for (var i = 1; i < numSelected; i++) {
  1155. if (!matchPaths(path,getHierarchyRootsPath(selectedItems[i].parentNode)))
  1156. return false;
  1157. }
  1158. }
  1159. return true;
  1160. }
  1161. function getHierarchyRootsPath(node) {
  1162. while (!dimCache.getCategory(parseInt(node.getAttribute("dimIdx")),node.getAttribute("code")).isAlternateParent() &&
  1163. !dimCache.getCategory(parseInt(node.getAttribute("dimIdx")),node.getAttribute("code")).isTopNode()) {
  1164. node = node.parentNode.previousSibling;
  1165. }
  1166. return createPath(node);
  1167. }
  1168. this.getHierarchyRootsPath = getHierarchyRootsPath;
  1169. function createPath(node) {
  1170. var path = new Array();
  1171. while (node.getAttribute("topNode") != "true") {
  1172. path[path.length] = node.getAttribute("code");
  1173. node = node.parentNode.previousSibling;
  1174. }
  1175. path[path.length] = node.getAttribute("code");
  1176. return path;
  1177. }
  1178. function matchPaths(path1,path2) {
  1179. if (path1.length != path2.length)
  1180. return false;
  1181. for (var i = 0; i < path1.length; i++) {
  1182. if (path1[i] != path2[i])
  1183. return false;
  1184. }
  1185. return true;
  1186. }
  1187. //Used to enable the child categories of only 1 hierarchy in the tree.
  1188. this.setEnabledRootNode = function(path) {
  1189. enabledRootPath = path;
  1190. if (path == null)
  1191. enableAllTreeNodes();
  1192. //Work backwards down the path to find the node
  1193. var enabledRootNode = treeContainer.firstChild;
  1194. for (var i = path.length - 2; i >= 0; i--) {
  1195. //Find the child of the previous node with the correct code
  1196. var child = enabledRootNode.nextSibling.firstChild;
  1197. if (!child)
  1198. return;
  1199. while (child.getAttribute("code") != path[i]) {
  1200. if (!child.nextSibling || !child.nextSibling.nextSibling)
  1201. return;
  1202. child = child.nextSibling.nextSibling;
  1203. }
  1204. enabledRootNode = child;
  1205. }
  1206. refreshTreeNodeEnabling(treeContainer.firstChild,treeContainer.firstChild == enabledRootNode);
  1207. }
  1208. function enableAllTreeNodes() {
  1209. enabledRootPath = null;
  1210. refreshTreeNodeEnabling(treeContainer.firstChild,true);
  1211. }
  1212. this.enableAllTreeNodes = enableAllTreeNodes;
  1213. function refreshTreeNodeEnabling(node,enabled) {
  1214. if (node.getAttribute("textNode") == "true") //Could be a loading or more node.
  1215. return;
  1216. var cat = dimCache.getCategory(parseInt(node.getAttribute("dimIdx")),node.getAttribute("code"));
  1217. var childrenEnabled = enabled;
  1218. if (cat.isTopNode() || cat.isAlternateParent()) { //We have a hierarchy parent
  1219. setEnabled(node,(enabledRootPath == null || cat.isTopNode()));
  1220. if (enabledRootPath == null || matchPaths(createPath(node),enabledRootPath)) { //all children are enabled
  1221. childrenEnabled = true;
  1222. } else {
  1223. childrenEnabled = false;
  1224. }
  1225. } else {
  1226. setEnabled(node,enabled);
  1227. }
  1228. var dims = node.nextSibling.childNodes;
  1229. for (var i = 0;i < dims.length; i += 2) {
  1230. refreshTreeNodeEnabling(dims[i],childrenEnabled);
  1231. }
  1232. }
  1233. function setEnabled(node,enabled) {
  1234. var icon = node.childNodes[node.childNodes.length - 2];
  1235. if (enabled)
  1236. node.setAttribute("tndisabled","false");
  1237. else
  1238. node.setAttribute("tndisabled","true");
  1239. if (enabled || node.getAttribute("isHierRoot") == "true") {
  1240. node.childNodes[node.childNodes.length - 1].className = "dimtree_text";
  1241. icon.setAttribute("enabled","true");
  1242. } else {
  1243. node.childNodes[node.childNodes.length - 1].className = "dimtree_text_disabled";
  1244. icon.setAttribute("enabled","false");
  1245. }
  1246. icon.firstChild.src = images[getIconImageIdx(parseInt(icon.getAttribute("iconType")),parseInt(icon.parentNode.getAttribute("expand")),(enabled || node.getAttribute("isHierRoot") == "true"))].src;
  1247. }
  1248. //Should only be used on cube trees.
  1249. this.loadNewDimensionChildren = function(dimIdx) {
  1250. var node = treeContainer.childNodes[1].childNodes[parseInt(dimIdx) * 2]; //Get the dimension root node
  1251. var dimTopCatNode = dimCache.getDimTopNode(parseInt(dimIdx));
  1252. //Only if all the children have been loaded and are in the tree, do we load the new children.
  1253. if (node.nextSibling.childNodes.length && node.nextSibling.lastChild.getAttribute("more") != "true") {
  1254. loadTreeChildren(treeContainer.firstChild.firstChild,node.nextSibling,parseInt(dimIdx),dimTopCatNode.getCode(),dimTopCatNode.getNumChildrenLoaded());
  1255. }
  1256. }
  1257. //Should only be used on cube trees.
  1258. //Assume that existing items can only be deleted, or renamed.
  1259. this.updateDimensionChildren = function(dimIdx) {
  1260. var nodesChildren = treeContainer.childNodes[1].childNodes[parseInt(dimIdx) * 2 + 1]; //Get the dimension root node
  1261. var dimTopCatNode = dimCache.getDimTopNode(parseInt(dimIdx));
  1262. var treeChildrenIdx = 0;
  1263. var dimCacheChildrenIdx = 0;
  1264. while (nodesChildren.childNodes.length > (treeChildrenIdx * 2)) {
  1265. //(treeChildrenIdx * 2) because there are two divs for each child
  1266. //The first for the actual child, and the second for its children.
  1267. if (nodesChildren.childNodes[treeChildrenIdx * 2].getAttribute("code") == dimTopCatNode.getChildren()[dimCacheChildrenIdx]) {
  1268. var node = nodesChildren.childNodes[treeChildrenIdx * 2];
  1269. var cat = dimCache.getCategory(dimIdx, dimTopCatNode.getChildren()[dimCacheChildrenIdx]);
  1270. //Check if the name has changed
  1271. if (node.childNodes[node.childNodes.length - 1].firstChild.nodeValue != cat.getLabel()) {
  1272. node.childNodes[node.childNodes.length - 1].firstChild.nodeValue = cat.getLabel();
  1273. }
  1274. //Check if the children have changed (we can do this the easy way, as we only have 1 tree that stays around).
  1275. //Easy Way: check if we have no children in the dimcache, if so then repopulate the kids.
  1276. var childDiv = node.nextSibling;
  1277. if (!cat.getNumChildrenLoaded()) {
  1278. if (!cat.isLeaf()) {
  1279. //Ensure that the node has the correct joint type
  1280. if (parseInt(node.getAttribute("expand")) == EXPAND_NONE)
  1281. changeJointType(node, getJointType(node), EXPAND_CLOSED);
  1282. //clear the nodes children
  1283. clearChildDiv(node);
  1284. //If the node is expanded, reload the children
  1285. if (node.getAttribute("expand") == EXPAND_OPEN) {
  1286. loadTreeChildren(treeContainer.firstChild.firstChild,childDiv,parseInt(node.getAttribute("dimIdx")),node.getAttribute("code"),0);
  1287. }
  1288. } else {
  1289. //Ensure that the node has the correct joint type
  1290. if (parseInt(node.getAttribute("expand")) != EXPAND_NONE)
  1291. changeJointType(node, getJointType(node), EXPAND_NONE);
  1292. //clear the nodes children
  1293. clearChildDiv(node);
  1294. node.nextSibling.className = "dimtree_content_div_hidden";
  1295. }
  1296. }
  1297. dimCacheChildrenIdx++;
  1298. treeChildrenIdx++;
  1299. } else { //Node deleted
  1300. var node = nodesChildren.childNodes[treeChildrenIdx * 2];
  1301. var childDiv = nodesChildren.childNodes[(treeChildrenIdx * 2) + 1];
  1302. nodesChildren.removeChild(node);
  1303. nodesChildren.removeChild(childDiv);
  1304. //Update the joints in the tree.
  1305. if (treeChildrenIdx * 2 == nodesChildren.childNodes.length) {
  1306. var prevNode = nodesChildren.childNodes[(treeChildrenIdx - 1) * 2];
  1307. changeJointType(prevNode, JOINT_L, prevNode.getAttribute("expand"));
  1308. }
  1309. }
  1310. }
  1311. }
  1312. function changeJointType(node, jointType, expand) {
  1313. var joint = node.childNodes[node.childNodes.length - 3];
  1314. node.setAttribute("expand", expand);
  1315. joint.firstChild.src = images[getJointImageIdx(jointType, parseInt(expand))].src;
  1316. joint.setAttribute("jointType",jointType);
  1317. if (parseInt(expand) == EXPAND_OPEN) {
  1318. joint.onclick = function(event) { colapseNode(event, treeNum); }
  1319. } else if (parseInt(expand) == EXPAND_CLOSED) {
  1320. joint.onclick = function(event) { expandNode(event, treeNum); }
  1321. } else {
  1322. joint.onclick = "";
  1323. }
  1324. changePrevCodeBit(node, parseInt(node.childNodes.length - 3), (jointType == JOINT_T)? 1 : 0);
  1325. }
  1326. function clearChildDiv(node) {
  1327. var childDiv = node.nextSibling;
  1328. while(childDiv.childNodes.length) {
  1329. childDiv.removeChild(childDiv.lastChild);
  1330. }
  1331. childDiv.setAttribute("subtree",SUBTREE_EMPTY);
  1332. }
  1333. function getJointType(node) {
  1334. return node.childNodes[node.childNodes.length - 3].getAttribute("jointType");
  1335. }
  1336. function changePrevCodeBit(node, pos, bit) {
  1337. var childDiv = node.nextSibling;
  1338. var prevCode = childDiv.getAttribute("prevCode");
  1339. var newPrevCode = prevCode;
  1340. if (prevCode.length > pos) {
  1341. newPrevCode = prevCode.substr(0,pos) + bit + prevCode.substr(pos + 1);
  1342. }
  1343. if (prevCode.length - 1 > pos) {
  1344. node.childNodes[pos].src = images[(bit? IMAGE_I : IMAGE_BLANK)].src;
  1345. }
  1346. childDiv.setAttribute("prevCode",newPrevCode);
  1347. for (var i = 0; i < childDiv.childNodes.length; i += 2) {
  1348. changePrevCodeBit(childDiv.childNodes[i], pos, bit);
  1349. }
  1350. }
  1351. }
  1352. //*********************
  1353. //Event handlers
  1354. function dragStart(event, item, treeNum) {
  1355. if (item.getAttribute("tndisabled") == "true")
  1356. return;
  1357. var rs = "@";
  1358. var parentId = 0;
  1359. var parentNode = item.parentNode.parentNode.previousSibling;
  1360. if (parentNode.getAttribute("dimIdx") == item.parentNode.getAttribute("dimIdx"))
  1361. parentId = parentNode.getAttribute("ppdsId");
  1362. topparent.getGlobal("dndManager").setDrag("dim" + rs + item.parentNode.getAttribute("dimIdx") + rs + "level" + rs + "1" + rs + "ppds_id" + rs + item.parentNode.getAttribute("ppdsId") + rs + "code" + rs + item.parentNode.getAttribute("code") + rs + "parentId" + rs + parentId);
  1363. //Get the hierarchy root of the dragged category
  1364. var catNode = dimCache.getCategory(item.parentNode.getAttribute("dimIdx"),item.parentNode.getAttribute("code"));
  1365. catNode = dimCache.getCategory(item.parentNode.getAttribute("dimIdx"),catNode.findHierarchyRoot());
  1366. topparent.getGlobal("dndManager").setHierRootOfDraggedCategory(catNode.getPPDSID());
  1367. event = event || window.event;
  1368. var eventM = new eventManager(event);
  1369. eventM.theEvent.dataTransfer.effectAllowed="all";
  1370. }
  1371. function mouseover(item, treeNum) {
  1372. if (item.getAttribute("tndisabled") == "true")
  1373. return;
  1374. if (!dimTrees[treeNum].getTreeWideSelect()) {
  1375. if (item.className == "dimtree_text_selected")
  1376. item.className = "dimtree_text_selected dimtree_text_rollover";
  1377. else
  1378. item.className = "dimtree_text dimtree_text_rollover";
  1379. setStatus(item.parentNode);
  1380. }
  1381. return true;
  1382. }
  1383. function mouseout(item, treeNum) {
  1384. if (item.getAttribute("tndisabled") == "true")
  1385. return;
  1386. if (!dimTrees[treeNum].getTreeWideSelect()) {
  1387. if (item.className == "dimtree_text_selected dimtree_text_rollover")
  1388. item.className = "dimtree_text_selected";
  1389. else
  1390. item.className = "dimtree_text";
  1391. window.status = "";
  1392. }
  1393. return true;
  1394. }
  1395. function contextmenu(event, item, treeNum) {
  1396. if (item.getAttribute("tndisabled") == "true")
  1397. return;
  1398. var eventM = new eventManager(event);
  1399. eventM.preventDefault();
  1400. contextMenu(event, item);
  1401. }
  1402. function ctrlclickPlusClick(event, item, treeNum) {
  1403. if ( event != null && event["altKey"] )
  1404. {
  1405. contextmenu(event, item, treeNum);
  1406. }
  1407. click(event, item, treeNum);
  1408. }
  1409. function ctrlclickNOclick(event, item, treeNum) {
  1410. if ( event != null && event["altKey"] )
  1411. {
  1412. contextmenu(event, item, treeNum);
  1413. }
  1414. }
  1415. function click(event, item, treeNum) {
  1416. if (item.getAttribute("tndisabled") == "true")
  1417. return;
  1418. var eventM = new eventManager(event);
  1419. eventM.cancelBubble();
  1420. topparent.executeCrossFrameFunction ( 'hidePopupMenu', '', true);
  1421. if (dimTrees[treeNum].getTreeWideSelect())
  1422. dimTrees[treeNum].selectItem(item.childNodes[item.childNodes.length - 1],(topparent.getGlobal("MacGecko"))? eventM.theEvent.altKey : eventM.theEvent.ctrlKey);
  1423. else
  1424. dimTrees[treeNum].selectItem(item,(topparent.getGlobal("MacGecko"))? eventM.theEvent.altKey : eventM.theEvent.ctrlKey);
  1425. }
  1426. function expandNode(event, treeNum) {
  1427. //change the icons
  1428. var eventM = new eventManager(event);
  1429. eventM.cancelBubble();
  1430. topparent.executeCrossFrameFunction ( 'hidePopupMenu', '', true);
  1431. var sourceObj = eventM.getSrc().parentNode;
  1432. if (topparent.getXtabFrame())
  1433. dimTrees[treeNum].expandItem(sourceObj)
  1434. }
  1435. function colapseNode(event, treeNum) {
  1436. //change the icons
  1437. var eventM = new eventManager(event);
  1438. eventM.cancelBubble();
  1439. topparent.executeCrossFrameFunction ( 'hidePopupMenu', '', true);
  1440. var sourceObj = eventM.getSrc().parentNode;
  1441. dimTrees[treeNum].colapseItem(sourceObj);
  1442. }
  1443. function setStatus(item) {
  1444. var hiddenForm;
  1445. if (topparent.getXtabFrame())
  1446. hiddenForm = topparent.getXtabFrame().document.fhidden;
  1447. if( hiddenForm && hiddenForm.SHN != "undefined" && hiddenForm.SHN != null && hiddenForm.SHN.value == 1)
  1448. window.status = dimCache.getCategory(item.getAttribute("dimIdx"), item.getAttribute("code")).getFullName();
  1449. else
  1450. window.status = dimCache.getCategory(item.getAttribute("dimIdx"), item.getAttribute("code")).getLabel();
  1451. return true;
  1452. }
  1453. function toggleNames(useShortName) {
  1454. //get all <a> nodes
  1455. var nodes = document.getElementsByTagName("a");
  1456. for (var i = 0; i < nodes.length; i++){
  1457. //we care only about <a> nodes that contain ppdsId attribute,
  1458. //since those are ones with category info
  1459. if(nodes[i].parentNode.getAttribute("ppdsId") != null && nodes[i].parentNode.getAttribute("ppdsId") != "undefined"){
  1460. nodes[i].removeChild(nodes[i].firstChild);
  1461. if (useShortName) {
  1462. nodes[i].appendChild(document.createTextNode(dimCache.getCategory(parseInt(nodes[i].parentNode.getAttribute("dimIdx")),nodes[i].parentNode.getAttribute("code")).getFullName()));
  1463. } else {
  1464. nodes[i].appendChild(document.createTextNode(dimCache.getCategory(parseInt(nodes[i].parentNode.getAttribute("dimIdx")),nodes[i].parentNode.getAttribute("code")).getLabel()));
  1465. }
  1466. }
  1467. }
  1468. }