! Tests the PANEL /JSETUP switch to use a Swing Frame (form), e.g.
! one that is created by a GUI builder.
!
! @bug      1227 - PANEL: AWT Window is shown with /JSETUP switch
! @author:  Neon Ngo
!
startmacro
  switch INTERACTIVE  interAct     GET DEF=TRUE
  switch COREGRAPHICS coreGraphics GET DEF=FALSE SDEF=TRUE ! for a quick check of graphics - more extreme tests - since 3.8.1

  ! Start Interactive test section
  if interAct or coreGraphics then
    invoke z:jvmHangFix nxm.sys.lib.Shell.getJVMHangWorkaround()
    res z:mytrue true
    invoke ,, nxm.sys.lib.Shell.setJVMHangWorkaround(^mytrue)

    pipe on
      panel/msgid=MAIN/setup/controls=gc

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

      set instructions "Should see two separate sd360 macros in their own Swing Frames &
                        by using the /JSETUP switch. One of them uses the existing &
                        GControls (AWT) from the macro (it has more control options). &
                        The other uses a few Swing Controls.\n\n&
                        1) Test the 'PAUSE' then 'RUN' buttons in each.\n\n&
                        The bottom plot in one of the panels uses a PushPopPanel.\n\n&
                        2) Click on the 'V' and pop the plot to a separate display\n\n&
                        3) Resize the plot\n\n&
                        4) Click on the 'V' and push the plot back in\n\n&
                        5) Click on the 'V' to Pop it back to that display.\n\n&
                        The size and position should be saved from where you had it.\n\n&
                        You should see a legend in the bottom right corner of the plots in the bottom frame."
      gcontrol text idtext  "Instructions" "^instructions" 24 35 /title

      sd360/id=sd360a/bg/jsetup=nxm.sys.test.test_panel_jsetup_wb inf ! changed to use _wb file in 3.1.2 so we test Eclipse GUIs
      sd360/id=sd360b/legend={CORNER=BR}/bg/jsetup=nxm.sys.test.test_panel_jsetup_no_pane0/HIDEWIDGET inf
      sd360/id=sd360c/legend={CORNER=BR}/bg/jsetup=nxm.sys.test.test_panel_jsetup_no_pane0 inf

      ! Check for proper function of HIDEWIDGET switch

      !Check by seeing if "OVER" is listed as a key
      res overTestPass false
      if (( ^{reg.sd360a.registry.panel.controls} CONTAINS "OVER" ) AND &
         ( ^{reg.sd360c.registry.panel.controls} CONTAINS "OVER" ) AND &
         ( ^{reg.sd360b.registry.panel.controls} NCONTAINS "OVER" )) then res overTestPass true

      ! Close extra panel that was just used for testing the HIDEWIDGET switch
      if reg.sd360c REXISTS then message FUNC=send ID=sd360c NAME=exit INFO=0

      assert/text="^reg.main.name: Java Registry Contains Proper Controls" overTestPass

      ! move the sd360 macro using the /JSETUP without pane0 to different position
      ! invoke graphicsContainer reg.sd360b.getGraphicsContainer()
      ! invoke ,, graphicsContainer.setBounds(280,320,500,300)
    pipe off
    invoke ,, nxm.sys.lib.Shell.setJVMHangWorkaround(^jvmHangFix)
  endif
endmacro

!******************************************************************************!
! process messages for interactive tests
!******************************************************************************!
procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User Indicated Tests" msg.data eqss "PASS"
    if reg.sd360a REXISTS then message FUNC=send ID=sd360a NAME=exit INFO=0
    if reg.sd360b REXISTS then message FUNC=send ID=sd360b NAME=exit INFO=0
    pipe stop
  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
