line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl -w
|
2
|
|
|
|
|
|
|
#
|
3
|
|
|
|
|
|
|
# Tk Transaction Manager.
|
4
|
|
|
|
|
|
|
# Application window.
|
5
|
|
|
|
|
|
|
#
|
6
|
|
|
|
|
|
|
# makarow, demed
|
7
|
|
|
|
|
|
|
#
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1312
|
use Tk::TM::Lib;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Tk::TM::wApp;
|
12
|
|
|
|
|
|
|
require 5.000;
|
13
|
|
|
|
|
|
|
use strict;
|
14
|
|
|
|
|
|
|
use Tk::Tree;
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
|
17
|
|
|
|
|
|
|
$VERSION = '0.53';
|
18
|
|
|
|
|
|
|
@ISA = ('Tk::MainWindow');
|
19
|
|
|
|
|
|
|
@EXPORT_OK = qw(DBILogin);
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $PathLast ='0';
|
22
|
|
|
|
|
|
|
my $PathOpen =undef;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1;
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#######################
|
28
|
|
|
|
|
|
|
sub new {
|
29
|
|
|
|
|
|
|
my $class=shift;
|
30
|
|
|
|
|
|
|
my $self =new Tk::MainWindow(@_);
|
31
|
|
|
|
|
|
|
bless $self,$class;
|
32
|
|
|
|
|
|
|
$self->initialize(@_);
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#######################
|
38
|
|
|
|
|
|
|
sub initialize {
|
39
|
|
|
|
|
|
|
my $self = shift;
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $tmp =$self->Menubutton();
|
42
|
|
|
|
|
|
|
my $fnt =$tmp->cget(-font);
|
43
|
|
|
|
|
|
|
$tmp->destroy;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->{-wgmnu} =$self->tmMenu()->pack(-fill=>'x');
|
46
|
|
|
|
|
|
|
$self->{-wgmnu}->set(-dos=>[]);
|
47
|
|
|
|
|
|
|
my $area =$self->Frame()->pack(-expand=>'yes',-fill=>'both');
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$self->{-wgnav} =$area->Scrolled('Tree',-scrollbars=>'se',-font=>$fnt
|
50
|
|
|
|
|
|
|
,-itemtype=>'text'
|
51
|
|
|
|
|
|
|
,-command=>sub{$self->ScrOpen(@_)}
|
52
|
|
|
|
|
|
|
# ,-cursor=>'hand2'
|
53
|
|
|
|
|
|
|
)->pack(-fill=>'y',-side=>'left');
|
54
|
|
|
|
|
|
|
$self->{-wgscr} =$area->Frame(-borderwidth=>2,-relief=>'groove')->pack(-expand=>'yes',-fill=>'both');
|
55
|
|
|
|
|
|
|
$self->{-wgmnu}->set(-wgind=>$self->Label(-anchor=>'w',-relief=>'sunken')->pack(-expand=>'yes',-fill=>'x'));
|
56
|
|
|
|
|
|
|
$self->{-title} =$self->cget(-title);
|
57
|
|
|
|
|
|
|
$self->{-mdnav} ='treee';
|
58
|
|
|
|
|
|
|
$self->{-parm} ={}; $self->{-wgmnu}->set(-parm => $self->{-parm});
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->ConfigSpecs(-font=>['DESCENDANTS']);
|
61
|
|
|
|
|
|
|
$self->ConfigSpecs(-relief=>['CHILDREN']);
|
62
|
|
|
|
|
|
|
$self->ConfigSpecs(-background=>['CHILDREN']);
|
63
|
|
|
|
|
|
|
$self->ConfigSpecs(-foreground=>['CHILDREN']);
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->bind('' ,sub{map {$_->focusForce() if /tree/i} $self->{-wgnav}->children()});
|
66
|
|
|
|
|
|
|
$self->bind('',sub{map {$_->focusForce() if /tree/i} $self->{-wgnav}->children()});
|
67
|
|
|
|
|
|
|
$self->{-wgnav}->bind('' ,sub{$self->{-wgnav}->focusNext()});
|
68
|
|
|
|
|
|
|
$self->{-wgnav}->bind('',sub{$self->{-wgnav}->focusPrev()});
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$self->bind('',sub{$self->destroybind() if $_[0] && $_[0] eq $self});
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$self;
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#######################
|
76
|
|
|
|
|
|
|
sub destroybind {
|
77
|
|
|
|
|
|
|
my $self =$_[0];
|
78
|
|
|
|
|
|
|
print "destroybind(",join(', ',map {defined($_) ? $_ : 'null'} @_),")\n" if $Tk::TM::Common::Debug;
|
79
|
|
|
|
|
|
|
my $pth0 =$PathOpen; return if !$pth0;
|
80
|
|
|
|
|
|
|
my $dta0 =(defined($pth0) ? $self->{-wgnav}->info('data',$pth0) : undef);
|
81
|
|
|
|
|
|
|
ref($dta0->{-cbcmd}) && $self->Try($dta0->{-cbcmd},$dta0,'stop','',undef);
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#######################
|
85
|
|
|
|
|
|
|
sub set {
|
86
|
|
|
|
|
|
|
return(keys(%{$_[0]})) if scalar(@_) ==1;
|
87
|
|
|
|
|
|
|
return($_[0]->{$_[1]}) if scalar(@_) ==2;
|
88
|
|
|
|
|
|
|
my ($self, %opt) =@_;
|
89
|
|
|
|
|
|
|
foreach my $k (keys(%opt)) {
|
90
|
|
|
|
|
|
|
$self->{$k} =$opt{$k};
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
$self;
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#######################
|
97
|
|
|
|
|
|
|
sub setscr {
|
98
|
|
|
|
|
|
|
my ($self, $op, $lbl, $sub, $parm, $opt) =@_;
|
99
|
|
|
|
|
|
|
if (!defined($op) ||$op eq '') {
|
100
|
|
|
|
|
|
|
$PathLast =$PathLast =~/^(.*)\.([^\.]+)$/ ? "$1." .($2 +1) : $PathLast +1
|
101
|
|
|
|
|
|
|
}
|
102
|
|
|
|
|
|
|
elsif ($op eq '+') {
|
103
|
|
|
|
|
|
|
eval {$self->{-wgnav}->setmode($PathLast,'open'); $self->{-wgnav}->open($PathLast)};
|
104
|
|
|
|
|
|
|
$PathLast =$PathLast .'.0'
|
105
|
|
|
|
|
|
|
}
|
106
|
|
|
|
|
|
|
elsif ($op =~/^\d/) {
|
107
|
|
|
|
|
|
|
my @a =split(/\./, $PathLast);
|
108
|
|
|
|
|
|
|
eval {$self->{-wgnav}->setmode($PathLast,'open'); $self->{-wgnav}->open($PathLast)}
|
109
|
|
|
|
|
|
|
if $#a <$op;
|
110
|
|
|
|
|
|
|
$a[$op] +=1;
|
111
|
|
|
|
|
|
|
$PathLast =join('.',@a[0..$op])
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
if ($lbl =~/^Login$/ && !ref($sub)) {
|
114
|
|
|
|
|
|
|
$lbl =Tk::TM::Lang::txtMsg($lbl);
|
115
|
|
|
|
|
|
|
$sub =\&DBILogin;
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
$opt ={} if !defined($opt);
|
118
|
|
|
|
|
|
|
$opt->{-cbcmd} =$sub;
|
119
|
|
|
|
|
|
|
$opt->{-cbnme} =$sub;
|
120
|
|
|
|
|
|
|
$opt->{-label} =$lbl;
|
121
|
|
|
|
|
|
|
$opt->{-title} ='';
|
122
|
|
|
|
|
|
|
$opt->{-parm} =(ref($parm) ? $parm : {});
|
123
|
|
|
|
|
|
|
$opt->{-parmc} =$self->{-parm}; # common to app parameters
|
124
|
|
|
|
|
|
|
$opt->{-dos} =undef;
|
125
|
|
|
|
|
|
|
$opt->{-do} =undef; # 1-st data object, autoset
|
126
|
|
|
|
|
|
|
# {-reread} =undef; # reread master always if not current
|
127
|
|
|
|
|
|
|
$opt->{-rereadc}=undef; # reread master toggle, autoclear
|
128
|
|
|
|
|
|
|
$opt->{-wgapp} =$self;
|
129
|
|
|
|
|
|
|
$opt->{-wgmnu} =$self->{-wgmnu};
|
130
|
|
|
|
|
|
|
$opt->{-wgscr} =$self->{-wgscr};
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$self->{-wgnav}->add($PathLast,-text=>$lbl,-data=>$opt);
|
133
|
|
|
|
|
|
|
}
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#######################
|
136
|
|
|
|
|
|
|
sub Try {
|
137
|
|
|
|
|
|
|
my ($self,$sub) =(shift,shift);
|
138
|
|
|
|
|
|
|
my $ret =ref($sub) eq 'CODE' ? eval {&{$sub}(@_)} : $sub;
|
139
|
|
|
|
|
|
|
print "Try(",join(',',map {defined($_) ? $_ : 'null'} @_),")->",defined($ret) ? $ret : 'null',"\n" if $Tk::TM::Common::Debug;
|
140
|
|
|
|
|
|
|
$self->messageBox(-icon=>'error',-type=>'Ok',-title=>Tk::TM::Lang::txtMsg('Error')
|
141
|
|
|
|
|
|
|
,-message=> $@) if $@;
|
142
|
|
|
|
|
|
|
$ret
|
143
|
|
|
|
|
|
|
}
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#######################
|
146
|
|
|
|
|
|
|
sub ScrOpen {
|
147
|
|
|
|
|
|
|
print "ScrOpen(",join(', ',map {defined($_) ? $_ : 'null'} @_),")\n" if $Tk::TM::Common::Debug;
|
148
|
|
|
|
|
|
|
my ($self, $pth1) =@_;
|
149
|
|
|
|
|
|
|
my $dta1 =$self->{-wgnav}->info('data',$pth1);
|
150
|
|
|
|
|
|
|
my $pthM =($pth1 =~/^(.*)\.([^\.]+)$/ ? $1 : undef);
|
151
|
|
|
|
|
|
|
my $dtaM =(defined($pthM) ? $self->{-wgnav}->info('data',$pthM) : undef);
|
152
|
|
|
|
|
|
|
my $pth0 =$PathOpen;
|
153
|
|
|
|
|
|
|
my $dta0 =(defined($pth0) ? $self->{-wgnav}->info('data',$pth0) : undef);
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
if (!defined($dta1->{-cbnme})) {return($pth0)} # grouping only
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
if (defined($pth0) && $pth0 eq $pth1 ) {return($pth0)} # the same screen
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
if (defined($pthM) && !defined($dtaM->{-cbnme})) {$pthM =$dtaM =undef}
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
if ($self->{-mdnav} =~/tree/i && defined($pthM) && defined($dtaM->{-cbnme})
|
162
|
|
|
|
|
|
|
&& !ref($dtaM->{-dos})) {return($pth0)}
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
if ($self->{-mdnav} =~/treee/i && defined($pthM) && defined($dtaM->{-cbnme})
|
165
|
|
|
|
|
|
|
&& substr($pth0 ||'',0,length($pthM)) ne $pthM) {return($pth0)}
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
if (defined($pth0)) {
|
168
|
|
|
|
|
|
|
$dta0->{-do} =ref($dta0->{-dos}) ? $dta0->{-dos}->[0] : undef;
|
169
|
|
|
|
|
|
|
$self->{-wgmnu}->Stop('#save#force');
|
170
|
|
|
|
|
|
|
my $rstp =ref($dta0->{-cbcmd}) ? $self->Try($dta0->{-cbcmd},$dta0,'stop','',$dta1) : 1;
|
171
|
|
|
|
|
|
|
if (!$rstp && $self->{-mdnav} =~/tree/i
|
172
|
|
|
|
|
|
|
&& defined($pthM) && defined($pth0) && $pth0 eq $pthM) {
|
173
|
|
|
|
|
|
|
return($pth0)
|
174
|
|
|
|
|
|
|
}
|
175
|
|
|
|
|
|
|
$self->{-wgmnu}->doAll(sub{shift->Sleep('#wgs#dta')});
|
176
|
|
|
|
|
|
|
}
|
177
|
|
|
|
|
|
|
foreach my $w ($self->{-wgscr}->children) {$w->destroy}
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
if ($self->{-mdnav} =~/tree/i
|
180
|
|
|
|
|
|
|
&& defined($pthM) && defined($pth0) && $pth0 ne $pthM) {
|
181
|
|
|
|
|
|
|
if ($dtaM->{-reread} || $dtaM->{-rereadc}) { # reread master
|
182
|
|
|
|
|
|
|
$dtaM->{-rereadc} =undef;
|
183
|
|
|
|
|
|
|
$self->{-wgmnu}->set(-dos=>($dtaM->{-dos} ? $dtaM->{-dos} : []));
|
184
|
|
|
|
|
|
|
$self->{-wgmnu}->Reread();
|
185
|
|
|
|
|
|
|
$self->{-wgmnu}->doAll(sub{shift->Sleep('#dta')})
|
186
|
|
|
|
|
|
|
}
|
187
|
|
|
|
|
|
|
$dta0 =$dtaM;
|
188
|
|
|
|
|
|
|
}
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
$self->{-wgmnu}->set(-dos=>(ref($dta1->{-dos}) ? $dta1->{-dos} : []));
|
191
|
|
|
|
|
|
|
$self->configure(-title=>(($dta1->{-title} ne '' ? $dta1->{-title} .' - ' : '') .$dta1->{-label} .' - ' .$self->{-title}));
|
192
|
|
|
|
|
|
|
if (!ref($dta1->{-cbcmd})) {
|
193
|
|
|
|
|
|
|
foreach my $d (($0 =~/^(.+)[\\\/][^\\\/]+$/ ? "$1" : "."), @INC) {
|
194
|
|
|
|
|
|
|
next if !-f "$d/" .$dta1->{-cbnme};
|
195
|
|
|
|
|
|
|
$self->Try(sub{$dta1->{-cbcmd} =do("$d/" .$dta1->{-cbnme}) });
|
196
|
|
|
|
|
|
|
last;
|
197
|
|
|
|
|
|
|
}
|
198
|
|
|
|
|
|
|
}
|
199
|
|
|
|
|
|
|
if (ref($dta1->{-cbcmd})) {
|
200
|
|
|
|
|
|
|
$self->Try($dta1->{-cbcmd},$dta1,'start','',$dta0);
|
201
|
|
|
|
|
|
|
$dta1->{-do} =ref($dta1->{-dos}) ? $dta1->{-dos}->[0] : undef;
|
202
|
|
|
|
|
|
|
# print join(',',$self->{-wgscr}->children()),"\n";
|
203
|
|
|
|
|
|
|
}
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
$self->{-wgmnu}->set(-dos=>(ref($dta1->{-dos}) ? $dta1->{-dos} : []));
|
206
|
|
|
|
|
|
|
$self->configure(-title=>(($dta1->{-title} ne '' ? $dta1->{-title} .' - ' : '') .$dta1->{-label} .' - ' .$self->{-title}));
|
207
|
|
|
|
|
|
|
$PathOpen =$pth1
|
208
|
|
|
|
|
|
|
}
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#######################
|
212
|
|
|
|
|
|
|
sub Start {
|
213
|
|
|
|
|
|
|
my $self =shift;
|
214
|
|
|
|
|
|
|
my @chld =$self->{-wgnav}->info('children');
|
215
|
|
|
|
|
|
|
$PathOpen =$chld[0];
|
216
|
|
|
|
|
|
|
my $dta =$self->{-wgnav}->info('data',$PathOpen);
|
217
|
|
|
|
|
|
|
$self->Try($dta->{-cbcmd},$dta,'start','');
|
218
|
|
|
|
|
|
|
$dta->{-do} =ref($dta->{-dos}) ? $dta->{-dos}->[0] : undef;
|
219
|
|
|
|
|
|
|
$self->{-wgmnu}->set(-dos=>(ref($dta->{-dos}) ? $dta->{-dos} : []));
|
220
|
|
|
|
|
|
|
$self->configure(-title=>(($dta->{-title} ne '' ? $dta->{-title} .' - ' : '') .$dta->{-label} .' - ' .$self->{-title}));
|
221
|
|
|
|
|
|
|
}
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
#######################
|
225
|
|
|
|
|
|
|
sub DBILogin {
|
226
|
|
|
|
|
|
|
print "DBILogin(",join(', ',map {defined($_) ? $_ : 'null'} @_),")\n" if $Tk::TM::Common::Debug;
|
227
|
|
|
|
|
|
|
my ($self, $cmd) =@_;
|
228
|
|
|
|
|
|
|
return(1) if $cmd !~/start/;
|
229
|
|
|
|
|
|
|
Tk::TM::Common::DBILogin([$self->{-wgscr}, $self->{-wgmnu}->set(-wgind)]
|
230
|
|
|
|
|
|
|
,$self->{-parm}->{-dsn}
|
231
|
|
|
|
|
|
|
,$self->{-parm}->{-usr}
|
232
|
|
|
|
|
|
|
,$self->{-parm}->{-psw}
|
233
|
|
|
|
|
|
|
,ref($self->{-parm}) ? '#' .join('#',keys(%{$self->{-parm}})): $self->{-parm}
|
234
|
|
|
|
|
|
|
,$self->{-parm}->{-dbopt}
|
235
|
|
|
|
|
|
|
);
|
236
|
|
|
|
|
|
|
$self->{-dos} =[];
|
237
|
|
|
|
|
|
|
} |