!**************************************************************************************************!
! Purpose: test the GCONTROL FILE with sticky filter and aux list
!
! Arguments: None
!
! @bug      NXM-1936 GCONTROL (GFILES): filter, aux list, and options should be sticky
! @since    NeXtMidas 2.7.3
! @author:  J. Bauer
!**************************************************************************************************!
startmacro

switch INTERACTIVE interAct GET DEF=TRUE

! save off AUX.DAT and switch to DAT with all the test files
call setDatDir
res origDatAux "^{aux.dat}"
invoke nm_root nxm.sys.lib.Shell.getNmRoot()
if nm_root EQS "classpath:" then
  res aux.dat "^{nm_root}/^{datDirSlash}/"
else
  res aux.dat "^{nm_root}^{datDirSlash}/"
endif

if interAct then

  pipe init

    panel/msgid=MAIN/setup/controls=gc

    gcontrol label macro "MACRO" alwaysOpen
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemcolors {PASS=GREEN,FAIL=RED}

    gcontrol label test "TESTS" open
      ! DAT only, NOPATH
      set flags "EXT"
      gcontrol/title TEXT instructions1 "INSTRUCTIONS" "" 24 10
        gcontrol FILE FILE_DAT_NOPATH "File Chooser: DAT only, ^flags" &
             world.prm "*.tmp|prm" "DAT" 60 10 /FLAGS="^flags"
        set instruct "Files in DAT aux should be listed and world.prm should be shown as the current file.\n\n&
                      1) Click on world.prm and change the default aux list and file extension filter.\n&
                      2) Click on 'Submit' in the file chooser dialog and then click on world.prm again.\n&
                      The changes you just made should appear in the dialog.\n\n&
                      ** Help for newer team members ***\n&
                      Example alternate file filer: *.tmp|prm|txt|jpg\n&
                      Make sure after filling in field to hit ENTER"
        set gc.instructions1.value "^instruct"

      

  pipe off
endif

res aux.dat "^origDatAux"  ! restore original AUX.DAT

endmacro

!**************************************************************************************************!
procedure processMessage m:msg

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

  else
    ! do nothing
    !say "^reg.main.name: unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif

return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
