// SETUP SHAREABLE SECTIONS /* All sample code is provided for illustrative purposes only. This example has not been thoroughly tested under all conditions. There is no guarantee of reliability, serviceability, or function of this program. Craig Forant me@craigforant.com Reverted check box logic and modified the dialog box layout Note that check boxes in the DB now mean that there is a section, i.e. "inherited" access in the DOORS GUI is _not_ checked. This means reverted check boxes in the DOORS GUI and in this DB, but IMHO it improves the intuitive use of the DB. Peter Albert */ /******************************************************************************/ // GLOBALS /******************************************************************************/ const int LIST_WIDTH = 400 const int LIST_HEIGHT = 15 string objHead = "Object Heading" string objAbsNo = "Absolute Number" string dummyList[] = {} string levels[] = {"all", "1", "2", "3", "4", "5"} DB share_DB DBE listOfHeadings_DBE DBE rescanDBE = null DBE checkAllDBE = null DBE unCheckAllDBE = null DBE createSectionsDBE = null DBE levelsDBE = null /******************************************************************************/ // FUNCTIONS /******************************************************************************/ //----------------------------------------------------------------------------// void activeAll(bool makeActive) { if (makeActive) { active checkAllDBE; active unCheckAllDBE; active createSectionsDBE//; active listOfHeadings_DBE } else { inactive checkAllDBE; inactive unCheckAllDBE; inactive createSectionsDBE//; inactive listOfHeadings_DBE } } //----------------------------------------------------------------------------// void checkRights() { if (canControl(current Module) && isEdit(current Module)) {activeAll(true)} else {activeAll(false)} } //----------------------------------------------------------------------------// void killDB(DB xx) { hide(xx) destroy(xx) xx = null } //----------------------------------------------------------------------------// string choiceYesNo(string question) { string buttons[] = {"Yes", "No"} string answer int result = messageBox(question,buttons, msgQuery) // 0 = yes; 1 = no;; if (result == 0) answer = "yes"; if (result == 1) answer = "no"; return answer } //----------------------------------------------------------------------------// void doSelect(DBE xx,int i){ // do this when item is selected } void doDeselect(DBE xx,int i) { // do this when item is deselected } void doActivate(DBE xx,int i) { // do this when item is double clicked bool isCheck = getCheck(xx,i) if (!isCheck){setCheck(xx, i, true)} else {setCheck(xx, i, false)} } //----------------------------------------------------------------------------// void setShareable(DB xx) { int iIndex for (iIndex = 0; iIndex < noElems(listOfHeadings_DBE); iIndex++) { bool isCheck = getCheck(listOfHeadings_DBE,iIndex) string objAbsNo = getColumnValue(listOfHeadings_DBE,iIndex,0) int absNo = intOf objAbsNo Object checkedObj = object(absNo) if (isCheck) { specific checkedObj } else { inherited checkedObj } } /* string answer = choiceYesNo("Do you want to save the module?") if (answer == "yes"){ save(current Module) killDB(share_DB) } else{ killDB(share_DB) } */ killDB(share_DB) } //----------------------------------------------------------------------------// void setCheckBox(DBE xx,int i) { setCheck(xx,i,true) } //----------------------------------------------------------------------------// void setAllChecks(DB xx) { int iIndex for (iIndex = 0; iIndex < noElems(listOfHeadings_DBE); iIndex++) { setCheck(listOfHeadings_DBE,iIndex,true) } } //----------------------------------------------------------------------------// void setNoChecks(DB xx) { int iIndex for (iIndex = 0; iIndex < noElems(listOfHeadings_DBE); iIndex++) { setCheck(listOfHeadings_DBE,iIndex,false) } } //----------------------------------------------------------------------------// void scanModule(DB xx) { checkRights() empty listOfHeadings_DBE Object o Module m = current if (null m){return} for o in m do { string oNum = number o "" string oHead = o.objHead "" string oID = o.objAbsNo "" // separate out headings if (!matches("-",oNum)) { // all object numbers for non headings have a dash. int numEle = noElems(listOfHeadings_DBE) insert(listOfHeadings_DBE,numEle,oID) set(listOfHeadings_DBE,numEle,1,oNum) set(listOfHeadings_DBE,numEle,2,oHead) // now to set the checkboxes to match each heading's inherit from parent checkbox bool b isAccessInherited(o,b) if (!b) setCheckBox(listOfHeadings_DBE,numEle) } } } //----------------------------------------------------------------------------// void setLevels(DBE dbe) { int l = get(levelsDBE) level l scanModule(share_DB) } //----------------------------------------------------------------------------// void setupDB() { share_DB = create("Shareable Edit Setup", styleCentered) listOfHeadings_DBE = listView( share_DB,listViewOptionCheckboxes,LIST_WIDTH,15,dummyList ) set (listOfHeadings_DBE,doSelect,doDeselect,doActivate) levelsDBE = choice(share_DB, "Level ", levels, 0, 5, false) set (levelsDBE, setLevels) rescanDBE = apply(share_DB,"Rescan", scanModule) checkAllDBE = apply(share_DB,"Check All",setAllChecks) unCheckAllDBE = apply(share_DB,"Uncheck All",setNoChecks) createSectionsDBE = apply(share_DB,"Create sections",setShareable) realize share_DB setExtraHeightShare(listOfHeadings_DBE, 1.0) insertColumn(listOfHeadings_DBE,0,"Section / ID",75,iconNone) insertColumn(listOfHeadings_DBE,1,"Object Number",100,iconNone) insertColumn(listOfHeadings_DBE,2,"Object Heading",300,iconNone) } /******************************************************************************/ // MAIN /******************************************************************************/ setupDB scanModule(share_DB) show share_DB ca