NB. built from project: ~Source\classes\filetype\filetype
NB. provides jfiletype form
NB.
NB. methods:
NB.   create
NB.   destroy
NB.
NB. on exit calls jfiletype_result in creator locale
NB.
NB. y. is a boxed list:
NB.   0  filetype
NB.   1  filefilters

coclass 'jfiletype'


j=. FIXFONT
SELECTFONT=: j,(0 e. #j)#'"Courier New" 10'

PTOP=: 1
CLOSE=: ''
SORT=: ''
RESULT=: 'filetype_result__COCREATOR'
create=: jfiletype_run
destroy=: codestroy
finfo=: wdinfo @ ('File Types'&;)
fquery=: wdquery ('File Types'&;)
JFILETYPE=: 0 : 0
pc jfiletype closeok dialog;pn "File Types";
xywh 1 6 185 100;cc g0 groupbox rightmove bottommove;cn "";
xywh 10 13 62 11;cc label static;cn "Description";
xywh 72 13 62 11;cc label static;cn "Type Filters";
xywh 4 23 178 62;cc types listbox ws_hscroll ws_vscroll rightmove bottommove;
xywh 10 89 45 12;cc up button topmove bottommove;cn "Move &Up";
xywh 57 89 45 12;cc down button topmove bottommove;cn "Move Do&wn";
xywh 137 89 45 12;cc delete button topmove bottommove;cn "&Delete";
xywh 1 109 185 55;cc g0 groupbox topmove rightmove bottommove;cn "";
xywh 7 120 43 11;cc label static topmove bottommove;cn "Description:";
xywh 51 119 131 11;cc desc edit ws_border es_autohscroll topmove rightmove bottommove;
xywh 7 134 43 11;cc label static topmove bottommove;cn "Type Filters:";
xywh 51 133 131 11;cc filter edit ws_border es_autohscroll topmove rightmove bottommove;
xywh 8 149 45 12;cc addtop button topmove bottommove;cn "Add at &top";
xywh 55 149 45 12;cc addend button topmove bottommove;cn "Add at &end";
xywh 135 149 45 12;cc replace button topmove bottommove;cn "&Replace";
xywh 191 10 45 12;cc ok button leftmove rightmove;cn "OK";
xywh 191 25 45 12;cc cancel button leftmove rightmove;cn "Cancel";
pas 4 4;pcenter;ptop;
rem form end;
)
jfiletype_run=: 3 : 0
'TYPE FILTERS'=: y.
wd JFILETYPE
wd 'settabstops types 60'
XNDX=: ({."1 FILTERS) i. <TYPE
jfiletypeshow''
wd 'pshow;'
)
jfiletypeshow=: 3 : 0
if. #FILTERS do.
  j=. }. , LF ,. '"' ,. (>{."1 FILTERS) ,. TAB ,"1 (>{:"1 FILTERS) ,. '"'
  wd 'set types ', j
  wd 'setselect types ',": XNDX
  jfiletypeshowdetails''
end.
)
jfiletypeshowdetails=: 3 : 0
if. 0 <: XNDX do.
  'j k'=. XNDX { FILTERS
  wd 'set desc *',j
  wd 'set filter *',k
end.
)
jfiletype_up_button=: 3 : 0
if. #ndx=. ". types_select do.
  ind=. ndx, ndx1=. 0 >. ndx-1
  FILTERS=: (|.ind{FILTERS) ind} FILTERS
  XNDX=: ndx1
  jfiletypeshow''
end.
)
jfiletype_down_button=: 3 : 0
if. #ndx=. ". types_select do.
  ind=. ndx, ndx1=. (<:#FILTERS) <. ndx+1
  FILTERS=: (|.ind{FILTERS) ind} FILTERS
  XNDX=: ndx1
  jfiletypeshow''
end.
)
jfiletype_delete_button=: 3 : 0
if. #ndx=. ". types_select do.
  msg=. 'OK to delete: ',>{.ndx{FILTERS
  if. 0=2 fquery msg do.
    FILTERS=: FILTERS #~ -. (i.#FILTERS) e. ndx
    XNDX=: (<:#FILTERS) <. ndx
    jfiletypeshow''
  end.
end.
)
jfiletype_types_select=: 3 : 0
XNDX=: ". types_select
jfiletypeshowdetails''
)
jfiletype_addtop_button=: 3 : 0
if. jfiletype_addcheck'' do.
  FILTERS=: ~. (desc;filter),FILTERS
  XNDX=: 0
  jfiletypeshow''
end.
)
jfiletype_addend_button=: 3 : 0
if. jfiletype_addcheck'' do.
  FILTERS=: ~. FILTERS, desc;filter
  XNDX=: ({."1 FILTERS) i. <desc
  jfiletypeshow''
end.
)
jfiletype_replace_button=: 3 : 0
if. jfiletype_addcheck'' do.
  if. #ndx=. ". types_select do.
    FILTERS=: (desc;filter) ndx} FILTERS
    XNDX=: ndx
    jfiletypeshow''
  end.
end.
)
jfiletype_addcheck=: 3 : 0
r=. 0
if. 0=#desc do.
  finfo 'Enter the description'
elseif. 20<#desc do.
  finfo 'Descriptions may not exceed 20 characters'
elseif. 0=#filter do.
  finfo 'Enter the type filters'
elseif. 1 do. r=. 1
end.
r
)
jfiletypeclose=: 3 : 0
if. #ndx=. ". types_select do.
  TYPE=: 0 pick ndx{FILTERS
end.
wd 'pclose'
try. filetype_result__COCREATOR TYPE;<FILTERS catch. end.
destroy''
)
jfiletype_cancel_button=: 3 : 0
wd 'pclose;'
destroy''
)
jfiletype_ok_button=: jfiletype_close=: jfiletypeclose
jfiletype_cancel=: jfiletype_cancel_button