/* IBM Confidential OCO Source Materials IBM Cognos Products: uipe (C) Copyright IBM Corp. 2014 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. */ var G_UIPE = {}; G_UIPE.M_sProfileDTD = "../pat/profiles/rs_profile.dtd"; G_UIPE.M_sProfileVersion = "http://www.ibm.com/xmlns/prod/ba/rs/rsprofile.1/"; G_UIPE.F_SetInlineProfileDTD = function( v_sDTD ) { this.m_sInlineProfileDTD = '\r\n'; }; G_UIPE.F_GetInlineProfileDTD = function() { return this.m_sInlineProfileDTD; }; G_UIPE.F_GetWebcontentURL = function() { if( this.m_sWebcontentURL ) { return this.m_sWebcontentURL; } var v_doc = document; if( v_doc.domain ) { var v_sURL = v_doc.location.href; // Compensate for URLs that didn't encode slashes var v_iQuestionMark = v_sURL.indexOf( "?" ); if( v_iQuestionMark > 0 ) { v_sURL = v_sURL.substring( 0, v_iQuestionMark ); } var v_iSlash = v_sURL.lastIndexOf( "/" ); if( v_iSlash > 0 ) { v_sURL = v_sURL.substring( 0, v_iSlash ); v_iSlash = v_sURL.lastIndexOf( "/" ); if( v_iSlash > 0 ) { v_sURL = v_sURL.substring( 0, v_iSlash ); this.m_sWebcontentURL = v_sURL; return v_sURL; } } } // we should never get here this.m_sWebcontentURL = ""; return this.m_sWebcontentURL; }; G_UIPE.f_setGatewayURL = function( v_sURL ) { if( v_sURL ) { G_CCHL.M_sGatewayURL = v_sURL; } else { G_CCHL.M_sGatewayURL = this.m_sGateway ? this.m_sGateway : ( this.F_GetWebcontentURL() + "/cgi-bin/cognos.cgi" ); } }; G_UIPE.F_Init = function() { this.m_sProductLocale = g_UIPEParameters["uipe_productLocale"] || "en"; this.m_sProfileStoreID = g_UIPEParameters["uipe_UIProfileStoreID"]; this.m_sProfileName = g_UIPEParameters["uipe_UIProfileName"]; this.m_sSkin = g_UIPEParameters["uipe_skin"]; this.m_sGateway = g_UIPEParameters["ui.gateway"]; this.f_setGatewayURL( "" ); if( !this.m_sProfileStoreID && !this.m_sProfileName) { D_MsgBox.F_Show( null, G_ResManager.F_GetString( "IDS_UIPE_INVALID_PARAMETERS" ), G_ResManager.F_GetString( "IDS_UIPE_TITLE" ), D_MsgBox.K_iWarning ); return; } G_CCHL.M_sProductLocale = this.m_sProductLocale; G_CCHL.M_sContentLocale = this.m_sProductLocale; G_ResManager.F_SetLocale( this.m_sProductLocale ); this.f_sendResourceRequest(); }; G_UIPE.f_sendResourceRequest = function( ) { var v_bUseCache = true; var v_sAppURL = this.F_GetAppURL(); var v_aStringFiles = ["cchl/res/cchl_strings_not_localized.xml", "cchl/res/cchl_strings", "../pat/res/reportstudio_not_localized.xml", "../pat/res/reportstudio", "res/uipe_not_localized.xml", "res/uipe_strings" ]; var v_oStringsRequest = new C_StringsRequest( null, v_aStringFiles, v_bUseCache ); var v_aResFiles = ["res/uipeResources.xml", "res/uipe.xml", "../cchl/res/cchl_resources.xml", G_UIPE.M_sProfileDTD]; var v_oResourcesRequest = new C_MultiFileRequest( null, v_aResFiles, null, v_bUseCache ); var v_oStringsAndResourcesRequest = new C_MultiRequest( new C_RequestListenerRedirect( this, "f_onResourcesRequestComplete" ), [ v_oStringsRequest, v_oResourcesRequest ] ); v_oStringsAndResourcesRequest.F_Send(); }; G_UIPE.f_onResourcesRequestComplete = function( v_oRequest ) { var v_aRequests = v_oRequest.F_GetRequests(); var v_oStringsRequest = v_aRequests[0]; var v_oResourcesRequest = v_aRequests[1]; var v_oError = v_oStringsRequest.F_GetError(); if( v_oError ) { C_Dialog.F_ShowDetailedMsgWindow( v_oError.F_GetErrorSummary(), "Failed to load strings", v_oError.F_GetErrorDetails(), D_MsgBox.K_iError ); this.f_blankWindow(); return; } var v_oError = v_oResourcesRequest.F_GetError(); if( v_oError ) { var v_oFileContents = v_oResourcesRequest.F_GetFileContents(); var v_aFailed = []; for( var v_sFile in v_oFileContents ) { if( this.M_oOptionalResFiles[v_sFile] ) { // ignore failure if optional file does not exist } else if( v_oFileContents[v_sFile] === null ) { v_aFailed.push( v_sFile ); } } if( v_aFailed.length > 0 ) { C_Dialog.F_ShowDetailedMsgWindow( v_oError.F_GetErrorSummary(), "Multi File Request Error", v_oError.F_GetErrorDetails(), D_MsgBox.K_iError ); this.f_blankWindow(); return; } } document.title = G_ResManager.F_GetString("IDS_UIPE_TITLE"); document.getElementById("profileName").innerText = G_ResManager.F_GetString("IDS_UIPE_HEADER") + this.m_sProfileName; var v_oFileContents = v_oResourcesRequest.F_GetFileContents(); this.f_processFileContents( v_oFileContents ); if( !this.m_sProfileStoreID ) { var v_oRequest = new C_UIProfileQueryRequest( new C_RequestListenerRedirect( this, "f_onQueryRequestComplete" ) ); v_oRequest.F_Send(); }else { setTimeout( this.f_loadProfile.F_CreateMethodCallback( this ), 0 ); } }; G_UIPE.f_onQueryRequestComplete = function( v_oRequest ) { var v_oError = v_oRequest && v_oRequest.F_GetError(); if( v_oError ) { F_ShowError(v_oError); return; } if( this.m_sProfileName ) { var v_oNameMap = v_oRequest.F_GetNameMap(); if( v_oNameMap ) { this.m_sProfileStoreID = v_oNameMap[this.m_sProfileName] || ""; } } if( !this.m_sProfileStoreID ) { 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 ); }else { this.f_loadProfile(); } }; G_UIPE.f_loadProfile = function( ) { // get profile content by this.m_sProfileStoreID var v_oRequest = new C_UIProfileLoadRequest( new C_RequestListenerRedirect( this, "f_onLoadRequestComplete" ), this.m_sProfileStoreID ); v_oRequest.F_Send(); }; G_UIPE.f_onLoadRequestComplete = function( v_oRequest ) { var v_oError = v_oRequest.F_GetError(); if( v_oError ) { 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 ); return; } this.m_nProfile = v_oRequest.F_GetUIProfile(); G_UIPE.f_onInit(); }; G_UIPE.f_blankWindow = function() { document.body.innerText = ""; }; G_UIPE.f_onInit = function() { document.body.setAttribute( "aria-label", G_ResManager.F_GetString("IDS_UIPE_TITLE") ); G_ResManager.F_ApplyResStrings( document.body ); var v_nCheckAllView = G_ResManager.F_GetResource( "CheckAll" ); this.m_oCheckAllListView = new C_ListView( document.getElementById( "divCheckAll" ), v_nCheckAllView, this ); this.m_oCheckAllListView.F_GetContainer().setAttribute("aria-label", G_ResManager.F_GetString("IDS_AC_CHECK_ALL")); this.m_oCheckAllListView.F_Draw(); var v_nAction = G_ResManager.F_GetResource( "Action" ); this.m_oActionListView = new C_ListView( document.getElementById( "divAction" ), v_nAction, this ); this.m_oActionListView.F_GetContainer().setAttribute("aria-label", G_ResManager.F_GetString("IDS_AC_ACTION")); this.m_oActionListView.F_Draw(); this.f_initializeUI(); }; G_UIPE.f_initializeUI = function() { this.f_initNavTree(); this.f_initAllDecks(); var v_nTreeView = this.m_oNavigationTree.F_GetTreeViewNode(); var v_nTreeNode = v_nTreeView.selectSingleNode( ".//treeNode[@value='toolbars']/*" ); if( v_nTreeNode ) { this.m_oNavigationTree.F_SelectNode( v_nTreeNode, false, true ); this.f_updateActionListView( v_nTreeNode ); } }; G_UIPE.f_initNavTree = function() { var v_nNavTree = G_ResManager.F_GetResource( "NavigationTree" ); this.f_initTreeNodes( v_nNavTree, "toolbars", "toolbar" ); this.f_initTreeNodes( v_nNavTree, "tabControls", "tabControl" ); this.f_initTreeNodes( v_nNavTree, "explorers", "explorer" ); this.f_initTreeNodes( v_nNavTree, "chartGroups", "chartGroup" ); this.f_initTreeNodes( v_nNavTree, "defaultSettings", "settingsGroup" ); this.f_initTreeNodes( v_nNavTree, "toolboxes", "listView" ); this.f_initTreeNodes( v_nNavTree, "listViews", "listView" ); this.f_initMenubars( v_nNavTree ); this.f_initMenuPopups( v_nNavTree ); this.f_initPropertiesTree( v_nNavTree ); this.f_initDialogsTreeNodes( v_nNavTree ); this.m_oNavigationTree = new C_TreeView( document.getElementById("divNavigationTree"), v_nNavTree, this ); }; G_UIPE.f_initTreeNodes = function( v_nNavTree, v_sParentNodeName, v_sNodeName ) { var doc = v_nNavTree.ownerDocument; var v_nFolder = v_nNavTree.selectSingleNode( ".//treeNode[@value='" + v_sParentNodeName + "']" ); var v_nNodes = this.m_nStudioUIResources.selectSingleNode( v_sParentNodeName ).selectNodes( v_sNodeName ); var v_iLength = v_nNodes.length; for( var i = 0; i < v_iLength; i++ ) { var v_nNode = v_nNodes.item( i ); var v_sNodeName = v_nNode.nodeName; var v_sNodeValue = ( v_sNodeName == "settingsGroup" ) ? v_nNode.getAttribute( "name" ) : v_nNode.getAttribute( "id" ); var v_nNewTreeNode = v_nFolder.appendChild( doc.createElement( "treeNode" ) ); v_nNewTreeNode.setAttribute( "nodeName", v_sNodeName ); v_nNewTreeNode.setAttribute( "value", v_sNodeValue ); this.f_copyAttributes( v_nNewTreeNode, v_nNode ); } }; G_UIPE.f_initLabels = function() { var v_nNodes = this.m_nStudioUIResources.selectNodes( ".//*[@idsLabel]" ); for( var i = 0; i < v_nNodes.length; i++ ) { var v_nNode = v_nNodes.item( i ); var v_sIdsLabel = v_nNode.getAttribute( "idsLabel" ); if( v_sIdsLabel != "" ) { v_nNode.setAttribute( "label", G_ResManager.F_GetString( v_sIdsLabel ) ); } } } G_UIPE.f_initPropertiesTree = function(v_nNavTree) { var doc = v_nNavTree.ownerDocument; var v_nPropertiesTreeNodes = v_nNavTree.selectSingleNode(".//treeNode[@value='properties']"); var v_nPropertySheetSelection = this.m_nStudioUIResources.selectSingleNode("propertySheets").selectNodes("propertySheet"); var v_iLength = v_nPropertySheetSelection.length; for( var i = 0; i < v_iLength; i++) { var v_nPropertySheet = v_nPropertySheetSelection.item(i); var v_sNodeName = v_nPropertySheet.nodeName; var v_nNewPropertySheetTreeNode = v_nPropertiesTreeNodes.appendChild(doc.createElement("treeNode")); v_nNewPropertySheetTreeNode.setAttribute("nodeName", v_nPropertySheet.nodeName); v_nNewPropertySheetTreeNode.setAttribute("value", v_nPropertySheet.getAttribute("id")); v_nNewPropertySheetTreeNode.setAttribute("expandable", "true"); this.f_copyAttributes( v_nNewPropertySheetTreeNode, v_nPropertySheet ); var v_nGroups = v_nPropertySheet.selectNodes(".//group"); for( var j = 0; j < v_nGroups.length; j++) { var v_nGroup = v_nGroups.item(j); var v_sNodeName = v_nGroup.nodeName; var v_nNewGroupNode = v_nNewPropertySheetTreeNode.appendChild(doc.createElement("treeNode")); v_nNewGroupNode.setAttribute("nodeName", v_nGroup.nodeName); v_nNewGroupNode.setAttribute("value", v_nGroup.getAttribute("name")); this.f_copyAttributes( v_nNewGroupNode, v_nGroup ); } } }; G_UIPE.f_initDialogsTreeNodes = function( v_nNavTree ) { var doc = v_nNavTree.ownerDocument; var v_nDialogsTreeNode = v_nNavTree.selectSingleNode( ".//treeNode[@value='dialogs']" ); var v_nNodesSelection = this.m_nStudioUIResources.selectSingleNode( "dialogs" ).selectNodes( "dialog" ); var v_iLength = v_nNodesSelection.length; for( var i = 0; i < v_iLength; i++ ) { var v_nNode = v_nNodesSelection.item( i ); var v_sNodeName = v_nNode.nodeName; var v_sNodeValue = v_nNode.getAttribute( "id" ); var v_nNewNode = v_nDialogsTreeNode.appendChild( doc.createElement( "treeNode" ) ); v_nNewNode.setAttribute( "nodeName", v_sNodeName ); v_nNewNode.setAttribute( "value", v_sNodeValue ); v_nNewNode.setAttribute( "expandable", "true" ); this.f_copyAttributes( v_nNewNode, v_nNode ); // find all child node for dialog, may include hideElements, menuPopups, listViews, menubars, toolbars, propertySheets, tabControls. var v_nChildNodeSelection = v_nNode.selectNodes( "./*" ); for( var v_iChild = 0; v_iChild < v_nChildNodeSelection.length; v_iChild++ ) { var v_nChildNode = v_nChildNodeSelection.item( v_iChild ); var v_nNewChildNode = v_nNewNode.appendChild( doc.createElement( "treeNode" ) ); v_nNewChildNode.setAttribute( "nodeName", v_nChildNode.nodeName ); v_nNewChildNode.setAttribute( "value", v_nChildNode.parentNode.getAttribute( "id" ) + "_" + v_nChildNode.nodeName ); // if child node has its own description then create it. if ( v_nChildNode.getAttribute( "idsDescription" ) ) { U_XML.F_CopyAttribute( v_nNewChildNode, v_nChildNode, "idsDescription" ); } this.f_copyAttributes( v_nNewChildNode, v_nChildNode ); if( v_nChildNode.nodeName == "hideElements" ) { continue; } v_nNewChildNode.setAttribute( "expandable", "true" ); var v_nChildChildNodeSelection = v_nChildNode.selectNodes( "./*" ); for( var v_iChildChild = 0; v_iChildChild < v_nChildChildNodeSelection.length; v_iChildChild++ ) { var v_nChildChildNode = v_nChildChildNodeSelection.item( v_iChildChild ); var v_nNewChildChildNode = v_nNewChildNode.appendChild( doc.createElement( "treeNode" ) ); v_nNewChildChildNode.setAttribute( "nodeName", v_nChildChildNode.nodeName ); v_nNewChildChildNode.setAttribute( "value", v_nChildChildNode.getAttribute( "id" ) ); this.f_copyAttributes( v_nNewChildChildNode, v_nChildChildNode ); } } } }; G_UIPE.f_initAllDecks = function() { var v_nNavTreeView = this.m_oNavigationTree.F_GetTreeViewNode(); var v_nlTreeNodes = v_nNavTreeView.selectNodes( "//treeNode" ); var v_divDeckMain = document.getElementById( "deckMain" ); var v_iLength = v_nlTreeNodes.length; this.m_oEditorViews = {}; this.m_aDeckId = []; for( var i = 0; i < v_iLength; i++ ) { var v_nTreeNode = v_nlTreeNodes.item( i ); var v_sId = this.f_getTreeNodeId( v_nTreeNode ); var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); if( this.m_aDeckId.indexOf( v_sId ) == -1 ) { this.m_aDeckId.push( v_sId ); var v_divContent = v_divDeckMain.appendChild( document.createElement( "div" ) ); v_divContent.id = "uipe_" + v_sId; var v_sLabel = v_nTreeNode.getAttribute( "idsLabel" ); if ( v_sLabel ) { v_divContent.setAttribute( "aria-label", G_ResManager.F_GetString( v_sLabel ) ); } } // for properSheet and chartGroup, we need to create editor in the beginning instead of create them when user click node in the navigation tree if( v_sNodeName == "propertySheet" || v_sNodeName == "chartGroups" || v_sNodeName == "chartGroup" ) { this.m_oEditorViews[v_sId] = this.f_createUIEditor( v_nTreeNode, v_divContent ); } } this.m_oDeck = new C_Deck( v_divDeckMain, this ); }; G_UIPE.F_Deck_OnBeforeCardVisible = function( v_oDeck, v_divNewCard, v_iOldCardIndex, v_iNewCardIndex ) { var v_nCurrentTreeNode = this.m_nCurrentTreeNode; // skip "Loading" card so minus 1 var v_sId = this.m_aDeckId[v_iNewCardIndex - 1]; if ( !this.m_oEditorViews[v_sId] ) { var v_divCard = document.getElementById( "uipe_" + v_sId ); U_DOM.F_RemoveAllChildren( v_divCard ); var v_sNodeName = v_nCurrentTreeNode.getAttribute( "nodeName" ); var v_sTemplateId = v_nCurrentTreeNode.getAttribute( "refPopup" ); if( v_sTemplateId ) { if( !this.m_oEditorViews[v_sTemplateId] ) { this.m_oEditorViews[v_sTemplateId] = this.f_createUIEditor( v_nCurrentTreeNode, v_divCard ); } } else { this.m_oEditorViews[v_sId] = this.f_createUIEditor( v_nCurrentTreeNode, v_divCard ); } } }; G_UIPE.f_createBlankEditor = function( v_nTreeNode, v_divEditorView ) { var v_sDescId = v_nTreeNode.getAttribute('idsDescription2') || v_nTreeNode.getAttribute('idsDescription'); var v_sDesc = (v_sDescId) ? G_ResManager.F_GetString( v_sDescId ) : "Description goes here..."; var v_divDescription = document.createElement('div'); v_divDescription.style.width = "100%"; v_divDescription.style.padding = "4px"; v_divDescription.innerText = v_sDesc; v_divEditorView.appendChild( v_divDescription ); v_nTreeNode.setAttribute( "blankView", "true" ); return null; }; G_UIPE.f_createHelpContentEditor = function( v_nTreeNode, v_divEditorView ) { var v_tblContent = v_divEditorView.appendChild( document.createElement( "table" ) ); v_tblContent.style.width = "298px"; var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); v_tblContent.setAttribute( "id", v_sNodeName ); var v_sLabel = v_nTreeNode.getAttribute( "idsLabel" ); if ( v_sLabel ) { v_tblContent.setAttribute( "aria-label", G_ResManager.F_GetString( v_sLabel ) ); } if( v_sNodeName == "helpContents" ) { this.m_oHelpComboBoxEditor = new C_ComboBox( v_tblContent, null, G_ResManager.F_GetResource( "HelpContent" ), this ); var v_nProfileNode = this.m_nProfile.selectSingleNode( ".//helpContents" ); if( v_nProfileNode ) { this.m_oHelpComboBoxEditor.F_SelectByValue( v_nProfileNode.selectSingleNode( "./ibmHelpContents" ).getAttribute( "type" ) ); } else { // set default value "professional" this.m_oHelpComboBoxEditor.F_SelectByValue( "professional" ); } this.m_sHelpComboBoxDefaultValue = this.m_oHelpComboBoxEditor.F_GetValue(); return this.m_oHelpComboBoxEditor; } else if( v_sNodeName == "helpGettingStarted" ) { this.m_oGettingStartComboBoxEditor = new C_ComboBox( v_tblContent, null, G_ResManager.F_GetResource( "HelpContent" ), this ); var v_nProfileNode = this.m_nProfile.selectSingleNode( ".//helpGettingStarted" ); if( v_nProfileNode ) { this.m_oGettingStartComboBoxEditor.F_SelectByValue( v_nProfileNode.selectSingleNode( "./ibmHelpGettingStarted" ).getAttribute( "type" ) ); } else { // set default value "professional" this.m_oGettingStartComboBoxEditor.F_SelectByValue( "professional" ); } this.m_sGettingStartComboBoxDefaultValue = this.m_oGettingStartComboBoxEditor.F_GetValue(); return this.m_oGettingStartComboBoxEditor; } return null; }; G_UIPE.f_createSettingSheetEditor = function( v_nTreeNode, v_divEditorView ) { var v_sName = v_nTreeNode.getAttribute( "value" ); var v_nSettingGroup = this.m_nStudioUIResources.selectSingleNode( ".//settingsGroup[@name='" + v_sName + "']" ); var v_oSettingsSheetEditor = new C_SettingSheet( v_divEditorView, v_nSettingGroup, this, document.body ); var v_aGroupSettings = v_nSettingGroup.selectNodes( "./setting" ); for( var i = 0; i < v_aGroupSettings.length; i++ ) { var v_sSettingName = v_aGroupSettings.item( i ).getAttribute( "name" ); var v_sValue = null; var v_nProfileSetting = this.m_nProfile.selectSingleNode( ".//setting[@name='" + v_sSettingName + "']" ); if ( v_nProfileSetting ) { v_sValue = v_nProfileSetting.getAttribute( "defaultValue" ); } v_oSettingsSheetEditor.F_ShowSetting( v_sSettingName, v_sValue ); } return v_oSettingsSheetEditor; }; G_UIPE.f_createPropertiesEditor = function(v_nTreeNode, v_divEditorView) { var v_sID = v_nTreeNode.getAttribute("value"); var v_nPropertyGroup = this.m_nStudioUIResources.selectSingleNode(".//group[@name='" + v_sID + "']"); var v_sPropertySheetID = v_nPropertyGroup.parentNode.parentNode.getAttribute( "id" ); var v_oPropertyEditor = new C_PropertyEditor( v_divEditorView, v_nPropertyGroup, this.m_nStudioUIResources.selectSingleNode( ".//objects" ), this.m_nStudioUIResources.selectSingleNode( ".//namedSets" ) ); var v_nPropertyProfile = this.m_nProfile.selectSingleNode( ".//propertySheet[@id='" + v_sPropertySheetID + "']/propertyVisibility" ); var v_sAction = "hide"; var v_aProfiledPropertyNames = []; if( v_nPropertyProfile ) { v_sAction = v_nPropertyProfile.getAttribute( "action" ); v_aProfiledPropertyNames = U_XML.F_AppendValues( null, v_nPropertyProfile.selectNodes( ".//property/@name" )); v_nTreeNode.setAttribute( "actionValue", v_sAction ); } var v_aUIPEPropertyNames = U_XML.F_AppendValues( null, v_nPropertyGroup.selectNodes( ".//property/@name" )); var v_aCheckedPropertyNames = this.f_buildCheckedItemIDSet( v_sAction == "show", v_aProfiledPropertyNames, v_aUIPEPropertyNames); var v_oProfilePropertyWithAppliesToNames = []; if( v_nPropertyProfile ) { v_oProfilePropertyWithAppliesToNames = U_XML.F_AppendValues( null, v_nPropertyProfile.selectNodes( "./property[appliesTo]/@name" ) ); } var v_aCheckedProperties = []; for( var i = 0; i < v_aUIPEPropertyNames.length; i++ ) { var v_sPropertyName = v_aUIPEPropertyNames[i]; if( v_aCheckedPropertyNames.indexOf( v_sPropertyName ) == -1 && v_oProfilePropertyWithAppliesToNames.indexOf( v_sPropertyName ) == -1) { continue; } v_aCheckedProperties.push( v_sPropertyName ); var v_nUIPEProperty = v_nPropertyGroup.selectSingleNode( ".//property[@name='" + v_sPropertyName + "']" ); var v_aUIPEPropertyObjectNames = U_XML.F_AppendValues( null, v_nUIPEProperty.selectNodes( "./objectRef/@name" ) ); var v_aUIPEPropertyNamedSetNames = U_XML.F_AppendValues( null, v_nUIPEProperty.selectNodes( "./namedSetRef/@name" ) ); var v_aCheckedObjects = v_aUIPEPropertyObjectNames; var v_aCheckedNamedSets = v_aUIPEPropertyNamedSetNames; if( v_oProfilePropertyWithAppliesToNames.indexOf( v_sPropertyName ) != -1) { var v_nProfileProperty = v_nPropertyProfile.selectSingleNode( "./property[@name='" + v_sPropertyName + "']" ); var v_aProfilePropertyObjectNames = U_XML.F_AppendValues( null, v_nProfileProperty.selectNodes( ".//parentContainer[@type='object']/@name" ) ); v_aCheckedObjects = this.f_buildCheckedItemIDSet( v_sAction == "show", v_aProfilePropertyObjectNames, v_aUIPEPropertyObjectNames); var v_aProfilePropertyNamedSetNames = U_XML.F_AppendValues( null, v_nProfileProperty.selectNodes( ".//parentContainer[@type='namedSet']/@name" ) ); v_aCheckedNamedSets = this.f_buildCheckedItemIDSet( v_sAction == "show", v_aProfilePropertyNamedSetNames, v_aUIPEPropertyNamedSetNames); } v_oPropertyEditor.F_SetObjectsChecked(v_sPropertyName, v_aCheckedObjects); v_oPropertyEditor.F_SetNamedSetsChecked(v_sPropertyName, v_aCheckedNamedSets); } v_oPropertyEditor.F_SetPropertiesChecked( v_aCheckedProperties ); return v_oPropertyEditor; }; G_UIPE.f_createListViewEditor = function( v_nTreeNode, v_divEditorView ) { var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); var v_sID = v_nTreeNode.getAttribute( "value" ); var v_sChildrenPath = ".//" + v_sNodeName + "[@id='" + v_sID + "']/"; switch ( v_sNodeName ) { case "menubar": v_sChildrenPath += "menu"; break; case "menu": case "menuItem": if( !v_nTreeNode.getAttribute( "refPopup" ) ) { v_sChildrenPath += "menuPopup/menuItem"; } else { var v_sMenuItemPath = ".//menuPopupTemplates/menuPopup[@id='" + v_nTreeNode.getAttribute( "refPopup" ) + "']/menuItem"; var v_sSeparatorLabelPath = ".//menuPopupTemplates/menuPopup[@id='" + v_nTreeNode.getAttribute( "refPopup" ) + "']/menuSeparatorLabel"; v_sChildrenPath = v_sMenuItemPath + "|" + v_sSeparatorLabelPath; } break; case "menuPopup": if( !v_nTreeNode.getAttribute( "refPopup" ) ) { v_sChildrenPath += "menuItem"; } else { v_sChildrenPath = ".//menuPopupTemplates/menuPopup[@id='" + v_nTreeNode.getAttribute( "refPopup" ) + "']/menuItem"; } break; case "toolbar": v_sChildrenPath += "toolbarButton"; break; case "listView": v_sChildrenPath += "listItem"; break; case "tabControl": v_sChildrenPath += "tab"; break; case "explorer": v_sChildrenPath += "explorerButton"; break; case "chartGroup": v_sChildrenPath += "chartType"; break; case "propertySheet": v_sChildrenPath += "properties/group"; break; case "hideElements": var v_sParentId = v_nTreeNode.getAttribute( "value" ).split( "_" )[0]; v_sChildrenPath = ".//dialog[@id='" + v_sParentId + "']/hideElements/hideElement"; break; default : return null; } var v_oListViewEditor = new C_ListView( v_divEditorView, null, this ); v_oListViewEditor.F_GetListViewNode().setAttribute( "view", "checkbox" ); var v_nListItems = v_oListViewEditor.F_GetListItemsNode(); var v_aSelectedIDs = null; var v_nUIPENode = null; var doc = v_nListItems.ownerDocument; var v_nProfileNode = null; if( v_sNodeName == "chartGroup" ) { v_nProfileNode = this.m_nProfile.selectSingleNode( "./chartTypes" ); v_nUIPENode = this.m_nStudioUIResources.selectSingleNode( ".//*[@id='" + v_nTreeNode.getAttribute( "value" ) + "']" ); v_aSelectedIDs = this.f_getCheckedItemIDs( v_nProfileNode, v_nUIPENode ); } else { v_nProfileNode = this.f_getProfileNodeByTreeNode( v_nTreeNode ); if ( v_nProfileNode ) { if( v_nTreeNode.getAttribute( "nodeName" ) == "hideElements" ) { v_nUIPENode = this.m_nStudioUIResources.selectSingleNode( ".//*[@id='" + v_nProfileNode.parentNode.getAttribute( "id" ) + "']/hideElements" ); } else { v_nUIPENode = this.m_nStudioUIResources.selectSingleNode( ".//*[@id='" + v_nProfileNode.getAttribute( "id" ) + "']" ); // hide Elements do not need action node because it means "hide" var v_sAction = null; if( v_nProfileNode.nodeName == "propertySheet" ) { var v_nPropertyVisibility = v_nProfileNode.selectSingleNode( "./propertyVisibility" ); if( v_nPropertyVisibility ) { v_sAction = v_nPropertyVisibility.getAttribute( "action" ); } else { v_sAction = "hide"; } v_nTreeNode.setAttribute( "originalActionValue", v_sAction ); } else { v_sAction = v_nProfileNode.getAttribute( "action" ); } v_nTreeNode.setAttribute( "actionValue", v_sAction); } if( v_nProfileNode.nodeName == "propertySheet" ) { v_aSelectedIDs = this.f_buildCheckedItemIDSet( v_sAction == "show" , U_XML.F_AppendValues( null, v_nProfileNode.selectNodes( "./propertyVisibility/group/@name" )), U_XML.F_AppendValues( null, this.m_nStudioUIResources.selectNodes( ".//propertySheet[@id='" + v_nProfileNode.getAttribute( "id" ) + "']/properties/group/@name" ) )); } else { v_aSelectedIDs = this.f_getCheckedItemIDs( v_nProfileNode, v_nUIPENode ); } } } if ( v_sSeparatorLabelPath && this.m_nStudioUIResources.selectNodes( v_sSeparatorLabelPath ).length > 0 ) { v_nTreeNode.setAttribute( "hasSepartorLabel", "true" ); v_oListViewEditor.F_GetListViewNode().setAttribute( "indentLength", "16" ); } var v_nChildrenNodes = this.m_nStudioUIResources.selectNodes( v_sChildrenPath ); for( var i = 0; i < v_nChildrenNodes.length; i++ ) { var v_nResourceItem = v_nChildrenNodes.item( i ); var v_sIdentifier = v_nResourceItem.nodeName == "group" ? "name" : "id"; var v_sId = v_nResourceItem.getAttribute( v_sIdentifier ); var v_nListItem = v_nListItems.appendChild( doc.createElement( "listItem" ) ); if ( v_sId ) { v_nListItem.setAttribute( "value", v_sId ); } U_XML.F_CopyAttribute( v_nListItem, v_nResourceItem, "smallIcon" ); this.f_copyAttributes( v_nListItem, v_nResourceItem ); if ( v_nTreeNode.getAttribute( "hasSepartorLabel" ) ) { if ( v_nResourceItem.nodeName == "menuSeparatorLabel" ) { v_nListItem.setAttribute( "staticCheckbox", "true" ); } else { v_nListItem.setAttribute( "indentLevel", "1" ); } } if( v_sNodeName == "chartGroup" ) { if( v_aSelectedIDs && v_aSelectedIDs.indexOf( v_sId ) != -1 ) { v_nListItem.setAttribute( "checked", "true" ); v_nListItem.setAttribute( "oriChecked", "true" ); } } else if( v_sNodeName == "hideElements" ) { // hide elements do not have "show/hide" so uncheck all when profile node does not existing if( v_aSelectedIDs && v_aSelectedIDs.indexOf( v_sId ) != -1 ) { v_nListItem.setAttribute( "checked", "true" ); } } else { // if profile node does not existes, all the list item should be selected if( !v_nProfileNode || ( v_aSelectedIDs && v_aSelectedIDs.indexOf( v_sId ) != -1 ) ) { v_nListItem.setAttribute( "checked", "true" ); v_nListItem.setAttribute( "oriChecked", "true" ); } } } v_oListViewEditor.F_Draw(); if ( v_nTreeNode.getAttribute( "hasSepartorLabel" ) ) { this.f_hideListViewCheckBox( v_oListViewEditor ); } return v_oListViewEditor; }; G_UIPE.f_hideListViewCheckBox = function( v_oListViewEditor, v_sAction ) { var v_nListItems = v_oListViewEditor.F_GetListItems(); for( var i = 0; i < v_nListItems.length; i++ ) { var v_nlistItem = v_nListItems.item( i ); if( v_nlistItem.getAttribute( "staticCheckbox" ) == "true" ) { var v_elListItem = document.getElementById( v_nlistItem.getAttribute("htmlId") ); var v_el = v_elListItem.getElementsByTagName( "IMG" ).item(0); if ( v_el ) { v_el.parentNode.removeChild( v_el ); } if ( v_sAction ) { v_nlistItem.setAttribute( "checked", v_sAction == "hide" ? "true" : "false" ); } } } }; G_UIPE.f_createUIEditor = function( v_nTreeNode, v_divEditorView ) { var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); switch ( v_sNodeName ) { case "menubar": case "menu": case "menuItem": case "menuPopup": case "toolbar": case "listView": case "tabControl": case "explorer": case "chartGroup": case "hideElements": case "propertySheet": return this.f_createListViewEditor( v_nTreeNode, v_divEditorView ); case "settingsGroup": return this.f_createSettingSheetEditor( v_nTreeNode, v_divEditorView ); case "group": return this.f_createPropertiesEditor(v_nTreeNode, v_divEditorView); case "helpContents": case "helpGettingStarted": return this.f_createHelpContentEditor( v_nTreeNode, v_divEditorView ); default : return this.f_createBlankEditor( v_nTreeNode, v_divEditorView ); } }; G_UIPE.f_getProfileNodeByTreeNode = function( v_nTreeNode, v_nProfile ) { v_nProfile = v_nProfile || this.m_nProfile; var v_sProfileNodeId = this.f_getProfileNodeIDByTreeNode( v_nTreeNode ); var v_nProfileNode = null; if( v_nTreeNode.getAttribute( "nodeName" ) == "hideElements" ) { var v_sDialogId = v_sProfileNodeId.split( "_" )[0]; v_nProfileNode = v_nProfile.selectSingleNode(".//dialog[@id='" + v_sDialogId + "']/hideElements" ); } else { v_nProfileNode = v_nProfile.selectSingleNode(".//*[@id='" + v_sProfileNodeId + "']" ); } return v_nProfileNode; }; G_UIPE.f_getProfileNodeIDByTreeNode = function( v_nTreeNode ) { var v_sID = v_nTreeNode.getAttribute( "value" ); var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); if( v_sNodeName == "menu" || v_sNodeName == "menuItem" ) { if( v_nTreeNode.getAttribute( "refPopup" ) ) { v_sID = v_nTreeNode.getAttribute( "refPopup" ); } else { v_sID = this.m_nStudioUIResources.selectSingleNode( ".//" + v_sNodeName + "[@id='" + v_sID + "']/menuPopup" ).getAttribute( "id" ); } } return v_sID; }; G_UIPE.f_initMenubars = function( v_nNavTree ) { var doc = v_nNavTree.ownerDocument; var v_nMenubarsTreeNode = v_nNavTree.selectSingleNode( ".//treeNode[@value='menubars']" ); var v_nlResMenubars = this.m_nStudioUIResources.selectNodes( "menubars/menubar" ); for( var v_iMenubar = 0; v_iMenubar < v_nlResMenubars.length; v_iMenubar++ ) { var v_nResMenubar = v_nlResMenubars.item( v_iMenubar ); var v_nMenubarTreeNode = v_nMenubarsTreeNode.appendChild( doc.createElement( "treeNode" ) ); v_nMenubarTreeNode.setAttribute( "nodeName", "menubar" ); v_nMenubarTreeNode.setAttribute( "value", v_nResMenubar.getAttribute( "id" ) ); v_nMenubarTreeNode.setAttribute( "expandable", "true" ); v_nMenubarTreeNode.setAttribute( "expanded", "true" ); v_nMenubarTreeNode.setAttribute( "hideCheckbox", "true" ); this.f_copyAttributes( v_nMenubarTreeNode, v_nResMenubar ); var v_nlResMenus = v_nResMenubar.selectNodes( "menu" ); for ( var v_iMenu = 0; v_iMenu < v_nlResMenus.length; v_iMenu++ ) { var v_nResMenu = v_nlResMenus.item( v_iMenu ); if (v_nResMenu.selectSingleNode( "menuPopup" )) { var v_nMenuTreeNode = v_nMenubarTreeNode.appendChild( doc.createElement( "treeNode" ) ); v_nMenuTreeNode.setAttribute( "nodeName", v_nResMenu.nodeName ); v_nMenuTreeNode.setAttribute( "value", v_nResMenu.getAttribute( "id" ) ); v_nMenuTreeNode.setAttribute( "hideCheckbox", "true" ); this.f_copyAttributes( v_nMenuTreeNode, v_nResMenu ); if( v_nResMenu.selectSingleNode( "menuPopup/menuItem/menuPopup" ) ) { v_nMenuTreeNode.setAttribute( "expandable", "true" ); } this.f_appendMenuPopups( v_nMenuTreeNode, v_nResMenu ); } } } }; G_UIPE.f_initMenuPopups = function( v_nNavTree ) { var v_nMenuPopupsTreeNode = v_nNavTree.selectSingleNode( ".//treeNode[@value='menuPopups']" ); var v_nResMenuPopups = this.m_nStudioUIResources.selectSingleNode( "menuPopups" ); this.f_appendMenuPopups( v_nMenuPopupsTreeNode, v_nResMenuPopups ); }; G_UIPE.f_appendMenuPopups = function( v_nTreeNode, v_nResNode ) { var doc = v_nTreeNode.ownerDocument; // menuPopup node may exists with path "menuPopups->menuPopup" or "menuPopups->menuPopup->menuItem->menuPopup" var v_nlResMenuPopups = v_nResNode.selectNodes( "menuPopup" ); for( var v_iMenuPopup = 0; v_iMenuPopup < v_nlResMenuPopups.length; v_iMenuPopup++ ) { var v_nResMenuPopup = v_nlResMenuPopups.item( v_iMenuPopup ); var v_nMenuPopupTreeNode = null; if( v_nResMenuPopup.parentNode.nodeName == "menuPopups" ) { v_nMenuPopupTreeNode = v_nTreeNode.appendChild( doc.createElement( "treeNode" ) ); v_nMenuPopupTreeNode.setAttribute( "nodeName", v_nResMenuPopup.nodeName ); if( v_nResMenuPopup.selectSingleNode( "menuItem/menuPopup" ) ) { v_nMenuPopupTreeNode.setAttribute( "expandable", "true" ); } v_nMenuPopupTreeNode.setAttribute( "value", v_nResMenuPopup.getAttribute( "id" ) ); v_nMenuPopupTreeNode.setAttribute( "hideCheckbox", "true" ); this.f_copyAttributes( v_nMenuPopupTreeNode, v_nResMenuPopup ); } // if use template, menuItems store in var v_nlResMenuItems = null; if( v_nResMenuPopup.getAttribute( "refPopup" ) ) { v_nlResMenuItems = this.m_nStudioUIResources.selectNodes( ".//menuPopupTemplates/menuPopup[@id='" + v_nResMenuPopup.getAttribute( "refPopup" ) + "']/menuItem" ) } else { v_nlResMenuItems = v_nResMenuPopup.selectNodes( "menuItem" ); } for( var i = 0; i < v_nlResMenuItems.length; i++ ) { var v_nResMenuItem = v_nlResMenuItems.item( i ); if( v_nResMenuItem.selectSingleNode( "menuPopup" ) ) { var v_nChildTreeNode = doc.createElement( "treeNode" ); ( v_nMenuPopupTreeNode ? v_nMenuPopupTreeNode : v_nTreeNode ).appendChild( v_nChildTreeNode ); v_nChildTreeNode.setAttribute( "nodeName", v_nResMenuItem.nodeName ); var v_nResMenuItemPopup = v_nResMenuItem.selectSingleNode( "menuPopup" ); if( v_nResMenuItemPopup ) { // if use template, search menuPopup from to determine whether current node is an "expandable" one if( v_nResMenuItemPopup.getAttribute( "refPopup" ) ) { if( this.m_nStudioUIResources.selectSingleNode( ".//menuPopupTemplates/menuPopup[@id='" + v_nResMenuItemPopup.getAttribute( "refPopup" ) + "']/menuItem/menuPopup" ) ) { v_nChildTreeNode.setAttribute( "expandable", "true" ); } } else if( v_nResMenuItemPopup.selectSingleNode( "menuItem/menuPopup" ) ) { v_nChildTreeNode.setAttribute( "expandable", "true" ); } } v_nChildTreeNode.setAttribute( "value", v_nResMenuItem.getAttribute( "id" ) ); if( v_nResMenuItem.selectSingleNode( "menuPopup" ) ) { if( v_nResMenuItem.selectSingleNode( "menuPopup" ).getAttribute( "refPopup" ) ) { v_nChildTreeNode.setAttribute( "refPopup", v_nResMenuItem.selectSingleNode( "menuPopup" ).getAttribute( "refPopup" ) ); } } this.f_copyAttributes( v_nChildTreeNode, v_nResMenuItem ); this.f_appendMenuPopups( v_nChildTreeNode, v_nResMenuItem ); } } } }; G_UIPE.F_ListView_OnCheckboxClick = function( v_oListViewType, v_nListItem ) { var v_sID = this.f_getTreeNodeId( this.m_oNavigationTree.F_GetSingleSelectedNode() ); var v_oListView = this.m_oEditorViews[v_sID]; switch( v_oListViewType ) { case this.m_oCheckAllListView : if ( v_nListItem.getAttribute( "checked" ) == "true" ) { v_oListView.F_CheckAll(); } else { v_oListView.F_UncheckAll(); } if( this.m_oNavigationTree.F_GetSelectedNode().getAttribute( "nodeName" ) != "group" ) { var v_oListItems = v_oListView.F_GetListItems(); for( var i = 0; i < v_oListItems.length; i++ ) { this.f_highlightListItemAndTreeNode( v_oListView, v_oListItems.item( i ) ); } } break; case this.m_oActionListView : var v_sAction = v_nListItem.getAttribute( "checked" ) == "true" ? "hide" : "show"; this.m_oNavigationTree.F_GetSingleSelectedNode().setAttribute( "actionValue", v_sAction ); this.f_highlightListItemAndTreeNode( v_oListViewType, v_nListItem ); break; default: this.f_highlightListItemAndTreeNode( v_oListViewType, v_nListItem ); return; } if ( this.m_oNavigationTree.F_GetSingleSelectedNode().getAttribute( "hasSepartorLabel" ) ) { this.f_hideListViewCheckBox( v_oListView, this.m_oNavigationTree.F_GetSingleSelectedNode().getAttribute( "actionValue") ); } }; G_UIPE.F_HighlightListItem = function( v_oListViewType, v_nListItem ) { var v_sHtmlID = v_nListItem.getAttribute( "htmlId" ); var v_eListViewDiv = document.getElementById( v_sHtmlID ).firstChild.firstChild; var v_eListViewSpan = v_eListViewDiv.getElementsByTagName( "SPAN" )[0]; var v_nTreeNode = this.m_oNavigationTree.F_GetSelectedNode(); if( v_oListViewType == this.m_oActionListView ) { // do not need to consider "checked" equals "oriChecked" or not since this status is not always correct for this.m_oActionListView if( v_nTreeNode.getAttribute( "highlight" ) && v_nTreeNode.getAttribute( "highlight" ) == "true" ) { v_nListItem.removeAttribute( "highlight" ); v_eListViewSpan.className = ""; return false; } else { v_nListItem.setAttribute( "highlight", "true" ); v_eListViewSpan.className = "uipeHighlight"; return true; } } else { // here v_oListViewType can not be this.m_oCheckAllListView if( Boolean( v_nListItem.getAttribute( "checked" ) == "true" ) != Boolean( v_nListItem.getAttribute( "oriChecked" ) == "true" ) ) { v_nListItem.setAttribute( "highlight", "true" ); v_eListViewSpan.className = "uipeHighlight"; return true; } else { v_nListItem.removeAttribute( "highlight" ); v_eListViewSpan.className = ""; return false; } } }; G_UIPE.f_highlightListItemAndTreeNode = function( v_oListViewType, v_nListItem ) { var v_bHighlightListItem = this.F_HighlightListItem( v_oListViewType, v_nListItem ); if( v_bHighlightListItem ) { this.F_HighlightSelectedTreeNode( true ); } else { if( !v_oListViewType.F_GetListViewNode().selectSingleNode( ".//listItem[@highlight]" ) ) { this.F_HighlightSelectedTreeNode( false ); } } } G_UIPE.F_HighlightSelectedTreeNode = function( v_bHighlight ) { this.F_HighlightTreeNode( this.m_oNavigationTree, this.m_oNavigationTree.F_GetSelectedNode(), v_bHighlight ); }; G_UIPE.F_HighlightSettings = function( v_elFixedValueCell, v_bChangeDefault ) { // TR->TBODY->TABLE->TD->TR->TD(lable TD) var v_elLable = v_elFixedValueCell.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild; if( v_bChangeDefault ) { // make sure only one "uipeDefaultSettingsHighlight" added to the Element if( v_elLable.className.indexOf( "uipeDefaultSettingsHighlight" ) == -1 ) { v_elLable.className += " uipeDefaultSettingsHighlight"; } // value TD if( v_elFixedValueCell.firstChild.tagName == "INPUT" ) { if( v_elFixedValueCell.firstChild.className.indexOf( "uipeDefaultSettingsHighlight" ) == -1 ) { v_elFixedValueCell.firstChild.className += " uipeDefaultSettingsHighlight"; } } else { if( v_elFixedValueCell.className.indexOf( "uipeDefaultSettingsHighlight" ) == -1 ) { v_elFixedValueCell.className += " uipeDefaultSettingsHighlight"; } } this.F_HighlightSelectedTreeNode( true ); } else { v_elLable.className = v_elLable.className.replace( "uipeDefaultSettingsHighlight", "" ); // value TD if( v_elFixedValueCell.firstChild.tagName == "INPUT" ) { v_elFixedValueCell.firstChild.className = v_elFixedValueCell.firstChild.className.replace( "uipeDefaultSettingsHighlight", "" ); } else { v_elFixedValueCell.className = v_elFixedValueCell.className.replace( "uipeDefaultSettingsHighlight", "" ); } this.F_HighlightSelectedTreeNode( false ); } }; G_UIPE.F_HighlightTreeNode = function( v_oTreeView, v_nTreeNode, v_bHighlight ) { var v_sHtmlId = v_nTreeNode.getAttribute( "htmlId" ); var v_eTreeNodeDiv = v_oTreeView.F_GetElementById( v_sHtmlId ); var v_eTreeNodeSpan = v_eTreeNodeDiv.getElementsByTagName( "SPAN" )[0]; if( v_bHighlight ) { if( v_nTreeNode.getAttribute( "highlight" ) != "true" ) { v_nTreeNode.setAttribute( "highlight", "true" ); v_nTreeNode.setAttribute( "classPrefix", "uipeHighlight clsTreeNode" ); v_eTreeNodeSpan.className = "uipeHighlight " + v_eTreeNodeSpan.className; } } else { if( v_nTreeNode.getAttribute( "highlight" ) ) { v_nTreeNode.removeAttribute( "highlight" ); v_nTreeNode.removeAttribute( "classPrefix" ); v_eTreeNodeSpan.className = v_eTreeNodeSpan.className.replace( "uipeHighlight ", "" ); } } if( v_nTreeNode.parentNode && v_nTreeNode.parentNode.nodeName != "treeView" ) { this.F_HighlightTreeNode( v_oTreeView, v_nTreeNode.parentNode, v_nTreeNode.parentNode.selectSingleNode( ".//treeNode[@highlight]" ) ); } }; G_UIPE.f_getCheckedItemIDs = function( v_nProfileNode, v_nUIPENode ) { var v_aUIPEIDs = U_XML.F_AppendValues( null, v_nUIPENode.selectNodes( "*/@id" ) ); if( !v_nProfileNode ) { return v_aUIPEIDs; } var v_bShow = false; if( v_nProfileNode.nodeName == "hideElements" ) { // for child nodes in hideElements, we should show them as selected ones v_bShow = true; } else { v_bShow = v_nProfileNode.getAttribute( "action" ) == "show"; } var v_sIdentifer = v_nProfileNode.nodeName == "listView" ? "value" : "id"; var v_aProfileIDs = U_XML.F_AppendValues( null, v_nProfileNode.selectNodes( "*/@" + v_sIdentifer ) ); return this.f_buildCheckedItemIDSet( v_bShow, v_aProfileIDs, v_aUIPEIDs ); }; G_UIPE.f_buildCheckedItemIDSet = function( v_bShow, v_aProfileIDs, v_aUIPEIDs ) { var v_aIDs = []; for( var i = 0; i < v_aUIPEIDs.length; i++ ) { var v_sID = v_aUIPEIDs[i]; var v_bContained = v_aProfileIDs.indexOf( v_sID ) != -1 ; if( ( v_bShow && v_bContained ) || ( !v_bShow && !v_bContained ) ) { v_aIDs.push( v_sID ); } } return v_aIDs; }; G_UIPE.f_copyAttributes = function( v_nTarget, v_nSource ) { U_XML.F_CopyAttribute( v_nTarget, v_nSource, "smallIcon" ); if( !!(v_nSource.getAttribute( "idsDescription2" )) ) { U_XML.F_CopyAttribute( v_nTarget, v_nSource, "idsDescription2" ) } if( !!(v_nSource.getAttribute( "idsLabel" )) && U_XML.F_CopyAttribute( v_nTarget, v_nSource, "idsLabel" ) ) { return; } if( !!(v_nSource.getAttribute( "label" )) && U_XML.F_CopyAttribute( v_nTarget, v_nSource, "label" ) ) { return; } v_nTarget.setAttribute( "label", v_nSource.getAttribute( "id" ) ); }; G_UIPE.f_getActionValue = function( v_nTreeNode ) { var v_sAction = v_nTreeNode.getAttribute( "actionValue" ); // only chartGroups have action attribute if( v_nTreeNode.getAttribute( "nodeName" ) == "chartGroup" ) { return ""; } return v_sAction || "hide"; }; G_UIPE.f_updateActionListView = function( v_nTreeNode ) { var v_nListItems = this.m_oActionListView.F_GetListItems(); var v_sChecked = this.f_getActionValue( v_nTreeNode ) == "hide" ? "true" : "false"; v_nListItems.item( 0 ).setAttribute( "checked", v_sChecked ); v_nListItems.item( 0 ).setAttribute( "oriChecked", v_sChecked ); this.m_oActionListView.F_Draw(); if( v_nTreeNode.getAttribute( "highlight" ) && v_nTreeNode.getAttribute( "highlight" ) == "true" ) { var v_nListItem = v_nListItems.item( 0 ); var v_sHtmlID = v_nListItem.getAttribute( "htmlId" ); var v_eListViewDiv = document.getElementById( v_sHtmlID ).firstChild.firstChild; var v_eListViewSpan = v_eListViewDiv.getElementsByTagName( "SPAN" )[0]; v_eListViewSpan.className = "uipeHighlight"; } }; G_UIPE.f_updateTitleBar = function( v_nTreeNode ) { var v_sTitle = ""; var v_nlNodes = v_nTreeNode.selectNodes("ancestor-or-self::treeNode[@idsLabel]"); if( v_nlNodes && v_nlNodes.length > 0 ) { var v_aValues = []; for( var i = 0; i < v_nlNodes.length; i++ ) { v_aValues.push( C_TreeView.F_GetTreeNodeLabel(v_nlNodes[i]) ); } v_sTitle = v_aValues.join(" -> "); } document.getElementById( "divTitle" ).innerText = v_sTitle; }; G_UIPE.f_updateInfoBox = function( v_nTreeNode ) { var v_sTooltip = ""; var v_sDescription = ""; var v_nTooltip = v_nTreeNode.selectSingleNode( "ancestor-or-self::*[@idsTooltip][1]" ); if( v_nTooltip ) { var v_sIdsTooltip = v_nTooltip.getAttribute( "idsTooltip" ); v_sTooltip = G_ResManager.F_GetString( v_sIdsTooltip ); } var v_nDesc = v_nTreeNode.selectSingleNode( "ancestor-or-self::*[@idsDescription][1]" ); if( v_nDesc ) { var v_sIdsDesc = v_nDesc.getAttribute( "idsDescription" ); v_sDescription = G_ResManager.F_GetString( v_sIdsDesc ); } document.getElementById( "infoTitle" ).innerText = v_sTooltip; document.getElementById( "infoDescription" ).innerText = v_sDescription; }; G_UIPE.F_ComboBox_OnChange = function( v_oComboBox, v_nListItem ) { var v_tblContainer = v_oComboBox.F_GetContainer(); // TABLE->TBODY->TR->TD(comboBoxIcon)->TD(comboBoxText)->DIV var v_divText = v_tblContainer.firstChild.firstChild.firstChild.nextSibling.firstChild; if( v_oComboBox == this.m_oHelpComboBoxEditor ) { if( v_nListItem.getAttribute( "value" ) != this.m_sHelpComboBoxDefaultValue ) { v_divText.className = "uipeHighlight"; this.F_HighlightSelectedTreeNode( true ); } else { v_divText.className = ""; this.F_HighlightSelectedTreeNode( false ); } } else if( v_oComboBox == this.m_oGettingStartComboBoxEditor ) { if( v_nListItem.getAttribute( "value" ) != this.m_sGettingStartComboBoxDefaultValue ) { v_divText.className = "uipeHighlight"; this.F_HighlightSelectedTreeNode( true ); } else { v_divText.className = ""; this.F_HighlightSelectedTreeNode( false ); } } }; G_UIPE.F_TreeView_OnNodeClick = function( v_oTreeView, v_nTreeNode) { switch( v_oTreeView ) { case this.m_oNavigationTree: this.f_updateTitleBar( v_nTreeNode ); var v_iIndex = 0; var v_sValue = this.f_getTreeNodeId( v_nTreeNode ); for( var i = 0; i < this.m_aDeckId.length; i++ ) { var v_sCurrentCardId = this.m_aDeckId[i]; if( v_sValue == v_sCurrentCardId ) { v_iIndex = i; break; } } // since template exists in menuPopup, the node in navigation tree DO NOT has one-one relationship with cards in main deck, // 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. this.m_nCurrentTreeNode = v_nTreeNode; // skip the "Loading" deck so we need to add 1 this.m_oDeck.F_SetIndex( v_iIndex + 1 ); var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); var v_sDeckMainHeight = "360px"; var v_sDeckMainWidth = "300px"; switch( v_sNodeName ) { case "hideElements": case "group": case "chartGroup": this.m_oCheckAllListView.F_GetContainer().style.display = ""; this.m_oActionListView.F_GetContainer().style.display = "none"; var v_nListItems = this.m_oCheckAllListView.F_GetListItems(); v_nListItems.item( 0 ).setAttribute( "checked", "false" ); this.m_oCheckAllListView.F_Draw(); v_sDeckMainHeight = "400px"; break; case "chartGroups": this.m_oCheckAllListView.F_GetContainer().style.display = "none"; this.m_oActionListView.F_GetContainer().style.display = ""; if( !v_nTreeNode.getAttribute( "actionValue" ) ) { var v_nChartTypes = this.m_nProfile.selectSingleNode( "./chartTypes" ); if( v_nChartTypes ) { v_nTreeNode.setAttribute( "actionValue", v_nChartTypes.getAttribute( "action" ) ); } else { v_nTreeNode.setAttribute( "actionValue", "hide" ); } } this.f_updateActionListView( v_nTreeNode ); break; case "helpContents": case "helpGettingStarted": this.m_oCheckAllListView.F_GetContainer().style.display = "none"; this.m_oActionListView.F_GetContainer().style.display = "none"; v_sDeckMainHeight = "400px"; break; case "settingsGroup": this.m_oCheckAllListView.F_GetContainer().style.display = "none"; this.m_oActionListView.F_GetContainer().style.display = "none"; v_sDeckMainHeight = "400px"; v_sDeckMainWidth = "490px"; break; default: if( v_nTreeNode.getAttribute( "blankView" ) == "true" ) { this.m_oCheckAllListView.F_GetContainer().style.display = "none"; this.m_oActionListView.F_GetContainer().style.display = "none"; } else { this.m_oCheckAllListView.F_GetContainer().style.display = ""; this.m_oActionListView.F_GetContainer().style.display = ""; this.f_updateActionListView( v_nTreeNode ); var v_nListItems = this.m_oCheckAllListView.F_GetListItems(); v_nListItems.item( 0 ).setAttribute( "checked", "false" ); this.m_oCheckAllListView.F_Draw(); } break; } this.f_updateInfoBox( v_nTreeNode ); var v_divDeckMain = document.getElementById( "deckMain" ); v_divDeckMain.style.height = v_sDeckMainHeight; v_divDeckMain.style.width = v_sDeckMainWidth; break; } }; G_UIPE.f_processFileContents = function( v_oFileContents ) { for( var v_sFile in v_oFileContents ) { if( v_sFile.indexOf( "res/" ) != -1 ) { G_HAL.F_AddFileToLoadedList( v_sFile ); var doc = U_XML.F_LoadString( D_XmlError, v_oFileContents[v_sFile], false, true ); var v_nResources = doc.selectSingleNode( "/resources" ); if( v_nResources ) { U_Utils.F_ReplaceStringResources( v_nResources ); } if (v_sFile.indexOf( "res/uipe.xml" ) != -1) { this.m_nStudioUIResources = v_nResources; this.f_initLabels(); } else { G_ResManager.F_AddResourcesDoc( doc, v_sFile ); } } else if ( v_sFile == G_UIPE.M_sProfileDTD ) { G_UIPE.F_SetInlineProfileDTD( v_oFileContents[v_sFile] ); } } }; G_UIPE.F_GetAppURL = function() { if( !this.m_sAppURL ) { var v_doc = document; var a = v_doc.location.pathname.split( "/" ); a.pop(); this.m_sAppURL = this.F_GetWebcontentURL() + "/" + a.pop() + "/"; } return this.m_sAppURL; }; G_UIPE.F_ViewUIProfileSource = function() { var v_sTitle = G_ResManager.F_GetString( "IDS_UIPE_OPENSOURCE" ); var v_nProfile = this.f_buildUpdatedProfile(); D_UIProfileSource.F_Show( this, v_sTitle, false, v_nProfile.xml ); }; G_UIPE.F_SaveProfileToCM = function( v_nProfile, v_bReloadUI ) { if( !v_nProfile ) { v_nProfile = this.f_buildUpdatedProfile(); } var v_docProfile = U_XML.F_LoadString( null, G_UIPE.F_GetInlineProfileDTD() + v_nProfile.xml ); if( !v_docProfile ) { 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 ); return; } this.m_nProfile = v_nProfile; var v_oRequest = new C_UIProfileSaveRequest( new C_RequestListenerRedirect( this, "f_onSaveRequestComplete" ), this.m_sProfileStoreID, v_nProfile, v_bReloadUI); v_oRequest.F_Send(); }; G_UIPE.f_onSaveRequestComplete = function( v_oRequest ) { 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 ); }; G_UIPE.f_onSaveMsgOKClick = function() { window.close(); }; G_UIPE.f_createProfileNodeFromEditorView = function( v_nTreeNode, v_oEditorView ) { var v_sAction = this.f_getActionValue( v_nTreeNode ); var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); if( v_sAction == "hide" && v_oEditorView.F_GetUncheckedListItems().length == 0 && v_sNodeName != "propertySheet" && v_sNodeName != "hideElements" ) { return null; } var v_sID = v_nTreeNode.getAttribute( "value" ); var v_sProfileNodeName = null; var v_sProfileSubNodeName = null; var v_sProfileNodeID = this.f_getProfileNodeIDByTreeNode( v_nTreeNode ); switch( v_sNodeName ) { case "menubar" : v_sProfileNodeName = "menubar"; v_sProfileSubNodeName = "menu"; break; case "menu" : case "menuItem" : case "menuPopup" : v_sProfileNodeName = "menuPopup"; v_sProfileSubNodeName = "menuItem"; break; case "toolbar" : v_sProfileNodeName = "toolbar"; v_sProfileSubNodeName = "toolbarButton"; break; case "listView" : v_sProfileNodeName = "listView"; v_sProfileSubNodeName = "listItem"; break; case "tabControl" : v_sProfileNodeName = "tabControl"; v_sProfileSubNodeName = "tab"; break; case "explorer" : v_sProfileNodeName = "explorer"; v_sProfileSubNodeName = "explorerButton"; break; case "propertySheet": v_sProfileNodeName = "propertySheet"; v_sProfileSubNodeName = "group"; break; case "hideElements" : v_sProfileNodeName = "hideElements"; v_sProfileSubNodeName = "hideElement"; break; case "chartGroup" : v_sProfileNodeName = "chartGroup"; v_sProfileSubNodeName = "chartType"; // action attribute exists in its parent node chartGroups v_sAction = this.f_getActionValue( v_nTreeNode.parentNode ); break; default : return null; } var doc = v_nTreeNode.ownerDocument; var v_nProfileNode = null; if( v_sNodeName == "hideElements" ) { v_nProfileNode = doc.createElement( v_sProfileNodeName ); } else { // we do not need to consider "chartGroup" here since only "chartType" we added later is useful information v_nProfileNode = doc.createElement( v_sProfileNodeName ); v_nProfileNode.setAttribute( "id", v_sProfileNodeID ); if (v_sProfileSubNodeName == "group") { var v_nProfileSubNode = doc.createElement("propertyVisibility"); v_nProfileNode.appendChild(v_nProfileSubNode); v_nProfileNode = v_nProfileSubNode; } v_nProfileNode.setAttribute( "action", v_sAction ); } var v_nCheckedListItems = null; // hide Elements do not have action attribute but it means the selected item is going to be hiden if( v_sAction == "show" || v_sNodeName == "hideElements" ) { v_nCheckedListItems = v_oEditorView.F_GetCheckedListItems(); } else { v_nCheckedListItems = v_oEditorView.F_GetUncheckedListItems(); } for( var i = 0; i < v_nCheckedListItems.length; i++ ) { var v_nCheckedItem = v_nCheckedListItems.item( i ); var v_nProfileSubNode = doc.createElement( v_sProfileSubNodeName ); if( v_sProfileSubNodeName == "listItem" ) { v_nProfileSubNode.setAttribute( "value", v_nCheckedItem.getAttribute( "value" ) ); } else if( v_sProfileSubNodeName == "group" ) { v_nProfileSubNode.setAttribute( "name", v_nCheckedItem.getAttribute( "value" ) ); } else { v_nProfileSubNode.setAttribute( "id", v_nCheckedItem.getAttribute( "value" ) ); } v_nProfileNode.appendChild( v_nProfileSubNode ); } return v_sProfileSubNodeName == "group" ? v_nProfileNode.parentNode : ( v_nProfileNode.childNodes.length == 0 ? null : v_nProfileNode ); } G_UIPE.f_getProfileParentNodeByTreeNode = function( v_nProfile, v_nTreeNode ) { var v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); var v_sParentNodeName = ""; var v_sParentNodePath = ""; var v_bDialogNode = false; if( v_sNodeName == "menuPopup" || v_sNodeName == "toolbar" || v_sNodeName == "menubar" || v_sNodeName == "listView" || v_sNodeName == "tabControl" || v_sNodeName == "propertySheet" ) { // for toolbars, menuPopups, listViews in dialog, we need to store them in correct position if( v_nTreeNode.parentNode.parentNode && v_nTreeNode.parentNode.parentNode.getAttribute( "nodeName" ) == "dialog" ) { var v_sParentId = v_nTreeNode.parentNode.parentNode.getAttribute( "value" ); v_sParentNodePath = "dialogs/dialog[@id='" + v_sParentId + "']"; v_bDialogNode = true; } } switch( v_sNodeName ) { case "menu": case "menuItem": case "menuPopup": v_sParentNodeName = "menuPopups"; break; case "toolbar": v_sParentNodeName = "toolbars"; break; case "menubar": v_sParentNodeName = "menubars"; break; case "listView": v_sParentNodeName = "listViews"; break; case "tabControl": v_sParentNodeName = "tabControls"; break; case "explorer": v_sParentNodeName = "explorers"; break; case "propertySheet": v_sParentNodeName = "propertySheets"; break; case "hideElements": var v_sParentId = v_nTreeNode.getAttribute( "value" ).split( "_" )[0]; v_sParentNodePath = "dialogs/dialog[@id='" + v_sParentId + "']"; v_bDialogNode = true; break; default : return null; } if( v_sParentNodePath ) { v_sParentNodePath = v_sParentNodeName ? ( v_sParentNodePath + "/" + v_sParentNodeName ) : v_sParentNodePath; } else { v_sParentNodePath = v_sParentNodeName; } var v_nParentNode = v_nProfile.selectSingleNode( "./" + v_sParentNodePath ); var doc = v_nProfile.ownerDocument; if( !v_nParentNode ) { if( v_bDialogNode ) { if( !v_nProfile.selectSingleNode( "./dialogs" ) ) { v_nParentNode = doc.createElement( "dialogs" ); v_nProfile.appendChild( v_nParentNode ); } if( !v_nProfile.selectSingleNode( "./dialogs/dialog[@id='" + v_sParentId + "']" ) ) { v_nParentNode = doc.createElement( "dialog" ); v_nParentNode.setAttribute( "id", v_sParentId ) v_nProfile.selectSingleNode( "./dialogs" ).appendChild( v_nParentNode ); } if( v_sParentNodeName && !v_nProfile.selectSingleNode( "./dialogs/dialog[@id='" + v_sParentId + "']/" + v_sParentNodeName ) ) { if( v_sParentNodeName.length > 0 ) { v_nParentNode = doc.createElement( v_sParentNodeName ); v_nProfile.selectSingleNode( "./dialogs/dialog[@id='" + v_sParentId + "']" ).appendChild( v_nParentNode ); } } } else { v_nParentNode = doc.createElement( v_sParentNodeName ); v_nProfile.appendChild( v_nParentNode ); } } return v_nParentNode; } G_UIPE.f_buildIdentifierFilter = function( v_sIdentify, v_aValues ) { var v_sRemovePath = "["; for( var j = 0; j < v_aValues.length; j++ ) { if( j != 0 ) { v_sRemovePath += " or "; } v_sRemovePath += "@" + v_sIdentify + "='" + v_aValues[j] + "'"; } v_sRemovePath += "]"; return v_sRemovePath; }; G_UIPE.f_buildUpdatedProfile = function() { var v_nUpdatedProfile = this.m_nProfile.cloneNode( true ); var v_nResources = this.m_oNavigationTree.F_GetTreeViewNode(); var doc = v_nResources.ownerDocument; var v_nNodesSelection = v_nResources.selectNodes( "//treeNode" ); var v_sNodeName = ""; var v_iLength = v_nNodesSelection.length; for( var i = 0; i < v_iLength; i++ ) { var v_nTreeNode = v_nNodesSelection.item( i ); v_sNodeName = v_nTreeNode.getAttribute( "nodeName" ); var v_sId = this.f_getTreeNodeId( v_nTreeNode ); var v_oEditorView = this.m_oEditorViews[v_sId]; var v_nUpdatedProfileNode = null; // chartGroups is a special blank view because it contains show/hide checkbox if( v_oEditorView || v_sNodeName == "chartGroups" ) { if( v_sNodeName == "settingsGroup" ) { var v_nSettingsNode = v_nUpdatedProfile.selectSingleNode( "./defaultSettings" ); var v_aSettingNames = U_XML.F_AppendValues( null, this.m_nStudioUIResources.selectNodes( ".//settingsGroup[@name='" + v_sId + "']/setting/@name" ) ); var v_sRemovePath = ".//setting" + this.f_buildIdentifierFilter( "name", v_aSettingNames ); U_XML.F_RemoveNodes( v_nSettingsNode, v_sRemovePath ); var v_oUpdatedSettings = v_oEditorView.F_GetUpdatedSettings(); for( var o in v_oUpdatedSettings ) { var v_nSettingNode = v_nSettingsNode.appendChild( doc.createElement( "setting" ) ); v_nSettingNode.setAttribute( "name", o ); v_nSettingNode.setAttribute( "defaultValue", v_oUpdatedSettings[o] ); } } else if( v_sNodeName == "chartGroups" ) { var v_nChartTypesProfileNode = v_nUpdatedProfile.selectSingleNode( "./chartTypes" ); if( !v_nChartTypesProfileNode ) { var doc = v_nUpdatedProfile.ownerDocument; v_nChartTypesProfileNode = doc.createElement( "chartTypes" ); v_nUpdatedProfile.appendChild( v_nChartTypesProfileNode ); } else { U_XML.F_RemoveNodes( v_nChartTypesProfileNode, "./chartType" ); } v_nChartTypesProfileNode.setAttribute( "action", this.f_getActionValue( v_nTreeNode ) ); } else if( v_sNodeName == "chartGroup" ) { v_nUpdatedProfileNode = this.f_createProfileNodeFromEditorView( v_nTreeNode, v_oEditorView ); if( !v_nUpdatedProfileNode ) { continue; } var v_nChartTypesProfileNode = v_nUpdatedProfile.selectSingleNode( "./chartTypes" ); var v_nChartTypeNodeSelection = v_nUpdatedProfileNode.selectNodes( "./chartType" ); for( var v_iChartTypeItem = 0; v_iChartTypeItem < v_nChartTypeNodeSelection.length; v_iChartTypeItem++ ) { v_nChartTypesProfileNode.appendChild( v_nChartTypeNodeSelection.item( v_iChartTypeItem ) ); } } else if( v_sNodeName == "helpContents" ) { var v_nHelpNode = v_nUpdatedProfile.selectSingleNode( "./helpContents" ); var v_nSubHelpNode = null; if( v_nHelpNode ) { v_nSubHelpNode = v_nHelpNode.selectSingleNode( "./ibmHelpContents" ); v_nSubHelpNode.setAttribute( "type", this.m_oHelpComboBoxEditor.F_GetValue() ); } else { var doc = v_nUpdatedProfile.ownerDocument; var v_nParentNode = doc.createElement( "helpContents" ); var v_nChildNode = doc.createElement( "ibmHelpContents" ); v_nChildNode.setAttribute( "type", this.m_oHelpComboBoxEditor.F_GetValue() ); v_nParentNode.appendChild( v_nChildNode ); v_nUpdatedProfile.appendChild( v_nParentNode ); } } else if( v_sNodeName == "helpGettingStarted" ) { var v_nGettingStartNode = v_nUpdatedProfile.selectSingleNode( "./helpGettingStarted" ); var v_nSubGettingStartNode = null; if( v_nGettingStartNode ) { v_nSubGettingStartNode = v_nGettingStartNode.selectSingleNode( "./ibmHelpGettingStarted" ); v_nSubGettingStartNode.setAttribute( "type", this.m_oGettingStartComboBoxEditor.F_GetValue() ); } else { var doc = v_nUpdatedProfile.ownerDocument; var v_nParentNode = doc.createElement( "helpGettingStarted" ); var v_nChildNode = doc.createElement( "ibmHelpGettingStarted" ); v_nChildNode.setAttribute( "type", this.m_oGettingStartComboBoxEditor.F_GetValue() ); v_nParentNode.appendChild( v_nChildNode ); v_nUpdatedProfile.appendChild( v_nParentNode ); } } else if( v_sNodeName == "group" ) { var v_sGroupName = v_nTreeNode.getAttribute( "value" ); var v_sPropertySheetID = v_nTreeNode.parentNode.getAttribute( "value" ); // remove properties in var v_bShow = this.f_getActionValue( v_nTreeNode.parentNode ) == "show"; var v_nProfilePropertyVisibility = v_nUpdatedProfile.selectSingleNode( ".//propertySheet[@id='" + v_sPropertySheetID + "']/propertyVisibility" ); // remove properties in profile var v_oGroupProperties = v_oEditorView.F_GetPropertyNames(); var v_sRemovePath = "./property["; for( var j = 0; j < v_oGroupProperties.length; j++ ) { if( j != 0 ) { v_sRemovePath += " or "; } v_sRemovePath += "@name='" + v_oGroupProperties[j] + "'"; } v_sRemovePath += "]"; U_XML.F_RemoveNodes( v_nProfilePropertyVisibility, v_sRemovePath ); var v_oProfilePropertNames = null; var v_oCheckedPropertyNames = v_oEditorView.F_GetCheckedPropertyNames(); var v_oUncheckedPropertyNames = v_oEditorView.F_GetUncheckedPropertyNames(); if( v_bShow ) { v_oProfilePropertyNames = v_oCheckedPropertyNames; } else { v_oProfilePropertyNames = v_oUncheckedPropertyNames; for( var j = 0; j < v_oCheckedPropertyNames.length; j++ ) { if( v_oEditorView.F_GetUncheckedObjectNames( v_oCheckedPropertyNames[j] ).length > 0 || v_oEditorView.F_GetUncheckedNamedSetNames( v_oCheckedPropertyNames[j] ).length > 0 ) { v_oProfilePropertyNames.push( v_oCheckedPropertyNames[j] ); } } } for( var j = 0; j < v_oProfilePropertyNames.length; j++ ) { var v_sProfilePropertyName = v_oProfilePropertyNames[j]; var v_nProfileProperty = v_nProfilePropertyVisibility.appendChild( doc.createElement( "property" ) ); v_nProfileProperty.setAttribute( "name", v_sProfilePropertyName ); var v_oProfileObjectNames = []; var v_oProfileNamedSetNames = []; if( v_bShow ) { if( v_oEditorView.F_GetUncheckedObjectNames( v_sProfilePropertyName ).length != 0 || v_oEditorView.F_GetUncheckedNamedSetNames( v_sProfilePropertyName ).length != 0 ) { v_oProfileObjectNames = v_oEditorView.F_GetCheckedObjectNames( v_sProfilePropertyName ); v_oProfileNamedSetNames = v_oEditorView.F_GetCheckedNamedSetNames( v_sProfilePropertyName ); } } else { if( v_oCheckedPropertyNames.indexOf( v_sProfilePropertyName ) != -1 ) { v_oProfileObjectNames = v_oEditorView.F_GetUncheckedObjectNames( v_sProfilePropertyName ); v_oProfileNamedSetNames = v_oEditorView.F_GetUncheckedNamedSetNames( v_sProfilePropertyName ); } else { v_oProfileObjectNames = []; v_oProfileNamedSetNames = []; } } if( v_oProfileObjectNames.length > 0 || v_oProfileNamedSetNames.length > 0 ) { var v_nAppliesTo = v_nProfileProperty.appendChild( doc.createElement( "appliesTo" ) ); for( var k = 0; k < v_oProfileObjectNames.length; k++ ) { var v_sObjectName = v_oProfileObjectNames[k]; var v_nObject = v_nAppliesTo.appendChild( doc.createElement( "parentContainer" ) ); v_nObject.setAttribute( "type", "object" ); v_nObject.setAttribute( "name", v_sObjectName ); } for( var k = 0; k < v_oProfileNamedSetNames.length; k++ ) { var v_sNamedSetName = v_oProfileNamedSetNames[k]; var v_nNamedSet = v_nAppliesTo.appendChild( doc.createElement( "parentContainer" ) ); v_nNamedSet.setAttribute( "type", "namedSet" ); v_nNamedSet.setAttribute( "name", v_sNamedSetName ); } } } } else { v_nUpdatedProfileNode = this.f_createProfileNodeFromEditorView(v_nTreeNode, v_oEditorView); var v_nProfileNode = this.f_getProfileNodeByTreeNode( v_nTreeNode, v_nUpdatedProfile ); if( v_nUpdatedProfileNode) { if( v_nProfileNode ) { v_nProfileNode.parentNode.replaceChild( v_nUpdatedProfileNode, v_nProfileNode ); } else { var v_nProfileParentNode = this.f_getProfileParentNodeByTreeNode( v_nUpdatedProfile, v_nTreeNode ); v_nProfileParentNode.appendChild( v_nUpdatedProfileNode ); } } else { if( v_nProfileNode ) { // remove the parent if there is no child, our profile do not support this kind of contents: "", "" if ( v_nProfileNode.parentNode.childNodes.length == 1 ) { v_nProfileNode.parentNode.parentNode.removeChild( v_nProfileNode.parentNode ); } else { v_nProfileNode.parentNode.removeChild( v_nProfileNode ); } } } if( v_sNodeName == "propertySheet" ) { var v_sPropertySheetName = v_nTreeNode.getAttribute( "value" ); var v_nPropertyVisibility = v_nUpdatedProfileNode.selectSingleNode( "./propertyVisibility" ); if( !v_nPropertyVisibility ) { v_nPropertyVisibility = v_nUpdatedProfileNode.appendChild( doc.createElement( "propertyVisibility" ) ); v_nPropertyVisibility.setAttribute( "action", "hide" ); } var v_nOriginalProfilePropertyVisibility = this.m_nProfile.selectSingleNode( ".//propertySheet[@id='" + v_sPropertySheetName + "']/propertyVisibility" ); if( !v_nOriginalProfilePropertyVisibility ) { v_nOriginalProfilePropertyVisibility = doc.createElement( "propertyVisibility" ); } // check if action value had not been changed, clone the properties from original profile. if( this.f_getActionValue( v_nTreeNode ) == v_nTreeNode.getAttribute( "originalActionValue" ) ) { var v_oOriginalProfileProperties = v_nOriginalProfilePropertyVisibility.selectNodes( "./property" ); for( var j = 0; j < v_oOriginalProfileProperties.length; j++ ) { v_nPropertyVisibility.appendChild( v_oOriginalProfileProperties.item( j ).cloneNode( true ) ); } } else { var v_aAllPropertyNames = U_XML.F_AppendValues( null, G_ResManager.F_GetResourcesDoc().documentElement.selectNodes( ".//propertySheet[@id='" + v_sPropertySheetName + "']//property/@name" ) ); var v_aProfilePropertyNames = this.f_complementSet( v_aAllPropertyNames, U_XML.F_AppendValues( null, v_nOriginalProfilePropertyVisibility.selectNodes( "./property/@name" ) ) ); for( var j = 0; j < v_aProfilePropertyNames.length; j++ ) { var v_nProfileProperty = v_nPropertyVisibility.appendChild( doc.createElement( "property" ) ); v_nProfileProperty.setAttribute( "name", v_aProfilePropertyNames[j] ); } // handle all the properties with appliesTo var v_oPropertiesWithAppliesTo = v_nOriginalProfilePropertyVisibility.selectNodes( "./property[appliesTo]" ); for( var j = 0; j < v_oPropertiesWithAppliesTo.length; j++ ) { var v_nProfileProperty = v_nPropertyVisibility.appendChild( doc.createElement( "property" ) ); var v_sPropertyName = v_oPropertiesWithAppliesTo.item( j ).getAttribute( "name" ); v_nProfileProperty.setAttribute( "name", v_sPropertyName ); var v_nAppliesTo = v_nProfileProperty.appendChild( doc.createElement( "appliesTo" ) ); var v_oAllParentContainers = G_ResManager.F_GetResourcesDoc().documentElement.selectNodes( ".//propertySheet[@id='" + v_sPropertySheetName + "']//property[@name='" + v_sPropertyName + "']/*" ); var v_aOriginalAppliesToNames = U_XML.F_AppendValues( null, v_oPropertiesWithAppliesTo.item( j ).selectNodes( "./appliesTo/*/@name" ) ); for( var k = 0; k < v_oAllParentContainers.length; k++ ) { var v_nContainer = v_oAllParentContainers.item( k ); var v_sContainerName = v_nContainer.getAttribute( "name" ); if( v_aOriginalAppliesToNames.indexOf( v_sContainerName ) == -1) { var v_nParentContainer = v_nAppliesTo.appendChild( doc.createElement( "parentContainer" ) ); v_nParentContainer.setAttribute( "name", v_sContainerName ); v_nParentContainer.setAttribute( "type", v_nContainer.nodeName == "objectRef" ? "object" : "namedSet" ); } } } } } } } } // remove if it does not have any child nodes var v_nChartTypesProfileNode = v_nUpdatedProfile.selectSingleNode( "./chartTypes" ); if ( v_nChartTypesProfileNode.childNodes.length == 0 && v_nChartTypesProfileNode.getAttribute( "action" ) == "hide" ) { U_XML.F_RemoveNodes( v_nUpdatedProfile, "./chartTypes" ); } return v_nUpdatedProfile; }; G_UIPE.f_complementSet = function( v_aA1, v_aA2 ) { var v_aA3 = []; for( var i = 0; i < v_aA1.length; i++ ) { if( v_aA2.indexOf( v_aA1[i] ) == -1) { v_aA3.push( v_aA1[i] ); } } return v_aA3; }; G_UIPE.f_getTreeNodeId = function( v_nTreeNode ) { // for the menuPopup which has template content, use template ID as id return v_nTreeNode.getAttribute( "refPopup" ) ? v_nTreeNode.getAttribute( "refPopup" ) : v_nTreeNode.getAttribute( "value" ); }; G_UIPE.F_Cancel = function() { window.close(); }; G_UIPE.F_Search = function() { if( this.m_iNextCounter > 0 ) { // we need to clear the last searched result var v_nSearchedNode = this.m_nSearchResult.item( this.m_iNextCounter - 1 ); var v_aClearedNode = []; v_aClearedNode.push( null ); v_aClearedNode.push( v_nSearchedNode ); this.f_locateAndClearNode( v_aClearedNode ); } if( this.m_sSearchText != document.getElementById( "txtSearch" ).value ) { this.m_nSearchResult = null; } var v_sSearchText = document.getElementById( "txtSearch" ).value; v_sSearchText = v_sSearchText.F_LTrim(); v_sSearchText = v_sSearchText.F_RTrim(); if( v_sSearchText.length == 0 ) { return; } this.m_sSearchText = v_sSearchText; if( !this.m_nSearchResult ) { // we do not want to locate "menuPopups/listViews/menubars/toolbars/propertySheets/tabControls" nodes in 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'))]"; this.m_nSearchResult = this.m_nStudioUIResources.selectNodes( v_sTextContentFilter ); this.m_iNextCounter = 0; } if( this.m_nSearchResult.length > 0 && this.m_iNextCounter < this.m_nSearchResult.length ) { var v_nSearchedNode = this.m_nSearchResult.item( this.m_iNextCounter ); var v_nPreviousSearchedNode = null; var v_aNode = []; v_aNode.push( v_nSearchedNode ); if( this.m_iNextCounter > 0 ) { v_nPreviousSearchedNode = this.m_nSearchResult.item( this.m_iNextCounter - 1 ); v_aNode.push( v_nPreviousSearchedNode ); } this.f_locateAndClearNode( v_aNode ); this.m_iNextCounter++; } else { D_MsgBox.F_Show( null, G_ResManager.F_GetString( "IDS_UIPE_SEARCH_NOMORERESULT" ), G_ResManager.F_GetString( "IDS_UIPE_TITLE" ), D_MsgBox.K_iWarning ); } }; G_UIPE.f_locateAndClearNode = function( v_aNode ) { // 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 for( var i = 0; i < v_aNode.length; i++ ) { var v_nNode = v_aNode[i]; if( !v_nNode ) { continue; } var v_sNodeName = v_nNode.nodeName; var v_sNodeIdentifier = this.f_getNodeIdentifier( v_nNode ); var v_sNodeID = v_nNode.getAttribute( v_sNodeIdentifier ); var v_sTreeNodeValue = null; var v_sTemplateId = null; var v_nParentNode = null; switch( v_sNodeName ) { case "toolbarButton" : case "setting" : case "listItem" : case "tab" : case "explorerButton" : case "chartType" : case "property" : v_nParentNode = v_nNode.parentNode; v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) ); break; case "hideElement" : // hideElements do not have id attribute v_nParentNode = v_nNode.parentNode.parentNode; v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) ); break; case "menuItem" : if( v_nNode.parentNode.parentNode.nodeName == "menuPopups" ) { v_nParentNode = v_nNode.parentNode; } else if( v_nNode.parentNode.parentNode.nodeName == "menu" || v_nNode.parentNode.parentNode.nodeName == "menuItem" ) { v_nParentNode = v_nNode.parentNode.parentNode; } else if( v_nNode.parentNode.parentNode.nodeName == "menuPopupTemplates" ) { v_sTemplateId = v_nNode.parentNode.getAttribute( "id" ); // items in menuPopupTemplates shares one v_oEditorView so just locate the first tree node v_nParentNode = this.m_nStudioUIResources.selectNodes( ".//menuPopup[@refPopup='" + v_sTemplateId + "']" ).item( 0 ).parentNode; } v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) ); break; case "menuPopup" : if( v_nNode.parentNode.nodeName == "menu" ) { v_nParentNode = v_nNode.parentNode; v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) ); } else if( v_nNode.parentNode.nodeName == "menuPopups" ) { v_sTreeNodeValue = v_sNodeID; } else if( v_nNode.parentNode.nodeName == "menuPopupTemplates" ) { v_sTemplateId = v_nNode.getAttribute( "id" ); // items in menuPopupTemplates shares one v_oEditorView so just locate the first tree node v_nParentNode = this.m_nStudioUIResources.selectNodes( ".//menuPopup[@refPopup='" + v_sTemplateId + "']" ).item( 0 ).parentNode; v_sTreeNodeValue = v_nParentNode.getAttribute( this.f_getNodeIdentifier( v_nParentNode ) ); } break; default: v_sTreeNodeValue = v_sNodeID; } if( i == 0 ) { // only select searched node and do not select previous node again var v_nTreeNode = null; if( v_sNodeName == "hideElement" ) { v_nTreeNode = this.m_oNavigationTree.F_GetTreeViewNode().selectSingleNode( ".//treeNode[@value='" + v_sTreeNodeValue + "']/treeNode[@nodeName='hideElements']" ); } else { v_nTreeNode = this.m_oNavigationTree.F_GetTreeViewNode().selectSingleNode( ".//treeNode[@value='" + v_sTreeNodeValue + "']" ); } this.m_oNavigationTree.F_EnsureVisible( v_nTreeNode, document.getElementById("divNavTreeContainer") ); this.m_oNavigationTree.F_SelectNode( v_nTreeNode, false, true ); } if( v_sTreeNodeValue != v_sNodeID ) { if( v_sNodeName == "hideElement" ) { v_sTreeNodeValue += "_hideElements"; } var v_oEditorView = null; if( v_nNode.parentNode.parentNode.nodeName == "menuPopupTemplates" ) { v_oEditorView = this.m_oEditorViews[v_sTemplateId]; } else { v_oEditorView = this.m_oEditorViews[v_sTreeNodeValue]; } switch( v_sNodeName ) { case "toolbarButton" : case "menuItem" : case "listItem" : case "tab" : case "explorerButton" : case "chartType" : case "hideElement" : var v_nListItem = v_oEditorView.F_GetListViewNode().selectSingleNode( ".//listItem[@value='" + v_sNodeID + "']" ); var v_sHtmlID = v_nListItem.getAttribute( "htmlId" ); var v_eListViewDiv = document.getElementById( v_sHtmlID ).firstChild.firstChild; var v_eListViewSpan = v_eListViewDiv.getElementsByTagName( "SPAN" )[0]; if( i == 0 ) { v_eListViewSpan.className = "clsListItem_hover"; var v_elListItem = document.getElementById( v_nListItem.getAttribute( "htmlId" ) ); var v_iOffset = U_DOM.F_GetRelativeOffset( v_elListItem, v_elListItem.offsetParent ).top; document.getElementById("deckMain").scrollTop = v_iOffset; } else { v_eListViewSpan.className = ""; } break; case "setting" : var v_elValue = v_oEditorView.F_GetFixedValueCell( v_sNodeID ); v_elLable = v_elValue.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild; if( i == 0 ) { v_elLable.className = "clsListItem_hover"; var v_iOffset = U_DOM.F_GetRelativeOffset( v_elLable, v_elLable.offsetParent ).top; document.getElementById("deckMain").scrollTop = v_iOffset; } else { v_elLable.className = ""; } break; case "property" : var v_nPropertyTreeNode = v_oEditorView.F_GetPropertyTreeView().F_GetTreeViewNode().selectSingleNode( ".//treeNode[@value='" + v_sNodeID + "']" ); var v_sHtmlId = v_nPropertyTreeNode.getAttribute( "htmlId" ); var v_eTreeNodeDiv = document.getElementById( v_sHtmlId ); // we can not add class to since its own hover style, so insteadly, we add class to the parent node of if( i == 0 ) { v_eTreeNodeDiv.className = "clsListItem_hover"; v_oEditorView.F_GetPropertyTreeView().F_EnsureVisible( v_nPropertyTreeNode, v_eTreeNodeDiv.parentNode ); } else { v_eTreeNodeDiv.className = ""; } break; default: } } } }; G_UIPE.f_getNodeIdentifier = function( v_nNode ) { var v_sNodeName = v_nNode.nodeName; var v_sNodeIdentifier = null; switch( v_sNodeName ) { case "settingsGroup": case "setting": case "property": case "group": v_sNodeIdentifier = "name"; break; default: v_sNodeIdentifier = "id"; } return v_sNodeIdentifier; }; G_UIPE.F_SettingSheet_OnCycleDropDownList = function( v_oSettingSheet, v_sName, v_sValue, v_nListView ) { var v_nListItem = C_ListView.F_FindListItem( v_nListView, "value", v_sValue ); if ( !v_nListItem ) { // don't attempt to cycle if can't find current item return; } var v_sNextValue = ""; var v_nNextSibling = U_XML.F_GetNextSiblingElement( v_nListItem ); if ( v_nNextSibling ) { v_sNextValue = v_nNextSibling.getAttribute( "value" ); } else { v_sNextValue = v_nListView.selectSingleNode( "listItems/listItem" ).getAttribute( "value" ); } v_oSettingSheet.F_OnSettingChange( v_sName, v_sNextValue ); };