| 1 | package CPANPLUS::Shell::Wx::UpdateWizard; | ||
| 2 | |||
| 3 | 1 | ▶ | use base qw(Wx::Wizard); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | use Wx qw/:allclasses wxID_OK wxID_CANCEL wxHORIZONTAL | ||
| 5 | wxVERTICAL wxADJUST_MINSIZE wxDefaultPosition wxDefaultSize wxTE_MULTILINE | ||
| 6 | wxTE_READONLY wxTE_CENTRE wxTE_WORDWRAP wxALIGN_CENTER_VERTICAL wxEXPAND | ||
| 7 | wxALIGN_CENTER_HORIZONTAL wxGA_HORIZONTAL wxGA_SMOOTH wxLC_REPORT | ||
| 8 | wxSUNKEN_BORDER/; | ||
| 9 | use Wx::Event qw(EVT_WIZARD_PAGE_CHANGED EVT_WINDOW_CREATE EVT_BUTTON EVT_CHECKBOX EVT_WIZARD_PAGE_CHANGING); | ||
| 10 | use Wx::ArtProvider qw/:artid :clientid/; | ||
| 11 | use Cwd; | ||
| 12 | use Data::Dumper; | ||
| 13 | |||
| 14 | use Wx::Locale gettext => '_T'; | ||
| 15 | |||
| 16 | use constant { | ||
| 17 | INTRO_PAGE=>0, | ||
| 18 | UPDATE_TYPE_PAGE=>1, | ||
| 19 | REVIEW_UPDATE_PAGE=>2, | ||
| 20 | PROGRESS_PAGE=>3, | ||
| 21 | REPORT_PAGE=>4 | ||
| 22 | }; | ||
| 23 | |||
| 24 | sub new{ | ||
| 25 | my $class = shift; | ||
| 26 | my ($parent) = @_; | ||
| 27 | my $self = $class->SUPER::new($parent,-1,"Update CPANPLUS"); | ||
| 28 | $self->{parent} = $parent; | ||
| 29 | EVT_WIZARD_PAGE_CHANGED($self,$self,\&OnPageChanged); | ||
| 30 | #get all the pages | ||
| 31 | $self->{page1}=CPANPLUS::Shell::Wx::UpdateWizard::IntroPage->new($self); | ||
| 32 | |||
| 33 | return $self; | ||
| 34 | } | ||
| 35 | |||
| 36 | sub OnPageChanged{ | ||
| 37 | my ($self,$event)=@_; | ||
| 38 | #print "OnPageChanged ",@_,"\n"; | ||
| 39 | my $curPage=$event->GetPage; | ||
| 40 | my $type=$curPage->{type}; | ||
| 41 | #print "TYPE IS $type"; | ||
| 42 | # if ($type eq 'PROGRESS_PAGE'){ | ||
| 43 | # $curPage->doUpdate(); | ||
| 44 | # } | ||
| 45 | } | ||
| 46 | |||
| 47 | #runs the wizard. | ||
| 48 | sub Run{ | ||
| 49 | my $self=shift; | ||
| 50 | $self->RunWizard($self->{page1}); | ||
| 51 | } | ||
| 52 | |||
| 53 | sub SetCPPObject{ | ||
| 54 | my $self=shift; | ||
| 55 | $self->{cpan}=shift; | ||
| 56 | |||
| 57 | #get the version so we can see if Selfupdate is supported | ||
| 58 | my $curVersion=$self->{cpan}->VERSION; | ||
| 59 | $curVersion=~s/_//; #delete underscore in version so we can compare | ||
| 60 | print "Current CPP Verison is: $curVersion\n"; | ||
| 61 | if ( $curVersion >= 0.7702){ #check if we can use CPANPLUS::Selfupdate | ||
| 62 | $self->{update} = $self->{cpan}->selfupdate_object; | ||
| 63 | }else{ | ||
| 64 | $self->{update}=undef; | ||
| 65 | } | ||
| 66 | |||
| 67 | if ($self->{update}){ print "Using Selfupdate!\n";} | ||
| 68 | |||
| 69 | $self->_setupTheList(); | ||
| 70 | } | ||
| 71 | |||
| 72 | #this sets up a hash of all the values in selfupdate. | ||
| 73 | #this should work with all | ||
| 74 | sub _setupTheList{ | ||
| 75 | my $self=shift; | ||
| 76 | my $update=$self->{update}; | ||
| 77 | |||
| 78 | #if we can't use selfupdate,set list to just CPANPLUS and return | ||
| 79 | unless ($update){ | ||
| 80 | $self->{theList}={core_mods => {'CPANPLUS'=>'0.77_02'}} ; | ||
| 81 | return; | ||
| 82 | } | ||
| 83 | |||
| 84 | #check for enabled features | ||
| 85 | foreach $m ($update->list_enabled_features){ | ||
| 86 | $self->{theList}->{enabled_features}->{$m}= \$update->modules_for_feature($m,AS_HASH); | ||
| 87 | } | ||
| 88 | foreach $m ($update->list_features(AS_HASH)){ | ||
| 89 | $self->{theList}->{features}->{$m}= \$update->modules_for_feature($m,AS_HASH); | ||
| 90 | } | ||
| 91 | $self->{theList}->{core_deps} = $update->list_core_dependencies(AS_HASH); | ||
| 92 | $self->{theList}->{core_mods} = $update->list_core_modules(AS_HASH); | ||
| 93 | |||
| 94 | #the areas to update | ||
| 95 | $self->{theList}->{areas_to_update}={ | ||
| 96 | core_mods=>0, | ||
| 97 | core_deps=>0, | ||
| 98 | features=>0, | ||
| 99 | enabled_features=>0 | ||
| 100 | }; | ||
| 101 | |||
| 102 | # print Dumper $self->{theList}; | ||
| 103 | $self->{page1}->GetNext()->check_update(); | ||
| 104 | } | ||
| 105 | |||
| 106 | |||
| 107 | #this is a template for a page. You must set the var's | ||
| 108 | # $self->{nextPage} and $self->{prevPage} in your constructor | ||
| 109 | package CPANPLUS::Shell::Wx::UpdateWizard::Page; | ||
| 110 | use base qw(Wx::WizardPage); | ||
| 111 | use Wx; | ||
| 112 | use Wx::Event qw(EVT_WIZARD_PAGE_CHANGED EVT_WINDOW_CREATE); | ||
| 113 | use Data::Dumper; | ||
| 114 | use constant { | ||
| 115 | INTRO_PAGE=>0, | ||
| 116 | UPDATE_TYPE_PAGE=>1, | ||
| 117 | REVIEW_UPDATE_PAGE=>2, | ||
| 118 | PROGRESS_PAGE=>3, | ||
| 119 | REPORT_PAGE=>4 | ||
| 120 | }; | ||
| 121 | use Wx::Locale gettext => '_T'; | ||
| 122 | |||
| 123 | sub new{ | ||
| 124 | my $class = shift; | ||
| 125 | my ($parent) = @_; | ||
| 126 | my $self = $class->SUPER::new($parent); | ||
| 127 | $self->{parent}=$parent; | ||
| 128 | $self->{prevPage}=undef; | ||
| 129 | $self->{nextPage}=undef; | ||
| 130 | return $self; | ||
| 131 | } | ||
| 132 | sub GetParent{ my $self=shift; return $self->{parent};} | ||
| 133 | sub SetPrev{ my $self=shift; $self->{prevPage}=shift;} | ||
| 134 | sub GetNext{ my $self=shift; return $self->{nextPage};} | ||
| 135 | sub GetPrev{ my $self=shift; return $self->{prevPage};} | ||
| 136 | |||
| 137 | #page 1: introduction | ||
| 138 | package CPANPLUS::Shell::Wx::UpdateWizard::IntroPage; | ||
| 139 | |||
| 140 | use base qw(CPANPLUS::Shell::Wx::UpdateWizard::Page); | ||
| 141 | use Wx qw/:allclasses wxHORIZONTAL | ||
| 142 | wxVERTICAL wxADJUST_MINSIZE wxDefaultPosition wxDefaultSize wxTE_MULTILINE | ||
| 143 | wxTE_READONLY wxTE_CENTRE wxTE_WORDWRAP wxALIGN_CENTER_VERTICAL wxEXPAND | ||
| 144 | wxALIGN_CENTER_HORIZONTAL/; | ||
| 145 | use Wx::Event qw(EVT_WIZARD_PAGE_CHANGED EVT_WINDOW_CREATE); | ||
| 146 | use Data::Dumper; | ||
| 147 | |||
| 148 | use Wx::Locale gettext => '_T'; | ||
| 149 | |||
| 150 | sub new{ | ||
| 151 | my $class = shift; | ||
| 152 | my ($parent) = @_; | ||
| 153 | my $self = $class->SUPER::new($parent); | ||
| 154 | $self->{type}=INTRO_PAGE; | ||
| 155 | |||
| 156 | $txt = Wx::TextCtrl->new($self, -1, | ||
| 157 | _T("Welcome to the CPANPLUS update wizard. \n". | ||
| 158 | " \nWe will begin by asking a few simple questions to update ". | ||
| 159 | "CPANPLUS. \n \nClick Next to begin."), | ||
| 160 | wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_CENTRE|wxTE_WORDWRAP); | ||
| 161 | |||
| 162 | $txt->Enable(0); | ||
| 163 | |||
| 164 | $sizer = Wx::BoxSizer->new(wxVERTICAL); | ||
| 165 | $sizer->Add($txt, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | ||
| 166 | $self->SetSizer($sizer); | ||
| 167 | $sizer->Fit($self); | ||
| 168 | |||
| 169 | $self->{nextPage}=CPANPLUS::Shell::Wx::UpdateWizard::UpdateTypePage->new($self->{parent}); | ||
| 170 | $self->{nextPage}->SetPrev($self); | ||
| 171 | |||
| 172 | bless($self,$class); | ||
| 173 | return $self; | ||
| 174 | } | ||
| 175 | |||
| 176 | #page 2: | ||
| 177 | package CPANPLUS::Shell::Wx::UpdateWizard::UpdateTypePage; | ||
| 178 | |||
| 179 | use base qw(CPANPLUS::Shell::Wx::UpdateWizard::Page); | ||
| 180 | use Wx qw/:allclasses wxHORIZONTAL | ||
| 181 | wxVERTICAL wxADJUST_MINSIZE wxDefaultPosition wxDefaultSize wxTE_MULTILINE | ||
| 182 | wxTE_READONLY wxTE_CENTRE wxTE_WORDWRAP wxALIGN_CENTER_VERTICAL wxEXPAND | ||
| 183 | wxALIGN_CENTER_HORIZONTAL/; | ||
| 184 | use Wx::Event qw(EVT_CHECKBOX); | ||
| 185 | use Data::Dumper; | ||
| 186 | |||
| 187 | use Wx::Locale gettext => '_T'; | ||
| 188 | |||
| 189 | sub new{ | ||
| 190 | my $class = shift; | ||
| 191 | my ($parent) = @_; | ||
| 192 | my $self = $class->SUPER::new($parent); | ||
| 193 | |||
| 194 | $self->{type}=UPDATE_TYPE_PAGE; | ||
| 195 | |||
| 196 | $self->{parent}=$parent; | ||
| 197 | |||
| 198 | $txt = Wx::TextCtrl->new($self, -1, _T("First, we need to know which modules you would like to update:"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_CENTRE|wxTE_WORDWRAP); | ||
| 199 | $parent->{update_core} = Wx::CheckBox->new($self, -1, _T("Core: \n Just the core CPANPLUS modules."), wxDefaultPosition, wxDefaultSize, ); | ||
| 200 | $parent->{update_deps} = Wx::CheckBox->new($self, -1, _T("Dependencies: \n All the modules which CPANPLUS depends upon."), wxDefaultPosition, wxDefaultSize, ); | ||
| 201 | $parent->{update_efeatures} = Wx::CheckBox->new($self, -1, _T("Enabled Features: \n Currently enabled features of CPANPLUS."), wxDefaultPosition, wxDefaultSize, ); | ||
| 202 | $parent->{update_features} = Wx::CheckBox->new($self, -1, _T("All Features: \n Enabled and Non-Enabled Features"), wxDefaultPosition, wxDefaultSize, ); | ||
| 203 | $parent->{update_all} = Wx::CheckBox->new($self, -1, _T("All"), wxDefaultPosition, wxDefaultSize, ); | ||
| 204 | $line = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, ); | ||
| 205 | $parent->{latest_version} = Wx::CheckBox->new($self, -1, _T("Update to Latest Version"), wxDefaultPosition, wxDefaultSize, ); | ||
| 206 | |||
| 207 | $txt->Enable(0); | ||
| 208 | |||
| 209 | $parent->{update_all}->SetValue(1); | ||
| 210 | $parent->{latest_version}->SetValue(1); | ||
| 211 | |||
| 212 | $sizer = Wx::BoxSizer->new(wxVERTICAL); | ||
| 213 | $sizer->Add($txt, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | ||
| 214 | $sizer->Add($parent->{update_core}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | ||
| 215 | $sizer->Add($parent->{update_deps}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | ||
| 216 | $sizer->Add($parent->{update_efeatures}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | ||
| 217 | $sizer->Add($parent->{update_features}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | ||
| 218 | $sizer->Add($parent->{update_all}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | ||
| 219 | $sizer->Add($line, 0, wxEXPAND, 0); | ||
| 220 | $sizer->Add($parent->{latest_version}, 0, wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 0); | ||
| 221 | $self->SetSizer($sizer); | ||
| 222 | $sizer->Fit($self); | ||
| 223 | bless($self,$class); | ||
| 224 | |||
| 225 | EVT_CHECKBOX($self,$parent->{update_core},\&UpdateCore); | ||
| 226 | EVT_CHECKBOX($self,$parent->{update_deps},\&UpdateDeps); | ||
| 227 | EVT_CHECKBOX($self,$parent->{update_efeatures},\&UpdateEFeatures); | ||
| 228 | EVT_CHECKBOX($self,$parent->{update_features},\&UpdateFeatures); | ||
| 229 | EVT_CHECKBOX($self,$parent->{update_all},\&UpdateAll); | ||
| 230 | EVT_CHECKBOX($self,$parent->{latest_version},\&UpdateLatest); | ||
| 231 | |||
| 232 | $self->{nextPage}=CPANPLUS::Shell::Wx::UpdateWizard::ReviewUpdatesPage->new($self->{parent}); | ||
| 233 | $self->{nextPage}->SetPrev($self); | ||
| 234 | |||
| 235 | return $self; | ||
| 236 | |||
| 237 | } | ||
| 238 | sub check_update{ | ||
| 239 | my $self=shift; | ||
| 240 | $parent=$self->{parent}; | ||
| 241 | #if we can't use selfupdate, disable all relevant controls | ||
| 242 | unless ($parent->{update}){ | ||
| 243 | $parent->{update_core}->Enable(0); | ||
| 244 | $parent->{update_deps}->Enable(0); | ||
| 245 | $parent->{update_efeatures}->Enable(0); | ||
| 246 | $parent->{update_features}->Enable(0); | ||
| 247 | $parent->{update_all}->Enable(0); | ||
| 248 | } | ||
| 249 | |||
| 250 | } | ||
| 251 | sub UpdateCore{ | ||
| 252 | my $self=shift; | ||
| 253 | my $event=shift; | ||
| 254 | $parent=$self->{parent}; | ||
| 255 | $parent->{theList}->{areas_to_update}->{core_mods}=$event->IsChecked; | ||
| 256 | $self->{nextPage}->Populate(); | ||
| 257 | } | ||
| 258 | sub UpdateDeps{ | ||
| 259 | my $self=shift; | ||
| 260 | my $event=shift; | ||
| 261 | $parent=$self->{parent}; | ||
| 262 | $parent->{theList}->{areas_to_update}->{core_deps}=$event->IsChecked; | ||
| 263 | $self->{nextPage}->Populate(); | ||
| 264 | } | ||
| 265 | sub UpdateEFeatures{ | ||
| 266 | my $self=shift; | ||
| 267 | my $event=shift; | ||
| 268 | $parent=$self->{parent}; | ||
| 269 | $parent->{theList}->{areas_to_update}->{enabled_features}=$event->IsChecked; | ||
| 270 | $self->{nextPage}->Populate(); | ||
| 271 | } | ||
| 272 | sub UpdateFeatures{ | ||
| 273 | my $self=shift; | ||
| 274 | my $event=shift; | ||
| 275 | $parent=$self->{parent}; | ||
| 276 | $parent->{theList}->{areas_to_update}->{features}=$event->IsChecked; | ||
| 277 | $self->{nextPage}->Populate(); | ||
| 278 | } | ||
| 279 | sub UpdateAll{ | ||
| 280 | my $self=shift; | ||
| 281 | my $event=shift; | ||
| 282 | $parent=$self->{parent}; | ||
| 283 | $parent->{theList}->{areas_to_update}->{all}=$event->IsChecked; | ||
| 284 | $self->{nextPage}->Populate(); | ||
| 285 | } | ||
| 286 | sub UpdateLatest{ | ||
| 287 | my $self=shift; | ||
| 288 | my $event=shift; | ||
| 289 | $parent=$self->{parent}; | ||
| 290 | $parent->{theList}->{_latest}=$event->IsChecked; | ||
| 291 | $self->{nextPage}->Populate(); | ||
| 292 | } | ||
| 293 | #page 3 | ||
| 294 | package CPANPLUS::Shell::Wx::UpdateWizard::ReviewUpdatesPage; | ||
| 295 | |||
| 296 | use base qw(CPANPLUS::Shell::Wx::UpdateWizard::Page); | ||
| 297 | use Wx qw/:allclasses wxHORIZONTAL wxLB_MULTIPLE | ||
| 298 | wxVERTICAL wxADJUST_MINSIZE wxDefaultPosition wxDefaultSize wxTE_MULTILINE | ||
| 299 | wxTE_READONLY wxTE_CENTRE wxTE_WORDWRAP wxALIGN_CENTER_VERTICAL wxEXPAND | ||
| 300 | wxALIGN_CENTER_HORIZONTAL wxSUNKEN_BORDER wxPD_APP_MODAL wxPD_CAN_ABORT | ||
| 301 | wxPD_ELAPSED_TIME wxPD_ESTIMATED_TIME wxPD_REMAINING_TIME/; | ||
| 302 | use Wx::Event qw(EVT_BUTTON EVT_WIZARD_PAGE_CHANGED EVT_WINDOW_CREATE | ||
| 303 | EVT_LISTBOX EVT_LIST_ITEM_SELECTED); | ||
| 304 | use Data::Dumper; | ||
| 305 | use CPANPLUS::Shell::Wx::util; | ||
| 306 | |||
| 307 | use Wx::Locale gettext => '_T'; | ||
| 308 | |||
| 309 | sub new{ | ||
| 310 | my $class = shift; | ||
| 311 | my ($parent) = @_; | ||
| 312 | my $self = $class->SUPER::new($parent); | ||
| 313 | |||
| 314 | $self->{type}=REVIEW_UPDATE_PAGE; | ||
| 315 | |||
| 316 | $txt = Wx::TextCtrl->new($self, -1, _T("Next, review all the modules that need to be upgraded or installed. Press the Update button when ready."), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_CENTRE|wxTE_WORDWRAP); | ||
| 317 | #$parent->{update_list} = Wx::CheckListBox->new($self, -1, wxDefaultPosition, wxDefaultSize, [],wxSUNKEN_BORDER); | ||
| 318 | #$parent->{update_list} = Wx::ListBox->new($self, -1, wxDefaultPosition, wxDefaultSize, [],wxSUNKEN_BORDER|wxLB_MULTIPLE); | ||
| 319 | $parent->{update_list} = CPANPLUS::Shell::Wx::Frame::ActionsList->new($self, -1, wxDefaultPosition, wxDefaultSize, [],wxSUNKEN_BORDER|wxLB_MULTIPLE); | ||
| 320 | $parent->{do_update} = Wx::Button->new($self,-1,_T("Update!")); | ||
| 321 | |||
| 322 | |||
| 323 | $txt->Enable(0); | ||
| 324 | |||
| 325 | $sizer = Wx::BoxSizer->new(wxVERTICAL); | ||
| 326 | $sizer->Add($txt, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | ||
| 327 | $sizer->Add($parent->{update_list}, 1, wxEXPAND, 0); | ||
| 328 | $sizer->Add($parent->{do_update}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); | ||
| 329 | $self->SetSizer($sizer); | ||
| 330 | $sizer->Fit($self); | ||
| 331 | bless($self,$class); | ||
| 332 | |||
| 333 | EVT_BUTTON($self,$parent->{do_update},\&_update); | ||
| 334 | |||
| 335 | $self->{nextPage}=CPANPLUS::Shell::Wx::UpdateWizard::ReportPage->new($self->{parent}); | ||
| 336 | $self->{nextPage}->SetPrev($self); | ||
| 337 | |||
| 338 | return $self; | ||
| 339 | |||
| 340 | } | ||
| 341 | |||
| 342 | sub Populate{ | ||
| 343 | my $self=shift; | ||
| 344 | $parent=$self->{parent}; | ||
| 345 | my $list=$parent->{theList}; | ||
| 346 | my $listctrl=$parent->{update_list}; | ||
| 347 | $listctrl->ClearList(); | ||
| 348 | |||
| 349 | my @mods=(); | ||
| 350 | my $num=1; | ||
| 351 | |||
| 352 | foreach $area (keys(%$list)){ | ||
| 353 | #skip 'features' and 'areas' since the need special handling | ||
| 354 | next if ($area eq 'areas_to_update' || $area eq 'features' || | ||
| 355 | $area eq 'enabled_features' || !($list->{areas_to_update}->{$area}) | ||
| 356 | ); | ||
| 357 | foreach $name (keys(%{$list->{$area}})){ | ||
| 358 | my $h={name=>$name,version=>$list->{$area}->{$name}}; | ||
| 359 | #print Dumper $h; | ||
| 360 | push(@mods,$h) unless grep {$_->{name} =~ /^$name$/} @mods; | ||
| 361 | $num++; | ||
| 362 | } | ||
| 363 | } | ||
| 364 | if ($list->{areas_to_update}->{features}){ | ||
| 365 | foreach my $confDep (keys(%{$list->{features}})){ | ||
| 366 | my $confDepList=$list->{features}->{$confDep}; | ||
| 367 | next if ref($confDepList) eq 'SCALAR'; #skip empty refs | ||
| 368 | $confDepList=$$confDepList if ref($confDepList) eq 'REF'; | ||
| 369 | foreach $name (keys(%{$confDepList})){ | ||
| 370 | my $h={name=>$name,version=>$confDepList->{$name}}; | ||
| 371 | #print Dumper $h; | ||
| 372 | push (@mods,$h ) unless grep {$_->{name} =~ /^$name$/} @mods; | ||
| 373 | $num++; | ||
| 374 | } | ||
| 375 | } | ||
| 376 | } | ||
| 377 | if ($list->{areas_to_update}->{enabled_features}){ | ||
| 378 | foreach my $confDep (keys(%{$list->{enabled_features}})){ | ||
| 379 | my $confDepList=$list->{enabled_features}->{$confDep}; | ||
| 380 | next if ref($confDepList) eq 'SCALAR'; #skip empty refs | ||
| 381 | $confDepList=$$confDepList if ref($confDepList) eq 'REF'; | ||
| 382 | foreach $name (keys(%{$confDepList})){ | ||
| 383 | my $h={name=>$name,version=>$confDepList->{$name}}; | ||
| 384 | #print Dumper $h; | ||
| 385 | push (@mods,$h ) unless grep {$_->{name} =~ /^$name$/} @mods; | ||
| 386 | $num++; | ||
| 387 | } | ||
| 388 | } | ||
| 389 | } | ||
| 390 | |||
| 391 | #add all the items to the list | ||
| 392 | foreach $m (@mods){ | ||
| 393 | $listctrl->AddActionWithPre($m->{name},$m->{version},'update'); | ||
| 394 | } | ||
| 395 | } | ||
| 396 | |||
| 397 | #run the update | ||
| 398 | sub _update{ | ||
| 399 | my $self=shift; | ||
| 400 | my $parent=$self->{parent}; | ||
| 401 | my $list=$parent->{theList}; | ||
| 402 | my $listctrl=$parent->{update_list}; | ||
| 403 | my $modtree=Wx::Window::FindWindowByName('tree_modules'); | ||
| 404 | print "Running Update..."; | ||
| 405 | my $total=$listctrl->GetItemCount; | ||
| 406 | my $progress=Wx::ProgressDialog->new( | ||
| 407 | "Updating CPANPLUS...", | ||
| 408 | "Updating...",$total*6,$self, | ||
| 409 | wxPD_APP_MODAL|wxPD_CAN_ABORT|wxPD_ELAPSED_TIME|wxPD_ESTIMATED_TIME|wxPD_REMAINING_TIME); | ||
| 410 | my $i=1; | ||
| 411 | my $debug=''; | ||
| 412 | while ($listctrl->GetItemCount > 0){ | ||
| 413 | my $name=$listctrl->GetItemText(0); | ||
| 414 | my $mod=$modtree->_get_mod($name); | ||
| 415 | next unless $mod; | ||
| 416 | $self->_install($mod,$progress,\$i,\$debug); | ||
| 417 | #$mod->install(); | ||
| 418 | $listctrl->DeleteItem(0); | ||
| 419 | $i++; | ||
| 420 | } | ||
| 421 | $progress->Destroy(); | ||
| 422 | $parent->{problems}->SetValue($parent->{problems}->GetValue. | ||
| 423 | "\nOUTPUT:\n\n".$debug."\n\nSee Log Tab for full output.\n"); | ||
| 424 | _uShowErr(); | ||
| 425 | } | ||
| 426 | |||
| 427 | sub _install{ | ||
| 428 | my ($self,$mod,$progress,$curProgRef,$txtref)=@_; | ||
| 429 | return unless $mod; | ||
| 430 | $$txtref.=$mod->name.":\n"; | ||
| 431 | |||
| 432 | if ($progress->Update($$curProgRef,"Fetching ".$mod->name."...")){ | ||
| 433 | $$txtref.="\tFetch: "; | ||
| 434 | if ($mod->fetch()){ | ||
| 435 | $$txtref.="[Success]\n"; | ||
| 436 | $$curProgRef++; | ||
| 437 | }else{ | ||
| 438 | $$txtref.="[Failed]\n"; | ||
| 439 | return 0; | ||
| 440 | } | ||
| 441 | }else{$$txtref.="User Cancelled\n";return 0;} | ||
| 442 | |||
| 443 | if ($progress->Update($$curProgRef,"Extracting ".$mod->name."...")){ | ||
| 444 | $$txtref.="\tExtract: "; | ||
| 445 | if ($mod->extract()){ | ||
| 446 | $$txtref.="[Success]\n"; | ||
| 447 | $$curProgRef++; | ||
| 448 | }else{ | ||
| 449 | $$txtref.="[Failed]\n"; | ||
| 450 | return 0; | ||
| 451 | } | ||
| 452 | }else{$$txtref.="User Cancelled\n";return 0;} | ||
| 453 | |||
| 454 | if ($progress->Update($$curProgRef,"Preparing ".$mod->name."...")){ | ||
| 455 | $$txtref.="\tPrepare: "; | ||
| 456 | if ($mod->prepare()){ | ||
| 457 | $$txtref.="[Success]\n"; | ||
| 458 | $$curProgRef++; | ||
| 459 | }else{ | ||
| 460 | $$txtref.="[Failed]\n"; | ||
| 461 | return 0; | ||
| 462 | } | ||
| 463 | }else{$$txtref.="User Cancelled\n";return 0;} | ||
| 464 | |||
| 465 | if ($progress->Update($$curProgRef,"Building ".$mod->name."...")){ | ||
| 466 | $$txtref.="\tBuild: "; | ||
| 467 | if ($mod->create()){ | ||
| 468 | $$txtref.="[Success]\n"; | ||
| 469 | $$curProgRef++; | ||
| 470 | }else{ | ||
| 471 | $$txtref.="[Failed]\n"; | ||
| 472 | return 0; | ||
| 473 | } | ||
| 474 | }else{$$txtref.="User Cancelled\n";return 0;} | ||
| 475 | |||
| 476 | if ($progress->Update($$curProgRef,"Testing ".$mod->name."...")){ | ||
| 477 | $$txtref.="\tTest: "; | ||
| 478 | if ($mod->test()){ | ||
| 479 | $$txtref.="[Success]\n"; | ||
| 480 | $$curProgRef++; | ||
| 481 | }else{ | ||
| 482 | $$txtref.="[Failed]\n"; | ||
| 483 | return 0; | ||
| 484 | } | ||
| 485 | }else{$$txtref.="User Cancelled\n";return 0;} | ||
| 486 | |||
| 487 | if ($progress->Update($$curProgRef,"Installing ".$mod->name."...")){ | ||
| 488 | $$txtref.="\tInstall: "; | ||
| 489 | if ($mod->install()){ | ||
| 490 | $$txtref.="[Success]\n"; | ||
| 491 | $$curProgRef++; | ||
| 492 | }else{ | ||
| 493 | $$txtref.="[Failed]\n"; | ||
| 494 | return 0; | ||
| 495 | } | ||
| 496 | }else{$$txtref.="User Cancelled\n";return 0;} | ||
| 497 | |||
| 498 | return 1; | ||
| 499 | } | ||
| 500 | |||
| 501 | |||
| 502 | #page 3 | ||
| 503 | package CPANPLUS::Shell::Wx::UpdateWizard::ReportPage; | ||
| 504 | |||
| 505 | use base qw(CPANPLUS::Shell::Wx::UpdateWizard::Page); | ||
| 506 | use Wx qw/:allclasses wxHORIZONTAL | ||
| 507 | wxVERTICAL wxADJUST_MINSIZE wxDefaultPosition wxDefaultSize wxTE_MULTILINE | ||
| 508 | wxTE_READONLY wxTE_CENTRE wxTE_WORDWRAP wxALIGN_CENTER_VERTICAL wxEXPAND | ||
| 509 | wxALIGN_CENTER_HORIZONTAL wxSUNKEN_BORDER/; | ||
| 510 | use Wx::Event qw(EVT_WIZARD_PAGE_CHANGED EVT_WINDOW_CREATE); | ||
| 511 | use Data::Dumper; | ||
| 512 | use CPANPLUS::Shell::Wx::util; | ||
| 513 | |||
| 514 | use Wx::Locale gettext => '_T'; | ||
| 515 | |||
| 516 | sub new{ | ||
| 517 | my $class = shift; | ||
| 518 | my ($parent) = @_; | ||
| 519 | my $self = $class->SUPER::new($parent); | ||
| 520 | |||
| 521 | $self->{type}=REPORT_PAGE; | ||
| 522 | |||
| 523 | $parent->{problems} = Wx::TextCtrl->new($self, -1, _T("If there were any problems, they are listed below."), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_WORDWRAP); | ||
| 524 | $parent->{problems}->Enable(0); | ||
| 525 | |||
| 526 | $sizer = Wx::BoxSizer->new(wxVERTICAL); | ||
| 527 | $sizer->Add($parent->{problems}, 1, wxEXPAND|wxADJUST_MINSIZE, 0); | ||
| 528 | $self->SetSizer($sizer); | ||
| 529 | $sizer->Fit($self); | ||
| 530 | |||
| 531 | return $self; | ||
| 532 | |||
| 533 | } | ||
| 534 | |||
| 535 | sub ShowDebug{ | ||
| 536 | my $self=shift; | ||
| 537 | |||
| 538 | |||
| 539 | } | ||
| 540 | 1; | ||