text: var adhocStart={TopicsTreeContainerId:"topicsTreeArea",DomainTreeContainerId:"domainsTreeArea",OlapConnectionsTreeContainerId:"olapConectionsTreeArea",DefaultTopicsPath:"",DefaultDomainsPath:"/Domains/Simple_Domain",DefaultOlapConnectionPath:"/analysis/connections/Foodmart/Sales",selectedRealmURI:"",selectedSubType:"",options:null,TOPIC:"topics",DOMAIN:"domains",OLAP_CONNECTION:"olapConnections",TOPIC_LAUNCH_TYPE:"ADH_045b_TOPIC",DOMAIN_LAUNCH_TYPE:"ADH_045a_DOMAIN",OLAP_CONNECTION_LAUNCH_TYPE:"ADH_108_DATA_CHOOSER_OLAP_CONNECTIONS",initialize:function(){dialogs.popup.show($("sourceDialog"),!0);var e="unspecifiedTopic";if(this.DefaultTopicsPath=defaultTopic?defaultTopicDir+defaultTopic:defaultTopicDir+e,isNotNullORUndefined(this.TopicsTreeContainerId)){switch(window.launchType){case this.DOMAIN_LAUNCH_TYPE:this.hideRealmTree(this.DOMAIN),this.getDomains();break;case this.OLAP_CONNECTION_LAUNCH_TYPE:this.hideRealmTree(this.OLAP_CONNECTION),this.getOlapConnections();break;default:this.getTopics()}this.initializeHandlers()}},initializeHandlers:function(){$$("fieldset#reportTypes > .button").each(function(e){Event.observe($(e),"click",function(t){var o=$(e).identify();"cancel"!==o&&("chart"==o&&(o="ichart"),this.startWithRealm(o),Event.stop(t))}.bind(this))}.bind(this)),$("dataChooserBtn").observe("click",function(e){var t="table";this.startWithRealm(t),Event.stop(e)}.bind(this)),$("olapChartBtn").observe("click",function(e){this.startWithRealm("olap_ichart"),Event.stop(e)}.bind(this)),$("olapCrosstabBtn").observe("click",function(e){this.startWithRealm("olap_crosstab"),Event.stop(e)}.bind(this)),$("dataChooserSource").observe("mouseup",function(e){var t=e.element(),o=matchAny(t,["button.action.up"],!0);o&&"cancel"==o.identify()&&(this.cancelTopic(alreadyEditing),Event.stop(e))}.bind(this));var e=isSupportsTouch()?"drag:touchstart":"mouseup";Event.observe($$("#sourceDialog > .content > .header")[0],e,function(e){this.getRealm(e.memo?e.memo.targetEvent:e)}.bind(this)),this._enableCancelButtons()},getRealm:function(e){var t=Event.extend(getEvent(e)).element();if(t.hasClassName("tab")||(t=t.up("li")),t){var o=t.readAttribute("id"),a=$(t).hasClassName(layoutModule.SELECTED_CLASS);a||(this.hideRealmTree(o),o===this.TOPIC?this.getTopics():o===this.DOMAIN?this.getDomains():o===this.OLAP_CONNECTION&&this.getOlapConnections())}},_toggleEnableDisableReportBtns:function(e){var t=e.getSelectedNode(),o=!(t&&t.isParent()||!t);adhocStart._enableReportTypeButtons(o),adhocStart._enableDataChooserButtons(o),adhocStart._enableOlapCrosstabButtons(o)},_processTreeNodeIcon:function(e){if(e.isParent())for(var t=0;t<e.childs.length;t++)this._processTreeNodeIcon(e.childs[t]);else adhocStart._updateLeafIcons(e)},_updateLeafIcons:function(e){e&&null!=e.param.extra&&("SLDS"==e.param.extra.subType?e.param.cssClass="domain":"sl.no.ds"==e.param.extra.subType?e.param.cssClass="domain topic":"QueryBuilder"==e.param.extra.creator?e.param.cssClass="domain topic":"OLAPDS"==e.param.extra.subType||(e.param.cssClass="olap.no.ds"==e.param.extra.subType?"olap":"Cube"==e.param.extra.subType?"olap":"topic"),e.refreshStyle())},getTopics:function(){var e,t=!1;$(this.TopicsTreeContainerId).childElements().length<1?(e=adhocStart.getTopicsTree(),t=!0):e=dynamicTree.trees[adhocStart.TopicsTreeContainerId],this.setSelectedRealmDescription(""),e.observe("leaf:selected",function(e){var t=e.memo.node;this._enableReportTypeButtons(!0),this.setRealmProps(t.param)}.bind(this)),e.observe("leaf:dblclick",function(){var e="table";this.startWithRealm(e)}.bind(this)),e.observe("node:selected",function(){this.setRealmProps(null),this._enableReportTypeButtons(!1)}.bind(this)),e.observe("nodeIcon:click",function(e){var t=e.memo.node;t.childs>0&&(this.setRealmProps(null),this._enableReportTypeButtons(!1))}.bind(this)),e.observe("children:loaded",function(e){var t=e.memo.nodes;t.each(function(e){adhocStart._processTreeNodeIcon(e)}.bind(this))});var o=function(e){function t(){var e=dynamicTree.trees[adhocStart.TopicsTreeContainerId],t=e.getRootNode().childs;t&&0==t.length&&adhocStart.setSelectedRealmDescription(noTopicsMessage);var o=e.getSelectedNode();null==o||o.isParent()||adhocStart.setRealmProps(o.param),adhocStart._toggleEnableDisableReportBtns(e),adhocStart._processTreeNodeIcon(e.getRootNode()),adhocStart.hideRealmTree(adhocStart.getRealmType())}return function(){e.openAndSelectNode(this.DefaultTopicsPath,t,!0)}.bind(adhocStart)}(e);e.showTreePrefetchNodes(adhocStart.DefaultTopicsPath,o,ajaxErrorHandler),this._markAdhocTypeAsSelected(this.TOPIC)},getDomains:function(){var e,t=!1;$(this.DomainTreeContainerId).childElements().length<1?(e=adhocStart.getDomainsTree(),t=!0):e=dynamicTree.trees[adhocStart.DomainTreeContainerId],this.setSelectedRealmDescription(""),e.observe("leaf:selected",function(e){var t=e.memo.node;t.isSelected()&&this._enableDataChooserButtons(!0),this.setRealmProps(t.param)}.bind(adhocStart)),e.observe("node:selected",function(){this._enableDataChooserButtons(!1),this.setRealmProps(null)}.bind(adhocStart)),e.observe("nodeIcon:click",function(e){var t=e.memo.node;t.childs>0&&(this.setRealmProps(null),this._enableReportTypeButtons(!1))}.bind(adhocStart)),e.observe("children:loaded",function(e){var t=e.memo.nodes;t.each(function(e){adhocStart._processTreeNodeIcon(e)}.bind(this))});var o=function(){var e="com.jaspersoft.commons.semantic.datasource.SemanticLayerDataSource",t=dynamicTree.trees[adhocStart.DomainTreeContainerId],o=t.getRootNode().childs,a=new Array,n=function(t){for(var o=new Array,a=0;a<t.length;a++)t[a].param.type==e?o.push(t[a]):o=o.concat(n(t[a].childs));return o};a=n(o);for(var r=null,s=0;s<a.length;s++)t.openAndSelectNode(a[s].param.uri,null),this.setRealmProps(a[s].param),r=a[s].parent;a.length>0&&(t.openAndSelectNode(a[0].param.uri,null),this.setRealmProps(a[0].param)),adhocStart._toggleEnableDisableReportBtns(t),adhocStart._processTreeNodeIcon(t.getRootNode()),adhocStart.hideRealmTree(adhocStart.getRealmType())}.bind(adhocStart);e.showTreePrefetchNodes(adhocStart.DefaultDomainsPath,o,ajaxErrorHandler),this._markAdhocTypeAsSelected(this.DOMAIN)},getOlapConnections:function(){var e;e=$(this.OlapConnectionsTreeContainerId).childElements().length<1?adhocStart.getOlapConnectionsTree():dynamicTree.trees[adhocStart.OlapConnectionsTreeContainerId],this.setSelectedRealmDescription(""),e.observe("leaf:selected",function(e){var t=e.memo.node;t.isSelected()&&this._enableOlapCrosstabButtons(!0),this.setRealmProps(t.param)}.bind(adhocStart)),e.observe("node:selected",function(){this._enableOlapCrosstabButtons(!1),this.setRealmProps(null)}.bind(adhocStart)),e.observe("nodeIcon:click",function(e){var t=e.memo.node;t.childs>0&&(this.setRealmProps(null),this._enableReportTypeButtons(!1))}.bind(adhocStart)),e.observe("children:loaded",function(e){var t=e.memo.nodes;t.each(function(e){adhocStart._processTreeNodeIcon(e)}.bind(this))});var t=function(){var e=dynamicTree.trees[adhocStart.OlapConnectionsTreeContainerId],t=this._getAllLeaves(e.getRootNode()),o=t.find(function(e){return e.param.uri===adhocStart.DefaultOlapConnectionPath}.bind(adhocStart));o&&(e.openAndSelectNode(o.param.uri,null),this.setRealmProps(o.param)),adhocStart._toggleEnableDisableReportBtns(e),adhocStart._processTreeNodeIcon(e.getRootNode()),adhocStart.hideRealmTree(adhocStart.getRealmType())}.bind(adhocStart);e.showTreePrefetchNodes(adhocStart.DefaultOlapConnectionPath,t,ajaxErrorHandler),this._markAdhocTypeAsSelected(this.OLAP_CONNECTION)},_getAllLeaves:function(e){var t=new Array;return e.isParent()?e.childs.each(function(e){t=t.concat(adhocStart._getAllLeaves(e))}):t.push(e),t},getTopicsTree:function(){return dynamicTree.createRepositoryTree(adhocStart.TopicsTreeContainerId,{providerId:"topicTreeDataProvider",rootUri:"/",bShowRoot:!1,treeErrorHandlerFn:function(){}})},getDomainsTree:function(){return dynamicTree.createRepositoryTree(adhocStart.DomainTreeContainerId,{providerId:"semanticTreeDataProvider",rootUri:"/",bShowRoot:!1,treeErrorHandlerFn:function(){}})},getOlapConnectionsTree:function(){return adhocStart.createOlapConnectionsTree(adhocStart.OlapConnectionsTreeContainerId,{providerId:"olapConnectionTreeDataProvider",rootUri:"/",bShowRoot:!1,treeErrorHandlerFn:function(){},hideLoader:!0})},startWithRealm:function(e){var t,o=this.getRealmSubType(),a=this.getRealmURI(),n="";"Topic"===o?t="startAdHocWithTopic":"SLDS"===o?t="startQueryBuilder":"Cube"===o&&(t="startAdhocForOlap",a=a.substring(0,a.lastIndexOf("/")),n="cube="+encodeText(this.getRealmName())),isNotNullORUndefined(t)&&isNotNullORUndefined(e)&&isNotNullORUndefined(a)&&(this._enableReportTypeButtons(!1),this._enableDataChooserButtons(!1),this._enableOlapCrosstabButtons(!1),document.location="flow.html?_flowId=adhocFlow&realm="+encodeURIComponent(encodeURIComponent(a))+"&_flowExecutionKey="+flowExecutionKey+"&reportType="+e+"&_eventId="+t+(n?"&"+n:"")+"&decorate="+(__jrsConfigs__.initAdditionalUIComponents?"yes":"no")+(window.isEmbeddedDesigner?"&embeddedDesigner=true":""))},getReportType:function(){var e=$$("#reportTypes >.selected")[0];return e?$(e).readAttribute("id"):"table"},getRealmType:function(){var e,t=$$("#sourceFilter >.selected");return e=t.length?t[0].readAttribute("id"):adhocStart.TOPIC},hideRealmTree:function(e){adhocStart._showTopicsTree(e===this.TOPIC),adhocStart._showDomainsTree(e===this.DOMAIN),adhocStart._showOlapConnectionsTree(e===this.OLAP_CONNECTION)},_markAdhocTypeAsSelected:function(e){[this.TOPIC,this.DOMAIN,this.OLAP_CONNECTION].each(function(e){$(e).removeClassName(layoutModule.SELECTED_CLASS)}),$(e).addClassName(layoutModule.SELECTED_CLASS)},_showTopicsTree:function(e){if(e)$("topicsTreeArea").removeClassName(layoutModule.HIDDEN_CLASS),$("reportTypes").removeClassName(layoutModule.HIDDEN_CLASS);else{var t=dynamicTree.trees[adhocStart.TopicsTreeContainerId];selectedNode=t?t.getSelectedNode():null,selectedNode&&selectedNode.deselect(),$("topicsTreeArea").addClassName(layoutModule.HIDDEN_CLASS),$("reportTypes").addClassName(layoutModule.HIDDEN_CLASS)}},_showDomainsTree:function(e){if(e)$(adhocStart.DomainTreeContainerId).removeClassName(layoutModule.HIDDEN_CLASS),$("dataChooserBtn").removeClassName(layoutModule.HIDDEN_CLASS);else{var t=dynamicTree.trees[adhocStart.DomainTreeContainerId];selectedNode=t?t.getSelectedNode():null,selectedNode&&selectedNode.deselect(),$(adhocStart.DomainTreeContainerId).addClassName(layoutModule.HIDDEN_CLASS),$("dataChooserBtn").addClassName(layoutModule.HIDDEN_CLASS)}},_showOlapConnectionsTree:function(e){if(e)$(adhocStart.OlapConnectionsTreeContainerId).removeClassName(layoutModule.HIDDEN_CLASS),$("olapTypes").removeClassName(layoutModule.HIDDEN_CLASS);else{var t=dynamicTree.trees[adhocStart.OlapConnectionsTreeContainerId];selectedNode=t?t.getSelectedNode():null,selectedNode&&selectedNode.deselect(),$(adhocStart.OlapConnectionsTreeContainerId).addClassName(layoutModule.HIDDEN_CLASS),$("olapTypes").addClassName(layoutModule.HIDDEN_CLASS)}},cancelRealms:function(){history.back()},cancelTopic:function(e){e?history.back():this.redirectToHomePage()},redirectToHomePage:function(){jQuery(document).trigger("adhocDesigner:cancel"),document.location="flow.html?_flowId=homeFlow"},getRealmURI:function(){return this.selectedRealmURI},getRealmSubType:function(){return this.selectedSubType},getRealmName:function(){return this.selectedRealmName},setSelectedRealmDescription:function(e){$("nodeDescription").innerHTML="object"==typeof e?"":e},setRealmProps:function(e){isNotNullORUndefined(e)&&isNotNullORUndefined(e.extra)?(this.selectedRealmURI=e.uri,this.selectedRealmName=e.id,this.selectedSubType=e.extra.subType,this.setSelectedRealmDescription(e.extra.desc)):(this.selectedRealmURI="",this.selectedRealmName="",this.selectedSubType="",this.setSelectedRealmDescription(""))},_enableReportTypeButtons:function(e){$$("fieldset#reportTypes > .button").each(function(t){e?$(t).writeAttribute("disabled",null):$(t).writeAttribute("disabled","disabled")})},_enableDataChooserButtons:function(e){if(e){var t=dynamicTree.trees[adhocStart.DomainTreeContainerId],o=t&&t.getSelectedNode();o&&(e="sl.no.ds"!==o.param.id),!e&&o&&o.deselect()}$("dataChooserBtn").writeAttribute("disabled",e?null:"disabled")},_enableOlapCrosstabButtons:function(e){if(e){var t=dynamicTree.trees[adhocStart.OlapConnectionsTreeContainerId],o=t&&t.getSelectedNode();o&&(e="olap.no.ds"!==o.param.id),!e&&o&&o.deselect()}buttonManager[e?"enable":"disable"]($("olapChartBtn")),buttonManager[e?"enable":"disable"]($("olapCrosstabBtn"))},_enableCancelButtons:function(){$$("#cancel.button").each(function(e){$(e).writeAttribute("disabled",null)})}};adhocStart.createOlapConnectionsTree=function(e,t){return adhocStart.RepositoryFolder=function(e){dynamicTree.TreeNode.call(this,e),this.Types={Folder:new dynamicTree.TreeNode.Type("com.jaspersoft.jasperserver.api.metadata.common.domain.Folder"),MondrianConnection:new dynamicTree.TreeNode.Type("com.jaspersoft.ji.ja.security.domain.MondrianConnection"),SecureMondrianConnection:new dynamicTree.TreeNode.Type("com.jaspersoft.ji.ja.security.domain.SecureMondrianConnection"),XMLConnection:new dynamicTree.TreeNode.Type("com.jaspersoft.jasperserver.api.metadata.olap.domain.XMLAConnection"),SuperRoot:new dynamicTree.TreeNode.Type("superroot"),Root:new dynamicTree.TreeNode.Type("root")},this.nodeHeaderTemplateDomId="list_responsive_collapsible_folders:folders"},adhocStart.RepositoryFolder.prototype=deepClone(dynamicTree.RepositoryFolder.prototype),adhocStart.RepositoryFolder.addMethod("isParent",function(){return this.param.type==this.Types.Folder.name||this.param.type==this.Types.SuperRoot.name||this.param.type==this.Types.Root.name||this.param.type==this.Types.MondrianConnection.name||this.param.type==this.Types.SecureMondrianConnection.name||this.param.type==this.Types.XMLConnection.name}),dynamicTree.createRepositoryTree(e,Object.extend({nodeClass:adhocStart.RepositoryFolder},t))},"undefined"==typeof require&&document.observe("dom:loaded",adhocStart.initialize.bind(adhocStart));