<@doc> Implements a pool of all locked models currently participating in the build process (c) SAP AG 2003-2006. All rights reserved. /////////////////////////////////////////////////////////////////////// // CLASS DEFINITION class GroupsManager inherit gml:Object; /////////////////////////////////////////////////////////////////////// // PRIVATE MEMBESRS property mGroups = {}; property mChoiceStatus = false; property mDCsDefaultGrpId = '$DCsProperties'; property mModelsDefaultPropsGrpId = '$ModelsProperties'; property mModelsDefaultLocGrpId = '$ModelsLocation'; /////////////////////////////////////////////////////////////////////// // PUBLIC METHODS constructor() end <@doc scope="public"> void method createGroup(id,title) if(!id)return; this.mGroups[id] = {}; this.mGroups[id].title = title; this.mGroups[id].id = id; end <@doc scope="public"> Object method getGroup(id) return this.mGroups[id]; end <@doc scope="public"> Object method getGroupsKey() var res = []; for(var key in this.mGroups) res.push(key); return res; end <@doc scope="public"> Boolean method addChildToGroup(groupId,id,displayName,icon,origObj) if(this.mGroups[groupId]){ if(!this.mGroups[groupId].childs){ this.mGroups[groupId].childs = []; } this.mGroups[groupId].childs.push({id:id,displayName:displayName,icon:icon,orig:origObj}); return true; } return false; end <@doc scope="public"> Array method getSelectedChildByGroup(groupId) var res=[]; if(this.mGroups[groupId]){ var childs = this.mGroups[groupId].childs; if(childs){ for(var idx=0 ; idx < childs.length ; ++idx){ if(childs[idx].selected){ var child = childs[idx]; res.push(child.orig ? child.orig : child); } } } } return res; end <@doc scope="public"> Array method getSelectedChilds() var res=[]; for(var key in this.mGroups){ var gSelect = this.getSelectedChildByGroup(key); if(gSelect && gSelect.length){ for(var k=0 ; k < gSelect.length ; ++k) res.push(gSelect[k]); } } return res; end <@doc scope="public"> void method selectALL(value) for(var k in this.mGroups){ var childs = this.mGroups[k].childs; if(childs){ for(var idx=0 ; idx < childs.length ; ++idx){ this.select(k,childs[idx].id,value); } } } end <@doc scope="public"> void method select(groupId,childId,sel,dis,forceSelect) if(this.mGroups[groupId]){ var childs = this.mGroups[groupId].childs; if(childs){ for(var idx=0 ; idx < childs.length ; ++idx){ var child = childs[idx]; if(child.id == childId){ if(dis!=null && dis!=undefined){ child.disabled = dis; } if(!child.disabled || forceSelect){ child.selected = sel; } return true; } } } return false; } end method selectEntireGroup(groupId,sel,dis,forceSelect) if(this.mGroups[groupId]){ var childs = this.mGroups[groupId].childs; if(childs){ for(var idx=0 ; idx < childs.length ; ++idx){ var child = childs[idx]; if(dis!=null && dis!=undefined){ child.disabled = dis; } if(!child.disabled || forceSelect){ child.selected = sel; } } return true; } return false; } end <@doc scope="public"> Array method getChild(groupId,childId) var grp = getGroup(groupId); if(grp && grp.childs){ var childs = grp.childs; for(var idx=0 ; idx < childs.length ; ++idx){ if(childs[idx].id==childId) return childs[idx]; } } return null; end <@doc scope="public"> Array method getChilds(groupId) if(this.mGroups[groupId]) return this.mGroups[groupId].childs; return null; end <@doc scope="public"> Void method clear(groupId) if(this.mGroups[groupId]) delete this.mGroups[groupId]; end <@doc scope="public"> Void method clearAll() this.mGroups = {}; end method setChoice(value) this.mChoiceStatus = value; end method getChoice() return this.mChoiceStatus; end <@doc scope="public"> Void method createDCsPropsGroup(dcsProperties) this.createGroup(this.mDCsDefaultGrpId); for(var i=0 ; i < dcsProperties.length ; ++i){ var dcProperties = dcsProperties[i]; if(dcProperties){ var isLcalRepository = $ENV.isLocalRepositoryKey(dcProperties.repository); var id = dcProperties.getName(); var name = this.removeImplKey(id); var state = dcProperties.getState(); var icon = isLcalRepository || (GETVAR('Platform') == 'eclipse')? '#URL[env~skin:icons.localDC.gif]' : (DCState.isSynced(state)|| DCState.isAddToSourceControl(state) ? '#URL[env~skin:icons.synced_dc.gif]' : '#URL[env~skin:icons.not_synced_dc.gif]'); this.addChildToGroup(this.mDCsDefaultGrpId,id, name,icon,dcProperties); } } end <@doc scope="public"> Void method createModelsPropsGroup(mdlsProperties, groupName) this.createGroup(groupName, groupName); for(var i=0 ; i < mdlsProperties.length ; ++i){ var mdlProps = mdlsProperties[i]; if(mdlProps){ var id = mdlProps.name; var name = mdlProps.name; var icon = CLASS('core.gml2:BlackService').metadata.icon16; this.addChildToGroup(groupName,id, name,icon,mdlProps); } } end <@doc scope="public"> Void method createModelsLocationGroup( mdlsLocation, groupName) this.createGroup(groupName, groupName); for(var i=0 ; i < mdlsLocation.length ; ++i){ var mdlLocation = mdlsLocation[i]; if(mdlLocation){ var id = mdlLocation.getId(); var name = mdlLocation.getDisplayName(); var icon = CLASS('core.gml2:Scenario').metadata.icon16; this.addChildToGroup(groupName,id, name,icon,mdlLocation); } } end //TBD - Move to a global place method removeImplKey(str) var suffix = '_impl'; var res = str; if(str){ lstIdx = str.lastIndexOf(suffix); if(lstIdx==str.length-suffix.length)res = str.substr(0,lstIdx); } return res; end <@doc scope="public"> Void method openDialog(dlgTitle,mainTxt,subTxt,choiceTxt,choiceTooltip,choiceValue, height, width,standalone) return MODAL("#URL[dev:common.SelectionDlg.htm]", {groupsMgr:this,title:dlgTitle,mainMsg:mainTxt,subMsg:subTxt,dialogHeight:height,dialogWidth:width,choice:{text:choiceTxt,tooltip:choiceTooltip,selected:choiceValue},standalone:standalone}, true); end