G_UIPE.js 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276
  1. /*
  2. IBM Confidential
  3. OCO Source Materials
  4. IBM Cognos Products: uipe
  5. (C) Copyright IBM Corp. 2014
  6. The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office.
  7. */
  8. var G_UIPE = {};
  9. G_UIPE.M_sProfileDTD = "../pat/profiles/rs_profile.dtd";
  10. G_UIPE.M_sProfileVersion = "http://www.ibm.com/xmlns/prod/ba/rs/rsprofile.1/";
  11. G_UIPE.F_SetInlineProfileDTD = function( v_sDTD )
  12. {
  13. this.m_sInlineProfileDTD = '<!DOCTYPE RSProfile [\r\n' + v_sDTD + '\r\n]>\r\n';
  14. };
  15. G_UIPE.F_GetInlineProfileDTD = function()
  16. {
  17. return this.m_sInlineProfileDTD;
  18. };
  19. G_UIPE.F_GetWebcontentURL = function()
  20. {
  21. if( this.m_sWebcontentURL )
  22. {
  23. return this.m_sWebcontentURL;
  24. }
  25. var v_doc = document;
  26. if( v_doc.domain )
  27. {
  28. var v_sURL = v_doc.location.href;
  29. // Compensate for URLs that didn't encode slashes
  30. var v_iQuestionMark = v_sURL.indexOf( "?" );
  31. if( v_iQuestionMark > 0 )
  32. {
  33. v_sURL = v_sURL.substring( 0, v_iQuestionMark );
  34. }
  35. var v_iSlash = v_sURL.lastIndexOf( "/" );
  36. if( v_iSlash > 0 )
  37. {
  38. v_sURL = v_sURL.substring( 0, v_iSlash );
  39. v_iSlash = v_sURL.lastIndexOf( "/" );
  40. if( v_iSlash > 0 )
  41. {
  42. v_sURL = v_sURL.substring( 0, v_iSlash );
  43. this.m_sWebcontentURL = v_sURL;
  44. return v_sURL;
  45. }
  46. }
  47. }
  48. // we should never get here
  49. this.m_sWebcontentURL = "";
  50. return this.m_sWebcontentURL;
  51. };
  52. G_UIPE.f_setGatewayURL = function( v_sURL )
  53. {
  54. if( v_sURL )
  55. {
  56. G_CCHL.M_sGatewayURL = v_sURL;
  57. }
  58. else
  59. {
  60. G_CCHL.M_sGatewayURL = this.m_sGateway ? this.m_sGateway : ( this.F_GetWebcontentURL() + "/cgi-bin/cognos.cgi" );
  61. }
  62. };
  63. G_UIPE.F_Init = function()
  64. {
  65. this.m_sProductLocale = g_UIPEParameters["uipe_productLocale"] || "en";
  66. this.m_sProfileStoreID = g_UIPEParameters["uipe_UIProfileStoreID"];
  67. this.m_sProfileName = g_UIPEParameters["uipe_UIProfileName"];
  68. this.m_sSkin = g_UIPEParameters["uipe_skin"];
  69. this.m_sGateway = g_UIPEParameters["ui.gateway"];
  70. this.f_setGatewayURL( "" );
  71. if( !this.m_sProfileStoreID && !this.m_sProfileName)
  72. {
  73. D_MsgBox.F_Show( null, G_ResManager.F_GetString( "IDS_UIPE_INVALID_PARAMETERS" ), G_ResManager.F_GetString( "IDS_UIPE_TITLE" ), D_MsgBox.K_iWarning );
  74. return;
  75. }
  76. G_CCHL.M_sProductLocale = this.m_sProductLocale;
  77. G_CCHL.M_sContentLocale = this.m_sProductLocale;
  78. G_ResManager.F_SetLocale( this.m_sProductLocale );
  79. this.f_sendResourceRequest();
  80. };
  81. G_UIPE.f_sendResourceRequest = function( )
  82. {
  83. var v_bUseCache = true;
  84. var v_sAppURL = this.F_GetAppURL();
  85. var v_aStringFiles = ["cchl/res/cchl_strings_not_localized.xml",
  86. "cchl/res/cchl_strings",
  87. "../pat/res/reportstudio_not_localized.xml",
  88. "../pat/res/reportstudio",
  89. "res/uipe_not_localized.xml",
  90. "res/uipe_strings"
  91. ];
  92. var v_oStringsRequest = new C_StringsRequest( null, v_aStringFiles, v_bUseCache );
  93. var v_aResFiles = ["res/uipeResources.xml", "res/uipe.xml", "../cchl/res/cchl_resources.xml", G_UIPE.M_sProfileDTD];
  94. var v_oResourcesRequest = new C_MultiFileRequest( null, v_aResFiles, null, v_bUseCache );
  95. var v_oStringsAndResourcesRequest = new C_MultiRequest( new C_RequestListenerRedirect( this, "f_onResourcesRequestComplete" ), [ v_oStringsRequest, v_oResourcesRequest ] );
  96. v_oStringsAndResourcesRequest.F_Send();
  97. };
  98. G_UIPE.f_onResourcesRequestComplete = function( v_oRequest )
  99. {
  100. var v_aRequests = v_oRequest.F_GetRequests();
  101. var v_oStringsRequest = v_aRequests[0];
  102. var v_oResourcesRequest = v_aRequests[1];
  103. var v_oError = v_oStringsRequest.F_GetError();
  104. if( v_oError )
  105. {
  106. C_Dialog.F_ShowDetailedMsgWindow( v_oError.F_GetErrorSummary(), "Failed to load strings", v_oError.F_GetErrorDetails(), D_MsgBox.K_iError );
  107. this.f_blankWindow();
  108. return;
  109. }
  110. var v_oError = v_oResourcesRequest.F_GetError();
  111. if( v_oError )
  112. {
  113. var v_oFileContents = v_oResourcesRequest.F_GetFileContents();
  114. var v_aFailed = [];
  115. for( var v_sFile in v_oFileContents )
  116. {
  117. if( this.M_oOptionalResFiles[v_sFile] )
  118. {
  119. // ignore failure if optional file does not exist
  120. }
  121. else if( v_oFileContents[v_sFile] === null )
  122. {
  123. v_aFailed.push( v_sFile );
  124. }
  125. }
  126. if( v_aFailed.length > 0 )
  127. {
  128. C_Dialog.F_ShowDetailedMsgWindow( v_oError.F_GetErrorSummary(), "Multi File Request Error", v_oError.F_GetErrorDetails(), D_MsgBox.K_iError );
  129. this.f_blankWindow();
  130. return;
  131. }
  132. }
  133. document.title = G_ResManager.F_GetString("IDS_UIPE_TITLE");
  134. document.getElementById("profileName").innerText = G_ResManager.F_GetString("IDS_UIPE_HEADER") + this.m_sProfileName;
  135. var v_oFileContents = v_oResourcesRequest.F_GetFileContents();
  136. this.f_processFileContents( v_oFileContents );
  137. if( !this.m_sProfileStoreID )
  138. {
  139. var v_oRequest = new C_UIProfileQueryRequest( new C_RequestListenerRedirect( this, "f_onQueryRequestComplete" ) );
  140. v_oRequest.F_Send();
  141. }else
  142. {
  143. setTimeout( this.f_loadProfile.F_CreateMethodCallback( this ), 0 );
  144. }
  145. };
  146. G_UIPE.f_onQueryRequestComplete = function( v_oRequest )
  147. {
  148. var v_oError = v_oRequest && v_oRequest.F_GetError();
  149. if( v_oError )
  150. {
  151. F_ShowError(v_oError);
  152. return;
  153. }
  154. if( this.m_sProfileName )
  155. {
  156. var v_oNameMap = v_oRequest.F_GetNameMap();
  157. if( v_oNameMap )
  158. {
  159. this.m_sProfileStoreID = v_oNameMap[this.m_sProfileName] || "";
  160. }
  161. }
  162. if( !this.m_sProfileStoreID )
  163. {
  164. D_MsgBox.F_Show( null, G_ResManager.F_GetString( "IDS_UIPE_PROFILE_NOT_FOUND_IN_CM" ), G_ResManager.F_GetString( "IDS_UIPE_TITLE" ), D_MsgBox.K_iWarning );
  165. }else
  166. {
  167. this.f_loadProfile();
  168. }
  169. };
  170. G_UIPE.f_loadProfile = function( )
  171. {
  172. // get profile content by this.m_sProfileStoreID
  173. var v_oRequest = new C_UIProfileLoadRequest( new C_RequestListenerRedirect( this, "f_onLoadRequestComplete" ), this.m_sProfileStoreID );
  174. v_oRequest.F_Send();
  175. };
  176. G_UIPE.f_onLoadRequestComplete = function( v_oRequest )
  177. {
  178. var v_oError = v_oRequest.F_GetError();
  179. if( v_oError )
  180. {
  181. F_DetailedMsgBox( v_oError.F_GetErrorSummary(), G_ResManager.F_GetString("IDS_UIPE_TITLE"), v_oError.F_GetErrorDetails(), v_oError.F_GetErrorCode(), D_MsgBox.K_iError );
  182. return;
  183. }
  184. this.m_nProfile = v_oRequest.F_GetUIProfile();
  185. G_UIPE.f_onInit();
  186. };
  187. G_UIPE.f_blankWindow = function()
  188. {
  189. document.body.innerText = "";
  190. };
  191. G_UIPE.f_onInit = function()
  192. {
  193. document.body.setAttribute( "aria-label", G_ResManager.F_GetString("IDS_UIPE_TITLE") );
  194. G_ResManager.F_ApplyResStrings( document.body );
  195. var v_nCheckAllView = G_ResManager.F_GetResource( "CheckAll" );
  196. this.m_oCheckAllListView = new C_ListView( document.getElementById( "divCheckAll" ), v_nCheckAllView, this );
  197. this.m_oCheckAllListView.F_GetContainer().setAttribute("aria-label", G_ResManager.F_GetString("IDS_AC_CHECK_ALL"));
  198. this.m_oCheckAllListView.F_Draw();
  199. var v_nAction = G_ResManager.F_GetResource( "Action" );
  200. this.m_oActionListView = new C_ListView( document.getElementById( "divAction" ), v_nAction, this );
  201. this.m_oActionListView.F_GetContainer().setAttribute("aria-label", G_ResManager.F_GetString("IDS_AC_ACTION"));
  202. this.m_oActionListView.F_Draw();
  203. this.f_initializeUI();
  204. };
  205. G_UIPE.f_initializeUI = function()
  206. {
  207. this.f_initNavTree();
  208. this.f_initAllDecks();
  209. var v_nTreeView = this.m_oNavigationTree.F_GetTreeViewNode();
  210. var v_nTreeNode = v_nTreeView.selectSingleNode( ".//treeNode[@value='toolbars']/*" );
  211. if( v_nTreeNode )
  212. {
  213. this.m_oNavigationTree.F_SelectNode( v_nTreeNode, false, true );
  214. this.f_updateActionListView( v_nTreeNode );
  215. }
  216. };
  217. G_UIPE.f_initNavTree = function()
  218. {
  219. var v_nNavTree = G_ResManager.F_GetResource( "NavigationTree" );
  220. this.f_initTreeNodes( v_nNavTree, "toolbars", "toolbar" );
  221. this.f_initTreeNodes( v_nNavTree, "tabControls", "tabControl" );
  222. this.f_initTreeNodes( v_nNavTree, "explorers", "explorer" );
  223. this.f_initTreeNodes( v_nNavTree, "chartGroups", "chartGroup" );
  224. this.f_initTreeNodes( v_nNavTree, "defaultSettings", "settingsGroup" );
  225. this.f_initTreeNodes( v_nNavTree, "toolboxes", "listView" );
  226. this.f_initTreeNodes( v_nNavTree, "listViews", "listView" );
  227. this.f_initMenubars( v_nNavTree );
  228. this.f_initMenuPopups( v_nNavTree );
  229. this.f_initPropertiesTree( v_nNavTree );
  230. this.f_initDialogsTreeNodes( v_nNavTree );
  231. this.m_oNavigationTree = new C_TreeView( document.getElementById("divNavigationTree"), v_nNavTree, this );
  232. };
  233. G_UIPE.f_initTreeNodes = function( v_nNavTree, v_sParentNodeName, v_sNodeName )
  234. {
  235. var doc = v_nNavTree.ownerDocument;
  236. var v_nFolder = v_nNavTree.selectSingleNode( ".//treeNode[@value='" + v_sParentNodeName + "']" );
  237. var v_nNodes = this.m_nStudioUIResources.selectSingleNode( v_sParentNodeName ).selectNodes( v_sNodeName );
  238. var v_iLength = v_nNodes.length;
  239. for( var i = 0; i < v_iLength; i++ )
  240. {
  241. var v_nNode = v_nNodes.item( i );
  242. var v_sNodeName = v_nNode.nodeName;
  243. var v_sNodeValue = ( v_sNodeName == "settingsGroup" ) ? v_nNode.getAttribute( "name" ) : v_nNode.getAttribute( "id" );
  244. var v_nNewTreeNode = v_nFolder.appendChild( doc.createElement( "treeNode" ) );
  245. v_nNewTreeNode.setAttribute( "nodeName", v_sNodeName );
  246. v_nNewTreeNode.setAttribute( "value", v_sNodeValue );
  247. this.f_copyAttributes( v_nNewTreeNode, v_nNode );
  248. }
  249. };
  250. G_UIPE.f_initLabels = function()
  251. {
  252. var v_nNodes = this.m_nStudioUIResources.selectNodes( ".//*[@idsLabel]" );
  253. for( var i = 0; i < v_nNodes.length; i++ )
  254. {
  255. var v_nNode = v_nNodes.item( i );
  256. var v_sIdsLabel = v_nNode.getAttribute( "idsLabel" );
  257. if( v_sIdsLabel != "" )
  258. {
  259. v_nNode.setAttribute( "label", G_ResManager.F_GetString( v_sIdsLabel ) );
  260. }
  261. }
  262. }
  263. G_UIPE.f_initPropertiesTree = function(v_nNavTree)
  264. {
  265. var doc = v_nNavTree.ownerDocument;
  266. var v_nPropertiesTreeNodes = v_nNavTree.selectSingleNode(".//treeNode[@value='properties']");
  267. var v_nPropertySheetSelection = this.m_nStudioUIResources.selectSingleNode("propertySheets").selectNodes("propertySheet");
  268. var v_iLength = v_nPropertySheetSelection.length;
  269. for( var i = 0; i < v_iLength; i++)
  270. {
  271. var v_nPropertySheet = v_nPropertySheetSelection.item(i);
  272. var v_sNodeName = v_nPropertySheet.nodeName;
  273. var v_nNewPropertySheetTreeNode = v_nPropertiesTreeNodes.appendChild(doc.createElement("treeNode"));
  274. v_nNewPropertySheetTreeNode.setAttribute("nodeName", v_nPropertySheet.nodeName);
  275. v_nNewPropertySheetTreeNode.setAttribute("value", v_nPropertySheet.getAttribute("id"));
  276. v_nNewPropertySheetTreeNode.setAttribute("expandable", "true");
  277. this.f_copyAttributes( v_nNewPropertySheetTreeNode, v_nPropertySheet );
  278. var v_nGroups = v_nPropertySheet.selectNodes(".//group");
  279. for( var j = 0; j < v_nGroups.length; j++)
  280. {
  281. var v_nGroup = v_nGroups.item(j);
  282. var v_sNodeName = v_nGroup.nodeName;
  283. var v_nNewGroupNode = v_nNewPropertySheetTreeNode.appendChild(doc.createElement("treeNode"));
  284. v_nNewGroupNode.setAttribute("nodeName", v_nGroup.nodeName);
  285. v_nNewGroupNode.setAttribute("value", v_nGroup.getAttribute("name"));
  286. this.f_copyAttributes( v_nNewGroupNode, v_nGroup );
  287. }
  288. }
  289. };
  290. G_UIPE.f_initDialogsTreeNodes = function( v_nNavTree )
  291. {
  292. var doc = v_nNavTree.ownerDocument;
  293. var v_nDialogsTreeNode = v_nNavTree.selectSingleNode( ".//treeNode[@value='dialogs']" );
  294. var v_nNodesSelection = this.m_nStudioUIResources.selectSingleNode( "dialogs" ).selectNodes( "dialog" );
  295. var v_iLength = v_nNodesSelection.length;
  296. for( var i = 0; i < v_iLength; i++ )
  297. {
  298. var v_nNode = v_nNodesSelection.item( i );
  299. var v_sNodeName = v_nNode.nodeName;
  300. var v_sNodeValue = v_nNode.getAttribute( "id" );
  301. var v_nNewNode = v_nDialogsTreeNode.appendChild( doc.createElement( "treeNode" ) );
  302. v_nNewNode.setAttribute( "nodeName", v_sNodeName );
  303. v_nNewNode.setAttribute( "value", v_sNodeValue );
  304. v_nNewNode.setAttribute( "expandable", "true" );
  305. this.f_copyAttributes( v_nNewNode, v_nNode );
  306. // find all child node for dialog, may include hideElements, menuPopups, listViews, menubars, toolbars, propertySheets, tabControls.
  307. var v_nChildNodeSelection = v_nNode.selectNodes( "./*" );
  308. for( var v_iChild = 0; v_iChild < v_nChildNodeSelection.length; v_iChild++ )
  309. {
  310. var v_nChildNode = v_nChildNodeSelection.item( v_iChild );
  311. var v_nNewChildNode = v_nNewNode.appendChild( doc.createElement( "treeNode" ) );
  312. v_nNewChildNode.setAttribute( "nodeName", v_nChildNode.nodeName );
  313. v_nNewChildNode.setAttribute( "value", v_nChildNode.parentNode.getAttribute( "id" ) + "_" + v_nChildNode.nodeName );
  314. // if child node has its own description then create it.
  315. if ( v_nChildNode.getAttribute( "idsDescription" ) )
  316. {
  317. U_XML.F_CopyAttribute( v_nNewChildNode, v_nChildNode, "idsDescription" );
  318. }
  319. this.f_copyAttributes( v_nNewChildNode, v_nChildNode );
  320. if( v_nChildNode.nodeName == "hideElements" )
  321. {
  322. continue;
  323. }
  324. v_nNewChildNode.setAttribute( "expandable", "true" );
  325. var v_nChildChildNodeSelection = v_nChildNode.selectNodes( "./*" );
  326. for( var v_iChildChild = 0; v_iChildChild < v_nChildChildNodeSelection.length; v_iChildChild++ )
  327. {
  328. var v_nChildChildNode = v_nChildChildNodeSelection.item( v_iChildChild );
  329. var v_nNewChildChildNode = v_nNewChildNode.appendChild( doc.createElement( "treeNode" ) );
  330. v_nNewChildChildNode.setAttribute( "nodeName", v_nChildChildNode.nodeName );
  331. v_nNewChildChildNode.setAttribute( "value", v_nChildChildNode.getAttribute( "id" ) );
  332. this.f_copyAttributes( v_nNewChildChildNode, v_nChildChildNode );
  333. }
  334. }
  335. }
  336. };
  337. G_UIPE.f_initAllDecks = function()
  338. {
  339. var v_nNavTreeView = this.m_oNavigationTree.F_GetTreeViewNode();
  340. var v_nlTreeNodes = v_nNavTreeView.selectNodes( "//treeNode" );
  341. var v_divDeckMain = document.getElementById( "deckMain" );
  342. var v_iLength = v_nlTreeNodes.length;
  343. this.m_oEditorViews = {};
  344. this.m_aDeckId = [];
  345. for( var i = 0; i < v_iLength; i++ )
  346. {
  347. var v_nTreeNode = v_nlTreeNodes.item( i );
  348. var v_sId = this.f_getTreeNodeId( v_nTreeNode );
  349. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  350. if( this.m_aDeckId.indexOf( v_sId ) == -1 )
  351. {
  352. this.m_aDeckId.push( v_sId );
  353. var v_divContent = v_divDeckMain.appendChild( document.createElement( "div" ) );
  354. v_divContent.id = "uipe_" + v_sId;
  355. var v_sLabel = v_nTreeNode.getAttribute( "idsLabel" );
  356. if ( v_sLabel )
  357. {
  358. v_divContent.setAttribute( "aria-label", G_ResManager.F_GetString( v_sLabel ) );
  359. }
  360. }
  361. // for properSheet and chartGroup, we need to create editor in the beginning instead of create them when user click node in the navigation tree
  362. if( v_sNodeName == "propertySheet" || v_sNodeName == "chartGroups" || v_sNodeName == "chartGroup" )
  363. {
  364. this.m_oEditorViews[v_sId] = this.f_createUIEditor( v_nTreeNode, v_divContent );
  365. }
  366. }
  367. this.m_oDeck = new C_Deck( v_divDeckMain, this );
  368. };
  369. G_UIPE.F_Deck_OnBeforeCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex )
  370. {
  371. var v_nCurrentTreeNode = this.m_nCurrentTreeNode;
  372. // skip "Loading" card so minus 1
  373. var v_sId = this.m_aDeckId[v_iNewCardIndex - 1];
  374. if ( !this.m_oEditorViews[v_sId] )
  375. {
  376. var v_divCard = document.getElementById( "uipe_" + v_sId );
  377. U_DOM.F_RemoveAllChildren( v_divCard );
  378. var v_sNodeName = v_nCurrentTreeNode.getAttribute( "nodeName" );
  379. var v_sTemplateId = v_nCurrentTreeNode.getAttribute( "refPopup" );
  380. if( v_sTemplateId )
  381. {
  382. if( !this.m_oEditorViews[v_sTemplateId] )
  383. {
  384. this.m_oEditorViews[v_sTemplateId] = this.f_createUIEditor( v_nCurrentTreeNode, v_divCard );
  385. }
  386. }
  387. else
  388. {
  389. this.m_oEditorViews[v_sId] = this.f_createUIEditor( v_nCurrentTreeNode, v_divCard );
  390. }
  391. }
  392. };
  393. G_UIPE.f_createBlankEditor = function( v_nTreeNode, v_divEditorView )
  394. {
  395. var v_sDescId = v_nTreeNode.getAttribute('idsDescription2') || v_nTreeNode.getAttribute('idsDescription');
  396. var v_sDesc = (v_sDescId) ? G_ResManager.F_GetString( v_sDescId ) : "Description goes here...";
  397. var v_divDescription = document.createElement('div');
  398. v_divDescription.style.width = "100%";
  399. v_divDescription.style.padding = "4px";
  400. v_divDescription.innerText = v_sDesc;
  401. v_divEditorView.appendChild( v_divDescription );
  402. v_nTreeNode.setAttribute( "blankView", "true" );
  403. return null;
  404. };
  405. G_UIPE.f_createHelpContentEditor = function( v_nTreeNode, v_divEditorView )
  406. {
  407. var v_tblContent = v_divEditorView.appendChild( document.createElement( "table" ) );
  408. v_tblContent.style.width = "298px";
  409. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  410. v_tblContent.setAttribute( "id", v_sNodeName );
  411. var v_sLabel = v_nTreeNode.getAttribute( "idsLabel" );
  412. if ( v_sLabel )
  413. {
  414. v_tblContent.setAttribute( "aria-label", G_ResManager.F_GetString( v_sLabel ) );
  415. }
  416. if( v_sNodeName == "helpContents" )
  417. {
  418. this.m_oHelpComboBoxEditor = new C_ComboBox( v_tblContent, null, G_ResManager.F_GetResource( "HelpContent" ), this );
  419. var v_nProfileNode = this.m_nProfile.selectSingleNode( ".//helpContents" );
  420. if( v_nProfileNode )
  421. {
  422. this.m_oHelpComboBoxEditor.F_SelectByValue( v_nProfileNode.selectSingleNode( "./ibmHelpContents" ).getAttribute( "type" ) );
  423. }
  424. else
  425. {
  426. // set default value "professional"
  427. this.m_oHelpComboBoxEditor.F_SelectByValue( "professional" );
  428. }
  429. this.m_sHelpComboBoxDefaultValue = this.m_oHelpComboBoxEditor.F_GetValue();
  430. return this.m_oHelpComboBoxEditor;
  431. }
  432. else if( v_sNodeName == "helpGettingStarted" )
  433. {
  434. this.m_oGettingStartComboBoxEditor = new C_ComboBox( v_tblContent, null, G_ResManager.F_GetResource( "HelpContent" ), this );
  435. var v_nProfileNode = this.m_nProfile.selectSingleNode( ".//helpGettingStarted" );
  436. if( v_nProfileNode )
  437. {
  438. this.m_oGettingStartComboBoxEditor.F_SelectByValue( v_nProfileNode.selectSingleNode( "./ibmHelpGettingStarted" ).getAttribute( "type" ) );
  439. }
  440. else
  441. {
  442. // set default value "professional"
  443. this.m_oGettingStartComboBoxEditor.F_SelectByValue( "professional" );
  444. }
  445. this.m_sGettingStartComboBoxDefaultValue = this.m_oGettingStartComboBoxEditor.F_GetValue();
  446. return this.m_oGettingStartComboBoxEditor;
  447. }
  448. return null;
  449. };
  450. G_UIPE.f_createSettingSheetEditor = function( v_nTreeNode, v_divEditorView )
  451. {
  452. var v_sName = v_nTreeNode.getAttribute( "value" );
  453. var v_nSettingGroup = this.m_nStudioUIResources.selectSingleNode( ".//settingsGroup[@name='" + v_sName + "']" );
  454. var v_oSettingsSheetEditor = new C_SettingSheet( v_divEditorView, v_nSettingGroup, this, document.body );
  455. var v_aGroupSettings = v_nSettingGroup.selectNodes( "./setting" );
  456. for( var i = 0; i < v_aGroupSettings.length; i++ )
  457. {
  458. var v_sSettingName = v_aGroupSettings.item( i ).getAttribute( "name" );
  459. var v_sValue = null;
  460. var v_nProfileSetting = this.m_nProfile.selectSingleNode( ".//setting[@name='" + v_sSettingName + "']" );
  461. if ( v_nProfileSetting )
  462. {
  463. v_sValue = v_nProfileSetting.getAttribute( "defaultValue" );
  464. }
  465. v_oSettingsSheetEditor.F_ShowSetting( v_sSettingName, v_sValue );
  466. }
  467. return v_oSettingsSheetEditor;
  468. };
  469. G_UIPE.f_createPropertiesEditor = function(v_nTreeNode, v_divEditorView)
  470. {
  471. var v_sID = v_nTreeNode.getAttribute("value");
  472. var v_nPropertyGroup = this.m_nStudioUIResources.selectSingleNode(".//group[@name='" + v_sID + "']");
  473. var v_sPropertySheetID = v_nPropertyGroup.parentNode.parentNode.getAttribute( "id" );
  474. var v_oPropertyEditor = new C_PropertyEditor( v_divEditorView, v_nPropertyGroup, this.m_nStudioUIResources.selectSingleNode( ".//objects" ), this.m_nStudioUIResources.selectSingleNode( ".//namedSets" ) );
  475. var v_nPropertyProfile = this.m_nProfile.selectSingleNode( ".//propertySheet[@id='" + v_sPropertySheetID + "']/propertyVisibility" );
  476. var v_sAction = "hide";
  477. var v_aProfiledPropertyNames = [];
  478. if( v_nPropertyProfile )
  479. {
  480. v_sAction = v_nPropertyProfile.getAttribute( "action" );
  481. v_aProfiledPropertyNames = U_XML.F_AppendValues( null, v_nPropertyProfile.selectNodes( ".//property/@name" ));
  482. v_nTreeNode.setAttribute( "actionValue", v_sAction );
  483. }
  484. var v_aUIPEPropertyNames = U_XML.F_AppendValues( null, v_nPropertyGroup.selectNodes( ".//property/@name" ));
  485. var v_aCheckedPropertyNames = this.f_buildCheckedItemIDSet( v_sAction == "show", v_aProfiledPropertyNames, v_aUIPEPropertyNames);
  486. var v_oProfilePropertyWithAppliesToNames = [];
  487. if( v_nPropertyProfile )
  488. {
  489. v_oProfilePropertyWithAppliesToNames = U_XML.F_AppendValues( null, v_nPropertyProfile.selectNodes( "./property[appliesTo]/@name" ) );
  490. }
  491. var v_aCheckedProperties = [];
  492. for( var i = 0; i < v_aUIPEPropertyNames.length; i++ )
  493. {
  494. var v_sPropertyName = v_aUIPEPropertyNames[i];
  495. if( v_aCheckedPropertyNames.indexOf( v_sPropertyName ) == -1 &&
  496. v_oProfilePropertyWithAppliesToNames.indexOf( v_sPropertyName ) == -1)
  497. {
  498. continue;
  499. }
  500. v_aCheckedProperties.push( v_sPropertyName );
  501. var v_nUIPEProperty = v_nPropertyGroup.selectSingleNode( ".//property[@name='" + v_sPropertyName + "']" );
  502. var v_aUIPEPropertyObjectNames = U_XML.F_AppendValues( null, v_nUIPEProperty.selectNodes( "./objectRef/@name" ) );
  503. var v_aUIPEPropertyNamedSetNames = U_XML.F_AppendValues( null, v_nUIPEProperty.selectNodes( "./namedSetRef/@name" ) );
  504. var v_aCheckedObjects = v_aUIPEPropertyObjectNames;
  505. var v_aCheckedNamedSets = v_aUIPEPropertyNamedSetNames;
  506. if( v_oProfilePropertyWithAppliesToNames.indexOf( v_sPropertyName ) != -1)
  507. {
  508. var v_nProfileProperty = v_nPropertyProfile.selectSingleNode( "./property[@name='" + v_sPropertyName + "']" );
  509. var v_aProfilePropertyObjectNames = U_XML.F_AppendValues( null, v_nProfileProperty.selectNodes( ".//parentContainer[@type='object']/@name" ) );
  510. v_aCheckedObjects = this.f_buildCheckedItemIDSet( v_sAction == "show", v_aProfilePropertyObjectNames, v_aUIPEPropertyObjectNames);
  511. var v_aProfilePropertyNamedSetNames = U_XML.F_AppendValues( null, v_nProfileProperty.selectNodes( ".//parentContainer[@type='namedSet']/@name" ) );
  512. v_aCheckedNamedSets = this.f_buildCheckedItemIDSet( v_sAction == "show", v_aProfilePropertyNamedSetNames, v_aUIPEPropertyNamedSetNames);
  513. }
  514. v_oPropertyEditor.F_SetObjectsChecked(v_sPropertyName, v_aCheckedObjects);
  515. v_oPropertyEditor.F_SetNamedSetsChecked(v_sPropertyName, v_aCheckedNamedSets);
  516. }
  517. v_oPropertyEditor.F_SetPropertiesChecked( v_aCheckedProperties );
  518. return v_oPropertyEditor;
  519. };
  520. G_UIPE.f_createListViewEditor = function( v_nTreeNode, v_divEditorView )
  521. {
  522. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  523. var v_sID = v_nTreeNode.getAttribute( "value" );
  524. var v_sChildrenPath = ".//" + v_sNodeName + "[@id='" + v_sID + "']/";
  525. switch ( v_sNodeName )
  526. {
  527. case "menubar":
  528. v_sChildrenPath += "menu";
  529. break;
  530. case "menu":
  531. case "menuItem":
  532. if( !v_nTreeNode.getAttribute( "refPopup" ) )
  533. {
  534. v_sChildrenPath += "menuPopup/menuItem";
  535. }
  536. else
  537. {
  538. var v_sMenuItemPath = ".//menuPopupTemplates/menuPopup[@id='" + v_nTreeNode.getAttribute( "refPopup" ) + "']/menuItem";
  539. var v_sSeparatorLabelPath = ".//menuPopupTemplates/menuPopup[@id='" + v_nTreeNode.getAttribute( "refPopup" ) + "']/menuSeparatorLabel";
  540. v_sChildrenPath = v_sMenuItemPath + "|" + v_sSeparatorLabelPath;
  541. }
  542. break;
  543. case "menuPopup":
  544. if( !v_nTreeNode.getAttribute( "refPopup" ) )
  545. {
  546. v_sChildrenPath += "menuItem";
  547. }
  548. else
  549. {
  550. v_sChildrenPath = ".//menuPopupTemplates/menuPopup[@id='" + v_nTreeNode.getAttribute( "refPopup" ) + "']/menuItem";
  551. }
  552. break;
  553. case "toolbar":
  554. v_sChildrenPath += "toolbarButton";
  555. break;
  556. case "listView":
  557. v_sChildrenPath += "listItem";
  558. break;
  559. case "tabControl":
  560. v_sChildrenPath += "tab";
  561. break;
  562. case "explorer":
  563. v_sChildrenPath += "explorerButton";
  564. break;
  565. case "chartGroup":
  566. v_sChildrenPath += "chartType";
  567. break;
  568. case "propertySheet":
  569. v_sChildrenPath += "properties/group";
  570. break;
  571. case "hideElements":
  572. var v_sParentId = v_nTreeNode.getAttribute( "value" ).split( "_" )[0];
  573. v_sChildrenPath = ".//dialog[@id='" + v_sParentId + "']/hideElements/hideElement";
  574. break;
  575. default :
  576. return null;
  577. }
  578. var v_oListViewEditor = new C_ListView( v_divEditorView, null, this );
  579. v_oListViewEditor.F_GetListViewNode().setAttribute( "view", "checkbox" );
  580. var v_nListItems = v_oListViewEditor.F_GetListItemsNode();
  581. var v_aSelectedIDs = null;
  582. var v_nUIPENode = null;
  583. var doc = v_nListItems.ownerDocument;
  584. var v_nProfileNode = null;
  585. if( v_sNodeName == "chartGroup" )
  586. {
  587. v_nProfileNode = this.m_nProfile.selectSingleNode( "./chartTypes" );
  588. v_nUIPENode = this.m_nStudioUIResources.selectSingleNode( ".//*[@id='" + v_nTreeNode.getAttribute( "value" ) + "']" );
  589. v_aSelectedIDs = this.f_getCheckedItemIDs( v_nProfileNode, v_nUIPENode );
  590. }
  591. else
  592. {
  593. v_nProfileNode = this.f_getProfileNodeByTreeNode( v_nTreeNode );
  594. if ( v_nProfileNode )
  595. {
  596. if( v_nTreeNode.getAttribute( "nodeName" ) == "hideElements" )
  597. {
  598. v_nUIPENode = this.m_nStudioUIResources.selectSingleNode( ".//*[@id='" + v_nProfileNode.parentNode.getAttribute( "id" ) + "']/hideElements" );
  599. }
  600. else
  601. {
  602. v_nUIPENode = this.m_nStudioUIResources.selectSingleNode( ".//*[@id='" + v_nProfileNode.getAttribute( "id" ) + "']" );
  603. // hide Elements do not need action node because it means "hide"
  604. var v_sAction = null;
  605. if( v_nProfileNode.nodeName == "propertySheet" )
  606. {
  607. var v_nPropertyVisibility = v_nProfileNode.selectSingleNode( "./propertyVisibility" );
  608. if( v_nPropertyVisibility )
  609. {
  610. v_sAction = v_nPropertyVisibility.getAttribute( "action" );
  611. }
  612. else
  613. {
  614. v_sAction = "hide";
  615. }
  616. v_nTreeNode.setAttribute( "originalActionValue", v_sAction );
  617. }
  618. else
  619. {
  620. v_sAction = v_nProfileNode.getAttribute( "action" );
  621. }
  622. v_nTreeNode.setAttribute( "actionValue", v_sAction);
  623. }
  624. if( v_nProfileNode.nodeName == "propertySheet" )
  625. {
  626. v_aSelectedIDs = this.f_buildCheckedItemIDSet(
  627. v_sAction == "show" ,
  628. U_XML.F_AppendValues( null, v_nProfileNode.selectNodes( "./propertyVisibility/group/@name" )),
  629. U_XML.F_AppendValues( null, this.m_nStudioUIResources.selectNodes( ".//propertySheet[@id='" + v_nProfileNode.getAttribute( "id" ) + "']/properties/group/@name" ) ));
  630. }
  631. else
  632. {
  633. v_aSelectedIDs = this.f_getCheckedItemIDs( v_nProfileNode, v_nUIPENode );
  634. }
  635. }
  636. }
  637. if ( v_sSeparatorLabelPath && this.m_nStudioUIResources.selectNodes( v_sSeparatorLabelPath ).length > 0 )
  638. {
  639. v_nTreeNode.setAttribute( "hasSepartorLabel", "true" );
  640. v_oListViewEditor.F_GetListViewNode().setAttribute( "indentLength", "16" );
  641. }
  642. var v_nChildrenNodes = this.m_nStudioUIResources.selectNodes( v_sChildrenPath );
  643. for( var i = 0; i < v_nChildrenNodes.length; i++ )
  644. {
  645. var v_nResourceItem = v_nChildrenNodes.item( i );
  646. var v_sIdentifier = v_nResourceItem.nodeName == "group" ? "name" : "id";
  647. var v_sId = v_nResourceItem.getAttribute( v_sIdentifier );
  648. var v_nListItem = v_nListItems.appendChild( doc.createElement( "listItem" ) );
  649. if ( v_sId )
  650. {
  651. v_nListItem.setAttribute( "value", v_sId );
  652. }
  653. U_XML.F_CopyAttribute( v_nListItem, v_nResourceItem, "smallIcon" );
  654. this.f_copyAttributes( v_nListItem, v_nResourceItem );
  655. if ( v_nTreeNode.getAttribute( "hasSepartorLabel" ) )
  656. {
  657. if ( v_nResourceItem.nodeName == "menuSeparatorLabel" )
  658. {
  659. v_nListItem.setAttribute( "staticCheckbox", "true" );
  660. }
  661. else
  662. {
  663. v_nListItem.setAttribute( "indentLevel", "1" );
  664. }
  665. }
  666. if( v_sNodeName == "chartGroup" )
  667. {
  668. if( v_aSelectedIDs && v_aSelectedIDs.indexOf( v_sId ) != -1 )
  669. {
  670. v_nListItem.setAttribute( "checked", "true" );
  671. v_nListItem.setAttribute( "oriChecked", "true" );
  672. }
  673. }
  674. else if( v_sNodeName == "hideElements" )
  675. {
  676. // hide elements do not have "show/hide" so uncheck all when profile node does not existing
  677. if( v_aSelectedIDs && v_aSelectedIDs.indexOf( v_sId ) != -1 )
  678. {
  679. v_nListItem.setAttribute( "checked", "true" );
  680. }
  681. }
  682. else
  683. {
  684. // if profile node does not existes, all the list item should be selected
  685. if( !v_nProfileNode || ( v_aSelectedIDs && v_aSelectedIDs.indexOf( v_sId ) != -1 ) )
  686. {
  687. v_nListItem.setAttribute( "checked", "true" );
  688. v_nListItem.setAttribute( "oriChecked", "true" );
  689. }
  690. }
  691. }
  692. v_oListViewEditor.F_Draw();
  693. if ( v_nTreeNode.getAttribute( "hasSepartorLabel" ) )
  694. {
  695. this.f_hideListViewCheckBox( v_oListViewEditor );
  696. }
  697. return v_oListViewEditor;
  698. };
  699. G_UIPE.f_hideListViewCheckBox = function( v_oListViewEditor, v_sAction )
  700. {
  701. var v_nListItems = v_oListViewEditor.F_GetListItems();
  702. for( var i = 0; i < v_nListItems.length; i++ )
  703. {
  704. var v_nlistItem = v_nListItems.item( i );
  705. if( v_nlistItem.getAttribute( "staticCheckbox" ) == "true" )
  706. {
  707. var v_elListItem = document.getElementById( v_nlistItem.getAttribute("htmlId") );
  708. var v_el = v_elListItem.getElementsByTagName( "IMG" ).item(0);
  709. if ( v_el )
  710. {
  711. v_el.parentNode.removeChild( v_el );
  712. }
  713. if ( v_sAction )
  714. {
  715. v_nlistItem.setAttribute( "checked", v_sAction == "hide" ? "true" : "false" );
  716. }
  717. }
  718. }
  719. };
  720. G_UIPE.f_createUIEditor = function( v_nTreeNode, v_divEditorView )
  721. {
  722. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  723. switch ( v_sNodeName )
  724. {
  725. case "menubar":
  726. case "menu":
  727. case "menuItem":
  728. case "menuPopup":
  729. case "toolbar":
  730. case "listView":
  731. case "tabControl":
  732. case "explorer":
  733. case "chartGroup":
  734. case "hideElements":
  735. case "propertySheet":
  736. return this.f_createListViewEditor( v_nTreeNode, v_divEditorView );
  737. case "settingsGroup":
  738. return this.f_createSettingSheetEditor( v_nTreeNode, v_divEditorView );
  739. case "group":
  740. return this.f_createPropertiesEditor(v_nTreeNode, v_divEditorView);
  741. case "helpContents":
  742. case "helpGettingStarted":
  743. return this.f_createHelpContentEditor( v_nTreeNode, v_divEditorView );
  744. default :
  745. return this.f_createBlankEditor( v_nTreeNode, v_divEditorView );
  746. }
  747. };
  748. G_UIPE.f_getProfileNodeByTreeNode = function( v_nTreeNode, v_nProfile )
  749. {
  750. v_nProfile = v_nProfile || this.m_nProfile;
  751. var v_sProfileNodeId = this.f_getProfileNodeIDByTreeNode( v_nTreeNode );
  752. var v_nProfileNode = null;
  753. if( v_nTreeNode.getAttribute( "nodeName" ) == "hideElements" )
  754. {
  755. var v_sDialogId = v_sProfileNodeId.split( "_" )[0];
  756. v_nProfileNode = v_nProfile.selectSingleNode(".//dialog[@id='" + v_sDialogId + "']/hideElements" );
  757. }
  758. else
  759. {
  760. v_nProfileNode = v_nProfile.selectSingleNode(".//*[@id='" + v_sProfileNodeId + "']" );
  761. }
  762. return v_nProfileNode;
  763. };
  764. G_UIPE.f_getProfileNodeIDByTreeNode = function( v_nTreeNode )
  765. {
  766. var v_sID = v_nTreeNode.getAttribute( "value" );
  767. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  768. if( v_sNodeName == "menu" || v_sNodeName == "menuItem" )
  769. {
  770. if( v_nTreeNode.getAttribute( "refPopup" ) )
  771. {
  772. v_sID = v_nTreeNode.getAttribute( "refPopup" );
  773. }
  774. else
  775. {
  776. v_sID = this.m_nStudioUIResources.selectSingleNode( ".//" + v_sNodeName + "[@id='" + v_sID + "']/menuPopup" ).getAttribute( "id" );
  777. }
  778. }
  779. return v_sID;
  780. };
  781. G_UIPE.f_initMenubars = function( v_nNavTree )
  782. {
  783. var doc = v_nNavTree.ownerDocument;
  784. var v_nMenubarsTreeNode = v_nNavTree.selectSingleNode( ".//treeNode[@value='menubars']" );
  785. var v_nlResMenubars = this.m_nStudioUIResources.selectNodes( "menubars/menubar" );
  786. for( var v_iMenubar = 0; v_iMenubar < v_nlResMenubars.length; v_iMenubar++ )
  787. {
  788. var v_nResMenubar = v_nlResMenubars.item( v_iMenubar );
  789. var v_nMenubarTreeNode = v_nMenubarsTreeNode.appendChild( doc.createElement( "treeNode" ) );
  790. v_nMenubarTreeNode.setAttribute( "nodeName", "menubar" );
  791. v_nMenubarTreeNode.setAttribute( "value", v_nResMenubar.getAttribute( "id" ) );
  792. v_nMenubarTreeNode.setAttribute( "expandable", "true" );
  793. v_nMenubarTreeNode.setAttribute( "expanded", "true" );
  794. v_nMenubarTreeNode.setAttribute( "hideCheckbox", "true" );
  795. this.f_copyAttributes( v_nMenubarTreeNode, v_nResMenubar );
  796. var v_nlResMenus = v_nResMenubar.selectNodes( "menu" );
  797. for ( var v_iMenu = 0; v_iMenu < v_nlResMenus.length; v_iMenu++ )
  798. {
  799. var v_nResMenu = v_nlResMenus.item( v_iMenu );
  800. if (v_nResMenu.selectSingleNode( "menuPopup" ))
  801. {
  802. var v_nMenuTreeNode = v_nMenubarTreeNode.appendChild( doc.createElement( "treeNode" ) );
  803. v_nMenuTreeNode.setAttribute( "nodeName", v_nResMenu.nodeName );
  804. v_nMenuTreeNode.setAttribute( "value", v_nResMenu.getAttribute( "id" ) );
  805. v_nMenuTreeNode.setAttribute( "hideCheckbox", "true" );
  806. this.f_copyAttributes( v_nMenuTreeNode, v_nResMenu );
  807. if( v_nResMenu.selectSingleNode( "menuPopup/menuItem/menuPopup" ) )
  808. {
  809. v_nMenuTreeNode.setAttribute( "expandable", "true" );
  810. }
  811. this.f_appendMenuPopups( v_nMenuTreeNode, v_nResMenu );
  812. }
  813. }
  814. }
  815. };
  816. G_UIPE.f_initMenuPopups = function( v_nNavTree )
  817. {
  818. var v_nMenuPopupsTreeNode = v_nNavTree.selectSingleNode( ".//treeNode[@value='menuPopups']" );
  819. var v_nResMenuPopups = this.m_nStudioUIResources.selectSingleNode( "menuPopups" );
  820. this.f_appendMenuPopups( v_nMenuPopupsTreeNode, v_nResMenuPopups );
  821. };
  822. G_UIPE.f_appendMenuPopups = function( v_nTreeNode, v_nResNode )
  823. {
  824. var doc = v_nTreeNode.ownerDocument;
  825. // menuPopup node may exists with path "menuPopups->menuPopup" or "menuPopups->menuPopup->menuItem->menuPopup"
  826. var v_nlResMenuPopups = v_nResNode.selectNodes( "menuPopup" );
  827. for( var v_iMenuPopup = 0; v_iMenuPopup < v_nlResMenuPopups.length; v_iMenuPopup++ )
  828. {
  829. var v_nResMenuPopup = v_nlResMenuPopups.item( v_iMenuPopup );
  830. var v_nMenuPopupTreeNode = null;
  831. if( v_nResMenuPopup.parentNode.nodeName == "menuPopups" )
  832. {
  833. v_nMenuPopupTreeNode = v_nTreeNode.appendChild( doc.createElement( "treeNode" ) );
  834. v_nMenuPopupTreeNode.setAttribute( "nodeName", v_nResMenuPopup.nodeName );
  835. if( v_nResMenuPopup.selectSingleNode( "menuItem/menuPopup" ) )
  836. {
  837. v_nMenuPopupTreeNode.setAttribute( "expandable", "true" );
  838. }
  839. v_nMenuPopupTreeNode.setAttribute( "value", v_nResMenuPopup.getAttribute( "id" ) );
  840. v_nMenuPopupTreeNode.setAttribute( "hideCheckbox", "true" );
  841. this.f_copyAttributes( v_nMenuPopupTreeNode, v_nResMenuPopup );
  842. }
  843. // if use template, menuItems store in <menuPopupTemplates>
  844. var v_nlResMenuItems = null;
  845. if( v_nResMenuPopup.getAttribute( "refPopup" ) )
  846. {
  847. v_nlResMenuItems = this.m_nStudioUIResources.selectNodes( ".//menuPopupTemplates/menuPopup[@id='" + v_nResMenuPopup.getAttribute( "refPopup" ) + "']/menuItem" )
  848. }
  849. else
  850. {
  851. v_nlResMenuItems = v_nResMenuPopup.selectNodes( "menuItem" );
  852. }
  853. for( var i = 0; i < v_nlResMenuItems.length; i++ )
  854. {
  855. var v_nResMenuItem = v_nlResMenuItems.item( i );
  856. if( v_nResMenuItem.selectSingleNode( "menuPopup" ) )
  857. {
  858. var v_nChildTreeNode = doc.createElement( "treeNode" );
  859. ( v_nMenuPopupTreeNode ? v_nMenuPopupTreeNode : v_nTreeNode ).appendChild( v_nChildTreeNode );
  860. v_nChildTreeNode.setAttribute( "nodeName", v_nResMenuItem.nodeName );
  861. var v_nResMenuItemPopup = v_nResMenuItem.selectSingleNode( "menuPopup" );
  862. if( v_nResMenuItemPopup )
  863. {
  864. // if use template, search menuPopup from <menuPopupTemplates> to determine whether current node is an "expandable" one
  865. if( v_nResMenuItemPopup.getAttribute( "refPopup" ) )
  866. {
  867. if( this.m_nStudioUIResources.selectSingleNode( ".//menuPopupTemplates/menuPopup[@id='" + v_nResMenuItemPopup.getAttribute( "refPopup" ) + "']/menuItem/menuPopup" ) )
  868. {
  869. v_nChildTreeNode.setAttribute( "expandable", "true" );
  870. }
  871. }
  872. else if( v_nResMenuItemPopup.selectSingleNode( "menuItem/menuPopup" ) )
  873. {
  874. v_nChildTreeNode.setAttribute( "expandable", "true" );
  875. }
  876. }
  877. v_nChildTreeNode.setAttribute( "value", v_nResMenuItem.getAttribute( "id" ) );
  878. if( v_nResMenuItem.selectSingleNode( "menuPopup" ) )
  879. {
  880. if( v_nResMenuItem.selectSingleNode( "menuPopup" ).getAttribute( "refPopup" ) )
  881. {
  882. v_nChildTreeNode.setAttribute( "refPopup", v_nResMenuItem.selectSingleNode( "menuPopup" ).getAttribute( "refPopup" ) );
  883. }
  884. }
  885. this.f_copyAttributes( v_nChildTreeNode, v_nResMenuItem );
  886. this.f_appendMenuPopups( v_nChildTreeNode, v_nResMenuItem );
  887. }
  888. }
  889. }
  890. };
  891. G_UIPE.F_ListView_OnCheckboxClick = function( v_oListViewType, v_nListItem )
  892. {
  893. var v_sID = this.f_getTreeNodeId( this.m_oNavigationTree.F_GetSingleSelectedNode() );
  894. var v_oListView = this.m_oEditorViews[v_sID];
  895. switch( v_oListViewType )
  896. {
  897. case this.m_oCheckAllListView :
  898. if ( v_nListItem.getAttribute( "checked" ) == "true" )
  899. {
  900. v_oListView.F_CheckAll();
  901. }
  902. else
  903. {
  904. v_oListView.F_UncheckAll();
  905. }
  906. if( this.m_oNavigationTree.F_GetSelectedNode().getAttribute( "nodeName" ) != "group" ) {
  907. var v_oListItems = v_oListView.F_GetListItems();
  908. for( var i = 0; i < v_oListItems.length; i++ )
  909. {
  910. this.f_highlightListItemAndTreeNode( v_oListView, v_oListItems.item( i ) );
  911. }
  912. }
  913. break;
  914. case this.m_oActionListView :
  915. var v_sAction = v_nListItem.getAttribute( "checked" ) == "true" ? "hide" : "show";
  916. this.m_oNavigationTree.F_GetSingleSelectedNode().setAttribute( "actionValue", v_sAction );
  917. this.f_highlightListItemAndTreeNode( v_oListViewType, v_nListItem );
  918. break;
  919. default:
  920. this.f_highlightListItemAndTreeNode( v_oListViewType, v_nListItem );
  921. return;
  922. }
  923. if ( this.m_oNavigationTree.F_GetSingleSelectedNode().getAttribute( "hasSepartorLabel" ) )
  924. {
  925. this.f_hideListViewCheckBox( v_oListView, this.m_oNavigationTree.F_GetSingleSelectedNode().getAttribute( "actionValue") );
  926. }
  927. };
  928. G_UIPE.F_HighlightListItem = function( v_oListViewType, v_nListItem )
  929. {
  930. var v_sHtmlID = v_nListItem.getAttribute( "htmlId" );
  931. var v_eListViewDiv = document.getElementById( v_sHtmlID ).firstChild.firstChild;
  932. var v_eListViewSpan = v_eListViewDiv.getElementsByTagName( "SPAN" )[0];
  933. var v_nTreeNode = this.m_oNavigationTree.F_GetSelectedNode();
  934. if( v_oListViewType == this.m_oActionListView )
  935. {
  936. // do not need to consider "checked" equals "oriChecked" or not since this status is not always correct for this.m_oActionListView
  937. if( v_nTreeNode.getAttribute( "highlight" ) && v_nTreeNode.getAttribute( "highlight" ) == "true" )
  938. {
  939. v_nListItem.removeAttribute( "highlight" );
  940. v_eListViewSpan.className = "";
  941. return false;
  942. }
  943. else
  944. {
  945. v_nListItem.setAttribute( "highlight", "true" );
  946. v_eListViewSpan.className = "uipeHighlight";
  947. return true;
  948. }
  949. }
  950. else
  951. {
  952. // here v_oListViewType can not be this.m_oCheckAllListView
  953. if( Boolean( v_nListItem.getAttribute( "checked" ) == "true" ) != Boolean( v_nListItem.getAttribute( "oriChecked" ) == "true" ) )
  954. {
  955. v_nListItem.setAttribute( "highlight", "true" );
  956. v_eListViewSpan.className = "uipeHighlight";
  957. return true;
  958. }
  959. else
  960. {
  961. v_nListItem.removeAttribute( "highlight" );
  962. v_eListViewSpan.className = "";
  963. return false;
  964. }
  965. }
  966. };
  967. G_UIPE.f_highlightListItemAndTreeNode = function( v_oListViewType, v_nListItem )
  968. {
  969. var v_bHighlightListItem = this.F_HighlightListItem( v_oListViewType, v_nListItem );
  970. if( v_bHighlightListItem )
  971. {
  972. this.F_HighlightSelectedTreeNode( true );
  973. }
  974. else
  975. {
  976. if( !v_oListViewType.F_GetListViewNode().selectSingleNode( ".//listItem[@highlight]" ) )
  977. {
  978. this.F_HighlightSelectedTreeNode( false );
  979. }
  980. }
  981. }
  982. G_UIPE.F_HighlightSelectedTreeNode = function( v_bHighlight )
  983. {
  984. this.F_HighlightTreeNode( this.m_oNavigationTree, this.m_oNavigationTree.F_GetSelectedNode(), v_bHighlight );
  985. };
  986. G_UIPE.F_HighlightSettings = function( v_elFixedValueCell, v_bChangeDefault )
  987. {
  988. // TR->TBODY->TABLE->TD->TR->TD(lable TD)
  989. var v_elLable = v_elFixedValueCell.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild;
  990. if( v_bChangeDefault )
  991. {
  992. // make sure only one "uipeDefaultSettingsHighlight" added to the Element
  993. if( v_elLable.className.indexOf( "uipeDefaultSettingsHighlight" ) == -1 )
  994. {
  995. v_elLable.className += " uipeDefaultSettingsHighlight";
  996. }
  997. // value TD
  998. if( v_elFixedValueCell.firstChild.tagName == "INPUT" )
  999. {
  1000. if( v_elFixedValueCell.firstChild.className.indexOf( "uipeDefaultSettingsHighlight" ) == -1 )
  1001. {
  1002. v_elFixedValueCell.firstChild.className += " uipeDefaultSettingsHighlight";
  1003. }
  1004. }
  1005. else
  1006. {
  1007. if( v_elFixedValueCell.className.indexOf( "uipeDefaultSettingsHighlight" ) == -1 )
  1008. {
  1009. v_elFixedValueCell.className += " uipeDefaultSettingsHighlight";
  1010. }
  1011. }
  1012. this.F_HighlightSelectedTreeNode( true );
  1013. }
  1014. else
  1015. {
  1016. v_elLable.className = v_elLable.className.replace( "uipeDefaultSettingsHighlight", "" );
  1017. // value TD
  1018. if( v_elFixedValueCell.firstChild.tagName == "INPUT" )
  1019. {
  1020. v_elFixedValueCell.firstChild.className = v_elFixedValueCell.firstChild.className.replace( "uipeDefaultSettingsHighlight", "" );
  1021. }
  1022. else
  1023. {
  1024. v_elFixedValueCell.className = v_elFixedValueCell.className.replace( "uipeDefaultSettingsHighlight", "" );
  1025. }
  1026. this.F_HighlightSelectedTreeNode( false );
  1027. }
  1028. };
  1029. G_UIPE.F_HighlightTreeNode = function( v_oTreeView, v_nTreeNode, v_bHighlight )
  1030. {
  1031. var v_sHtmlId = v_nTreeNode.getAttribute( "htmlId" );
  1032. var v_eTreeNodeDiv = v_oTreeView.F_GetElementById( v_sHtmlId );
  1033. var v_eTreeNodeSpan = v_eTreeNodeDiv.getElementsByTagName( "SPAN" )[0];
  1034. if( v_bHighlight )
  1035. {
  1036. if( v_nTreeNode.getAttribute( "highlight" ) != "true" )
  1037. {
  1038. v_nTreeNode.setAttribute( "highlight", "true" );
  1039. v_nTreeNode.setAttribute( "classPrefix", "uipeHighlight clsTreeNode" );
  1040. v_eTreeNodeSpan.className = "uipeHighlight " + v_eTreeNodeSpan.className;
  1041. }
  1042. }
  1043. else
  1044. {
  1045. if( v_nTreeNode.getAttribute( "highlight" ) )
  1046. {
  1047. v_nTreeNode.removeAttribute( "highlight" );
  1048. v_nTreeNode.removeAttribute( "classPrefix" );
  1049. v_eTreeNodeSpan.className = v_eTreeNodeSpan.className.replace( "uipeHighlight ", "" );
  1050. }
  1051. }
  1052. if( v_nTreeNode.parentNode && v_nTreeNode.parentNode.nodeName != "treeView" )
  1053. {
  1054. this.F_HighlightTreeNode( v_oTreeView, v_nTreeNode.parentNode, v_nTreeNode.parentNode.selectSingleNode( ".//treeNode[@highlight]" ) );
  1055. }
  1056. };
  1057. G_UIPE.f_getCheckedItemIDs = function( v_nProfileNode, v_nUIPENode )
  1058. {
  1059. var v_aUIPEIDs = U_XML.F_AppendValues( null, v_nUIPENode.selectNodes( "*/@id" ) );
  1060. if( !v_nProfileNode )
  1061. {
  1062. return v_aUIPEIDs;
  1063. }
  1064. var v_bShow = false;
  1065. if( v_nProfileNode.nodeName == "hideElements" )
  1066. {
  1067. // for child nodes in hideElements, we should show them as selected ones
  1068. v_bShow = true;
  1069. }
  1070. else
  1071. {
  1072. v_bShow = v_nProfileNode.getAttribute( "action" ) == "show";
  1073. }
  1074. var v_sIdentifer = v_nProfileNode.nodeName == "listView" ? "value" : "id";
  1075. var v_aProfileIDs = U_XML.F_AppendValues( null, v_nProfileNode.selectNodes( "*/@" + v_sIdentifer ) );
  1076. return this.f_buildCheckedItemIDSet( v_bShow, v_aProfileIDs, v_aUIPEIDs );
  1077. };
  1078. G_UIPE.f_buildCheckedItemIDSet = function( v_bShow, v_aProfileIDs, v_aUIPEIDs )
  1079. {
  1080. var v_aIDs = [];
  1081. for( var i = 0; i < v_aUIPEIDs.length; i++ )
  1082. {
  1083. var v_sID = v_aUIPEIDs[i];
  1084. var v_bContained = v_aProfileIDs.indexOf( v_sID ) != -1 ;
  1085. if( ( v_bShow && v_bContained ) || ( !v_bShow && !v_bContained ) )
  1086. {
  1087. v_aIDs.push( v_sID );
  1088. }
  1089. }
  1090. return v_aIDs;
  1091. };
  1092. G_UIPE.f_copyAttributes = function( v_nTarget, v_nSource )
  1093. {
  1094. U_XML.F_CopyAttribute( v_nTarget, v_nSource, "smallIcon" );
  1095. if( !!(v_nSource.getAttribute( "idsDescription2" )) )
  1096. {
  1097. U_XML.F_CopyAttribute( v_nTarget, v_nSource, "idsDescription2" )
  1098. }
  1099. if( !!(v_nSource.getAttribute( "idsLabel" )) && U_XML.F_CopyAttribute( v_nTarget, v_nSource, "idsLabel" ) )
  1100. {
  1101. return;
  1102. }
  1103. if( !!(v_nSource.getAttribute( "label" )) && U_XML.F_CopyAttribute( v_nTarget, v_nSource, "label" ) )
  1104. {
  1105. return;
  1106. }
  1107. v_nTarget.setAttribute( "label", v_nSource.getAttribute( "id" ) );
  1108. };
  1109. G_UIPE.f_getActionValue = function( v_nTreeNode )
  1110. {
  1111. var v_sAction = v_nTreeNode.getAttribute( "actionValue" );
  1112. // only chartGroups have action attribute
  1113. if( v_nTreeNode.getAttribute( "nodeName" ) == "chartGroup" )
  1114. {
  1115. return "";
  1116. }
  1117. return v_sAction || "hide";
  1118. };
  1119. G_UIPE.f_updateActionListView = function( v_nTreeNode )
  1120. {
  1121. var v_nListItems = this.m_oActionListView.F_GetListItems();
  1122. var v_sChecked = this.f_getActionValue( v_nTreeNode ) == "hide" ? "true" : "false";
  1123. v_nListItems.item( 0 ).setAttribute( "checked", v_sChecked );
  1124. v_nListItems.item( 0 ).setAttribute( "oriChecked", v_sChecked );
  1125. this.m_oActionListView.F_Draw();
  1126. if( v_nTreeNode.getAttribute( "highlight" ) && v_nTreeNode.getAttribute( "highlight" ) == "true" )
  1127. {
  1128. var v_nListItem = v_nListItems.item( 0 );
  1129. var v_sHtmlID = v_nListItem.getAttribute( "htmlId" );
  1130. var v_eListViewDiv = document.getElementById( v_sHtmlID ).firstChild.firstChild;
  1131. var v_eListViewSpan = v_eListViewDiv.getElementsByTagName( "SPAN" )[0];
  1132. v_eListViewSpan.className = "uipeHighlight";
  1133. }
  1134. };
  1135. G_UIPE.f_updateTitleBar = function( v_nTreeNode )
  1136. {
  1137. var v_sTitle = "";
  1138. var v_nlNodes = v_nTreeNode.selectNodes("ancestor-or-self::treeNode[@idsLabel]");
  1139. if( v_nlNodes && v_nlNodes.length > 0 )
  1140. {
  1141. var v_aValues = [];
  1142. for( var i = 0; i < v_nlNodes.length; i++ )
  1143. {
  1144. v_aValues.push( C_TreeView.F_GetTreeNodeLabel(v_nlNodes[i]) );
  1145. }
  1146. v_sTitle = v_aValues.join(" -> ");
  1147. }
  1148. document.getElementById( "divTitle" ).innerText = v_sTitle;
  1149. };
  1150. G_UIPE.f_updateInfoBox = function( v_nTreeNode )
  1151. {
  1152. var v_sTooltip = "";
  1153. var v_sDescription = "";
  1154. var v_nTooltip = v_nTreeNode.selectSingleNode( "ancestor-or-self::*[@idsTooltip][1]" );
  1155. if( v_nTooltip )
  1156. {
  1157. var v_sIdsTooltip = v_nTooltip.getAttribute( "idsTooltip" );
  1158. v_sTooltip = G_ResManager.F_GetString( v_sIdsTooltip );
  1159. }
  1160. var v_nDesc = v_nTreeNode.selectSingleNode( "ancestor-or-self::*[@idsDescription][1]" );
  1161. if( v_nDesc )
  1162. {
  1163. var v_sIdsDesc = v_nDesc.getAttribute( "idsDescription" );
  1164. v_sDescription = G_ResManager.F_GetString( v_sIdsDesc );
  1165. }
  1166. document.getElementById( "infoTitle" ).innerText = v_sTooltip;
  1167. document.getElementById( "infoDescription" ).innerText = v_sDescription;
  1168. };
  1169. G_UIPE.F_ComboBox_OnChange = function( v_oComboBox, v_nListItem )
  1170. {
  1171. var v_tblContainer = v_oComboBox.F_GetContainer();
  1172. // TABLE->TBODY->TR->TD(comboBoxIcon)->TD(comboBoxText)->DIV
  1173. var v_divText = v_tblContainer.firstChild.firstChild.firstChild.nextSibling.firstChild;
  1174. if( v_oComboBox == this.m_oHelpComboBoxEditor )
  1175. {
  1176. if( v_nListItem.getAttribute( "value" ) != this.m_sHelpComboBoxDefaultValue )
  1177. {
  1178. v_divText.className = "uipeHighlight";
  1179. this.F_HighlightSelectedTreeNode( true );
  1180. }
  1181. else
  1182. {
  1183. v_divText.className = "";
  1184. this.F_HighlightSelectedTreeNode( false );
  1185. }
  1186. }
  1187. else if( v_oComboBox == this.m_oGettingStartComboBoxEditor )
  1188. {
  1189. if( v_nListItem.getAttribute( "value" ) != this.m_sGettingStartComboBoxDefaultValue )
  1190. {
  1191. v_divText.className = "uipeHighlight";
  1192. this.F_HighlightSelectedTreeNode( true );
  1193. }
  1194. else
  1195. {
  1196. v_divText.className = "";
  1197. this.F_HighlightSelectedTreeNode( false );
  1198. }
  1199. }
  1200. };
  1201. G_UIPE.F_TreeView_OnNodeClick = function( v_oTreeView, v_nTreeNode)
  1202. {
  1203. switch( v_oTreeView )
  1204. {
  1205. case this.m_oNavigationTree:
  1206. this.f_updateTitleBar( v_nTreeNode );
  1207. var v_iIndex = 0;
  1208. var v_sValue = this.f_getTreeNodeId( v_nTreeNode );
  1209. for( var i = 0; i < this.m_aDeckId.length; i++ )
  1210. {
  1211. var v_sCurrentCardId = this.m_aDeckId[i];
  1212. if( v_sValue == v_sCurrentCardId )
  1213. {
  1214. v_iIndex = i;
  1215. break;
  1216. }
  1217. }
  1218. // since template exists in menuPopup, the node in navigation tree DO NOT has one-one relationship with cards in main deck,
  1219. // so we need to store current tree node here because in G_UIPE.F_Deck_OnBeforeCardVisible() we can not get tree node from card index.
  1220. this.m_nCurrentTreeNode = v_nTreeNode;
  1221. // skip the "Loading" deck so we need to add 1
  1222. this.m_oDeck.F_SetIndex( v_iIndex + 1 );
  1223. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  1224. var v_sDeckMainHeight = "360px";
  1225. var v_sDeckMainWidth = "300px";
  1226. switch( v_sNodeName )
  1227. {
  1228. case "hideElements":
  1229. case "group":
  1230. case "chartGroup":
  1231. this.m_oCheckAllListView.F_GetContainer().style.display = "";
  1232. this.m_oActionListView.F_GetContainer().style.display = "none";
  1233. var v_nListItems = this.m_oCheckAllListView.F_GetListItems();
  1234. v_nListItems.item( 0 ).setAttribute( "checked", "false" );
  1235. this.m_oCheckAllListView.F_Draw();
  1236. v_sDeckMainHeight = "400px";
  1237. break;
  1238. case "chartGroups":
  1239. this.m_oCheckAllListView.F_GetContainer().style.display = "none";
  1240. this.m_oActionListView.F_GetContainer().style.display = "";
  1241. if( !v_nTreeNode.getAttribute( "actionValue" ) )
  1242. {
  1243. var v_nChartTypes = this.m_nProfile.selectSingleNode( "./chartTypes" );
  1244. if( v_nChartTypes )
  1245. {
  1246. v_nTreeNode.setAttribute( "actionValue", v_nChartTypes.getAttribute( "action" ) );
  1247. }
  1248. else
  1249. {
  1250. v_nTreeNode.setAttribute( "actionValue", "hide" );
  1251. }
  1252. }
  1253. this.f_updateActionListView( v_nTreeNode );
  1254. break;
  1255. case "helpContents":
  1256. case "helpGettingStarted":
  1257. this.m_oCheckAllListView.F_GetContainer().style.display = "none";
  1258. this.m_oActionListView.F_GetContainer().style.display = "none";
  1259. v_sDeckMainHeight = "400px";
  1260. break;
  1261. case "settingsGroup":
  1262. this.m_oCheckAllListView.F_GetContainer().style.display = "none";
  1263. this.m_oActionListView.F_GetContainer().style.display = "none";
  1264. v_sDeckMainHeight = "400px";
  1265. v_sDeckMainWidth = "490px";
  1266. break;
  1267. default:
  1268. if( v_nTreeNode.getAttribute( "blankView" ) == "true" )
  1269. {
  1270. this.m_oCheckAllListView.F_GetContainer().style.display = "none";
  1271. this.m_oActionListView.F_GetContainer().style.display = "none";
  1272. }
  1273. else
  1274. {
  1275. this.m_oCheckAllListView.F_GetContainer().style.display = "";
  1276. this.m_oActionListView.F_GetContainer().style.display = "";
  1277. this.f_updateActionListView( v_nTreeNode );
  1278. var v_nListItems = this.m_oCheckAllListView.F_GetListItems();
  1279. v_nListItems.item( 0 ).setAttribute( "checked", "false" );
  1280. this.m_oCheckAllListView.F_Draw();
  1281. }
  1282. break;
  1283. }
  1284. this.f_updateInfoBox( v_nTreeNode );
  1285. var v_divDeckMain = document.getElementById( "deckMain" );
  1286. v_divDeckMain.style.height = v_sDeckMainHeight;
  1287. v_divDeckMain.style.width = v_sDeckMainWidth;
  1288. break;
  1289. }
  1290. };
  1291. G_UIPE.f_processFileContents = function( v_oFileContents )
  1292. {
  1293. for( var v_sFile in v_oFileContents )
  1294. {
  1295. if( v_sFile.indexOf( "res/" ) != -1 )
  1296. {
  1297. G_HAL.F_AddFileToLoadedList( v_sFile );
  1298. var doc = U_XML.F_LoadString( D_XmlError, v_oFileContents[v_sFile], false, true );
  1299. var v_nResources = doc.selectSingleNode( "/resources" );
  1300. if( v_nResources )
  1301. {
  1302. U_Utils.F_ReplaceStringResources( v_nResources );
  1303. }
  1304. if (v_sFile.indexOf( "res/uipe.xml" ) != -1)
  1305. {
  1306. this.m_nStudioUIResources = v_nResources;
  1307. this.f_initLabels();
  1308. }
  1309. else
  1310. {
  1311. G_ResManager.F_AddResourcesDoc( doc, v_sFile );
  1312. }
  1313. }
  1314. else if ( v_sFile == G_UIPE.M_sProfileDTD )
  1315. {
  1316. G_UIPE.F_SetInlineProfileDTD( v_oFileContents[v_sFile] );
  1317. }
  1318. }
  1319. };
  1320. G_UIPE.F_GetAppURL = function()
  1321. {
  1322. if( !this.m_sAppURL )
  1323. {
  1324. var v_doc = document;
  1325. var a = v_doc.location.pathname.split( "/" );
  1326. a.pop();
  1327. this.m_sAppURL = this.F_GetWebcontentURL() + "/" + a.pop() + "/";
  1328. }
  1329. return this.m_sAppURL;
  1330. };
  1331. G_UIPE.F_ViewUIProfileSource = function()
  1332. {
  1333. var v_sTitle = G_ResManager.F_GetString( "IDS_UIPE_OPENSOURCE" );
  1334. var v_nProfile = this.f_buildUpdatedProfile();
  1335. D_UIProfileSource.F_Show( this, v_sTitle, false, v_nProfile.xml );
  1336. };
  1337. G_UIPE.F_SaveProfileToCM = function( v_nProfile, v_bReloadUI )
  1338. {
  1339. if( !v_nProfile )
  1340. {
  1341. v_nProfile = this.f_buildUpdatedProfile();
  1342. }
  1343. var v_docProfile = U_XML.F_LoadString( null, G_UIPE.F_GetInlineProfileDTD() + v_nProfile.xml );
  1344. if( !v_docProfile )
  1345. {
  1346. D_MsgBox.F_Show( null, G_ResManager.F_GetString( "IDS_UIPE_PROFILE_DTD_VALIDATION" ), G_ResManager.F_GetString( "IDS_UIPE_TITLE" ), D_MsgBox.K_iWarning );
  1347. return;
  1348. }
  1349. this.m_nProfile = v_nProfile;
  1350. var v_oRequest = new C_UIProfileSaveRequest( new C_RequestListenerRedirect( this, "f_onSaveRequestComplete" ), this.m_sProfileStoreID, v_nProfile, v_bReloadUI);
  1351. v_oRequest.F_Send();
  1352. };
  1353. G_UIPE.f_onSaveRequestComplete = function( v_oRequest )
  1354. {
  1355. D_MsgBox.F_Show( null, G_ResManager.F_GetString( "IDS_UIPE_SAVE_SUCCESSFULLY" ), G_ResManager.F_GetString( "IDS_UIPE_TITLE" ), D_MsgBox.K_iInformation, null, G_UIPE.f_onSaveMsgOKClick, G_UIPE.f_onSaveMsgOKClick, null, null );
  1356. };
  1357. G_UIPE.f_onSaveMsgOKClick = function()
  1358. {
  1359. window.close();
  1360. };
  1361. G_UIPE.f_createProfileNodeFromEditorView = function( v_nTreeNode, v_oEditorView )
  1362. {
  1363. var v_sAction = this.f_getActionValue( v_nTreeNode );
  1364. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  1365. if( v_sAction == "hide" && v_oEditorView.F_GetUncheckedListItems().length == 0 && v_sNodeName != "propertySheet" && v_sNodeName != "hideElements" )
  1366. {
  1367. return null;
  1368. }
  1369. var v_sID = v_nTreeNode.getAttribute( "value" );
  1370. var v_sProfileNodeName = null;
  1371. var v_sProfileSubNodeName = null;
  1372. var v_sProfileNodeID = this.f_getProfileNodeIDByTreeNode( v_nTreeNode );
  1373. switch( v_sNodeName )
  1374. {
  1375. case "menubar" :
  1376. v_sProfileNodeName = "menubar";
  1377. v_sProfileSubNodeName = "menu";
  1378. break;
  1379. case "menu" :
  1380. case "menuItem" :
  1381. case "menuPopup" :
  1382. v_sProfileNodeName = "menuPopup";
  1383. v_sProfileSubNodeName = "menuItem";
  1384. break;
  1385. case "toolbar" :
  1386. v_sProfileNodeName = "toolbar";
  1387. v_sProfileSubNodeName = "toolbarButton";
  1388. break;
  1389. case "listView" :
  1390. v_sProfileNodeName = "listView";
  1391. v_sProfileSubNodeName = "listItem";
  1392. break;
  1393. case "tabControl" :
  1394. v_sProfileNodeName = "tabControl";
  1395. v_sProfileSubNodeName = "tab";
  1396. break;
  1397. case "explorer" :
  1398. v_sProfileNodeName = "explorer";
  1399. v_sProfileSubNodeName = "explorerButton";
  1400. break;
  1401. case "propertySheet":
  1402. v_sProfileNodeName = "propertySheet";
  1403. v_sProfileSubNodeName = "group";
  1404. break;
  1405. case "hideElements" :
  1406. v_sProfileNodeName = "hideElements";
  1407. v_sProfileSubNodeName = "hideElement";
  1408. break;
  1409. case "chartGroup" :
  1410. v_sProfileNodeName = "chartGroup";
  1411. v_sProfileSubNodeName = "chartType";
  1412. // action attribute exists in its parent node chartGroups
  1413. v_sAction = this.f_getActionValue( v_nTreeNode.parentNode );
  1414. break;
  1415. default :
  1416. return null;
  1417. }
  1418. var doc = v_nTreeNode.ownerDocument;
  1419. var v_nProfileNode = null;
  1420. if( v_sNodeName == "hideElements" )
  1421. {
  1422. v_nProfileNode = doc.createElement( v_sProfileNodeName );
  1423. }
  1424. else
  1425. {
  1426. // we do not need to consider "chartGroup" here since only "chartType" we added later is useful information
  1427. v_nProfileNode = doc.createElement( v_sProfileNodeName );
  1428. v_nProfileNode.setAttribute( "id", v_sProfileNodeID );
  1429. if (v_sProfileSubNodeName == "group") {
  1430. var v_nProfileSubNode = doc.createElement("propertyVisibility");
  1431. v_nProfileNode.appendChild(v_nProfileSubNode);
  1432. v_nProfileNode = v_nProfileSubNode;
  1433. }
  1434. v_nProfileNode.setAttribute( "action", v_sAction );
  1435. }
  1436. var v_nCheckedListItems = null;
  1437. // hide Elements do not have action attribute but it means the selected item is going to be hiden
  1438. if( v_sAction == "show" || v_sNodeName == "hideElements" )
  1439. {
  1440. v_nCheckedListItems = v_oEditorView.F_GetCheckedListItems();
  1441. }
  1442. else
  1443. {
  1444. v_nCheckedListItems = v_oEditorView.F_GetUncheckedListItems();
  1445. }
  1446. for( var i = 0; i < v_nCheckedListItems.length; i++ )
  1447. {
  1448. var v_nCheckedItem = v_nCheckedListItems.item( i );
  1449. var v_nProfileSubNode = doc.createElement( v_sProfileSubNodeName );
  1450. if( v_sProfileSubNodeName == "listItem" )
  1451. {
  1452. v_nProfileSubNode.setAttribute( "value", v_nCheckedItem.getAttribute( "value" ) );
  1453. }
  1454. else if( v_sProfileSubNodeName == "group" )
  1455. {
  1456. v_nProfileSubNode.setAttribute( "name", v_nCheckedItem.getAttribute( "value" ) );
  1457. }
  1458. else
  1459. {
  1460. v_nProfileSubNode.setAttribute( "id", v_nCheckedItem.getAttribute( "value" ) );
  1461. }
  1462. v_nProfileNode.appendChild( v_nProfileSubNode );
  1463. }
  1464. return v_sProfileSubNodeName == "group" ? v_nProfileNode.parentNode : ( v_nProfileNode.childNodes.length == 0 ? null : v_nProfileNode );
  1465. }
  1466. G_UIPE.f_getProfileParentNodeByTreeNode = function( v_nProfile, v_nTreeNode )
  1467. {
  1468. var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  1469. var v_sParentNodeName = "";
  1470. var v_sParentNodePath = "";
  1471. var v_bDialogNode = false;
  1472. if( v_sNodeName == "menuPopup" || v_sNodeName == "toolbar" || v_sNodeName == "menubar" || v_sNodeName == "listView" || v_sNodeName == "tabControl" || v_sNodeName == "propertySheet" )
  1473. {
  1474. // for toolbars, menuPopups, listViews in dialog, we need to store them in correct position
  1475. if( v_nTreeNode.parentNode.parentNode && v_nTreeNode.parentNode.parentNode.getAttribute( "nodeName" ) == "dialog" )
  1476. {
  1477. var v_sParentId = v_nTreeNode.parentNode.parentNode.getAttribute( "value" );
  1478. v_sParentNodePath = "dialogs/dialog[@id='" + v_sParentId + "']";
  1479. v_bDialogNode = true;
  1480. }
  1481. }
  1482. switch( v_sNodeName )
  1483. {
  1484. case "menu":
  1485. case "menuItem":
  1486. case "menuPopup":
  1487. v_sParentNodeName = "menuPopups";
  1488. break;
  1489. case "toolbar":
  1490. v_sParentNodeName = "toolbars";
  1491. break;
  1492. case "menubar":
  1493. v_sParentNodeName = "menubars";
  1494. break;
  1495. case "listView":
  1496. v_sParentNodeName = "listViews";
  1497. break;
  1498. case "tabControl":
  1499. v_sParentNodeName = "tabControls";
  1500. break;
  1501. case "explorer":
  1502. v_sParentNodeName = "explorers";
  1503. break;
  1504. case "propertySheet":
  1505. v_sParentNodeName = "propertySheets";
  1506. break;
  1507. case "hideElements":
  1508. var v_sParentId = v_nTreeNode.getAttribute( "value" ).split( "_" )[0];
  1509. v_sParentNodePath = "dialogs/dialog[@id='" + v_sParentId + "']";
  1510. v_bDialogNode = true;
  1511. break;
  1512. default :
  1513. return null;
  1514. }
  1515. if( v_sParentNodePath )
  1516. {
  1517. v_sParentNodePath = v_sParentNodeName ? ( v_sParentNodePath + "/" + v_sParentNodeName ) : v_sParentNodePath;
  1518. }
  1519. else
  1520. {
  1521. v_sParentNodePath = v_sParentNodeName;
  1522. }
  1523. var v_nParentNode = v_nProfile.selectSingleNode( "./" + v_sParentNodePath );
  1524. var doc = v_nProfile.ownerDocument;
  1525. if( !v_nParentNode )
  1526. {
  1527. if( v_bDialogNode )
  1528. {
  1529. if( !v_nProfile.selectSingleNode( "./dialogs" ) )
  1530. {
  1531. v_nParentNode = doc.createElement( "dialogs" );
  1532. v_nProfile.appendChild( v_nParentNode );
  1533. }
  1534. if( !v_nProfile.selectSingleNode( "./dialogs/dialog[@id='" + v_sParentId + "']" ) )
  1535. {
  1536. v_nParentNode = doc.createElement( "dialog" );
  1537. v_nParentNode.setAttribute( "id", v_sParentId )
  1538. v_nProfile.selectSingleNode( "./dialogs" ).appendChild( v_nParentNode );
  1539. }
  1540. if( v_sParentNodeName && !v_nProfile.selectSingleNode( "./dialogs/dialog[@id='" + v_sParentId + "']/" + v_sParentNodeName ) )
  1541. {
  1542. if( v_sParentNodeName.length > 0 )
  1543. {
  1544. v_nParentNode = doc.createElement( v_sParentNodeName );
  1545. v_nProfile.selectSingleNode( "./dialogs/dialog[@id='" + v_sParentId + "']" ).appendChild( v_nParentNode );
  1546. }
  1547. }
  1548. }
  1549. else
  1550. {
  1551. v_nParentNode = doc.createElement( v_sParentNodeName );
  1552. v_nProfile.appendChild( v_nParentNode );
  1553. }
  1554. }
  1555. return v_nParentNode;
  1556. }
  1557. G_UIPE.f_buildIdentifierFilter = function( v_sIdentify, v_aValues )
  1558. {
  1559. var v_sRemovePath = "[";
  1560. for( var j = 0; j < v_aValues.length; j++ )
  1561. {
  1562. if( j != 0 )
  1563. {
  1564. v_sRemovePath += " or ";
  1565. }
  1566. v_sRemovePath += "@" + v_sIdentify + "='" + v_aValues[j] + "'";
  1567. }
  1568. v_sRemovePath += "]";
  1569. return v_sRemovePath;
  1570. };
  1571. G_UIPE.f_buildUpdatedProfile = function()
  1572. {
  1573. var v_nUpdatedProfile = this.m_nProfile.cloneNode( true );
  1574. var v_nResources = this.m_oNavigationTree.F_GetTreeViewNode();
  1575. var doc = v_nResources.ownerDocument;
  1576. var v_nNodesSelection = v_nResources.selectNodes( "//treeNode" );
  1577. var v_sNodeName = "";
  1578. var v_iLength = v_nNodesSelection.length;
  1579. for( var i = 0; i < v_iLength; i++ )
  1580. {
  1581. var v_nTreeNode = v_nNodesSelection.item( i );
  1582. v_sNodeName = v_nTreeNode.getAttribute( "nodeName" );
  1583. var v_sId = this.f_getTreeNodeId( v_nTreeNode );
  1584. var v_oEditorView = this.m_oEditorViews[v_sId];
  1585. var v_nUpdatedProfileNode = null;
  1586. // chartGroups is a special blank view because it contains show/hide checkbox
  1587. if( v_oEditorView || v_sNodeName == "chartGroups" )
  1588. {
  1589. if( v_sNodeName == "settingsGroup" )
  1590. {
  1591. var v_nSettingsNode = v_nUpdatedProfile.selectSingleNode( "./defaultSettings" );
  1592. var v_aSettingNames = U_XML.F_AppendValues( null, this.m_nStudioUIResources.selectNodes( ".//settingsGroup[@name='" + v_sId + "']/setting/@name" ) );
  1593. var v_sRemovePath = ".//setting" + this.f_buildIdentifierFilter( "name", v_aSettingNames );
  1594. U_XML.F_RemoveNodes( v_nSettingsNode, v_sRemovePath );
  1595. var v_oUpdatedSettings = v_oEditorView.F_GetUpdatedSettings();
  1596. for( var o in v_oUpdatedSettings )
  1597. {
  1598. var v_nSettingNode = v_nSettingsNode.appendChild( doc.createElement( "setting" ) );
  1599. v_nSettingNode.setAttribute( "name", o );
  1600. v_nSettingNode.setAttribute( "defaultValue", v_oUpdatedSettings[o] );
  1601. }
  1602. }
  1603. else if( v_sNodeName == "chartGroups" )
  1604. {
  1605. var v_nChartTypesProfileNode = v_nUpdatedProfile.selectSingleNode( "./chartTypes" );
  1606. if( !v_nChartTypesProfileNode )
  1607. {
  1608. var doc = v_nUpdatedProfile.ownerDocument;
  1609. v_nChartTypesProfileNode = doc.createElement( "chartTypes" );
  1610. v_nUpdatedProfile.appendChild( v_nChartTypesProfileNode );
  1611. }
  1612. else
  1613. {
  1614. U_XML.F_RemoveNodes( v_nChartTypesProfileNode, "./chartType" );
  1615. }
  1616. v_nChartTypesProfileNode.setAttribute( "action", this.f_getActionValue( v_nTreeNode ) );
  1617. }
  1618. else if( v_sNodeName == "chartGroup" )
  1619. {
  1620. v_nUpdatedProfileNode = this.f_createProfileNodeFromEditorView( v_nTreeNode, v_oEditorView );
  1621. if( !v_nUpdatedProfileNode )
  1622. {
  1623. continue;
  1624. }
  1625. var v_nChartTypesProfileNode = v_nUpdatedProfile.selectSingleNode( "./chartTypes" );
  1626. var v_nChartTypeNodeSelection = v_nUpdatedProfileNode.selectNodes( "./chartType" );
  1627. for( var v_iChartTypeItem = 0; v_iChartTypeItem < v_nChartTypeNodeSelection.length; v_iChartTypeItem++ )
  1628. {
  1629. v_nChartTypesProfileNode.appendChild( v_nChartTypeNodeSelection.item( v_iChartTypeItem ) );
  1630. }
  1631. }
  1632. else if( v_sNodeName == "helpContents" )
  1633. {
  1634. var v_nHelpNode = v_nUpdatedProfile.selectSingleNode( "./helpContents" );
  1635. var v_nSubHelpNode = null;
  1636. if( v_nHelpNode )
  1637. {
  1638. v_nSubHelpNode = v_nHelpNode.selectSingleNode( "./ibmHelpContents" );
  1639. v_nSubHelpNode.setAttribute( "type", this.m_oHelpComboBoxEditor.F_GetValue() );
  1640. }
  1641. else
  1642. {
  1643. var doc = v_nUpdatedProfile.ownerDocument;
  1644. var v_nParentNode = doc.createElement( "helpContents" );
  1645. var v_nChildNode = doc.createElement( "ibmHelpContents" );
  1646. v_nChildNode.setAttribute( "type", this.m_oHelpComboBoxEditor.F_GetValue() );
  1647. v_nParentNode.appendChild( v_nChildNode );
  1648. v_nUpdatedProfile.appendChild( v_nParentNode );
  1649. }
  1650. }
  1651. else if( v_sNodeName == "helpGettingStarted" )
  1652. {
  1653. var v_nGettingStartNode = v_nUpdatedProfile.selectSingleNode( "./helpGettingStarted" );
  1654. var v_nSubGettingStartNode = null;
  1655. if( v_nGettingStartNode )
  1656. {
  1657. v_nSubGettingStartNode = v_nGettingStartNode.selectSingleNode( "./ibmHelpGettingStarted" );
  1658. v_nSubGettingStartNode.setAttribute( "type", this.m_oGettingStartComboBoxEditor.F_GetValue() );
  1659. }
  1660. else
  1661. {
  1662. var doc = v_nUpdatedProfile.ownerDocument;
  1663. var v_nParentNode = doc.createElement( "helpGettingStarted" );
  1664. var v_nChildNode = doc.createElement( "ibmHelpGettingStarted" );
  1665. v_nChildNode.setAttribute( "type", this.m_oGettingStartComboBoxEditor.F_GetValue() );
  1666. v_nParentNode.appendChild( v_nChildNode );
  1667. v_nUpdatedProfile.appendChild( v_nParentNode );
  1668. }
  1669. }
  1670. else if( v_sNodeName == "group" )
  1671. {
  1672. var v_sGroupName = v_nTreeNode.getAttribute( "value" );
  1673. var v_sPropertySheetID = v_nTreeNode.parentNode.getAttribute( "value" );
  1674. // remove properties in
  1675. var v_bShow = this.f_getActionValue( v_nTreeNode.parentNode ) == "show";
  1676. var v_nProfilePropertyVisibility = v_nUpdatedProfile.selectSingleNode( ".//propertySheet[@id='" + v_sPropertySheetID + "']/propertyVisibility" );
  1677. // remove properties in profile
  1678. var v_oGroupProperties = v_oEditorView.F_GetPropertyNames();
  1679. var v_sRemovePath = "./property[";
  1680. for( var j = 0; j < v_oGroupProperties.length; j++ )
  1681. {
  1682. if( j != 0 )
  1683. {
  1684. v_sRemovePath += " or ";
  1685. }
  1686. v_sRemovePath += "@name='" + v_oGroupProperties[j] + "'";
  1687. }
  1688. v_sRemovePath += "]";
  1689. U_XML.F_RemoveNodes( v_nProfilePropertyVisibility, v_sRemovePath );
  1690. var v_oProfilePropertNames = null;
  1691. var v_oCheckedPropertyNames = v_oEditorView.F_GetCheckedPropertyNames();
  1692. var v_oUncheckedPropertyNames = v_oEditorView.F_GetUncheckedPropertyNames();
  1693. if( v_bShow )
  1694. {
  1695. v_oProfilePropertyNames = v_oCheckedPropertyNames;
  1696. }
  1697. else
  1698. {
  1699. v_oProfilePropertyNames = v_oUncheckedPropertyNames;
  1700. for( var j = 0; j < v_oCheckedPropertyNames.length; j++ )
  1701. {
  1702. if( v_oEditorView.F_GetUncheckedObjectNames( v_oCheckedPropertyNames[j] ).length > 0 ||
  1703. v_oEditorView.F_GetUncheckedNamedSetNames( v_oCheckedPropertyNames[j] ).length > 0 )
  1704. {
  1705. v_oProfilePropertyNames.push( v_oCheckedPropertyNames[j] );
  1706. }
  1707. }
  1708. }
  1709. for( var j = 0; j < v_oProfilePropertyNames.length; j++ )
  1710. {
  1711. var v_sProfilePropertyName = v_oProfilePropertyNames[j];
  1712. var v_nProfileProperty = v_nProfilePropertyVisibility.appendChild( doc.createElement( "property" ) );
  1713. v_nProfileProperty.setAttribute( "name", v_sProfilePropertyName );
  1714. var v_oProfileObjectNames = [];
  1715. var v_oProfileNamedSetNames = [];
  1716. if( v_bShow )
  1717. {
  1718. if( v_oEditorView.F_GetUncheckedObjectNames( v_sProfilePropertyName ).length != 0 ||
  1719. v_oEditorView.F_GetUncheckedNamedSetNames( v_sProfilePropertyName ).length != 0 )
  1720. {
  1721. v_oProfileObjectNames = v_oEditorView.F_GetCheckedObjectNames( v_sProfilePropertyName );
  1722. v_oProfileNamedSetNames = v_oEditorView.F_GetCheckedNamedSetNames( v_sProfilePropertyName );
  1723. }
  1724. }
  1725. else
  1726. {
  1727. if( v_oCheckedPropertyNames.indexOf( v_sProfilePropertyName ) != -1 )
  1728. {
  1729. v_oProfileObjectNames = v_oEditorView.F_GetUncheckedObjectNames( v_sProfilePropertyName );
  1730. v_oProfileNamedSetNames = v_oEditorView.F_GetUncheckedNamedSetNames( v_sProfilePropertyName );
  1731. }
  1732. else {
  1733. v_oProfileObjectNames = [];
  1734. v_oProfileNamedSetNames = [];
  1735. }
  1736. }
  1737. if( v_oProfileObjectNames.length > 0 || v_oProfileNamedSetNames.length > 0 )
  1738. {
  1739. var v_nAppliesTo = v_nProfileProperty.appendChild( doc.createElement( "appliesTo" ) );
  1740. for( var k = 0; k < v_oProfileObjectNames.length; k++ )
  1741. {
  1742. var v_sObjectName = v_oProfileObjectNames[k];
  1743. var v_nObject = v_nAppliesTo.appendChild( doc.createElement( "parentContainer" ) );
  1744. v_nObject.setAttribute( "type", "object" );
  1745. v_nObject.setAttribute( "name", v_sObjectName );
  1746. }
  1747. for( var k = 0; k < v_oProfileNamedSetNames.length; k++ )
  1748. {
  1749. var v_sNamedSetName = v_oProfileNamedSetNames[k];
  1750. var v_nNamedSet = v_nAppliesTo.appendChild( doc.createElement( "parentContainer" ) );
  1751. v_nNamedSet.setAttribute( "type", "namedSet" );
  1752. v_nNamedSet.setAttribute( "name", v_sNamedSetName );
  1753. }
  1754. }
  1755. }
  1756. }
  1757. else
  1758. {
  1759. v_nUpdatedProfileNode = this.f_createProfileNodeFromEditorView(v_nTreeNode, v_oEditorView);
  1760. var v_nProfileNode = this.f_getProfileNodeByTreeNode( v_nTreeNode, v_nUpdatedProfile );
  1761. if( v_nUpdatedProfileNode)
  1762. {
  1763. if( v_nProfileNode )
  1764. {
  1765. v_nProfileNode.parentNode.replaceChild( v_nUpdatedProfileNode, v_nProfileNode );
  1766. }
  1767. else
  1768. {
  1769. var v_nProfileParentNode = this.f_getProfileParentNodeByTreeNode( v_nUpdatedProfile, v_nTreeNode );
  1770. v_nProfileParentNode.appendChild( v_nUpdatedProfileNode );
  1771. }
  1772. }
  1773. else
  1774. {
  1775. if( v_nProfileNode )
  1776. {
  1777. // remove the parent if there is no child, our profile do not support this kind of contents: "<explorers></explorers>", "<toolbars></toolbars>"
  1778. if ( v_nProfileNode.parentNode.childNodes.length == 1 )
  1779. {
  1780. v_nProfileNode.parentNode.parentNode.removeChild( v_nProfileNode.parentNode );
  1781. }
  1782. else
  1783. {
  1784. v_nProfileNode.parentNode.removeChild( v_nProfileNode );
  1785. }
  1786. }
  1787. }
  1788. if( v_sNodeName == "propertySheet" )
  1789. {
  1790. var v_sPropertySheetName = v_nTreeNode.getAttribute( "value" );
  1791. var v_nPropertyVisibility = v_nUpdatedProfileNode.selectSingleNode( "./propertyVisibility" );
  1792. if( !v_nPropertyVisibility )
  1793. {
  1794. v_nPropertyVisibility = v_nUpdatedProfileNode.appendChild( doc.createElement( "propertyVisibility" ) );
  1795. v_nPropertyVisibility.setAttribute( "action", "hide" );
  1796. }
  1797. var v_nOriginalProfilePropertyVisibility = this.m_nProfile.selectSingleNode( ".//propertySheet[@id='" + v_sPropertySheetName + "']/propertyVisibility" );
  1798. if( !v_nOriginalProfilePropertyVisibility )
  1799. {
  1800. v_nOriginalProfilePropertyVisibility = doc.createElement( "propertyVisibility" );
  1801. }
  1802. // check if action value had not been changed, clone the properties from original profile.
  1803. if( this.f_getActionValue( v_nTreeNode ) == v_nTreeNode.getAttribute( "originalActionValue" ) )
  1804. {
  1805. var v_oOriginalProfileProperties = v_nOriginalProfilePropertyVisibility.selectNodes( "./property" );
  1806. for( var j = 0; j < v_oOriginalProfileProperties.length; j++ )
  1807. {
  1808. v_nPropertyVisibility.appendChild( v_oOriginalProfileProperties.item( j ).cloneNode( true ) );
  1809. }
  1810. }
  1811. else
  1812. {
  1813. var v_aAllPropertyNames = U_XML.F_AppendValues( null,
  1814. G_ResManager.F_GetResourcesDoc().documentElement.selectNodes(
  1815. ".//propertySheet[@id='" + v_sPropertySheetName + "']//property/@name" ) );
  1816. var v_aProfilePropertyNames = this.f_complementSet( v_aAllPropertyNames,
  1817. U_XML.F_AppendValues( null, v_nOriginalProfilePropertyVisibility.selectNodes( "./property/@name" ) ) );
  1818. for( var j = 0; j < v_aProfilePropertyNames.length; j++ )
  1819. {
  1820. var v_nProfileProperty = v_nPropertyVisibility.appendChild( doc.createElement( "property" ) );
  1821. v_nProfileProperty.setAttribute( "name", v_aProfilePropertyNames[j] );
  1822. }
  1823. // handle all the properties with appliesTo
  1824. var v_oPropertiesWithAppliesTo = v_nOriginalProfilePropertyVisibility.selectNodes( "./property[appliesTo]" );
  1825. for( var j = 0; j < v_oPropertiesWithAppliesTo.length; j++ )
  1826. {
  1827. var v_nProfileProperty = v_nPropertyVisibility.appendChild( doc.createElement( "property" ) );
  1828. var v_sPropertyName = v_oPropertiesWithAppliesTo.item( j ).getAttribute( "name" );
  1829. v_nProfileProperty.setAttribute( "name", v_sPropertyName );
  1830. var v_nAppliesTo = v_nProfileProperty.appendChild( doc.createElement( "appliesTo" ) );
  1831. var v_oAllParentContainers = G_ResManager.F_GetResourcesDoc().documentElement.selectNodes( ".//propertySheet[@id='" + v_sPropertySheetName + "']//property[@name='" + v_sPropertyName + "']/*" );
  1832. var v_aOriginalAppliesToNames = U_XML.F_AppendValues( null, v_oPropertiesWithAppliesTo.item( j ).selectNodes( "./appliesTo/*/@name" ) );
  1833. for( var k = 0; k < v_oAllParentContainers.length; k++ )
  1834. {
  1835. var v_nContainer = v_oAllParentContainers.item( k );
  1836. var v_sContainerName = v_nContainer.getAttribute( "name" );
  1837. if( v_aOriginalAppliesToNames.indexOf( v_sContainerName ) == -1)
  1838. {
  1839. var v_nParentContainer = v_nAppliesTo.appendChild( doc.createElement( "parentContainer" ) );
  1840. v_nParentContainer.setAttribute( "name", v_sContainerName );
  1841. v_nParentContainer.setAttribute( "type", v_nContainer.nodeName == "objectRef" ? "object" : "namedSet" );
  1842. }
  1843. }
  1844. }
  1845. }
  1846. }
  1847. }
  1848. }
  1849. }
  1850. // remove <chartTypes> if it does not have any child nodes <chartType>
  1851. var v_nChartTypesProfileNode = v_nUpdatedProfile.selectSingleNode( "./chartTypes" );
  1852. if ( v_nChartTypesProfileNode.childNodes.length == 0 && v_nChartTypesProfileNode.getAttribute( "action" ) == "hide" )
  1853. {
  1854. U_XML.F_RemoveNodes( v_nUpdatedProfile, "./chartTypes" );
  1855. }
  1856. return v_nUpdatedProfile;
  1857. };
  1858. G_UIPE.f_complementSet = function( v_aA1, v_aA2 )
  1859. {
  1860. var v_aA3 = [];
  1861. for( var i = 0; i < v_aA1.length; i++ )
  1862. {
  1863. if( v_aA2.indexOf( v_aA1[i] ) == -1)
  1864. {
  1865. v_aA3.push( v_aA1[i] );
  1866. }
  1867. }
  1868. return v_aA3;
  1869. };
  1870. G_UIPE.f_getTreeNodeId = function( v_nTreeNode )
  1871. {
  1872. // for the menuPopup which has template content, use template ID as id
  1873. return v_nTreeNode.getAttribute( "refPopup" ) ? v_nTreeNode.getAttribute( "refPopup" ) : v_nTreeNode.getAttribute( "value" );
  1874. };
  1875. G_UIPE.F_Cancel = function()
  1876. {
  1877. window.close();
  1878. };
  1879. G_UIPE.F_Search = function()
  1880. {
  1881. if( this.m_iNextCounter > 0 )
  1882. {
  1883. // we need to clear the last searched result
  1884. var v_nSearchedNode = this.m_nSearchResult.item( this.m_iNextCounter - 1 );
  1885. var v_aClearedNode = [];
  1886. v_aClearedNode.push( null );
  1887. v_aClearedNode.push( v_nSearchedNode );
  1888. this.f_locateAndClearNode( v_aClearedNode );
  1889. }
  1890. if( this.m_sSearchText != document.getElementById( "txtSearch" ).value )
  1891. {
  1892. this.m_nSearchResult = null;
  1893. }
  1894. var v_sSearchText = document.getElementById( "txtSearch" ).value;
  1895. v_sSearchText = v_sSearchText.F_LTrim();
  1896. v_sSearchText = v_sSearchText.F_RTrim();
  1897. if( v_sSearchText.length == 0 )
  1898. {
  1899. return;
  1900. }
  1901. this.m_sSearchText = v_sSearchText;
  1902. if( !this.m_nSearchResult )
  1903. {
  1904. // we do not want to locate "menuPopups/listViews/menubars/toolbars/propertySheets/tabControls" nodes in <dialog/>
  1905. var v_sTextContentFilter = ".//*[not(self :: object | self :: namedSet | self :: menuPopups | self :: listViews | self :: menubars | self :: toolbars | self :: propertySheets | self :: tabControls | self :: menuSeparatorLabel | self :: enumValue | self :: hideElements)][contains(translate(@label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), translate(" + this.m_sSearchText.F_ToXPathString() + ", 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))]";
  1906. this.m_nSearchResult = this.m_nStudioUIResources.selectNodes( v_sTextContentFilter );
  1907. this.m_iNextCounter = 0;
  1908. }
  1909. if( this.m_nSearchResult.length > 0 && this.m_iNextCounter < this.m_nSearchResult.length )
  1910. {
  1911. var v_nSearchedNode = this.m_nSearchResult.item( this.m_iNextCounter );
  1912. var v_nPreviousSearchedNode = null;
  1913. var v_aNode = [];
  1914. v_aNode.push( v_nSearchedNode );
  1915. if( this.m_iNextCounter > 0 )
  1916. {
  1917. v_nPreviousSearchedNode = this.m_nSearchResult.item( this.m_iNextCounter - 1 );
  1918. v_aNode.push( v_nPreviousSearchedNode );
  1919. }
  1920. this.f_locateAndClearNode( v_aNode );
  1921. this.m_iNextCounter++;
  1922. }
  1923. else
  1924. {
  1925. D_MsgBox.F_Show( null, G_ResManager.F_GetString( "IDS_UIPE_SEARCH_NOMORERESULT" ), G_ResManager.F_GetString( "IDS_UIPE_TITLE" ), D_MsgBox.K_iWarning );
  1926. }
  1927. };
  1928. G_UIPE.f_locateAndClearNode = function( v_aNode )
  1929. {
  1930. // for the first searched result v_aNode only contains one node, for others v_aNode contains current result we need to locate and the previous result we need to clear
  1931. for( var i = 0; i < v_aNode.length; i++ )
  1932. {
  1933. var v_nNode = v_aNode[i];
  1934. if( !v_nNode )
  1935. {
  1936. continue;
  1937. }
  1938. var v_sNodeName = v_nNode.nodeName;
  1939. var v_sNodeIdentifier = this.f_getNodeIdentifier( v_nNode );
  1940. var v_sNodeID = v_nNode.getAttribute( v_sNodeIdentifier );
  1941. var v_sTreeNodeValue = null;
  1942. var v_sTemplateId = null;
  1943. var v_nParentNode = null;
  1944. switch( v_sNodeName )
  1945. {
  1946. case "toolbarButton" :
  1947. case "setting" :
  1948. case "listItem" :
  1949. case "tab" :
  1950. case "explorerButton" :
  1951. case "chartType" :
  1952. case "property" :
  1953. v_nParentNode = v_nNode.parentNode;
  1954. v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) );
  1955. break;
  1956. case "hideElement" :
  1957. // hideElements do not have id attribute
  1958. v_nParentNode = v_nNode.parentNode.parentNode;
  1959. v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) );
  1960. break;
  1961. case "menuItem" :
  1962. if( v_nNode.parentNode.parentNode.nodeName == "menuPopups" )
  1963. {
  1964. v_nParentNode = v_nNode.parentNode;
  1965. }
  1966. else if( v_nNode.parentNode.parentNode.nodeName == "menu" || v_nNode.parentNode.parentNode.nodeName == "menuItem" )
  1967. {
  1968. v_nParentNode = v_nNode.parentNode.parentNode;
  1969. }
  1970. else if( v_nNode.parentNode.parentNode.nodeName == "menuPopupTemplates" )
  1971. {
  1972. v_sTemplateId = v_nNode.parentNode.getAttribute( "id" );
  1973. // items in menuPopupTemplates shares one v_oEditorView so just locate the first tree node
  1974. v_nParentNode = this.m_nStudioUIResources.selectNodes( ".//menuPopup[@refPopup='" + v_sTemplateId + "']" ).item( 0 ).parentNode;
  1975. }
  1976. v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) );
  1977. break;
  1978. case "menuPopup" :
  1979. if( v_nNode.parentNode.nodeName == "menu" )
  1980. {
  1981. v_nParentNode = v_nNode.parentNode;
  1982. v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) );
  1983. }
  1984. else if( v_nNode.parentNode.nodeName == "menuPopups" )
  1985. {
  1986. v_sTreeNodeValue = v_sNodeID;
  1987. }
  1988. else if( v_nNode.parentNode.nodeName == "menuPopupTemplates" )
  1989. {
  1990. v_sTemplateId = v_nNode.getAttribute( "id" );
  1991. // items in menuPopupTemplates shares one v_oEditorView so just locate the first tree node
  1992. v_nParentNode = this.m_nStudioUIResources.selectNodes( ".//menuPopup[@refPopup='" + v_sTemplateId + "']" ).item( 0 ).parentNode;
  1993. v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) );
  1994. }
  1995. break;
  1996. default:
  1997. v_sTreeNodeValue = v_sNodeID;
  1998. }
  1999. if( i == 0 )
  2000. {
  2001. // only select searched node and do not select previous node again
  2002. var v_nTreeNode = null;
  2003. if( v_sNodeName == "hideElement" )
  2004. {
  2005. v_nTreeNode = this.m_oNavigationTree.F_GetTreeViewNode().selectSingleNode( ".//treeNode[@value='" + v_sTreeNodeValue + "']/treeNode[@nodeName='hideElements']" );
  2006. }
  2007. else
  2008. {
  2009. v_nTreeNode = this.m_oNavigationTree.F_GetTreeViewNode().selectSingleNode( ".//treeNode[@value='" + v_sTreeNodeValue + "']" );
  2010. }
  2011. this.m_oNavigationTree.F_EnsureVisible( v_nTreeNode, document.getElementById("divNavTreeContainer") );
  2012. this.m_oNavigationTree.F_SelectNode( v_nTreeNode, false, true );
  2013. }
  2014. if( v_sTreeNodeValue != v_sNodeID )
  2015. {
  2016. if( v_sNodeName == "hideElement" )
  2017. {
  2018. v_sTreeNodeValue += "_hideElements";
  2019. }
  2020. var v_oEditorView = null;
  2021. if( v_nNode.parentNode.parentNode.nodeName == "menuPopupTemplates" )
  2022. {
  2023. v_oEditorView = this.m_oEditorViews[v_sTemplateId];
  2024. }
  2025. else
  2026. {
  2027. v_oEditorView = this.m_oEditorViews[v_sTreeNodeValue];
  2028. }
  2029. switch( v_sNodeName )
  2030. {
  2031. case "toolbarButton" :
  2032. case "menuItem" :
  2033. case "listItem" :
  2034. case "tab" :
  2035. case "explorerButton" :
  2036. case "chartType" :
  2037. case "hideElement" :
  2038. var v_nListItem = v_oEditorView.F_GetListViewNode().selectSingleNode( ".//listItem[@value='" + v_sNodeID + "']" );
  2039. var v_sHtmlID = v_nListItem.getAttribute( "htmlId" );
  2040. var v_eListViewDiv = document.getElementById( v_sHtmlID ).firstChild.firstChild;
  2041. var v_eListViewSpan = v_eListViewDiv.getElementsByTagName( "SPAN" )[0];
  2042. if( i == 0 )
  2043. {
  2044. v_eListViewSpan.className = "clsListItem_hover";
  2045. var v_elListItem = document.getElementById( v_nListItem.getAttribute( "htmlId" ) );
  2046. var v_iOffset = U_DOM.F_GetRelativeOffset( v_elListItem, v_elListItem.offsetParent ).top;
  2047. document.getElementById("deckMain").scrollTop = v_iOffset;
  2048. }
  2049. else
  2050. {
  2051. v_eListViewSpan.className = "";
  2052. }
  2053. break;
  2054. case "setting" :
  2055. var v_elValue = v_oEditorView.F_GetFixedValueCell( v_sNodeID );
  2056. v_elLable = v_elValue.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild;
  2057. if( i == 0 )
  2058. {
  2059. v_elLable.className = "clsListItem_hover";
  2060. var v_iOffset = U_DOM.F_GetRelativeOffset( v_elLable, v_elLable.offsetParent ).top;
  2061. document.getElementById("deckMain").scrollTop = v_iOffset;
  2062. }
  2063. else
  2064. {
  2065. v_elLable.className = "";
  2066. }
  2067. break;
  2068. case "property" :
  2069. var v_nPropertyTreeNode = v_oEditorView.F_GetPropertyTreeView().F_GetTreeViewNode().selectSingleNode( ".//treeNode[@value='" + v_sNodeID + "']" );
  2070. var v_sHtmlId = v_nPropertyTreeNode.getAttribute( "htmlId" );
  2071. var v_eTreeNodeDiv = document.getElementById( v_sHtmlId );
  2072. // we can not add class to <span> since its own hover style, so insteadly, we add class to the parent node of <span>
  2073. if( i == 0 )
  2074. {
  2075. v_eTreeNodeDiv.className = "clsListItem_hover";
  2076. v_oEditorView.F_GetPropertyTreeView().F_EnsureVisible( v_nPropertyTreeNode, v_eTreeNodeDiv.parentNode );
  2077. }
  2078. else
  2079. {
  2080. v_eTreeNodeDiv.className = "";
  2081. }
  2082. break;
  2083. default:
  2084. }
  2085. }
  2086. }
  2087. };
  2088. G_UIPE.f_getNodeIdentifier = function( v_nNode )
  2089. {
  2090. var v_sNodeName = v_nNode.nodeName;
  2091. var v_sNodeIdentifier = null;
  2092. switch( v_sNodeName )
  2093. {
  2094. case "settingsGroup":
  2095. case "setting":
  2096. case "property":
  2097. case "group":
  2098. v_sNodeIdentifier = "name";
  2099. break;
  2100. default:
  2101. v_sNodeIdentifier = "id";
  2102. }
  2103. return v_sNodeIdentifier;
  2104. };
  2105. G_UIPE.F_SettingSheet_OnCycleDropDownList = function( v_oSettingSheet, v_sName, v_sValue, v_nListView )
  2106. {
  2107. var v_nListItem = C_ListView.F_FindListItem( v_nListView, "value", v_sValue );
  2108. if ( !v_nListItem )
  2109. {
  2110. // don't attempt to cycle if can't find current item
  2111. return;
  2112. }
  2113. var v_sNextValue = "";
  2114. var v_nNextSibling = U_XML.F_GetNextSiblingElement( v_nListItem );
  2115. if ( v_nNextSibling )
  2116. {
  2117. v_sNextValue = v_nNextSibling.getAttribute( "value" );
  2118. }
  2119. else
  2120. {
  2121. v_sNextValue = v_nListView.selectSingleNode( "listItems/listItem" ).getAttribute( "value" );
  2122. }
  2123. v_oSettingSheet.F_OnSettingChange( v_sName, v_sNextValue );
  2124. };