How to maintain selection in two different listViews simultaneously

I'm building a dialog box with two independent listView elements in it.

The trouble is that when I select an item in one listView, DOORS deselects the item in the other listView. I need to maintain a single item selection in both listViews simultaneously. (The user is selecting a name in one listView and a role in the other, establishing a relationship between two elements in different listViews). (Note that I am not talking about different columns in the same listView. I am talking about two discrete listViews in the same dialog box.)

Any ideas? 

Thanks in advance!


Bob3 - Thu Oct 15 23:30:26 EDT 2015

Re: How to maintain selection in two different listViews simultaneously
Pekka_Makinen - Fri Oct 16 04:36:35 EDT 2015

Even though the selection fades on the other listview when something is selected on the other, isn't there still a selection on? I hacked a short demo from the example in this discussion https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014680628

 

int    fDbeLv_clbkSortFunction(string s1, s2)
{     // Standard sort function when defining a column as sortable.
        // Developers Note: Some code if added herein will cause DXL exception Violations.
        //      Don't understand why, but this function needs to be kept as-is.
        int     Result
        print "S1 = " s1 " S2 = " s2 "\n"
        if     (s1 == s2) Result =  0
        elseif (s1 >  s2) Result =  1
        elseif (s1 <  s2) Result = -1
        else{} // all cases covered
        return(Result)
}  // end fDbeLv_clbkSortFunction()
 
 
DBE lv1, lv2, bttn
 
void activateModule (DBE x, int index) {
        print "I = " index " activated!\n"
        if (index < 0) return
        Buffer s = (getClientData(x, index)) Buffer
        print s "\n"
}             

void doStuff (DB x) {

    string Value1 = get lv1
    string Value2 = get lv2
    
    infoBox "Selected on 1 " Value1 " and selected on 2" Value2 ""

}             
 
string someData[] = {}
 
DB testDialog = centered "Listview Test"
 
label (testDialog, "" )
// remove the listViewOptionSortText and the code will not crash
lv1 = listView (testDialog,listViewOptionSortText, 200, 5, someData)
beside testDialog
lv2 = listView (testDialog,listViewOptionSortText, 200, 5, someData)
bttn = apply(testDialog, "Show selections", doStuff)

realize testDialog
 
insertColumn(lv1, 0, "Column 1"       , 80, iconNone)
insertColumn(lv1, 1, "Column 2"       , 80, iconNone)
 
set (lv1, 0, 1, "Some Data")
set (lv1, 1, 1, "More Data")

insertColumn(lv2, 0, "Column 1"       , 80, iconNone)
insertColumn(lv2, 1, "Column 2"       , 80, iconNone)
 
set (lv2, 0, 1, "Some Data")
set (lv2, 1, 1, "More Data")

 
set(lv1, 0, fDbeLv_clbkSortFunction)
set(lv1, 1, fDbeLv_clbkSortFunction)
 
void dummyCallback(DBE, int) {}
set(lv1, dummyCallback, dummyCallback, activateModule)   
set(lv2, dummyCallback, dummyCallback, activateModule)   
 
Buffer b1 = create(); b1 = "This is Index 1"
Buffer b2 = create(); b2 = "This is Index 2"
insert(lv1, 0,  "Line 1", b1, iconNone)
insert(lv1, 1,  "Line 2", b2, iconNone)

insert(lv2, 0,  "Line 1", b1, iconNone)
insert(lv2, 1,  "Line 2", b2, iconNone)  

show testDialog

and it does display both selections done to both listviews when you press Show selections.

Re: How to maintain selection in two different listViews simultaneously
Bob3 - Sat Oct 17 11:39:49 EDT 2015

Pekka_Makinen - Fri Oct 16 04:36:35 EDT 2015

Even though the selection fades on the other listview when something is selected on the other, isn't there still a selection on? I hacked a short demo from the example in this discussion https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014680628

 

int    fDbeLv_clbkSortFunction(string s1, s2)
{     // Standard sort function when defining a column as sortable.
        // Developers Note: Some code if added herein will cause DXL exception Violations.
        //      Don't understand why, but this function needs to be kept as-is.
        int     Result
        print "S1 = " s1 " S2 = " s2 "\n"
        if     (s1 == s2) Result =  0
        elseif (s1 >  s2) Result =  1
        elseif (s1 <  s2) Result = -1
        else{} // all cases covered
        return(Result)
}  // end fDbeLv_clbkSortFunction()
 
 
DBE lv1, lv2, bttn
 
void activateModule (DBE x, int index) {
        print "I = " index " activated!\n"
        if (index < 0) return
        Buffer s = (getClientData(x, index)) Buffer
        print s "\n"
}             

void doStuff (DB x) {

    string Value1 = get lv1
    string Value2 = get lv2
    
    infoBox "Selected on 1 " Value1 " and selected on 2" Value2 ""

}             
 
string someData[] = {}
 
DB testDialog = centered "Listview Test"
 
label (testDialog, "" )
// remove the listViewOptionSortText and the code will not crash
lv1 = listView (testDialog,listViewOptionSortText, 200, 5, someData)
beside testDialog
lv2 = listView (testDialog,listViewOptionSortText, 200, 5, someData)
bttn = apply(testDialog, "Show selections", doStuff)

realize testDialog
 
insertColumn(lv1, 0, "Column 1"       , 80, iconNone)
insertColumn(lv1, 1, "Column 2"       , 80, iconNone)
 
set (lv1, 0, 1, "Some Data")
set (lv1, 1, 1, "More Data")

insertColumn(lv2, 0, "Column 1"       , 80, iconNone)
insertColumn(lv2, 1, "Column 2"       , 80, iconNone)
 
set (lv2, 0, 1, "Some Data")
set (lv2, 1, 1, "More Data")

 
set(lv1, 0, fDbeLv_clbkSortFunction)
set(lv1, 1, fDbeLv_clbkSortFunction)
 
void dummyCallback(DBE, int) {}
set(lv1, dummyCallback, dummyCallback, activateModule)   
set(lv2, dummyCallback, dummyCallback, activateModule)   
 
Buffer b1 = create(); b1 = "This is Index 1"
Buffer b2 = create(); b2 = "This is Index 2"
insert(lv1, 0,  "Line 1", b1, iconNone)
insert(lv1, 1,  "Line 2", b2, iconNone)

insert(lv2, 0,  "Line 1", b1, iconNone)
insert(lv2, 1,  "Line 2", b2, iconNone)  

show testDialog

and it does display both selections done to both listviews when you press Show selections.

Pekka, thank you for your very helpful response. You're right, both selections remain intact although the earlier selection(s) fade upon making yet another selection in a different listView. I was doing DXL development on a virtual machine where the connection speed reduced the number of colors displayed to the user. As a result, I couldn't see the light grey selection color indicating that the selection was indeed being maintained upon making another selection in a different listView. 

 

Best regards!