NB. built from project: ~Source\main\dirs\dirs

script_z_ '~system\classes\grid\jsgrid.ijs'

coclass 'jdirs'


last=: 1 : 'x. " 1'
tolist=: }.@;@:((10{a.)&,@,@":&.>)
3 : 0''
p=. SMPRINT_j_
if. #p do.
  p=. (5{.p),'file',5}.p
end.
DIRPRINT=: p
)
dfmt=: 3 : 0
f=. ([: _2&{. [: '0'&, ":) &>
mth=. _3[\'   JanFebMarAprMayJunJulAugSepOctNovDec'
v=. ,. |: <. y.
y=. ":,.{.v
m=. (1{v) { mth
m=. (1{v) { '-',.mth,.'-'
'd h n s'=. f 2 }.v
d,.m,.y,.' ',.h,.':',.n,.':',.s
)
dirprint=: 3 : 0
if. 0 e. #y. do. return. end.
if. 0 e. #DIRPRINT do.
  wdinfo 'Print';'No session printer defined' return.
end.
try. '' DIRPRINT~ y.
catch. wdinfo 'Print';'Print failed.',LF,LF,'Check the printer is installed'
end.
)


create=: jdirf_run

coltypes=: 15 15 25
coltitle=: 'File';'Date';'Size'
colwidth=: 100 100 55
colstretch=: 3 1 1
filltype=: 4
sortenable=: 1
BINF=: 0 : 0
pc jdirf;pn "dirs";
xywh 8 6 169 10;cc s0 static;cn "filename";
xywh 8 17 150 100;cc grid isigraph ws_border ws_clipchildren rightmove bottommove;
xywh 158 17 9 100;cc scrollbarv scrollbarv leftmove rightmove bottommove;
xywh 179 11 40 12;cc open button bs_defpushbutton leftmove rightmove;cn "&Open";
xywh 179 25 40 12;cc view button leftmove rightmove;cn "&View";
xywh 179 39 40 12;cc run button leftmove rightmove;cn "&Run";
xywh 179 53 40 12;cc print button leftmove rightmove;cn "&Print";
xywh 179 85 40 12;cc delete button leftmove topmove rightmove bottommove;cn "Delete";
xywh 179 105 40 12;cc cancel button leftmove topmove rightmove bottommove;cn "Cancel";
pas 4 4;pcenter;
rem form end;
)
jdirf_run=: 3 : 0
y=. y.,(':'=_1{.y.)#PATHSEP_j_

if. 0=#dr=. 1 dir y do.
  wdinfo 'dirs';'no files in directory: ',y
  return.
end.

PATH=: (#~ +./\.@(PATHSEP_j_&=)) 0 pick dr

dataraw=: 3 {. last 2 dir y
nms=. {. last dataraw
dates=. < last [ _3}. last dfmt > 1{ last dataraw
sizes=. 'c' ffmt_jzgrid_ > 2{ last dataraw
data=: nms,.dates,.sizes

font1=: font0=: PROFONT

wd BINF

if. IFWINCE do.
  wd 'setshow print 0'
end.

wdfit ''
wd 'set s0 *',PATH
grid=: '' conew 'jsgrid'
init__grid''
wd 'setfocus grid'
wd 'pshow;'
)
destroy=: 3 : 0
wd 'pclose'
destroy__grid''
codestroy''
)
jdirf_gethilite=: 3 : 0
0 pick hilite__grid { dataraw__grid
)
jdirf_open_button=: 3 : 0
f=. PATH, jdirf_gethilite''
open_j_ f,('.'e.f)}.'.'
wd 'psel jdirf'
)
jdirf_print_button=: 3 : 0
dirprint PATH,jdirf_gethilite''
)
jdirf_view_button=: 3 : 0
file=. jdirf_gethilite''
file wdview 1!:1 <PATH,file
)
jdirf_run_button=: 3 : 0
load_base_ PATH,jdirf_gethilite''
)
jdirf_delete_button=: 3 : 0
file=. jdirf_gethilite''
if. 0 = 2 1 wdquery 'dirs';'OK to delete file:',LF,LF,PATH,file do.
  1!:55 <PATH,file
  msk=. hilite__grid ~: i.#data__grid
  if. 1 e. msk do.
    maskdata__grid msk
  else.
    jdirf_close''
  end.
end.
)
jdirf_cancel_button=: jdirf_cancel=: jdirf_close=: destroy
select_result=: jdirf_open_button
formselect=: 3 : 'wd''psel '',formhwnd'
jdirf_grid_size=: 3 : 'size__grid 0'
jdirf_grid_mbldown=: 3 : 'mbldown__grid sysdata'
jdirf_grid_mblup=: 3 : 'mblup__grid sysdata'
jdirf_grid_mbldbl=: 3 : 'mbldbl__grid sysdata'
jdirf_grid_mmove=: 3 : 'mmove__grid sysdata'
jdirf_grid_char=: 3 : 'char__grid sysdata;sysmodifiers'
jdirf_scrollbarv_button=: 3 : 0
scrollbarv__grid scrollbarv
wd'setfocus grid'
)