123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- function CCognosViewerToolbarHelper() {}
-
- CCognosViewerToolbarHelper.updateToolbarForCurrentSelection = function(oCV, oToolbar) {
- if (oToolbar) {
- var actionFactory = oCV.getActionFactory();
- for(var toolbarItem = 0; toolbarItem < oToolbar.length; ++toolbarItem)
- {
- var name = oToolbar[toolbarItem]["name"];
- if (typeof name != "undefined" && name != null) {
- var action = actionFactory.load(name);
- if (action != null && typeof action != "undefined") {
- var updatedToolbarItem = action.updateMenu(oToolbar[toolbarItem]);
- if (updatedToolbarItem.visible == false) {
- if (updatedToolbarItem.save) {
-
- oCV.getViewerWidget().addButtonToSavedToolbarButtons(name,oToolbar[toolbarItem],toolbarItem);
- }
- oToolbar.splice(toolbarItem, 1);
- --toolbarItem;
- } else {
- oToolbar[toolbarItem] = updatedToolbarItem;
- }
- }
- } else if (typeof oToolbar[toolbarItem]._root != "undefined") {
- CCognosViewerToolbarHelper.updateToolbarForCurrentSelection(oCV, oToolbar[toolbarItem]._root);
- } else if (oToolbar[toolbarItem].separator) {
- if (toolbarItem == 0 || (toolbarItem > 0 && oToolbar[toolbarItem - 1].separator) || toolbarItem == oToolbar.length) {
- oToolbar.splice(toolbarItem, 1);
- --toolbarItem;
- }
- }
- }
- }
- };
- CCognosViewerToolbarHelper.updateContextMenuForCurrentSelection = function(oCV, oContextMenu) {
-
-
-
- var tempContextMenu = [];
- if (oContextMenu) {
- var actionFactory = oCV.getActionFactory();
- for (var contextMenuItem = 0; contextMenuItem < oContextMenu.length; ++contextMenuItem) {
- var menuItem = oContextMenu[contextMenuItem];
- var name = oContextMenu[contextMenuItem]["name"];
-
- var isItemValidInArea = true;
- if (typeof name != "undefined") {
- var action = actionFactory.load(name);
-
-
-
-
- if(!action) {
- if(name == "drillDown")
- {
- action = actionFactory.load("DrillDown");
- }
- else if(name == "drillUp")
- {
- action = actionFactory.load("DrillUp");
- }
- }
-
- if (action != null && typeof action != "undefined") {
- if (typeof action.buildMenu == "function") {
-
- menuItem = action.buildMenu(oContextMenu[contextMenuItem]);
- }
- else {
- menuItem = action.updateMenu(oContextMenu[contextMenuItem]);
- }
-
- isItemValidInArea = action.isValidMenuItem();
-
- } else if(typeof menuItem.items != "undefined") {
- menuItem.items = CCognosViewerToolbarHelper.updateContextMenuForCurrentSelection(oCV, menuItem.items);
-
-
- isItemValidInArea = (menuItem.items && menuItem.items.length>0)? true:false;
-
- if (isItemValidInArea && menuItem.items.length ==1) {
- menuItem = menuItem.items[0];
- }
- }
- }
-
- if (menuItem && menuItem.visible !== false && isItemValidInArea) {
-
- if (menuItem.separator === true) {
- if (tempContextMenu.length > 0 && typeof tempContextMenu[tempContextMenu.length - 1].separator == "undefined") {
- tempContextMenu[tempContextMenu.length] = menuItem;
- }
- }
- else if (menuItem.useChildrenItems == true && menuItem.items && menuItem.items.length > 0) {
- if (!menuItem.disabled) {
- for (var subItems = 0; subItems < menuItem.items.length; subItems++) {
- tempContextMenu[tempContextMenu.length] = menuItem.items[subItems];
- }
- }
- }
- else if (typeof menuItem._root != "undefined") {
- tempContextMenu[tempContextMenu.length] = { "_root" : CCognosViewerToolbarHelper.updateContextMenuForCurrentSelection(oCV, menuItem._root)};
- }
- else {
- tempContextMenu[tempContextMenu.length] = menuItem;
- }
- }
- }
-
-
- if (tempContextMenu.length>1) {
-
- if (tempContextMenu[tempContextMenu.length - 1].separator) {
- tempContextMenu = tempContextMenu.splice(0, tempContextMenu.length - 1);
- }
- }
- }
- return tempContextMenu;
- };
|