adminPropertySheetManager.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2017
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. function adminPropertySheetManager(uniqueID, resManager, adminCommands, container, titleContainer, ppesAdminEventHandler) {
  9. //private members
  10. var m_oAdminCommands = adminCommands;
  11. var m_oContainer = container;
  12. var m_sUniqueID = uniqueID;
  13. var m_oResManager = resManager;
  14. var m_oTitleContainer = titleContainer;
  15. var m_oEventHandler = ppesAdminEventHandler;
  16. var m_aPropertySheets = new Array();
  17. var m_oTabControl = null;
  18. var m_oObjectPropertyTree = null;
  19. var m_oParentsPropertyTree = null;
  20. var m_sCurrentObject = null;
  21. var m_sParentObject = null;
  22. var m_sNewObject = null;
  23. var m_sNewParentObject = null;
  24. var m_sPDFPaginationDefaultValue = "";
  25. var m_thisInstance = this;
  26. var m_aDOMObjectToUnlink = new Array();
  27. var m_aPropertyNames = null; //Structures to keep track of property info
  28. var m_aPropValueInfo = null;
  29. var m_bChangesNotSaved = false;
  30. var m_CurrentObjName = null;
  31. //structure to store property value information
  32. function propValueInfo(name, type, subType, value, parentValue, specialized, xmlNode) {
  33. this.name = name;
  34. this.value = value;
  35. this.parentValue = parentValue;
  36. this.type = type;
  37. this.subType = subType;
  38. this.specialized = specialized;
  39. this.xmlNode = xmlNode;
  40. this.isDefault = function() { //Matches parent's value
  41. if (this.type == "int") {
  42. return (parseInt(this.value) == parseInt(this.parentValue));
  43. } else {
  44. return (this.value == this.parentValue);
  45. }
  46. }
  47. }
  48. //Handlers for specialized Property dialogs
  49. function colorPickerHandler( v_oPropertySheet, v_sName, v_oDialogListener ) {
  50. this.m_oPropertySheet = v_oPropertySheet;
  51. this.m_sName = v_sName;
  52. this.m_oDialogListener = v_oDialogListener;
  53. //Create the dialog
  54. D_Color.F_Show(null, false, this.m_oPropertySheet.F_GetPropertyValue(v_sName), null, this , false, false);
  55. this.F_Dialog_OnCommit = function( v_oDialog ) {
  56. this.m_oDialogListener.F_PropertySheet_OnPropertyChange( this.m_oPropertySheet, this.m_sName, v_oDialog.F_GetColor());
  57. }
  58. }
  59. function titleDialogHandler( v_oPropertySheet, v_sName, v_oDialogListener ) {
  60. this.m_oPropertySheet = v_oPropertySheet;
  61. this.m_sName = v_sName;
  62. this.m_oDialogListener = v_oDialogListener;
  63. //Create the dialog
  64. D_ppesAdminTitleDialog.F_Show(null, G_ResManager.F_GetString("IDS_PPESADMIN_DLGMAKETITLEFRAMETITLE") , this, this.m_oPropertySheet.F_GetPropertyValue(v_sName));
  65. this.F_Dialog_OnCommit = function( v_oDialog ) {
  66. this.m_oDialogListener.F_PropertySheet_OnPropertyChange( this.m_oPropertySheet, this.m_sName, v_oDialog.F_GetTitle());
  67. }
  68. }
  69. function pdfPaginationDialogHandler( v_oPropertySheet, v_sName, v_oDialogListener, v_sCurrentValue, v_sDefaultValue ) {
  70. this.m_oPropertySheet = v_oPropertySheet;
  71. this.m_sName = v_sName;
  72. this.m_oDialogListener = v_oDialogListener;
  73. //Create the dialog
  74. D_ppesAdminPDFPaginationDialog.F_Show(null, G_ResManager.F_GetString("IDS_PPESADMIN_DLGPDFPAGINATIONTITLE"), this, v_sCurrentValue, v_sDefaultValue );
  75. this.F_Dialog_OnCommit = function( v_oDialog ) {
  76. this.m_oDialogListener.F_PropertySheet_OnPropertyChange( this.m_oPropertySheet, this.m_sName, v_oDialog.F_GetValue() );
  77. }
  78. }
  79. //*** constructor ***
  80. {
  81. //Build up the neccessary DOM directly into the provided container
  82. //But keep it hidden intially
  83. getPDFDefaultValueString();
  84. var outerDIV = document.createElement("DIV");
  85. outerDIV.style.display = "none";
  86. if (!G_BrowserInfo.M_bIsIE) {
  87. var spacer = document.createElement("IMG");
  88. spacer.style.visibility = "hidden";
  89. spacer.style.height = "5px";
  90. outerDIV.appendChild(spacer);
  91. }
  92. var tabTable = document.createElement("TABLE");
  93. tabTable.id = m_sUniqueID + "propertyTabs";
  94. var tableBody = document.createElement("TBODY");
  95. var row = document.createElement("TR");
  96. var cell = document.createElement("TD");
  97. cell.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_DLGPROPERTIESCUBESETTINGSTAB")));
  98. row.appendChild(cell);
  99. cell = document.createElement("TD");
  100. cell.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_DLGPROPERTIESREPORTSETTINGSTAB")));
  101. row.appendChild(cell);
  102. tableBody.appendChild(row);
  103. tabTable.appendChild(tableBody);
  104. outerDIV.appendChild(tabTable);
  105. var panelsDIV = document.createElement("DIV");
  106. panelsDIV.id = m_sUniqueID + "propertyTabs_Panels";
  107. panelsDIV.style.width = "100%";
  108. var panel = document.createElement("DIV");
  109. panel.id = m_sUniqueID + "propertyTabs_Panel0";
  110. var cubePropSheetDIV = document.createElement("DIV");
  111. addPanelPropertysheet(panel, cubePropSheetDIV);
  112. addTabResetLinks(panel,"PWQ");
  113. panelsDIV.appendChild(panel);
  114. panel = document.createElement("DIV");
  115. panel.id = m_sUniqueID + "propertyTabs_Panel1";
  116. var reportPropSheetDIV = document.createElement("DIV");
  117. addPanelPropertysheet(panel, reportPropSheetDIV);
  118. addTabResetLinks(panel,"PWR");
  119. panelsDIV.appendChild(panel);
  120. outerDIV.appendChild(panelsDIV);
  121. m_oContainer.appendChild(outerDIV);
  122. m_oTabControl = new C_Tab(m_sUniqueID + "propertyTabs");
  123. //Now that the basic TAB HTML is created, create and intialize the property sheets.
  124. m_aPropertySheets["PWQ"] = new C_PropertySheet( cubePropSheetDIV, m_oResManager.F_GetResource( "ppesAdminPropertySheetPWQ" ) ,this, cubePropSheetDIV, "clsPropertiesPaneInputBlocker");
  125. m_aPropertySheets["PWR"] = new C_PropertySheet( reportPropSheetDIV, m_oResManager.F_GetResource( "ppesAdminPropertySheetPWR" ) ,this, reportPropSheetDIV, "clsPropertiesPaneInputBlocker");
  126. addTabButtons(outerDIV);
  127. }
  128. //destructor
  129. this.F_Detach = function() {
  130. //break circular references between DOM and javascript
  131. m_aPropertySheets["PWQ"].F_Detach();
  132. m_aPropertySheets["PWR"].F_Detach();
  133. for (var i = 0; i < m_aDOMObjectToUnlink.length; i++) {
  134. m_aDOMObjectToUnlink[i].pAdminPropSheetManager = null;
  135. }
  136. m_oTabControl.F_Detach();
  137. D_Color.F_Detach();
  138. D_ppesAdminTitleDialog.F_Detach();
  139. D_ppesAdminPDFPaginationDialog.F_Detach();
  140. }
  141. function addPanelPropertysheet(container, propSheetDiv) {
  142. var panelContentsDIV = document.createElement("DIV");
  143. panelContentsDIV.className = "ppesAdminPanelContentsContainer";
  144. var panelContentsTableHintDIV = document.createElement("DIV");
  145. panelContentsTableHintDIV.className = "ppesAdminPropertiesHintContainer";
  146. panelContentsTableHintDIV.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_SETTINGS_HINT")));
  147. panelContentsDIV.appendChild(panelContentsTableHintDIV);
  148. var panelContentsTableHeader = document.createElement("DIV");
  149. panelContentsTableHeader.className = "ppesAdminPropertiesHeader";
  150. panelContentsTableHeader.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_SETTINGS_PROPERTIES")));
  151. panelContentsDIV.appendChild(panelContentsTableHeader);
  152. propSheetDiv.className = "ppesAdminPropertiesContainer";
  153. panelContentsDIV.appendChild(propSheetDiv);
  154. container.appendChild(panelContentsDIV);
  155. }
  156. function addTabResetLinks(container, idPrefix) {
  157. var serverPropLinksDiv = document.createElement("DIV");
  158. serverPropLinksDiv.className = "ppesAdminPropertiesLinksContainer";
  159. var link = document.createElement("SPAN");
  160. link.className = "ppesAdminPropertiesLink";
  161. link.id = m_sUniqueID + idPrefix + "rsLink";
  162. link.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_BUTTONRESET")));
  163. link.pAdminPropSheetManager = m_thisInstance; //link the DOM object to this class to access the event handlers
  164. m_aDOMObjectToUnlink[m_aDOMObjectToUnlink.length] = link;
  165. link.onclick = function () { this.pAdminPropSheetManager.F_HandleResetSelectedProperty(); };
  166. serverPropLinksDiv.appendChild(link);
  167. link = document.createElement("SPAN");
  168. link.className = "ppesAdminPropertiesLink";
  169. link.id = m_sUniqueID + idPrefix + "rsaLink";
  170. link.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_BUTTONRESETALL")));
  171. link.pAdminPropSheetManager = m_thisInstance; //link the DOM object to this class to access the event handlers
  172. m_aDOMObjectToUnlink[m_aDOMObjectToUnlink.length] = link;
  173. link.onclick = function () { this.pAdminPropSheetManager.F_HandleResetAllProperties(); };
  174. serverPropLinksDiv.appendChild(link);
  175. link = document.createElement("SPAN");
  176. link.className = "ppesAdminPropertiesLinkSeperator";
  177. serverPropLinksDiv.appendChild(link);
  178. link = document.createElement("SPAN");
  179. link.className = "ppesAdminPropertiesLink";
  180. link.id = m_sUniqueID + idPrefix + "rsdLink";
  181. link.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_BUTTONFORCEDOWN")));
  182. link.pAdminPropSheetManager = m_thisInstance; //link the DOM object to this class to access the event handlers
  183. m_aDOMObjectToUnlink[m_aDOMObjectToUnlink.length] = link;
  184. link.onclick = function () { this.pAdminPropSheetManager.F_HandleResetAllDescendents(); };
  185. serverPropLinksDiv.appendChild(link);
  186. container.appendChild(serverPropLinksDiv);
  187. }
  188. function addTabButtons(container) {
  189. var serverPropButtonsDiv = document.createElement("DIV");
  190. serverPropButtonsDiv.className = "ppesAdminPropertiesButtonsContainer";
  191. button = document.createElement("BUTTON");
  192. button.className = "clsDlgButton";
  193. button.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_BUTTON_SAVE")));
  194. button.pAdminPropSheetManager = m_thisInstance; //link the DOM object to this class to access the event handlers
  195. m_aDOMObjectToUnlink[m_aDOMObjectToUnlink.length] = button;
  196. button.onclick = function () { this.pAdminPropSheetManager.F_HandleApply(); };
  197. serverPropButtonsDiv.appendChild(button);
  198. button = document.createElement("BUTTON");
  199. button.className = "clsDlgButton";
  200. button.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_BUTTON_RELOAD")));
  201. button.pAdminPropSheetManager = m_thisInstance; //link the DOM object to this class to access the event handlers
  202. m_aDOMObjectToUnlink[m_aDOMObjectToUnlink.length] = button;
  203. button.onclick = function () { this.pAdminPropSheetManager.F_HandleReload(); };
  204. serverPropButtonsDiv.appendChild(button);
  205. container.appendChild(serverPropButtonsDiv);
  206. }
  207. function isCurrentSelectionALeaf() {
  208. if (m_oObjectPropertyTree) {
  209. var objectClass = m_oObjectPropertyTree.getString("objectClass");
  210. return (objectClass == "powerPlay8Report")
  211. } else
  212. return false;
  213. }
  214. function isCurrentSelectionTheRoot() {
  215. return (m_oObjectPropertyTree && (m_oParentsPropertyTree == null));
  216. }
  217. function updateResetAllDescendentsEnabling() {
  218. if (isCurrentSelectionALeaf()) {
  219. //disable the reset all descendents call
  220. document.getElementById(m_sUniqueID + "PWQrsdLink").className = "ppesAdminPropertiesLinkDisabled";
  221. document.getElementById(m_sUniqueID + "PWRrsdLink").className = "ppesAdminPropertiesLinkDisabled";
  222. } else {
  223. //enable the reset all descendents call
  224. document.getElementById(m_sUniqueID + "PWQrsdLink").className = "ppesAdminPropertiesLink";
  225. document.getElementById(m_sUniqueID + "PWRrsdLink").className = "ppesAdminPropertiesLink";
  226. }
  227. if (isCurrentSelectionTheRoot()) {
  228. //disable the reset and reset all calls
  229. document.getElementById(m_sUniqueID + "PWQrsLink").className = "ppesAdminPropertiesLinkDisabled";
  230. document.getElementById(m_sUniqueID + "PWRrsLink").className = "ppesAdminPropertiesLinkDisabled";
  231. document.getElementById(m_sUniqueID + "PWQrsaLink").className = "ppesAdminPropertiesLinkDisabled";
  232. document.getElementById(m_sUniqueID + "PWRrsaLink").className = "ppesAdminPropertiesLinkDisabled";
  233. } else {
  234. //enable the reset and reset all calls
  235. document.getElementById(m_sUniqueID + "PWQrsLink").className = "ppesAdminPropertiesLink";
  236. document.getElementById(m_sUniqueID + "PWRrsLink").className = "ppesAdminPropertiesLink";
  237. document.getElementById(m_sUniqueID + "PWQrsaLink").className = "ppesAdminPropertiesLink";
  238. document.getElementById(m_sUniqueID + "PWRrsaLink").className = "ppesAdminPropertiesLink";
  239. }
  240. }
  241. this.hideView = function() {
  242. m_oContainer.firstChild.style.display = "none";
  243. }
  244. this.loadObjectProperties = function(obj,parentObj) {
  245. //obtain the properties of the object
  246. m_sCurrentObject = obj;
  247. m_sParentObject = parentObj;
  248. m_oContainer.firstChild.style.display = "none";
  249. m_oEventHandler.F_ShowProgressDialog(document.getElementById(m_sUniqueID + "ppesAdminTable"),G_ResManager.F_GetString("IDS_PPESADMIN_WORKING"));
  250. m_oAdminCommands.GetObjProperties(obj,handleGotObjectProperties);
  251. m_bChangesNotSaved = false;
  252. }
  253. var loadObjectProperties = this.loadObjectProperties;
  254. this.displayObjectProperties = function(obj,parentObj,cancelFunc) {
  255. //First we check if the current property sheet has been saved.
  256. if (m_bChangesNotSaved) {
  257. m_sNewObject = obj;
  258. m_sParentObject = parentObj;
  259. //Prompt the user to see if they would like to save their changes
  260. D_MsgBox.F_Show(null,G_ResManager.F_GetString("IDS_PPESADMIN_SAVE_PROMPT",m_CurrentObjName,m_CurrentObjName),G_ResManager.F_GetString("IDS_HAL_APP_TITLE"),null,D_MsgBox.K_iYesNoCancel,this.saveAndloadNewObjectProperties,cancelFunc,this.loadNewObjectProperties);
  261. } else {
  262. this.loadObjectProperties(obj,parentObj);
  263. }
  264. };
  265. this.loadNewObjectProperties = function() {
  266. loadObjectProperties(m_sNewObject,m_sParentObject);
  267. }
  268. var loadNewObjectProperties = this.loadNewObjectProperties;
  269. this.saveAndloadNewObjectProperties = function() {
  270. F_HandleApply(loadNewObjectProperties);
  271. }
  272. this.handleGotObjectProperties = function(objPropTree) {
  273. if (objPropTree.getNode("error")){
  274. handleErrorMsg(objPropTree, m_oEventHandler);
  275. return;
  276. }
  277. m_oObjectPropertyTree = objPropTree;
  278. m_CurrentObjName = m_oObjectPropertyTree.getString("Name");
  279. if (m_sParentObject != "" && m_sParentObject != null) {
  280. m_oEventHandler.F_ShowProgressDialog(document.getElementById(m_sUniqueID + "ppesAdminTable"),G_ResManager.F_GetString("IDS_PPESADMIN_WORKING"));
  281. m_oAdminCommands.GetObjProperties(m_sParentObject,handleGotAllObjectProperties);
  282. } else {
  283. handleGotAllObjectProperties(null);
  284. }
  285. };
  286. //local references, to allow access from callbacks
  287. var handleGotObjectProperties = this.handleGotObjectProperties;
  288. this.handleGotAllObjectProperties = function(parentsPropTree) {
  289. if (parentsPropTree && parentsPropTree.getNode("error")) {
  290. handleErrorMsg(parentsPropTree, m_oEventHandler);
  291. return;
  292. }
  293. while (m_oTitleContainer.childNodes.length) {
  294. m_oTitleContainer.removeChild(m_oTitleContainer.childNodes[m_oTitleContainer.childNodes.length - 1]);
  295. }
  296. m_oTitleContainer.appendChild(document.createTextNode(G_ResManager.F_GetString("IDS_PPESADMIN_EDIT_THE_SETTINGS",m_CurrentObjName)));
  297. m_oParentsPropertyTree = parentsPropTree;
  298. var bFoundFirstVisible = false;
  299. //clear out the values arrays
  300. m_aPropertyNames = new Array();
  301. m_aPropValueInfo = new Array();
  302. var objectClass = m_oObjectPropertyTree.getString("objectClass");
  303. if (objectClass == "content" || objectClass == "package" || objectClass == "folder") {
  304. m_oTabControl.F_SetTabDisplay(0,true);
  305. if (!bFoundFirstVisible)
  306. m_oTabControl.F_SetActiveTab(0);
  307. bFoundFirstVisible = true;
  308. if (m_oObjectPropertyTree.getNode("PWQ")) {
  309. m_aPropertySheets["PWQ"].F_SetUpdate(false);
  310. m_aPropertySheets["PWQ"].F_Clear(); //Clear the property sheet
  311. //Get this controls XML specification
  312. var propSheetXML = m_aPropertySheets["PWQ"].F_GetPropertySheetNode();
  313. addPropSheetGroups(m_aPropertySheets["PWQ"],propSheetXML.selectSingleNode("properties"));
  314. m_aPropertySheets["PWQ"].F_EndAllPropertyGroups();
  315. m_aPropertySheets["PWQ"].F_SetUpdate(true);
  316. }
  317. } else {
  318. m_oTabControl.F_SetTabDisplay(0,false);
  319. }
  320. if (true) { //All items have a report property tab
  321. m_oTabControl.F_SetTabDisplay(1,true);
  322. if (!bFoundFirstVisible)
  323. m_oTabControl.F_SetActiveTab(1);
  324. bFoundFirstVisible = true;
  325. if (m_oObjectPropertyTree.getNode("PWR")) {
  326. m_aPropertySheets["PWR"].F_SetUpdate(false);
  327. m_aPropertySheets["PWR"].F_Clear(); //Clear the property sheet
  328. //Get this controls XML specification
  329. var propSheetXML = m_aPropertySheets["PWR"].F_GetPropertySheetNode();
  330. addPropSheetGroups(m_aPropertySheets["PWR"],propSheetXML.selectSingleNode("properties"));
  331. m_aPropertySheets["PWR"].F_EndAllPropertyGroups();
  332. m_aPropertySheets["PWR"].F_SetUpdate(true);
  333. }
  334. } else {
  335. m_oTabControl.F_SetTabDisplay(1,false);
  336. }
  337. updateResetAllDescendentsEnabling();
  338. m_oEventHandler.F_HideProgressDialog();
  339. m_oContainer.firstChild.style.display = "";
  340. };
  341. //local references, to allow access from callbacks
  342. var handleGotAllObjectProperties = this.handleGotAllObjectProperties;
  343. this.hideObjectProperties = function() {
  344. m_oContainer.firstChild.style.display = "none";
  345. }
  346. //private methods
  347. //Property Sheet population methods
  348. function addPropSheetGroups(propSheet, xmlProperties) {
  349. if (!xmlProperties)
  350. return;
  351. for (var i = 0; i < xmlProperties.childNodes.length; i++) {
  352. addPropSheetGroup(propSheet, xmlProperties.childNodes[i]);
  353. }
  354. }
  355. function addPropSheetGroup(propSheet, xmlGroup) {
  356. if (!xmlGroup || xmlGroup.nodeName != "group")
  357. return;
  358. var attNodeChild = m_oObjectPropertyTree.getNode(xmlGroup.getAttribute("name"));
  359. if (attNodeChild) {
  360. propSheet.F_StartPropertyGroup( xmlGroup.getAttribute("name") );
  361. addPropSheetNodeList(propSheet, xmlGroup);
  362. propSheet.F_EndPropertyGroup();
  363. }
  364. }
  365. function addPropSheetNodeList(propSheet, xmlGroup) {
  366. for (var i = 0; i < xmlGroup.childNodes.length; i++) {
  367. if (xmlGroup.childNodes[i].nodeName == "property") {
  368. //Ensure that the node exists in the objects attribute tree before proceeding
  369. var attNamePath = xmlGroup.childNodes[i].getAttribute("name");
  370. var attNodeChild = m_oObjectPropertyTree.getNode(attNamePath);
  371. if (attNodeChild && (attNodeChild.type != "folder") ) {
  372. //Create a value record for this item
  373. var attValue = attNodeChild.value;
  374. var attParentsValue = null;
  375. if (m_oParentsPropertyTree) {
  376. var attParentNode = m_oParentsPropertyTree.getNode(attNamePath);
  377. if (attParentNode)
  378. attParentsValue = attParentNode.value;
  379. }
  380. m_aPropertyNames[m_aPropertyNames.length] = attNamePath;
  381. m_aPropValueInfo[attNamePath] = new propValueInfo(attNamePath, attNodeChild.type, attNodeChild.subType, attValue, attParentsValue, attNodeChild.specialized, xmlGroup.childNodes[i]);
  382. var bIsBold = (attNodeChild.specialized || attParentsValue == null || attParentsValue != attNodeChild.value);
  383. setPropertySheetValue( propSheet, attNamePath , m_aPropValueInfo[attNamePath].value, bIsBold );
  384. }
  385. //} else if (xmlGroup.childNodes[i].nodeName == "group") {
  386. // var newAttNode = attNode.getChild(xmlGroup.childNodes[i].getAttribute("name"));
  387. // if (newAttNode) {
  388. // addPropSheetGroup(propSheet, rootNode, newAttNode, xmlGroup.childNodes[i]);
  389. // }
  390. }
  391. }
  392. }
  393. function getPDFDefaultValueString() {
  394. // Initialize the defaults
  395. var v_nDefaults = G_ResManager.F_GetResource( 'ppesAdminPDFPaginationDefaults' );
  396. for (var i = 0; i < v_nDefaults.childNodes.length; i++) {
  397. if (v_nDefaults.childNodes[i].nodeName == "dialogValue") {
  398. m_sPDFPaginationDefaultValue += v_nDefaults.childNodes[i].getAttribute("name");
  399. m_sPDFPaginationDefaultValue += "=";
  400. m_sPDFPaginationDefaultValue += v_nDefaults.childNodes[i].getAttribute("value");
  401. m_sPDFPaginationDefaultValue += ";";
  402. }
  403. }
  404. }
  405. function isPDFControl( v_oPropInfo ) {
  406. return (v_oPropInfo.type == "string" && v_oPropInfo.subType == "MB");
  407. }
  408. function getPDFDisplayValue( v_sValue ) {
  409. if (v_sValue == "" || v_sValue == m_sPDFPaginationDefaultValue)
  410. return G_ResManager.F_GetString("IDS_PPESADMIN_DLGPDFPAGINATIONDEFAULT");
  411. else
  412. return G_ResManager.F_GetString("IDS_PPESADMIN_DLGPDFPAGINATIONCUSTOM");
  413. }
  414. //Because the HAL control does not allow us to set the bold ourselves,
  415. //we can fake it by using it's own non default mechanism.
  416. function setPropertySheetValue( v_oPropertySheet, v_sName , v_sValue, v_bBold ) {
  417. var oPropInfo = m_aPropValueInfo[v_sName];
  418. var sDisplayValue = "";
  419. if (isPDFControl(oPropInfo)) {
  420. sDisplayValue = getPDFDisplayValue(v_sValue);
  421. } else {
  422. sDisplayValue = ("" + v_sValue);//must pass a string
  423. }
  424. if (v_bBold) { //set to emtpy, so it will only be non-bold when the value is empty
  425. oPropInfo.xmlNode.setAttribute("defaultValue","");
  426. } else { //set it to the value so it will never be bold
  427. oPropInfo.xmlNode.setAttribute("defaultValue",sDisplayValue);
  428. }
  429. v_oPropertySheet.F_ShowProperty(v_sName,sDisplayValue);//must pass a string
  430. }
  431. //Custom Event Handlers
  432. this.F_HandleResetSelectedProperty = function() {
  433. if (!isCurrentSelectionTheRoot()) {
  434. //Get the Property sheet that the user is curently viewing.
  435. var propSheet = null;
  436. switch(m_oTabControl.F_GetActiveTab()) {
  437. case 0: propSheet = m_aPropertySheets["PWQ"]; break;
  438. case 1: propSheet = m_aPropertySheets["PWR"]; break;
  439. }
  440. var activeProperty = propSheet.F_GetActiveProperty();
  441. if (activeProperty && m_aPropValueInfo[activeProperty]) {
  442. //Change the value to the default
  443. setPropertySheetValue( propSheet, activeProperty , m_aPropValueInfo[activeProperty].parentValue, false );
  444. m_aPropValueInfo[activeProperty].value = m_aPropValueInfo[activeProperty].parentValue;
  445. m_aPropValueInfo[activeProperty].specialized = false; //We reset it, it is no longer specialized
  446. m_bChangesNotSaved = true;
  447. } else {
  448. D_MsgBox.F_Show(m_oContainer, G_ResManager.F_GetString("IDS_PPESADMIN_MAKE_SELECTION"), G_ResManager.F_GetString("IDS_HAL_APP_TITLE"), D_MsgBox.K_iOK);
  449. }
  450. }
  451. }
  452. this.F_HandleResetAllProperties = function() {
  453. if (!isCurrentSelectionTheRoot()) {
  454. //Get the Property sheet that the user is curently viewing.
  455. var propSheet = null;
  456. switch(m_oTabControl.F_GetActiveTab()) {
  457. case 0: propSheet = m_aPropertySheets["PWQ"]; break;
  458. case 1: propSheet = m_aPropertySheets["PWR"]; break;
  459. }
  460. for (var i = 0; i < m_aPropertyNames.length; i++) {
  461. var propInfo = m_aPropValueInfo[m_aPropertyNames[i]];
  462. if (propSheet.F_IsPropertyDisplayed(propInfo.name)) {
  463. setPropertySheetValue( propSheet, propInfo.name , propInfo.parentValue, false );
  464. propInfo.value = propInfo.parentValue;
  465. propInfo.specialized = false; //We reset it, it is no longer specialized
  466. }
  467. }
  468. m_bChangesNotSaved = true;
  469. }
  470. }
  471. this.handleGetResetDescendentsResult = function(result) {
  472. if (result.getString(ADM_COM_ERROR_NODE,false)) {
  473. handleErrorMsg(result, m_oEventHandler);
  474. return;
  475. } else {
  476. if (D_ppesAdminProgress.F_IsActiveDialog())
  477. D_ppesAdminProgress.F_Hide();
  478. D_MsgBox.F_Show(m_oContainer, G_ResManager.F_GetString("IDS_PPESADMIN_SUCCESSFULLYRESETDESCENDANTS"),G_ResManager.F_GetString("IDS_HAL_APP_TITLE"), null,D_MsgBox.K_iOK);
  479. }
  480. }
  481. var handleGetResetDescendentsResult = this.handleGetResetDescendentsResult;
  482. this.handleResetAllDescendents = function() {
  483. if (!isCurrentSelectionALeaf()) {
  484. m_oEventHandler.F_ShowProgressDialog(m_oContainer,G_ResManager.F_GetString("IDS_PPESADMIN_WORKING"));
  485. m_oAdminCommands.resetDescendants(m_sCurrentObject,handleGetResetDescendentsResult);
  486. }
  487. }
  488. this.F_HandleResetAllDescendents = function() {
  489. if (!isCurrentSelectionALeaf()) {
  490. D_MsgBox.F_Show(m_oContainer,G_ResManager.F_GetString("IDS_PPESADMIN_DLGFORCEDOWNSELECTED"),G_ResManager.F_GetString("IDS_HAL_APP_TITLE"),D_MsgBox.K_iWarning,D_MsgBox.K_iOKCancel,this.handleResetAllDescendents);
  491. }
  492. }
  493. this.handleApplyResult = function(result) {
  494. if (result.getString(ADM_COM_ERROR_NODE,false)) {
  495. handleErrorMsg(result, m_oEventHandler);
  496. return;
  497. } else {
  498. m_oEventHandler.F_HideProgressDialog();
  499. D_MsgBox.F_Show(m_oContainer, G_ResManager.F_GetString("IDS_PPESADMIN_SUCCESSFULLYAPPLIEDPROPERTIES"), G_ResManager.F_GetString("IDS_HAL_APP_TITLE"),D_MsgBox.K_iOK);
  500. m_bChangesNotSaved = false;
  501. }
  502. }
  503. var handleApplyResult = this.handleApplyResult;
  504. this.F_HandleApply = function(returnFunc) {
  505. //Here we build up an attribute tree containing only the non-default values from the 3 property sheets.
  506. //just tag the attribute tree that came in with specialized nodes.
  507. for (var i = 0; i < m_aPropertyNames.length; i++) {
  508. var propInfo = m_aPropValueInfo[m_aPropertyNames[i]];
  509. if (!propInfo.isDefault() || propInfo.specialized) {
  510. var attNode = m_oObjectPropertyTree.getNode(propInfo.name);
  511. attNode.value = propInfo.value;
  512. attNode.specialized = true;
  513. } else {
  514. var attNode = m_oObjectPropertyTree.getNode(propInfo.name);
  515. attNode.value = propInfo.parentValue;
  516. attNode.specialized = false;
  517. }
  518. }
  519. var specAttTree = m_oObjectPropertyTree.getSpecializedTreeCopy();
  520. m_oEventHandler.F_ShowProgressDialog(m_oContainer,G_ResManager.F_GetString("IDS_PPESADMIN_WORKING"));
  521. var sObjClass = m_oObjectPropertyTree.getString("objectClass");
  522. if (returnFunc) {
  523. m_oAdminCommands.SetObjProperties(m_sCurrentObject,sObjClass,specAttTree,returnFunc);
  524. } else {
  525. m_oAdminCommands.SetObjProperties(m_sCurrentObject,sObjClass,specAttTree,handleApplyResult);
  526. }
  527. }
  528. var F_HandleApply = this.F_HandleApply;
  529. this.F_HandleReload = function() {
  530. this.displayObjectProperties(m_sCurrentObject,m_sParentObject);
  531. }
  532. //HAL property sheet event handlers
  533. this.F_PropertySheet_OnPropertyChange = function( v_oPropertySheet, v_sName, v_sValue ) {
  534. //set the property value into the values store
  535. m_aPropValueInfo[v_sName].value = v_sValue;
  536. m_aPropValueInfo[v_sName].specialized = true; //We changed it, it has to be specialized.
  537. setPropertySheetValue( v_oPropertySheet, v_sName , v_sValue, true );
  538. m_bChangesNotSaved = true;
  539. }
  540. this.F_PropertySheet_GetPropertyListView = function( v_oPropertySheet, v_sName ) {
  541. return m_oResManager.F_GetResource( v_sName );
  542. }
  543. this.F_PropertySheet_OnShowDropDown = function( v_oPropertySheet, v_sName, v_sValue, v_nListView, td )
  544. {
  545. v_oPropertySheet.F_ShowListView( v_sName, v_sValue, v_nListView);
  546. };
  547. this.F_PropertySheet_OnPropertyAction = function( v_oPropertySheet, v_sName )
  548. {
  549. if (v_oPropertySheet.F_GetPropertyAttribute(v_sName, "type") == "colorAction") {
  550. new colorPickerHandler( v_oPropertySheet, v_sName, this );
  551. } else if (v_oPropertySheet.F_GetPropertyAttribute(v_sName, "type") == "action") {
  552. //Get the editor type from the attribute tree
  553. var subType = m_oObjectPropertyTree.getNode(v_sName).subType;
  554. switch (subType) {
  555. case "MT": new titleDialogHandler( v_oPropertySheet, v_sName, this ); break;
  556. case "MB": new pdfPaginationDialogHandler( v_oPropertySheet, v_sName, this, m_aPropValueInfo[v_sName].value, m_sPDFPaginationDefaultValue ); break;
  557. }
  558. }
  559. };
  560. function handleErrorMsg( objPropTree, m_oEventHandler ) {
  561. var errorMessage = "";
  562. switch (objPropTree.getString("error")) {
  563. case "NodeNotFoundException thrown":
  564. errorMessage = G_ResManager.F_GetString("IDS_PPESADMIN_ERR_NODE_NOT_FOUND_EXCEPTION");
  565. break;
  566. case "FailedToCommunicateWithCM":
  567. errorMessage = G_ResManager.F_GetString("IDS_PPESADMIN_ERR_FAILED_TO_COMM_WITH_CM");
  568. break;
  569. case "PassportExpired":
  570. location.href = location.pathname + "?b_action=cogadmin";
  571. break;
  572. default:
  573. errorMessage = objPropTree.getString("error");
  574. break;
  575. }
  576. // hide progress dialog
  577. m_oEventHandler.F_HideProgressDialog();
  578. if (errorMessage != "")
  579. // show error message & refresh PPAdmin tool on "OK".
  580. D_MsgBox.F_Show(null,errorMessage,G_ResManager.F_GetString("IDS_HAL_APP_TITLE"),D_MsgBox.K_iError, 1,
  581. function(){ m_bChangesNotSaved = false; //prevents the "Changes Not Saved" dialog from popping up
  582. m_oEventHandler.m_admPropManager.hideView();
  583. m_oEventHandler.mAdminTreeHandler.F_ClearTree(m_oEventHandler.m_oPPESAdminTree);
  584. m_oEventHandler.F_InitializeTree();
  585. });
  586. }
  587. };