!------------------------------------------------------------------------------!
! Tests for case where List2 does not show a row update
!
!   @Author : J Hallam / J. Bauer
!   @Version: $Id: test_list2_updaterow.mm,v 1.4 2015/12/22 16:48:20 ntn Exp $
!   @Bug 2311: LIST2: updateRow not refreshing display
!------------------------------------------------------------------------------!
!
startmacro

  res t:rows {1={DUMMY_COL1="One"},2={DUMMY_COL1="Two"},3={DUMMY_COL1="Three"}}

  res t:templ {}   ! The template
  res templ._GLOBAL_ {AUTOHIDE="FALSE",AUTOORDER="TRUE"}
  res templ.DUMMY_COL1 {WIDTH=12,ALIGN="CENTER",TYPE="STRING",LABEL="DATA"}

  pipe on

    panel/controls=gc/setup
    gcontrol label  macro   "MACRO"
      gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
      set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      res instructions "You should see a List2 with three one-column rows. &
                        Press the UPDATE button below. The rows should look &
                        the same. &
                        Press the REFRESH ROW 1 button and the 1st row should &
                        change to '1ST'. &
                        Press the REFRESH ALL ROWS button and the 2nd and 3rd &
                        rows should change to '2ND' and '3RD'. "
      gcontrol text idtext "Instructions" "^instructions" 24 12 /title

    gcontrol button update "" "UPDATE ALL ROWS"
    gcontrol button refreshRow1 "" "REFRESH ROW 1"
    gcontrol button refreshAllRows "" "REFRESH ALL ROWS"

    gcontrol line line1
    gcontrol button resetData "" "RESET DATA"

    INFO "!!!!! It is ok to see a message below for 'LIST2: No input file found, creating a Type 3000 RamFile... !!!!!"

    list2/id=mylist/msgid=main template=templ

    call loadData


  pipe off

endmacro

procedure processMessage m:msg

  if msg.name EQS "MAIN" then
    assert/text="^reg.main.name: user indicated" msg.data eqs "PASS"
    pipe stop

  elseif msg.name EQS "UPDATE" then
    res update1 reg.mylist.row(1)               ! Gets a reference
    sedit "1st" update1.DUMMY_COL1 "UPCASE"     ! Updates underlying List2 data
    invoke ,, reg.mylist.updateRow(1,^update1)  ! Does not show change because underlying data already updated

    res update2 reg.mylist.row(2)               ! Gets a reference
    sedit "2nd" update2.DUMMY_COL1 "UPCASE"     ! Updates underlying List2 data
    invoke ,, reg.mylist.updateRow(2,^update2)  ! Does not show change because underlying data already updated

    res update3 reg.mylist.row(3)               ! Gets a reference
    sedit "3rd" update3.DUMMY_COL1 "UPCASE"     ! Updates underlying List2 data
    invoke ,, reg.mylist.updateRow(3,^update3)  ! Does not show change because underlying data already updated

  elseif msg.name eqs "REFRESHROW1" then
    invoke reg.mylist.redraw(1)                 ! test the redraw in ListInterface and MJList

  elseif msg.name eqs "REFRESHALLROWS" then
    message send id=mylist ,, "REFRESH"         ! test the message version of refresh

  elseif msg.name eqs "RESETDATA" then
    call loadData

  endif

return

! load the data into the List2
procedure loadData
  invoke reg.mylist.removeAllRows()
  do ii 1 3
    set reg.mylist.addRow ^rows.^{ii}
  enddo
return

