Copy View

I'm having an issue with the new dxl features in 9.6 for link indicators and change bars.  It would appear that a script to copy a view does not correctly save the view columns as they appear in the org.

That being said this is what i have tired.

 

1.) disable new features added identifier instead of Changebars or link indicators.  Copy view works correctly.

2.) save view and view definitions multiple different places in the code.

 

one thing i have noticed is that at the end the view does look correct however if i change view and go back to that view it is not correct.

 

Additionally with this issue i'm having issue correctly applying the Graphics and Info for the columns.  When used and view is saved it tend to keep telling me i switched view information every time i switch the view. I don't have to do anything after i switch to the view it just keep telling me this.


dbonfiglio - Sat Dec 22 10:56:28 EST 2018

Re: Copy View
EHcnck - Thu Dec 27 10:28:49 EST 2018

Can you supply the script being used. within our copy view script I see no such issues when copying? Thank you.

Re: Copy View
dbonfiglio - Thu Dec 27 12:42:52 EST 2018

EHcnck - Thu Dec 27 10:28:49 EST 2018

Can you supply the script being used. within our copy view script I see no such issues when copying? Thank you.

At this time i am not able to provide the script as it is owned by my customer.  It does not appear to be related to the code i'm directly working on.  I believe it might be a bug as it seems to be inconstant..  I was really wondering if anyone else has see something similar.

Re: Copy View
EHcnck - Thu Dec 27 12:56:44 EST 2018

dbonfiglio - Thu Dec 27 12:42:52 EST 2018

At this time i am not able to provide the script as it is owned by my customer.  It does not appear to be related to the code i'm directly working on.  I believe it might be a bug as it seems to be inconstant..  I was really wondering if anyone else has see something similar.

What version of DOORS are you using, I've never seen this issue before and we copy views all the time? Thank you.

Re: Copy View
dbonfiglio - Thu Dec 27 13:36:58 EST 2018

EHcnck - Thu Dec 27 12:56:44 EST 2018

What version of DOORS are you using, I've never seen this issue before and we copy views all the time? Thank you.

actually it would appear the script is a version of http://www.galactic-solutions.com/GalacticDownloads.htm Copy view

i have added changebar and Linkindicators which started causing this problem. using 9.6.1.9

 

Re: Copy View
EHcnck - Thu Dec 27 13:56:11 EST 2018

dbonfiglio - Thu Dec 27 13:36:58 EST 2018

actually it would appear the script is a version of http://www.galactic-solutions.com/GalacticDownloads.htm Copy view

i have added changebar and Linkindicators which started causing this problem. using 9.6.1.9

 

//<
// Copy Views

/*
This script allows the user to copy the views to the current module from another
or from the current to multiple others.

Version Developed On    Date            By                                Notes
0.5.0   DOORS 5.1sr1 PC 07/11/01        Telelogic NA          Preliminary to see how people like the selection screen
1.0.0   DOORS 5.2 PC    02/10/02        Telelogic NA          Includes ViewDef information
1.1.0   DOORS 5.2 PC    07/22/02        Telelogic NA          Closes more modules on completion
1.1.1   DOORS 6.0sr1 PC 01/10/03        Telelogic NA          Doesn't copy title of main column
2.0.0   DOORS 7.1 PC    08/04/04        Telelogin NA          Corrected resizing issue, made more kitchen like
2.1.0   DOORS 9.6           02/11/15    Schneider-Electric    Reduce code(DB, DBE, etc.), made changes to Interface to use treeView for selection of Modules.
2.2.0   DOORS 9.6.1.2   09/21/15    Schneider-Electric    Add support for info, graphic, colour, etc.
2.3.0   DOORS 9.6.1.2   09/22/15    Schneider-Electric    Fix error protection on Copy.
2.4.0   DOORS 9.6.1.6   08/29/16    Schneider-Electric    Change around some logic, using stringFunctions.inc
*/

if ( !confirm "This tool copies views from the current module to other selected modules.\n" //-
                          "OR from a selected module TO the current module.\n\n" //-
                          "Use this tool to manage the consistency of views across the database.\n\n" //-
                          "It proceeds by asking the user to select if the current module is the Source or Destination." //-

                          "Continue?"
        )
{
        halt
}

pragma encoding, "UTF-8"
pragma runLim, 0

#include <C:\DXL\FX\includes\stringFunctions.inc>

// Constants

const string srcDest[]              = {"Source", "Destination", "Cancel"}
const string dummy[]                = {}
const int modListWidth              = 500
const int modWidth                  = 150
const int pathWidth                 = (modListWidth - modWidth)/2
const int viewWidth                 = modWidth
const int listLength                = 20
const int MINI_EXP_FP                           = 1
const int MINI_EXP_LINK_MODS            = 2
const int MINI_EXP_FORMAL_MODS          = 4
const int MINI_EXP_DESCRIPTIVE_MODS = 8
const int MINI_EXP_SHOW_DELETED         = 16
const int itemMask                  = MINI_EXP_FORMAL_MODS

// Variables

Skip moduleList                     = createString()
Module currMod, srcMod, destMod

DB  copyDB
DBE modListDBE
DBE viewListDBE
DBE splitDBE
DBE modFrameDBE
DBE viewFrameDBE
DBE okBtnDBE
DBE applyBtnDBE
DBE miniExplorerDBE

int srcChoice = -1

// Functions

// Returns whether or not the selected item in the tree view matches the type of module the 
// tree view was created to be able to select
bool itemMatchesSelectedMask(Item itm) {
        bool matchesMask = false

        if ( type(itm) == "Formal" && ((itemMask & MINI_EXP_FORMAL_MODS) == MINI_EXP_FORMAL_MODS) ) {
                matchesMask = true
        }
        else if ( type(itm) == "Link" && ((itemMask & MINI_EXP_LINK_MODS) == MINI_EXP_LINK_MODS) ) {
                matchesMask = true
        }
        else if ( type(itm) == "Descriptive" && ((itemMask & MINI_EXP_DESCRIPTIVE_MODS) == MINI_EXP_DESCRIPTIVE_MODS) ) {
                matchesMask = true
        }

        return(matchesMask)
}

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void listViews() {
        empty(viewListDBE)
        string viewName = null
        int dataRow     = 0

        inactive(okBtnDBE)
        inactive(applyBtnDBE)
        inactive(viewListDBE)

        for viewName in views srcMod do {
                insert(viewListDBE, dataRow++, viewName)
        }
} // listViews

// Adds a delete items to the modListDBE view.
void removeModuleFromList(DBE clicked) {
        int selectedRow   = get(modListDBE)
        string moduleName = getColumnValue(modListDBE, selectedRow, 2)
        
        delete(moduleList, moduleName)
        delete(modListDBE, selectedRow)
        
        if ( noElems(modListDBE) == 0 ) {
                inactive(okBtnDBE)
                inactive(applyBtnDBE)
        }
        if ( srcChoice == 1 ) {
                empty(viewListDBE)
        }
}

// Adds a new items to the modListDBE view.
void addModuleToList(DBE clicked) {
        string selectedModule = getRealPath(dbSep get(miniExplorerDBE))

        Item i          = item(selectedModule)
        Folder f        = getParentFolder(i)
        bool moduleOpen = false
        int currentRow  = 0

        if ( isDeleted(i) ) {
                warningBox(copyDB, "Cannot copy views to a deleted module.")
                return()
        }

        // check that the source module wasn't selected
        if ( rootName_(i) == rootName_(currMod) ) {
                warningBox(copyDB, "Cannot select the source module.")
                return()
        }

        // check that the item matches the module type the tree view was passed when it was created
        // and that it does not already exist in the list.
        if ( find(moduleList, rootName_(i)) ) {
                warningBox(copyDB, "Item of the same name already selected. Unable to add to list.")
                return()
        }

        if ( itemMatchesSelectedMask(i) ) {
                currentRow = noElems(modListDBE)

                // put in the module list
                insert(modListDBE, currentRow, name(i), getIcon(i))
                set     (modListDBE, currentRow, 2, rootName_(i))
                set     (modListDBE, currentRow, 1, name(f))
                set     (modListDBE, currentRow, 1, getIcon(item(rootName_(f))))
                put     (moduleList, rootName_(i), rootName_(i))
        }
        else {
                return()
        }

        int modSel = get(viewListDBE)
        if ( modSel > 0 ) {
                active(okBtnDBE)
                active(applyBtnDBE)
        }

        if ( srcChoice == 1 ) {
                string srcModName = getColumnValue(modListDBE, currentRow, 2)

                srcMod = read(srcModName, false, true)
                listViews

                if ( !null(srcMod) ) {
                        close(srcMod)
                }
        }

        active(viewListDBE)
}

// Adds a new item to the tree view.
void addItemToTree(DBE dbe, Item i) {
        string displayPath = getDisplayPath(i)

        // check if the path exists in the tree view
        if ( exists(miniExplorerDBE, displayPath) == false ) {
                // check that the item is not deleted or if it is, that the tree view was created with the option
                // to show deleted items.
                if ( isDeleted(i) == false || (isDeleted(i) == true && ((itemMask & MINI_EXP_SHOW_DELETED) == MINI_EXP_SHOW_DELETED)) ) {
                        // check item type
                        if ( type(i) == "Folder" || type(i) == "Project" ) {
                                Icon iconOpen
                                Icon iconClosed
                                string sDummyEntry = displayPath dbSep dummyItem

                                // assign project or folder specific icons
                                assignIcons(i, iconOpen, iconClosed)

                                // add entry (plus dummy)
                                insert(miniExplorerDBE, displayPath, iconClosed, iconOpen)
                                insert(miniExplorerDBE, sDummyEntry, iconClosed, iconOpen)
                        } else if ( itemMatchesSelectedMask(i) ) {
                                insert(miniExplorerDBE, displayPath, getIcon(i), getIcon(i))
                        }
                }
        }
}

// Opens the selected Project or Folder in the tree view and loads its containing items.
void displaySelectedBranch(DBE dbe, string sItemPath) {
        Folder fStart = folder(getRealPath(sItemPath))

        if ( !null(fStart) ) {
                Item i

                for i in all fStart do {
                        addItemToTree(miniExplorerDBE, i)
                }
        }
}

// DBE callback that fires when an element in the tree view is selected.
void doTreeSelect(DBE dbe) {
        string sel = getRealPath(dbSep get(miniExplorerDBE))

        if ( itemMatchesSelectedMask(item(sel)) ) {
                if ( noElems(modListDBE) > 0 && (srcChoice == 1) ) {
                        warningBox(copyDB, "Only allowed one Source Module.")
                } else {
                        addModuleToList(dbe)
                }
        }
}

// DBE callback that fires when an item in the tree view is double clicked.
bool doTreeExpand(DBE dbe, string sItem) {
        string sItemPath  = dbSep sItem
        string sDummyItem = sItemPath dbSep dummyItem

        // check status
        if ( exists(miniExplorerDBE, sDummyItem) == true ) {
                // remove dummy
                delete(miniExplorerDBE, sDummyItem)
        }

        // check status
        if ( theCurrentView == DATABASE_VIEW ) {
                // adjust view accordingly
                displaySelectedBranch(miniExplorerDBE, sItemPath)
        } else {
                Project prjOldRoot = getRootProject_()

                setRootProject_(project(getRootOfPath sItemPath))

                // adjust view accordingly
                displaySelectedBranch(miniExplorerDBE, sItemPath)

                setRootProject_(prjOldRoot)
        }

        return(true)
}

// Loads the tree view to start with the passed in folder opened.
void changeToStartFolder(Folder fStart) {
        if ( !null(fStart) ) {
                int i = 0

                // calculate max bound for loop
                int finish = length(rootName_(fStart))

                // prepare initial path
                string sFolderPath = ((theCurrentView == DATABASE_VIEW) ? dbDisplayRoot() : "")
                string sCharacter

                // process string
                for ( i = 0; i <= finish; i++ ) {
                        // obtain character
                        sCharacter = (rootName_(fStart))[i:i]

                        // check status
                        if ( sCharacter == dbSep || i == finish ) {
                                // check status
                                if ( theCurrentView == PROJECT_VIEW && sFolderPath == dbSep ) {
                                        continue
                                }

                                // update explorer
                                displaySelectedBranch(miniExplorerDBE, sFolderPath)
                        }

                        sFolderPath = sFolderPath sCharacter
                }

                // update explorer
                set(miniExplorerDBE, sFolderPath)
        } else {
                // default to database level
                displaySelectedBranch(miniExplorerDBE, dbDisplayRoot())
                set(miniExplorerDBE, dbDisplayRoot())
        }
}

//=================================================================================================
// Clears the destination view.
//
// Called by: copyViews
//
// Calls: none
//
bool clearDest(Module m, string viewName) {
        bool ret = load(m, view(viewName))
        Column c = null
    int i = 0
        int count = 0
        for c in m do {
                count++
        }
        current = m
        for ( i = 0; i < count; i++ ) {
                delete(column(0))
        }
        filtering(off)
        sorting(off)
        outlining(off)
        level(0)
        return ret
} // clearDest

//=================================================================================================
// Core view copying function.  Copies views from the list to the passed module.
//
// Called by: copyViewsCB
//
// Calls: clearDest
//
void copyViews(Module toMod) {
        Column srcCol              = null
        Column destCol             = null
        ViewDef vDef               = null
        Filter vFilt               = null
        Sort vSort                 = null
        AttrDef ad                 = null
        string errMsg              = null
        string attName             = null
        string colTitle            = null
        string colourAttr          = null
        string backgroundColorAttr = null
        string viewName            = null
        string modDModView         = null
        string modDUserView        = null
        int viewPos                = 0
        int colWidth               = 0
        int colCount               = 0
        int vLevel                 = 0
        bool err                   = false
        bool vShowingExplorer
        bool vAutoIndent
        bool vShowDeletedObjects
        bool vOverrideTableAttribute
        bool vEnableDefaultTableAttribute
        bool vShowGraphicsDatatips
        bool vShowGraphicsLinks
        bool vShowChangeBars
        bool vLinkIndicators
        bool vFilterTables
        bool vShowPictures
        bool vShowTables
        bool vDescendants
        bool vAncestors
        bool vDeletions
        bool vGraphics
        bool vFiltering
        bool vSorting
        bool vOutlining
        bool ViewExist

        for viewPos in viewListDBE do {      
                viewName = getColumnValue(viewListDBE, viewPos, 0)
                err      = false
                vFilt    = null
                vSort    = null
                
                current  = srcMod
                if ( load(view(viewName)) ) {
                        vDef = get(view(viewName))
                
                        modDModView = getDefaultViewForModule(srcMod)
                        modDUserView = getDefaultViewForUser(srcMod)

                        if ( filtering(srcMod) ) {
                                vFilt = current
                        }
                        if ( sorting(srcMod) ) {
                                vSort = current
                        }
                                        
                        vShowingExplorer = showingExplorer(srcMod)
                        vAutoIndent = autoIndent(srcMod)
                        vShowDeletedObjects = showDeletedObjects(srcMod)
                        vOverrideTableAttribute = overrideTableAttribute(srcMod)
                        vEnableDefaultTableAttribute = enableDefaultTableAttribute(srcMod)
                        vShowGraphicsDatatips = showGraphicsDatatips(srcMod)
                        vShowGraphicsLinks = showGraphicsLinks(srcMod)
                        vShowChangeBars = showChangeBars(srcMod)
                        vLinkIndicators = linkIndicators(srcMod)
                        vFilterTables = filterTables(srcMod)
                        vShowPictures = showPictures(srcMod)
                        vShowTables = showTables(srcMod)
                        vDescendants = descendants(srcMod)
                        vAncestors = ancestors(srcMod)
                        vDeletions = deletions(srcMod)
                        vGraphics = graphics(srcMod)
                        vFiltering = filtering(srcMod)
                        vSorting = sorting(srcMod)
                        vLevel = level(srcMod)
                        vOutlining = outlining(srcMod)
                                
                        ViewExist = clearDest(toMod, viewName) // Clears and sets current = toMod
                        colCount = 0
                        for srcCol in srcMod do {
                                destCol = column colCount++
                                attName = attrName(srcCol)
                                colTitle = title(srcCol)
                                colourAttr = color(srcCol)
                                backgroundColorAttr = backgroundColor(srcCol)
                                ad = null

                                if ( null(attName) ) {
                                        if ( main(srcCol) ) {
                                                if ( probeAttr_(srcMod, "Description") != colTitle ) {
                                                        title(destCol, colTitle)
                                                }
                                                main(destCol)
                                        } else {
                                                if ( !link(srcCol) && !changebar(srcCol) )
                                                        dxl(destCol, dxl(srcCol))
                                        }
                                } else {
                                        ad = find(toMod, attName)
                                        if ( null(ad) and attName != "Object Identifier" and
                                                attName != "Object Number" and attName != "Object Level" ) {
                                                        warningBox(copyDB, toString("Unable to copy '" + viewName + "' view, due to lack of '" + attName + "' attribute."))
                                                        err = true
                                                        break
                                                } else {
                                                        attribute(destCol, attName)
                                                }
                                }
                                if ( !main(srcCol) ) {
                                        title(destCol, colTitle)
                                }
                                colWidth = width(srcCol)
                                width(destCol, colWidth)
                                justify(destCol, justify(srcCol))

                                setManualRefresh(destCol, isManualRefresh(srcCol))
                                setRefreshDelta(destCol, getRefreshDelta(srcCol))

                if ( !null(colourAttr) ) {
                    ad = find(toMod, colourAttr)
                        
                    if ( !null(ad) ) {
                                                color(destCol, colourAttr)
                                        }
                }
                                        
                if ( !null(backgroundColorAttr) ) {
                    ad = find(toMod, backgroundColorAttr)
                        
                                        if ( !null(ad) ) {
                                                backgroundColor(destCol, backgroundColorAttr)
                                        }
                }

                                if ( graphics(srcCol) ) {
                                        graphics(destCol)
                                }
                                if ( info(srcCol) ) {
                                        info(destCol)
                                }
                                if ( changebar(srcCol) ) {
                                        changebar(destCol)
                                }
                                if ( link(srcCol) ) {
                                        link(destCol)
                                }
                        }
                } else {
                        infoBox(copyDB, toString("Unable to load view '" + viewName + "' at the source"))
                        continue
                }
                
                noError
                        if ( !null(vFilt) ) {
                                set(toMod, vFilt)
                                filtering(on)
                        }
                errMsg = lastError
                if ( !null(errMsg) ) {
                        warningBox(copyDB, toString("Unable to copy view '" + viewName + ",' due to " + errMsg))
                        err = true
                        continue
                }
                noError
                        if ( !null(vSort) ) {
                                set(toMod, vSort)
                                sorting(on)
                        }
                errMsg = lastError
                if ( !null(errMsg) ) {
                        warningBox(copyDB, toString("Unable to copy view '" + viewName + ",' due to " + errMsg))
                        err = true
                        continue
                }

                if ( err ) continue // Safeguard
                
                if ( vShowingExplorer ) { showExplorer(toMod) } else { hideExplorer(toMod) }
                autoIndent(vAutoIndent)
                showDeletedObjects(vShowDeletedObjects)
                overrideTableAttribute(vOverrideTableAttribute)
                enableDefaultTableAttribute(vEnableDefaultTableAttribute)
                showGraphicsDatatips(vShowGraphicsDatatips)
                showGraphicsLinks(vShowGraphicsLinks)
                showChangeBars(vShowChangeBars)
                linkIndicators(vLinkIndicators)
                filterTables(vFilterTables)
                showPictures(vShowPictures)
                showTables(vShowTables)
                descendants(vDescendants)
                ancestors(vAncestors)
                deletions(vDeletions)
                graphics(vGraphics)
                filtering(vFiltering)
                sorting(vSorting)
                level(vLevel)
                outlining(vOutlining)

                if ( ViewExist ) {
                        change(view(viewName), vDef)
                } else {
                        save(toMod, view(viewName), vDef)
                }
                if ( modDModView == viewName ) {
                        setDefaultViewForModule(toMod, modDModView)
                }
                if ( modDUserView == viewName ) {
                        setDefaultViewForUser(toMod, modDUserView)
                }
        }
} // copyViews

//=================================================================================================
// Callback function to act on user choices.
//
// Called by: getDest callback
//                              getGUI callback
//
// Calls:
//
void copyViewsCB(DB box) {
        if (srcChoice == 0) {
                int pos = 0
                for ( pos = 0; pos < noElems (modListDBE); pos++ ) {     
                        string modName = getColumnValue(modListDBE, pos, 2)

                        destMod = read(modName, true, true)

                        if ( !null(destMod) ) {
                                if ( destMod == srcMod ) {
                                        continue
                                }
                                copyViews(destMod)
                                if ( !null(destMod) ) {
                                        close(destMod)
                                }
                        } else {
                                errorBox(copyDB, toString("Failed to open {'" + modName + "'}"))
                        }
                }
        } else {
                if ( destMod == srcMod ) {
                        warningBox(copyDB, "Source and destination are the same.\nWhy bother?")
                } else {
                        srcMod = read(rootName_(srcMod), true, true)
                        if ( !null(srcMod) ) {
                                copyViews(destMod)
                                if ( !null srcMod ) {
                                        close(srcMod)
                                }
                        } else {
                                errorBox(copyDB, toString("Failed to open {'" + rootName_(srcMod) + "'}"))
                        }
                }
        }

        raise(copyDB)
} // copyViewsCB

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void viewSelectionMade(DBE lstv, int sel) {
        int modSel = noElems(modListDBE)

        if ( modSel > 0 ) {
                active(okBtnDBE)
                active(applyBtnDBE)
        }
} // viewSelectionMade

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void viewDeselected(DBE lstv, int sel) {
        int viewSel = get(lstv)

        if ( viewSel < 0 ) {
                inactive(okBtnDBE)
                inactive(applyBtnDBE)
        }
} // viewDeselected

//=================================================================================================
// Null function to satisfy the activate callback for the view list.
//
// Called by: getDest callback
//                              getGUI callback
//
// Calls: none
//
void viewActivated(DBE lstv, int sel) {
} // viewActivated

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void modSelectionMade(DBE lstv, int sel) {
} // modSelectionMade

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void modDeselected(DBE lstv, int sel) {
} // modDeselected

//=================================================================================================
// Null function to satisfy the activate callback for the module list.
//
// Called by: getDest callback
//                              getGUI callback
//
// Calls: none
//
void modActivated(DBE lstv, int sel) {
        removeModuleFromList(lstv)

        int modSel = noElems(lstv)
        if ( modSel == 0 ) {
                inactive(okBtnDBE)
                inactive(applyBtnDBE)
        }
} // modActivated

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void getGUI() {
        string projectName = null
        Project projectRoot = null

        copyDB = create(((srcChoice == 1)?("Copy Views from Another Module"):("Copy Views to Other Modules")), styleCentered)

        viewFrameDBE = frame(copyDB, "Select views", modWidth + 20, listLength * 22)
        viewFrameDBE->"right"->"unattached"
        viewFrameDBE->"bottom"->"unattached"

        viewListDBE = listView(copyDB, listViewOptionMultiselect, modWidth*3/2, listLength, dummy)
        viewListDBE->"top"->"inside"->viewFrameDBE
        viewListDBE->"left"->"inside"->viewFrameDBE
        viewListDBE->"right"->"inside"->viewFrameDBE
        viewListDBE->"bottom"->"inside"->viewFrameDBE
        set(viewListDBE, viewSelectionMade, viewDeselected, viewActivated)

        modFrameDBE = frame(copyDB, ((srcChoice == 1)?("Select source module"):("Select destination module(s)")), modListWidth + 20, listLength * 22)
        modFrameDBE->"left"->"unattached"
        modFrameDBE->"top"->"aligned"->viewFrameDBE
        modFrameDBE->"bottom"->"unattached"

        miniExplorerDBE = treeView(copyDB, treeViewOptionSorted, modListWidth, listLength/2)
        miniExplorerDBE->"left"->"inside"->modFrameDBE
        miniExplorerDBE->"right"->"form"
        miniExplorerDBE->"top"->"inside"->modFrameDBE
        miniExplorerDBE->"bottom"->"unattached"

        set(miniExplorerDBE, doTreeSelect)
        set(miniExplorerDBE, doTreeExpand)

        modListDBE = listView(copyDB, listViewOptionMultiselect, modListWidth, listLength/2, dummy)
        modListDBE->"left"->"inside"->modFrameDBE
        modListDBE->"right"->"form"
        modListDBE->"top"->"flush"->miniExplorerDBE
        modListDBE->"bottom"->"form"

        set(modListDBE, modSelectionMade, modDeselected, modActivated)  

        splitDBE = splitter(copyDB, viewFrameDBE, modFrameDBE, 5)
        splitDBE->"top"->"form"
        splitDBE->"left"->"unattached"
        splitDBE->"right"->"unattached"
        splitDBE->"bottom"->"form"

        okBtnDBE = ok(copyDB, "OK", copyViewsCB)
        applyBtnDBE = apply(copyDB, "Apply", copyViewsCB)
        inactive(okBtnDBE)
        inactive(applyBtnDBE)
        realize(copyDB)

        setExtraHeightShare(viewFrameDBE, 1.0)
        setExtraHeightShare(modFrameDBE, 1.0)
        setExtraWidthShare(viewFrameDBE,  0.4)
        setExtraWidthShare(modFrameDBE,  0.6)

        insertColumn(viewListDBE, 0, "View", viewWidth, iconNone)
        insertColumn(modListDBE, 0, "Module", modWidth, iconNone)
        insertColumn(modListDBE, 1, "from Project", modWidth, iconNone)
        insertColumn(modListDBE, 2, "Path", pathWidth, iconNone)

        if ( srcChoice == 0 ) listViews

        // check status
        if ( theCurrentView == DATABASE_VIEW ) {
                // adjust accordingly
                insert(miniExplorerDBE, dbDisplayRoot(), iconDatabase, iconDatabase)
        } else {
                projectRoot = getRootProject_()
                setRootProject_(null)

                // process database
                for projectName in database do {
                        addItemToTree(miniExplorerDBE, item(dbSep projectName))
                }

                setRootProject_(projectRoot)
        }

        changeToStartFolder(current Folder)

        block(copyDB)

        destroy(copyDB)
        copyDB = null   
} // getGUI

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void letsGo() {
        //http://www.ibm.com/developerworks/rational/library/memory-management-perms-api-doors/
        noError
                initNotDisplayedOpenModules()
        lastError

        // Initializations
        currMod = current
        srcMod  = null

        srcChoice = messageBox("Is the current module the source or destination for the views?", srcDest, msgQuery)
        if ( srcChoice == 0 ) {
                srcMod = currMod
                getGUI
        } else if ( srcChoice == 1 ) {
                destMod = currMod
                getGUI
        }

        noError
                closeNotDisplayedOpenedModules()
        lastError

        //freeing resources
        delete moduleList
} // letsGo

// Main
letsGo

 

Re: Copy View
dbonfiglio - Thu Dec 27 14:09:06 EST 2018

EHcnck - Thu Dec 27 13:56:11 EST 2018

//<
// Copy Views

/*
This script allows the user to copy the views to the current module from another
or from the current to multiple others.

Version Developed On    Date            By                                Notes
0.5.0   DOORS 5.1sr1 PC 07/11/01        Telelogic NA          Preliminary to see how people like the selection screen
1.0.0   DOORS 5.2 PC    02/10/02        Telelogic NA          Includes ViewDef information
1.1.0   DOORS 5.2 PC    07/22/02        Telelogic NA          Closes more modules on completion
1.1.1   DOORS 6.0sr1 PC 01/10/03        Telelogic NA          Doesn't copy title of main column
2.0.0   DOORS 7.1 PC    08/04/04        Telelogin NA          Corrected resizing issue, made more kitchen like
2.1.0   DOORS 9.6           02/11/15    Schneider-Electric    Reduce code(DB, DBE, etc.), made changes to Interface to use treeView for selection of Modules.
2.2.0   DOORS 9.6.1.2   09/21/15    Schneider-Electric    Add support for info, graphic, colour, etc.
2.3.0   DOORS 9.6.1.2   09/22/15    Schneider-Electric    Fix error protection on Copy.
2.4.0   DOORS 9.6.1.6   08/29/16    Schneider-Electric    Change around some logic, using stringFunctions.inc
*/

if ( !confirm "This tool copies views from the current module to other selected modules.\n" //-
                          "OR from a selected module TO the current module.\n\n" //-
                          "Use this tool to manage the consistency of views across the database.\n\n" //-
                          "It proceeds by asking the user to select if the current module is the Source or Destination." //-

                          "Continue?"
        )
{
        halt
}

pragma encoding, "UTF-8"
pragma runLim, 0

#include <C:\DXL\FX\includes\stringFunctions.inc>

// Constants

const string srcDest[]              = {"Source", "Destination", "Cancel"}
const string dummy[]                = {}
const int modListWidth              = 500
const int modWidth                  = 150
const int pathWidth                 = (modListWidth - modWidth)/2
const int viewWidth                 = modWidth
const int listLength                = 20
const int MINI_EXP_FP                           = 1
const int MINI_EXP_LINK_MODS            = 2
const int MINI_EXP_FORMAL_MODS          = 4
const int MINI_EXP_DESCRIPTIVE_MODS = 8
const int MINI_EXP_SHOW_DELETED         = 16
const int itemMask                  = MINI_EXP_FORMAL_MODS

// Variables

Skip moduleList                     = createString()
Module currMod, srcMod, destMod

DB  copyDB
DBE modListDBE
DBE viewListDBE
DBE splitDBE
DBE modFrameDBE
DBE viewFrameDBE
DBE okBtnDBE
DBE applyBtnDBE
DBE miniExplorerDBE

int srcChoice = -1

// Functions

// Returns whether or not the selected item in the tree view matches the type of module the 
// tree view was created to be able to select
bool itemMatchesSelectedMask(Item itm) {
        bool matchesMask = false

        if ( type(itm) == "Formal" && ((itemMask & MINI_EXP_FORMAL_MODS) == MINI_EXP_FORMAL_MODS) ) {
                matchesMask = true
        }
        else if ( type(itm) == "Link" && ((itemMask & MINI_EXP_LINK_MODS) == MINI_EXP_LINK_MODS) ) {
                matchesMask = true
        }
        else if ( type(itm) == "Descriptive" && ((itemMask & MINI_EXP_DESCRIPTIVE_MODS) == MINI_EXP_DESCRIPTIVE_MODS) ) {
                matchesMask = true
        }

        return(matchesMask)
}

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void listViews() {
        empty(viewListDBE)
        string viewName = null
        int dataRow     = 0

        inactive(okBtnDBE)
        inactive(applyBtnDBE)
        inactive(viewListDBE)

        for viewName in views srcMod do {
                insert(viewListDBE, dataRow++, viewName)
        }
} // listViews

// Adds a delete items to the modListDBE view.
void removeModuleFromList(DBE clicked) {
        int selectedRow   = get(modListDBE)
        string moduleName = getColumnValue(modListDBE, selectedRow, 2)
        
        delete(moduleList, moduleName)
        delete(modListDBE, selectedRow)
        
        if ( noElems(modListDBE) == 0 ) {
                inactive(okBtnDBE)
                inactive(applyBtnDBE)
        }
        if ( srcChoice == 1 ) {
                empty(viewListDBE)
        }
}

// Adds a new items to the modListDBE view.
void addModuleToList(DBE clicked) {
        string selectedModule = getRealPath(dbSep get(miniExplorerDBE))

        Item i          = item(selectedModule)
        Folder f        = getParentFolder(i)
        bool moduleOpen = false
        int currentRow  = 0

        if ( isDeleted(i) ) {
                warningBox(copyDB, "Cannot copy views to a deleted module.")
                return()
        }

        // check that the source module wasn't selected
        if ( rootName_(i) == rootName_(currMod) ) {
                warningBox(copyDB, "Cannot select the source module.")
                return()
        }

        // check that the item matches the module type the tree view was passed when it was created
        // and that it does not already exist in the list.
        if ( find(moduleList, rootName_(i)) ) {
                warningBox(copyDB, "Item of the same name already selected. Unable to add to list.")
                return()
        }

        if ( itemMatchesSelectedMask(i) ) {
                currentRow = noElems(modListDBE)

                // put in the module list
                insert(modListDBE, currentRow, name(i), getIcon(i))
                set     (modListDBE, currentRow, 2, rootName_(i))
                set     (modListDBE, currentRow, 1, name(f))
                set     (modListDBE, currentRow, 1, getIcon(item(rootName_(f))))
                put     (moduleList, rootName_(i), rootName_(i))
        }
        else {
                return()
        }

        int modSel = get(viewListDBE)
        if ( modSel > 0 ) {
                active(okBtnDBE)
                active(applyBtnDBE)
        }

        if ( srcChoice == 1 ) {
                string srcModName = getColumnValue(modListDBE, currentRow, 2)

                srcMod = read(srcModName, false, true)
                listViews

                if ( !null(srcMod) ) {
                        close(srcMod)
                }
        }

        active(viewListDBE)
}

// Adds a new item to the tree view.
void addItemToTree(DBE dbe, Item i) {
        string displayPath = getDisplayPath(i)

        // check if the path exists in the tree view
        if ( exists(miniExplorerDBE, displayPath) == false ) {
                // check that the item is not deleted or if it is, that the tree view was created with the option
                // to show deleted items.
                if ( isDeleted(i) == false || (isDeleted(i) == true && ((itemMask & MINI_EXP_SHOW_DELETED) == MINI_EXP_SHOW_DELETED)) ) {
                        // check item type
                        if ( type(i) == "Folder" || type(i) == "Project" ) {
                                Icon iconOpen
                                Icon iconClosed
                                string sDummyEntry = displayPath dbSep dummyItem

                                // assign project or folder specific icons
                                assignIcons(i, iconOpen, iconClosed)

                                // add entry (plus dummy)
                                insert(miniExplorerDBE, displayPath, iconClosed, iconOpen)
                                insert(miniExplorerDBE, sDummyEntry, iconClosed, iconOpen)
                        } else if ( itemMatchesSelectedMask(i) ) {
                                insert(miniExplorerDBE, displayPath, getIcon(i), getIcon(i))
                        }
                }
        }
}

// Opens the selected Project or Folder in the tree view and loads its containing items.
void displaySelectedBranch(DBE dbe, string sItemPath) {
        Folder fStart = folder(getRealPath(sItemPath))

        if ( !null(fStart) ) {
                Item i

                for i in all fStart do {
                        addItemToTree(miniExplorerDBE, i)
                }
        }
}

// DBE callback that fires when an element in the tree view is selected.
void doTreeSelect(DBE dbe) {
        string sel = getRealPath(dbSep get(miniExplorerDBE))

        if ( itemMatchesSelectedMask(item(sel)) ) {
                if ( noElems(modListDBE) > 0 && (srcChoice == 1) ) {
                        warningBox(copyDB, "Only allowed one Source Module.")
                } else {
                        addModuleToList(dbe)
                }
        }
}

// DBE callback that fires when an item in the tree view is double clicked.
bool doTreeExpand(DBE dbe, string sItem) {
        string sItemPath  = dbSep sItem
        string sDummyItem = sItemPath dbSep dummyItem

        // check status
        if ( exists(miniExplorerDBE, sDummyItem) == true ) {
                // remove dummy
                delete(miniExplorerDBE, sDummyItem)
        }

        // check status
        if ( theCurrentView == DATABASE_VIEW ) {
                // adjust view accordingly
                displaySelectedBranch(miniExplorerDBE, sItemPath)
        } else {
                Project prjOldRoot = getRootProject_()

                setRootProject_(project(getRootOfPath sItemPath))

                // adjust view accordingly
                displaySelectedBranch(miniExplorerDBE, sItemPath)

                setRootProject_(prjOldRoot)
        }

        return(true)
}

// Loads the tree view to start with the passed in folder opened.
void changeToStartFolder(Folder fStart) {
        if ( !null(fStart) ) {
                int i = 0

                // calculate max bound for loop
                int finish = length(rootName_(fStart))

                // prepare initial path
                string sFolderPath = ((theCurrentView == DATABASE_VIEW) ? dbDisplayRoot() : "")
                string sCharacter

                // process string
                for ( i = 0; i <= finish; i++ ) {
                        // obtain character
                        sCharacter = (rootName_(fStart))[i:i]

                        // check status
                        if ( sCharacter == dbSep || i == finish ) {
                                // check status
                                if ( theCurrentView == PROJECT_VIEW && sFolderPath == dbSep ) {
                                        continue
                                }

                                // update explorer
                                displaySelectedBranch(miniExplorerDBE, sFolderPath)
                        }

                        sFolderPath = sFolderPath sCharacter
                }

                // update explorer
                set(miniExplorerDBE, sFolderPath)
        } else {
                // default to database level
                displaySelectedBranch(miniExplorerDBE, dbDisplayRoot())
                set(miniExplorerDBE, dbDisplayRoot())
        }
}

//=================================================================================================
// Clears the destination view.
//
// Called by: copyViews
//
// Calls: none
//
bool clearDest(Module m, string viewName) {
        bool ret = load(m, view(viewName))
        Column c = null
    int i = 0
        int count = 0
        for c in m do {
                count++
        }
        current = m
        for ( i = 0; i < count; i++ ) {
                delete(column(0))
        }
        filtering(off)
        sorting(off)
        outlining(off)
        level(0)
        return ret
} // clearDest

//=================================================================================================
// Core view copying function.  Copies views from the list to the passed module.
//
// Called by: copyViewsCB
//
// Calls: clearDest
//
void copyViews(Module toMod) {
        Column srcCol              = null
        Column destCol             = null
        ViewDef vDef               = null
        Filter vFilt               = null
        Sort vSort                 = null
        AttrDef ad                 = null
        string errMsg              = null
        string attName             = null
        string colTitle            = null
        string colourAttr          = null
        string backgroundColorAttr = null
        string viewName            = null
        string modDModView         = null
        string modDUserView        = null
        int viewPos                = 0
        int colWidth               = 0
        int colCount               = 0
        int vLevel                 = 0
        bool err                   = false
        bool vShowingExplorer
        bool vAutoIndent
        bool vShowDeletedObjects
        bool vOverrideTableAttribute
        bool vEnableDefaultTableAttribute
        bool vShowGraphicsDatatips
        bool vShowGraphicsLinks
        bool vShowChangeBars
        bool vLinkIndicators
        bool vFilterTables
        bool vShowPictures
        bool vShowTables
        bool vDescendants
        bool vAncestors
        bool vDeletions
        bool vGraphics
        bool vFiltering
        bool vSorting
        bool vOutlining
        bool ViewExist

        for viewPos in viewListDBE do {      
                viewName = getColumnValue(viewListDBE, viewPos, 0)
                err      = false
                vFilt    = null
                vSort    = null
                
                current  = srcMod
                if ( load(view(viewName)) ) {
                        vDef = get(view(viewName))
                
                        modDModView = getDefaultViewForModule(srcMod)
                        modDUserView = getDefaultViewForUser(srcMod)

                        if ( filtering(srcMod) ) {
                                vFilt = current
                        }
                        if ( sorting(srcMod) ) {
                                vSort = current
                        }
                                        
                        vShowingExplorer = showingExplorer(srcMod)
                        vAutoIndent = autoIndent(srcMod)
                        vShowDeletedObjects = showDeletedObjects(srcMod)
                        vOverrideTableAttribute = overrideTableAttribute(srcMod)
                        vEnableDefaultTableAttribute = enableDefaultTableAttribute(srcMod)
                        vShowGraphicsDatatips = showGraphicsDatatips(srcMod)
                        vShowGraphicsLinks = showGraphicsLinks(srcMod)
                        vShowChangeBars = showChangeBars(srcMod)
                        vLinkIndicators = linkIndicators(srcMod)
                        vFilterTables = filterTables(srcMod)
                        vShowPictures = showPictures(srcMod)
                        vShowTables = showTables(srcMod)
                        vDescendants = descendants(srcMod)
                        vAncestors = ancestors(srcMod)
                        vDeletions = deletions(srcMod)
                        vGraphics = graphics(srcMod)
                        vFiltering = filtering(srcMod)
                        vSorting = sorting(srcMod)
                        vLevel = level(srcMod)
                        vOutlining = outlining(srcMod)
                                
                        ViewExist = clearDest(toMod, viewName) // Clears and sets current = toMod
                        colCount = 0
                        for srcCol in srcMod do {
                                destCol = column colCount++
                                attName = attrName(srcCol)
                                colTitle = title(srcCol)
                                colourAttr = color(srcCol)
                                backgroundColorAttr = backgroundColor(srcCol)
                                ad = null

                                if ( null(attName) ) {
                                        if ( main(srcCol) ) {
                                                if ( probeAttr_(srcMod, "Description") != colTitle ) {
                                                        title(destCol, colTitle)
                                                }
                                                main(destCol)
                                        } else {
                                                if ( !link(srcCol) && !changebar(srcCol) )
                                                        dxl(destCol, dxl(srcCol))
                                        }
                                } else {
                                        ad = find(toMod, attName)
                                        if ( null(ad) and attName != "Object Identifier" and
                                                attName != "Object Number" and attName != "Object Level" ) {
                                                        warningBox(copyDB, toString("Unable to copy '" + viewName + "' view, due to lack of '" + attName + "' attribute."))
                                                        err = true
                                                        break
                                                } else {
                                                        attribute(destCol, attName)
                                                }
                                }
                                if ( !main(srcCol) ) {
                                        title(destCol, colTitle)
                                }
                                colWidth = width(srcCol)
                                width(destCol, colWidth)
                                justify(destCol, justify(srcCol))

                                setManualRefresh(destCol, isManualRefresh(srcCol))
                                setRefreshDelta(destCol, getRefreshDelta(srcCol))

                if ( !null(colourAttr) ) {
                    ad = find(toMod, colourAttr)
                        
                    if ( !null(ad) ) {
                                                color(destCol, colourAttr)
                                        }
                }
                                        
                if ( !null(backgroundColorAttr) ) {
                    ad = find(toMod, backgroundColorAttr)
                        
                                        if ( !null(ad) ) {
                                                backgroundColor(destCol, backgroundColorAttr)
                                        }
                }

                                if ( graphics(srcCol) ) {
                                        graphics(destCol)
                                }
                                if ( info(srcCol) ) {
                                        info(destCol)
                                }
                                if ( changebar(srcCol) ) {
                                        changebar(destCol)
                                }
                                if ( link(srcCol) ) {
                                        link(destCol)
                                }
                        }
                } else {
                        infoBox(copyDB, toString("Unable to load view '" + viewName + "' at the source"))
                        continue
                }
                
                noError
                        if ( !null(vFilt) ) {
                                set(toMod, vFilt)
                                filtering(on)
                        }
                errMsg = lastError
                if ( !null(errMsg) ) {
                        warningBox(copyDB, toString("Unable to copy view '" + viewName + ",' due to " + errMsg))
                        err = true
                        continue
                }
                noError
                        if ( !null(vSort) ) {
                                set(toMod, vSort)
                                sorting(on)
                        }
                errMsg = lastError
                if ( !null(errMsg) ) {
                        warningBox(copyDB, toString("Unable to copy view '" + viewName + ",' due to " + errMsg))
                        err = true
                        continue
                }

                if ( err ) continue // Safeguard
                
                if ( vShowingExplorer ) { showExplorer(toMod) } else { hideExplorer(toMod) }
                autoIndent(vAutoIndent)
                showDeletedObjects(vShowDeletedObjects)
                overrideTableAttribute(vOverrideTableAttribute)
                enableDefaultTableAttribute(vEnableDefaultTableAttribute)
                showGraphicsDatatips(vShowGraphicsDatatips)
                showGraphicsLinks(vShowGraphicsLinks)
                showChangeBars(vShowChangeBars)
                linkIndicators(vLinkIndicators)
                filterTables(vFilterTables)
                showPictures(vShowPictures)
                showTables(vShowTables)
                descendants(vDescendants)
                ancestors(vAncestors)
                deletions(vDeletions)
                graphics(vGraphics)
                filtering(vFiltering)
                sorting(vSorting)
                level(vLevel)
                outlining(vOutlining)

                if ( ViewExist ) {
                        change(view(viewName), vDef)
                } else {
                        save(toMod, view(viewName), vDef)
                }
                if ( modDModView == viewName ) {
                        setDefaultViewForModule(toMod, modDModView)
                }
                if ( modDUserView == viewName ) {
                        setDefaultViewForUser(toMod, modDUserView)
                }
        }
} // copyViews

//=================================================================================================
// Callback function to act on user choices.
//
// Called by: getDest callback
//                              getGUI callback
//
// Calls:
//
void copyViewsCB(DB box) {
        if (srcChoice == 0) {
                int pos = 0
                for ( pos = 0; pos < noElems (modListDBE); pos++ ) {     
                        string modName = getColumnValue(modListDBE, pos, 2)

                        destMod = read(modName, true, true)

                        if ( !null(destMod) ) {
                                if ( destMod == srcMod ) {
                                        continue
                                }
                                copyViews(destMod)
                                if ( !null(destMod) ) {
                                        close(destMod)
                                }
                        } else {
                                errorBox(copyDB, toString("Failed to open {'" + modName + "'}"))
                        }
                }
        } else {
                if ( destMod == srcMod ) {
                        warningBox(copyDB, "Source and destination are the same.\nWhy bother?")
                } else {
                        srcMod = read(rootName_(srcMod), true, true)
                        if ( !null(srcMod) ) {
                                copyViews(destMod)
                                if ( !null srcMod ) {
                                        close(srcMod)
                                }
                        } else {
                                errorBox(copyDB, toString("Failed to open {'" + rootName_(srcMod) + "'}"))
                        }
                }
        }

        raise(copyDB)
} // copyViewsCB

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void viewSelectionMade(DBE lstv, int sel) {
        int modSel = noElems(modListDBE)

        if ( modSel > 0 ) {
                active(okBtnDBE)
                active(applyBtnDBE)
        }
} // viewSelectionMade

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void viewDeselected(DBE lstv, int sel) {
        int viewSel = get(lstv)

        if ( viewSel < 0 ) {
                inactive(okBtnDBE)
                inactive(applyBtnDBE)
        }
} // viewDeselected

//=================================================================================================
// Null function to satisfy the activate callback for the view list.
//
// Called by: getDest callback
//                              getGUI callback
//
// Calls: none
//
void viewActivated(DBE lstv, int sel) {
} // viewActivated

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void modSelectionMade(DBE lstv, int sel) {
} // modSelectionMade

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void modDeselected(DBE lstv, int sel) {
} // modDeselected

//=================================================================================================
// Null function to satisfy the activate callback for the module list.
//
// Called by: getDest callback
//                              getGUI callback
//
// Calls: none
//
void modActivated(DBE lstv, int sel) {
        removeModuleFromList(lstv)

        int modSel = noElems(lstv)
        if ( modSel == 0 ) {
                inactive(okBtnDBE)
                inactive(applyBtnDBE)
        }
} // modActivated

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void getGUI() {
        string projectName = null
        Project projectRoot = null

        copyDB = create(((srcChoice == 1)?("Copy Views from Another Module"):("Copy Views to Other Modules")), styleCentered)

        viewFrameDBE = frame(copyDB, "Select views", modWidth + 20, listLength * 22)
        viewFrameDBE->"right"->"unattached"
        viewFrameDBE->"bottom"->"unattached"

        viewListDBE = listView(copyDB, listViewOptionMultiselect, modWidth*3/2, listLength, dummy)
        viewListDBE->"top"->"inside"->viewFrameDBE
        viewListDBE->"left"->"inside"->viewFrameDBE
        viewListDBE->"right"->"inside"->viewFrameDBE
        viewListDBE->"bottom"->"inside"->viewFrameDBE
        set(viewListDBE, viewSelectionMade, viewDeselected, viewActivated)

        modFrameDBE = frame(copyDB, ((srcChoice == 1)?("Select source module"):("Select destination module(s)")), modListWidth + 20, listLength * 22)
        modFrameDBE->"left"->"unattached"
        modFrameDBE->"top"->"aligned"->viewFrameDBE
        modFrameDBE->"bottom"->"unattached"

        miniExplorerDBE = treeView(copyDB, treeViewOptionSorted, modListWidth, listLength/2)
        miniExplorerDBE->"left"->"inside"->modFrameDBE
        miniExplorerDBE->"right"->"form"
        miniExplorerDBE->"top"->"inside"->modFrameDBE
        miniExplorerDBE->"bottom"->"unattached"

        set(miniExplorerDBE, doTreeSelect)
        set(miniExplorerDBE, doTreeExpand)

        modListDBE = listView(copyDB, listViewOptionMultiselect, modListWidth, listLength/2, dummy)
        modListDBE->"left"->"inside"->modFrameDBE
        modListDBE->"right"->"form"
        modListDBE->"top"->"flush"->miniExplorerDBE
        modListDBE->"bottom"->"form"

        set(modListDBE, modSelectionMade, modDeselected, modActivated)  

        splitDBE = splitter(copyDB, viewFrameDBE, modFrameDBE, 5)
        splitDBE->"top"->"form"
        splitDBE->"left"->"unattached"
        splitDBE->"right"->"unattached"
        splitDBE->"bottom"->"form"

        okBtnDBE = ok(copyDB, "OK", copyViewsCB)
        applyBtnDBE = apply(copyDB, "Apply", copyViewsCB)
        inactive(okBtnDBE)
        inactive(applyBtnDBE)
        realize(copyDB)

        setExtraHeightShare(viewFrameDBE, 1.0)
        setExtraHeightShare(modFrameDBE, 1.0)
        setExtraWidthShare(viewFrameDBE,  0.4)
        setExtraWidthShare(modFrameDBE,  0.6)

        insertColumn(viewListDBE, 0, "View", viewWidth, iconNone)
        insertColumn(modListDBE, 0, "Module", modWidth, iconNone)
        insertColumn(modListDBE, 1, "from Project", modWidth, iconNone)
        insertColumn(modListDBE, 2, "Path", pathWidth, iconNone)

        if ( srcChoice == 0 ) listViews

        // check status
        if ( theCurrentView == DATABASE_VIEW ) {
                // adjust accordingly
                insert(miniExplorerDBE, dbDisplayRoot(), iconDatabase, iconDatabase)
        } else {
                projectRoot = getRootProject_()
                setRootProject_(null)

                // process database
                for projectName in database do {
                        addItemToTree(miniExplorerDBE, item(dbSep projectName))
                }

                setRootProject_(projectRoot)
        }

        changeToStartFolder(current Folder)

        block(copyDB)

        destroy(copyDB)
        copyDB = null   
} // getGUI

//=================================================================================================
//
//
// Called by:
//
// Calls:
//
void letsGo() {
        //http://www.ibm.com/developerworks/rational/library/memory-management-perms-api-doors/
        noError
                initNotDisplayedOpenModules()
        lastError

        // Initializations
        currMod = current
        srcMod  = null

        srcChoice = messageBox("Is the current module the source or destination for the views?", srcDest, msgQuery)
        if ( srcChoice == 0 ) {
                srcMod = currMod
                getGUI
        } else if ( srcChoice == 1 ) {
                destMod = currMod
                getGUI
        }

        noError
                closeNotDisplayedOpenedModules()
        lastError

        //freeing resources
        delete moduleList
} // letsGo

// Main
letsGo

 

correct if you expand the logic around line 442 to include changebar(Column ) and link(Column) which are now available 9.6 that is when it starting having issues.

Re: Copy View
EHcnck - Thu Dec 27 14:14:51 EST 2018

dbonfiglio - Thu Dec 27 14:09:06 EST 2018

correct if you expand the logic around line 442 to include changebar(Column ) and link(Column) which are now available 9.6 that is when it starting having issues.

did you execute my version, still having issues; its been working without issues on my end, we are running 9.6.1.8/9?

Re: Copy View
dbonfiglio - Thu Dec 27 15:03:39 EST 2018

EHcnck - Thu Dec 27 14:14:51 EST 2018

did you execute my version, still having issues; its been working without issues on my end, we are running 9.6.1.8/9?

sorry no i did not trying to look at it now.

Re: Copy View
dbonfiglio - Thu Dec 27 15:11:49 EST 2018

dbonfiglio - Thu Dec 27 15:03:39 EST 2018

sorry no i did not trying to look at it now.

Very strange  your script appears to be working correctly... I'll have to look it over to figure out how its different.   FYI i just tried added the logic you added with changebar and link in a similar location did not fix the problem strange must be something else effecting it.

Re: Copy View
dbonfiglio - Mon Jan 07 07:45:22 EST 2019

dbonfiglio - Thu Dec 27 15:11:49 EST 2018

Very strange  your script appears to be working correctly... I'll have to look it over to figure out how its different.   FYI i just tried added the logic you added with changebar and link in a similar location did not fix the problem strange must be something else effecting it.

I finished my testing last week and found there apparently is a problem when a new column is created. I found three different ways to do this

 

 

column c = insert (Column number)

column c = insert (module, Column Number)

column c = column number

both the first two options gave me problems. I was however not able to repeat the problem outside this particular code.  So it must be some kind of interaction inside the code in combination with the way the new column is declared.

Re: Copy View
EHcnck - Mon Jan 07 18:38:42 EST 2019

dbonfiglio - Mon Jan 07 07:45:22 EST 2019

I finished my testing last week and found there apparently is a problem when a new column is created. I found three different ways to do this

 

 

column c = insert (Column number)

column c = insert (module, Column Number)

column c = column number

both the first two options gave me problems. I was however not able to repeat the problem outside this particular code.  So it must be some kind of interaction inside the code in combination with the way the new column is declared.

this works for me no issue (DOORS 9.6.1.8/9); what errors are you getting?

Column c = insert (column 0)
attribute(c, "Object Text")
width(c, 250)

Re: Copy View
dbonfiglio - Tue Jan 08 04:58:27 EST 2019

EHcnck - Mon Jan 07 18:38:42 EST 2019

this works for me no issue (DOORS 9.6.1.8/9); what errors are you getting?

Column c = insert (column 0)
attribute(c, "Object Text")
width(c, 250)

I get two different problems, 

1.) Link bars and Change bars appear to not be saving in the correct location

2.) When the view is saved anytime you clicked to see the view and then switch out (without changing anything) Doors will prompt you with the you are about to loose changes related to the view. 

 

as i stated i only see this behavior inside the code and have not been able to reproduce outside this code.  however when i use option 1 or 2 it give me this problem. for now i think i'm good and no additional help is needed.  However if you have seen anyone has seen this similar bug it would be nice to find out what is the root cause of the problem.

Re: Copy View
EHcnck - Tue Jan 08 10:39:03 EST 2019

dbonfiglio - Tue Jan 08 04:58:27 EST 2019

I get two different problems, 

1.) Link bars and Change bars appear to not be saving in the correct location

2.) When the view is saved anytime you clicked to see the view and then switch out (without changing anything) Doors will prompt you with the you are about to loose changes related to the view. 

 

as i stated i only see this behavior inside the code and have not been able to reproduce outside this code.  however when i use option 1 or 2 it give me this problem. for now i think i'm good and no additional help is needed.  However if you have seen anyone has seen this similar bug it would be nice to find out what is the root cause of the problem.

I quickly modified this version of http://www.galactic-solutions.com/GalacticDownloads.htm Copy view

I've added changebar and Linkindicators using 9.6.1.9 I see no issues.


Attachments

Copy Views.dxl