| 1 | package ZConf::Runner::GUI; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use ZConf::Runner; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use ZConf::GUI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | ZConf::Runner::GUI - Various GUI stuff for ZConf::Runner. | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 1.0.1 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 3 | our $VERSION = '1.0.1'; | |||||||||
| 19 | |||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||
| 21 | |||||||||||
| 22 | This provides the ask dialog used by ZConf::Runner. | ||||||||||
| 23 | |||||||||||
| 24 | use ZConf::Runner::GUI; | ||||||||||
| 25 | |||||||||||
| 26 | my $zcr=ZConf::Runner->new(); | ||||||||||
| 27 | |||||||||||
| 28 | =head1 METHODS | ||||||||||
| 29 | |||||||||||
| 30 | =head2 new | ||||||||||
| 31 | |||||||||||
| 32 | This initializes it. | ||||||||||
| 33 | |||||||||||
| 34 | One arguement is taken and that is a hash value. | ||||||||||
| 35 | |||||||||||
| 36 | =head3 hash values | ||||||||||
| 37 | |||||||||||
| 38 | =head4 zcrunner | ||||||||||
| 39 | |||||||||||
| 40 | This is a ZConf::Runner object to use. If it is not specified, | ||||||||||
| 41 | a new one will be created. | ||||||||||
| 42 | |||||||||||
| 43 | =head4 zcgui | ||||||||||
| 44 | |||||||||||
| 45 | This is the ZConf::GUI object. If it is not passed, a new one will be created. | ||||||||||
| 46 | |||||||||||
| 47 | =cut | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub new{ | ||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 50 | 0 | my %args; | |||||||||
| 51 | 0 | ▶ | if(defined($_[1])){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | %args= %{$_[1]}; | |||||||||
| 53 | } | ||||||||||
| 54 | 0 | my $function='new'; | |||||||||
| 55 | |||||||||||
| 56 | 0 | my $self={error=>undef, errorString=>undef, module=>'ZConf-Runner-GUI'}; | |||||||||
| 57 | 0 | bless $self; | |||||||||
| 58 | |||||||||||
| 59 | #initiates | ||||||||||
| 60 | 0 | ▶ | if (!defined($args{zcrunner})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | $self->{zcr}=ZConf::Runner->new(); | |||||||||
| 62 | }else { | ||||||||||
| 63 | 0 | $self->{zcr}=$args{zcrunner}; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | #handles it if initializing ZConf::Runner failed | ||||||||||
| 67 | 0 | ▶ | if ($self->{zcr}->{error}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | my $errorstring=$self->{zcr}->{errorString}; | |||||||||
| 69 | 0 | $errorstring=~s/\"/\\\"/g; | |||||||||
| 70 | my $error='Initializing ZConf::Runner failed. error="'.$self->{zcr}->{error} | ||||||||||
| 71 | 0 | .'" errorString="'.$self->{zcr}->{errorString}.'"'; | |||||||||
| 72 | 0 | $self->{error}=3; | |||||||||
| 73 | 0 | $self->{errorString}=$error; | |||||||||
| 74 | 0 | warn('ZConf-GUI new:3: '.$error); | |||||||||
| 75 | 0 | return $self; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 0 | $self->{zconf}=$self->{zcr}->{zconf}; | |||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | if (!defined($args{zcgui})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | #initializes the GUI | ||||||||||
| 82 | 0 | $self->{gui}=ZConf::GUI->new({zconf=>$self->{zconf}}); | |||||||||
| 83 | 0 | ▶ | if ($self->{gui}->{error}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 0 | my $errorstring=$self->{gui}->{errorString}; | |||||||||
| 85 | 0 | $errorstring=~s/\"/\\\"/g; | |||||||||
| 86 | my $error='Initializing ZConf::GUI failed. error="'.$self->{gui}->{error} | ||||||||||
| 87 | 0 | .'" errorString="'.$self->{gui}->{errorString}.'"'; | |||||||||
| 88 | 0 | $self->{error}=2; | |||||||||
| 89 | 0 | $self->{errorString}=$error; | |||||||||
| 90 | 0 | warn('ZConf-Runner-GUI new:2: '.$error); | |||||||||
| 91 | 0 | return $self; | |||||||||
| 92 | } | ||||||||||
| 93 | }else { | ||||||||||
| 94 | 0 | $self->{gui}=$args{zcgui}; | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 0 | $self->{useX}=$self->{gui}->useX('ZConf::Runner'); | |||||||||
| 98 | |||||||||||
| 99 | 0 | my @preferred=$self->{gui}->which('ZConf::Runner'); | |||||||||
| 100 | |||||||||||
| 101 | 0 | my $toeval='use ZConf::Runner::GUI::'.$preferred[0].';'."\n". | |||||||||
| 102 | '$self->{be}=ZConf::Runner::GUI::'.$preferred[0]. | ||||||||||
| 103 | '->new({zconf=>$self->{zconf}, useX=>$self->{useX},'. | ||||||||||
| 104 | 'zcgui=>$self->{gui}, zcrunner=>$self->{zcr}}); return 1'; | ||||||||||
| 105 | |||||||||||
| 106 | 0 | my $er=eval($toeval); | |||||||||
| 107 | |||||||||||
| 108 | 0 | return $self; | |||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | =head2 ask | ||||||||||
| 112 | |||||||||||
| 113 | This is creates a dialog window asking what to do. | ||||||||||
| 114 | |||||||||||
| 115 | The first agruement is the action to be performed. The | ||||||||||
| 116 | second is the file it is to be performed on. The third | ||||||||||
| 117 | is an optional hash. It's accepted keys are as below. | ||||||||||
| 118 | |||||||||||
| 119 | =head3 hash args | ||||||||||
| 120 | |||||||||||
| 121 | Both hash args are currently required. | ||||||||||
| 122 | |||||||||||
| 123 | =head4 action | ||||||||||
| 124 | |||||||||||
| 125 | This is the action to be performed on the object. | ||||||||||
| 126 | |||||||||||
| 127 | =head4 object | ||||||||||
| 128 | |||||||||||
| 129 | This is the object to act on. | ||||||||||
| 130 | |||||||||||
| 131 | my $returned=$zcr->ask({action=>'view', object=>'/tmp/test.rdf'}); | ||||||||||
| 132 | if($zcr->{error}){ | ||||||||||
| 133 | print "Error!\n"; | ||||||||||
| 134 | }else{ | ||||||||||
| 135 | if($returned){ | ||||||||||
| 136 | print "Action setup.\n"; | ||||||||||
| 137 | } | ||||||||||
| 138 | } | ||||||||||
| 139 | |||||||||||
| 140 | =cut | ||||||||||
| 141 | |||||||||||
| 142 | 0 | ▶ | sub ask{ | ||||||||
|
Subroutine
ask: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 143 | 0 | my $self=$_[0]; | |||||||||
| 144 | 0 | my %args; | |||||||||
| 145 | 0 | ▶ | if(defined($_[1])){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 146 | 0 | %args= %{$_[1]}; | |||||||||
| 147 | } | ||||||||||
| 148 | |||||||||||
| 149 | 0 | $self->errorblank; | |||||||||
| 150 | |||||||||||
| 151 | 0 | my $returned=$self->{be}->ask(\%args); | |||||||||
| 152 | 0 | ▶ | if ($self->{be}->{error}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 153 | 0 | $self->{error}=5; | |||||||||
| 154 | $self->{errorString}='Backend errored. error="'.$self->{error}.'" '. | ||||||||||
| 155 | 0 | 'errorString=>"'.$self->{errorString}.'"'; | |||||||||
| 156 | 0 | warn('ZConf-Runner-GUI ask:5: '.$self->{errorString}); | |||||||||
| 157 | 0 | return undef; | |||||||||
| 158 | } | ||||||||||
| 159 | |||||||||||
| 160 | 0 | return $returned; | |||||||||
| 161 | } | ||||||||||
| 162 | |||||||||||
| 163 | =head2 dialogs | ||||||||||
| 164 | |||||||||||
| 165 | This returns the available dailogs. | ||||||||||
| 166 | |||||||||||
| 167 | =cut | ||||||||||
| 168 | |||||||||||
| 169 | 0 | ▶ | sub dialogs{ | ||||||||
|
Subroutine
dialogs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 170 | 0 | return ('ask'); | |||||||||
| 171 | } | ||||||||||
| 172 | |||||||||||
| 173 | =head2 windows | ||||||||||
| 174 | |||||||||||
| 175 | This returns a list of available windows. | ||||||||||
| 176 | |||||||||||
| 177 | =cut | ||||||||||
| 178 | |||||||||||
| 179 | 0 | ▶ | sub windows{ | ||||||||
|
Subroutine
windows: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 180 | 0 | return (); | |||||||||
| 181 | } | ||||||||||
| 182 | |||||||||||
| 183 | =head2 errorblank | ||||||||||
| 184 | |||||||||||
| 185 | This blanks the error storage and is only meant for internal usage. | ||||||||||
| 186 | |||||||||||
| 187 | It does the following. | ||||||||||
| 188 | |||||||||||
| 189 | $self->{error}=undef; | ||||||||||
| 190 | $self->{errorString}=""; | ||||||||||
| 191 | |||||||||||
| 192 | =cut | ||||||||||
| 193 | |||||||||||
| 194 | #blanks the error flags | ||||||||||
| 195 | 0 | ▶ | sub errorblank{ | ||||||||
|
Subroutine
errorblank: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 196 | 0 | my $self=$_[0]; | |||||||||
| 197 | |||||||||||
| 198 | 0 | $self->{error}=undef; | |||||||||
| 199 | 0 | $self->{errorString}=""; | |||||||||
| 200 | |||||||||||
| 201 | 0 | return 1; | |||||||||
| 202 | } | ||||||||||
| 203 | |||||||||||
| 204 | =head1 DIALOGS | ||||||||||
| 205 | |||||||||||
| 206 | ask | ||||||||||
| 207 | |||||||||||
| 208 | =head1 WINDOWS | ||||||||||
| 209 | |||||||||||
| 210 | At this time, no windows are supported. | ||||||||||
| 211 | |||||||||||
| 212 | =head1 ERROR CODES | ||||||||||
| 213 | |||||||||||
| 214 | =head2 1 | ||||||||||
| 215 | |||||||||||
| 216 | This means ZConf errored. | ||||||||||
| 217 | |||||||||||
| 218 | =head2 2 | ||||||||||
| 219 | |||||||||||
| 220 | Initializing ZConf::GUI failed. | ||||||||||
| 221 | |||||||||||
| 222 | =head2 3 | ||||||||||
| 223 | |||||||||||
| 224 | Initializing ZConf::Runner failed. | ||||||||||
| 225 | |||||||||||
| 226 | =head2 4 | ||||||||||
| 227 | |||||||||||
| 228 | Failed to initailize the primary backend. | ||||||||||
| 229 | |||||||||||
| 230 | =head2 5 | ||||||||||
| 231 | |||||||||||
| 232 | Backend errored. | ||||||||||
| 233 | |||||||||||
| 234 | =head1 AUTHOR | ||||||||||
| 235 | |||||||||||
| 236 | Zane C. Bowers, C<< <vvelox at vvelox.net> >> | ||||||||||
| 237 | |||||||||||
| 238 | =head1 BUGS | ||||||||||
| 239 | |||||||||||
| 240 | Please report any bugs or feature requests to C<bug-zconf-runner at rt.cpan.org>, or through | ||||||||||
| 241 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ZConf-Runner>. I will be notified, and then you'll | ||||||||||
| 242 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 243 | |||||||||||
| 244 | |||||||||||
| 245 | |||||||||||
| 246 | |||||||||||
| 247 | =head1 SUPPORT | ||||||||||
| 248 | |||||||||||
| 249 | You can find documentation for this module with the perldoc command. | ||||||||||
| 250 | |||||||||||
| 251 | perldoc ZConf::Runner | ||||||||||
| 252 | |||||||||||
| 253 | |||||||||||
| 254 | You can also look for information at: | ||||||||||
| 255 | |||||||||||
| 256 | =over 4 | ||||||||||
| 257 | |||||||||||
| 258 | =item * RT: CPAN's request tracker | ||||||||||
| 259 | |||||||||||
| 260 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ZConf-Runner> | ||||||||||
| 261 | |||||||||||
| 262 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 263 | |||||||||||
| 264 | L<http://annocpan.org/dist/ZConf-Runner> | ||||||||||
| 265 | |||||||||||
| 266 | =item * CPAN Ratings | ||||||||||
| 267 | |||||||||||
| 268 | L<http://cpanratings.perl.org/d/ZConf-Runner> | ||||||||||
| 269 | |||||||||||
| 270 | =item * Search CPAN | ||||||||||
| 271 | |||||||||||
| 272 | L<http://search.cpan.org/dist/ZConf-Runner> | ||||||||||
| 273 | |||||||||||
| 274 | =back | ||||||||||
| 275 | |||||||||||
| 276 | |||||||||||
| 277 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 278 | |||||||||||
| 279 | |||||||||||
| 280 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 281 | |||||||||||
| 282 | Copyright 2008 Zane C. Bowers, all rights reserved. | ||||||||||
| 283 | |||||||||||
| 284 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 285 | under the same terms as Perl itself. | ||||||||||
| 286 | |||||||||||
| 287 | |||||||||||
| 288 | =cut | ||||||||||
| 289 | |||||||||||
| 290 | 3 | 1; # End of ZConf::Runner | |||||||||