!----------------------------
begin OInterface
 prefix = G4Cmds_
end
!----------------------------
begin OWidget
 name = G4Cmds_palette
 type = XmFormDialog
 children = G4Cmds_get_list G4Cmds_path G4Cmds_up G4Cmds_frame_dirs G4Cmds_frame_hists G4Cmds_label G4Cmds_edit G4Cmds_dump G4Cmds_cancel G4Cmds_update
 autoUnmanage = False
 dialogTitle = G4 command chooser
 mapCallback = osh> callWidgetCallbacks G4Cmds_get_list activateCallback
end
!----------------------------
begin OWidget
 name = G4Cmds_get_list
 type = XmPushButton
 labelString = Update list
 leftAttachment = attach_form
 rightAttachment = attach_form
 topAttachment = attach_form
 activateCallback = osh>\
  list=`do G4 askListOfCommands | cutStringBegin - 1`\
  setWidgetResource G4Cmds_update value $list\
  setWidgetResource G4Cmds_path   value ''\
  callWidgetCallbacks G4Cmds_update activateCallback
end
!----------------------------
begin OWidget
 name = G4Cmds_path
 type = XmText
 leftAttachment = attach_form
 rightAttachment = attach_form
 topAttachment = attach_form
 topAttachment = attach_widget
 topWidget = G4Cmds_get_list
end
!----------------------------
begin OWidget
 name = G4Cmds_update
 type = XmText
 editMode = multi_line_edit
 activateCallback = osh>\
  setWidgetResource G4Cmds_dirs  selectedItems ''\
  setWidgetResource G4Cmds_objs  selectedItems ''\
  path=`getWidgetResource G4Cmds_path value`\
  test $path ne '' && path=`printf '%s/' $path`\
  lpath=`getStringLength $path`\
  pattern=`printf '%s*' $path`\
  list=`getWidgetResource G4Cmds_update value | matchString - $pattern | cutStringBegin - $lpath`\
  pattern=`printf '*/*' `\
  dirs=`matchString $list $pattern    | getStringWord - 1 '/' | removeDuplicates - | sort - `\
  objs=`matchString $list $pattern no | removeDuplicates -  | sort -`\
  test $dirs eq '' && setWidgetResource G4Cmds_dirs  items ''\
  test $dirs ne '' && setWidgetResource G4Cmds_dirs  items $dirs\
  test $objs eq '' && setWidgetResource G4Cmds_objs  items ''\
  test $objs ne '' && setWidgetResource G4Cmds_objs  items $objs
end
!----------------------------
begin OWidget
 name = G4Cmds_up
 type = XmPushButton
 labelString = Up directory
 topAttachment = attach_widget
 topWidget = G4Cmds_path
 leftAttachment = attach_form
 rightAttachment = attach_form
 activateCallback = osh>\
  path=`getWidgetResource G4Cmds_path value`\
  path=`removeLastStringWord $path '/'`\
  setWidgetResource G4Cmds_path value $path\
  callWidgetCallbacks G4Cmds_update activateCallback
end
!----------------------------
begin OWidget
 name = G4Cmds_frame_dirs
 type = XmFrame
 children = G4Cmds_dirs
 topAttachment = attach_widget
 topWidget = G4Cmds_up
 leftAttachment = attach_form
 rightAttachment = attach_position
 rightPosition = 50
 bottomAttachment = attach_widget
 bottomWidget = G4Cmds_label
end
!----------------------------
begin OWidget
 name = G4Cmds_dirs
 type = XmScrolledList
 background = lightgrey
 visibleItemCount = 10
 selectionPolicy = single_select
 scrollBarDisplayPolicy = static
 listSizePolicy = constant
 singleSelectionCallback = osh>\
  string=`getWidgetResource G4Cmds_dirs selectedItems`\
  test $string eq '' && exit \
  path=`getWidgetResource G4Cmds_path value`\
  #path=`removeLastStringWord $path '/'`\
  #setWidgetResource G4Cmds_path value $path\
  test $path ne '' && appendText G4Cmds_path '/'\
  appendText G4Cmds_path $string\
  callWidgetCallbacks G4Cmds_update activateCallback
end
!----------------------------
begin OWidget
 name = G4Cmds_frame_hists
 type = XmFrame
 children = G4Cmds_objs 
 topAttachment = attach_widget
 topWidget = G4Cmds_up
 leftAttachment = attach_widget
 leftWidget = G4Cmds_frame_dirs
 rightAttachment = attach_form
 bottomAttachment = attach_widget
 bottomWidget = G4Cmds_label
end
!----------------------------
begin OWidget
 name = G4Cmds_objs
 type = XmScrolledList
 background = lightgrey
 visibleItemCount = 10
 selectionPolicy = single_select
 listSizePolicy = constant
 scrollBarDisplayPolicy = static
end
!----------------------------
begin OWidget
 name = G4Cmds_label
 type = XmLabel
 labelString = Operations
 leftAttachment = attach_form
 rightAttachment = attach_form
 bottomAttachment = attach_widget
 bottomWidget = G4Cmds_edit
 background = black
 foreground = white
end
!----------------------------
begin OWidget
 name = G4Cmds_edit
 type = XmPushButton
 labelString = Edit
 leftAttachment = attach_form
 rightAttachment = attach_form
 bottomAttachment = attach_widget
 bottomWidget = G4Cmds_dump
 activateCallback = &osh>\
  path=`getWidgetResource G4Cmds_path value`\
  obj=`getWidgetResource G4Cmds_objs selectedItems`\
  string=`printf '/%s/%s' $path $obj`\
  name='G4Params.odb'\
  do G4 createCommandPanel $string $name\
  odb=`collect OInterface where dataBaseName eq $name`\
  isValid $odb && destroy $odb\
  load $name | realize - ;manageWidget G4Params_palette;raiseWidget G4Params_palette_popup
end
!----------------------------
begin OWidget
 name = G4Cmds_dump
 type = XmPushButton
 labelString = Guidance
 leftAttachment = attach_form
 rightAttachment = attach_form
 bottomAttachment = attach_widget
 bottomWidget = G4Cmds_cancel
 activateCallback = &osh>\
  path=`getWidgetResource G4Cmds_path value`\
  obj=`getWidgetResource G4Cmds_objs selectedItems`\
  string=`printf '/%s/%s' $path $obj`\
  echo `do G4 getCommandGuidance $string`
end
!----------------------------
begin OWidget
 name = G4Cmds_cancel
 type = XmPushButton
 labelString = Cancel
 activateCallback = osh> unmanageWidget `thisWidgetParent`
 bottomAttachment = attach_form
 leftAttachment = attach_form
 rightAttachment = attach_form
end


