Changeset 12378
- Timestamp:
- 08/27/10 00:28:57 (18 months ago)
- Location:
- trunk/Padre
- Files:
-
- 2 added
- 5 edited
-
lib/Padre/TaskHandle.pm (modified) (3 diffs)
-
lib/Padre/Wx/Directory.pm (modified) (7 diffs)
-
lib/Padre/Wx/Directory/Browse.pm (added)
-
lib/Padre/Wx/Directory/Path.pm (modified) (1 diff)
-
lib/Padre/Wx/Directory/TreeCtrl.pm (modified) (2 diffs)
-
lib/Padre/Wx/TreeCtrl.pm (added)
-
t/61-directory-path.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/TaskHandle.pm
r12338 r12378 313 313 # Pull off the queue 314 314 my $queue = $handle->queue or return 0; 315 push @$inbox, $queue->dequeue; 315 foreach my $message ( $queue->dequeue ) { 316 if ( $message->[0] eq 'cancel' ) { 317 $self->{cancel} = 1; 318 next; 319 } 320 } 321 322 # Check the message for valid structure 316 323 my $message = shift @$inbox or return 0; 317 318 # Check the message for valid structure319 324 unless ( Params::Util::_ARRAY($message) ) { 320 325 TRACE('Non-ARRAY message received by a worker thread') if DEBUG; … … 336 341 337 342 # Pull from the inbox first 338 my $inbox = $handle->inbox or return 0;343 my $inbox = $handle->inbox or return 0; 339 344 if ( @$inbox ) { 340 345 return shift @$inbox; … … 343 348 # Pull off the queue, non-blocking 344 349 my $queue = $handle->queue or return 0; 345 push @$inbox, $queue->dequeue_nb; 350 foreach my $message ( $queue->dequeue ) { 351 if ( $message->[0] eq 'cancel' ) { 352 $self->{cancel} = 1; 353 next; 354 } 355 } 356 357 # Check the message for valid structure 346 358 my $message = shift @$inbox or return 0; 347 348 # Check the message for valid structure349 359 unless ( Params::Util::_ARRAY($message) ) { 350 360 TRACE('Non-ARRAY message received by a worker thread') if DEBUG; -
trunk/Padre/lib/Padre/Wx/Directory.pm
r12330 r12378 104 104 # Create the tree control 105 105 $self->{tree} = Padre::Wx::Directory::TreeCtrl->new($self); 106 $self->{tree}->SetPlData( 107 $self->{tree}->GetRootItem, 108 Wx::TreeItemData->new( 109 Padre::Wx::Directory::Path->directory, 110 ), 111 ); 112 Wx::Event::EVT_TREE_ITEM_EXPANDED( 113 $self, 114 $self->{tree}, 115 sub { 116 shift->on_expand(@_); 117 } 118 ); 106 119 107 120 # Fill the panel … … 183 196 $search->ShowCancelButton(0); 184 197 $self->task_reset; 185 $self->refresh_render; 198 $self->clear; 199 $self->browse; 186 200 } else { 187 201 # Changing search term … … 204 218 } 205 219 220 sub on_expand { 221 my $self = shift; 222 my $event = shift; 223 my $item = $event->GetItem; 224 my $path = $self->{tree}->GetPlData($item); 225 return $self->browse( $path ); 226 } 227 206 228 207 229 … … 276 298 if ( $ide->project_exists( $self->{root} ) ) { 277 299 my $stash = Padre::Cache::stash( 278 __PACKAGE__, 279 $ide->project( $self->{root} ), 300 __PACKAGE__ => $ide->project( $self->{root} ), 280 301 ); 281 302 %$stash = ( … … 295 316 if ($project) { 296 317 my $stash = Padre::Cache::stash( 297 __PACKAGE__, 298 $project, 318 __PACKAGE__ => $project, 299 319 ); 300 320 if ( $stash->{root} ) { … … 306 326 } 307 327 308 # Flush the search box and rerender the tree 309 $self->{search}->SetValue(''); 310 $self->{search}->ShowCancelButton(0); 311 $self->refresh_render; 312 313 # Trigger the refresh task to update the temporary state 314 $self->task_request( 315 task => 'Padre::Wx::Directory::Task', 316 on_finish => 'refresh_finish', 317 recursive => 1, 318 @options, 319 ); 320 328 # Flush the search box and start the rerender 329 $self->clear; 330 $self->browse; 321 331 } 322 332 … … 394 404 395 405 return 1; 406 } 407 408 409 410 411 412 ###################################################################### 413 # Browse Methods 414 415 sub browse { 416 TRACE( $_[0] ) if DEBUG; 417 my $self = shift; 418 my $path = shift || Padre::Wx::Directory::Path->directory; 419 return if $self->searching; 420 421 # Switch tasks to the browse task 422 $self->task_reset; 423 $self->task_request( 424 task => 'Padre::Wx::Directory::Browse', 425 on_message => 'browse_message', 426 on_finish => 'browse_finish', 427 list => [ $path ], 428 ); 429 430 return; 431 } 432 433 sub browse_message { 434 TRACE( $_[0] ) if DEBUG; 435 my $self = shift; 436 my $task = shift; 437 my $parent = shift; 438 439 # Find the parent, discarding the message if we can't find it 440 my $tree = $self->{tree}; 441 my $cursor = $tree->GetRootItem; 442 foreach my $name ( $parent->path ) { 443 # Locate the child to descend to. 444 # Discard the entire message if the target child doesn't exist. 445 $cursor = $tree->GetChildByText( $cursor, $name ) or return 1; 446 } 447 448 # Temporarily skip if we've already filled this node. 449 # TODO: Upgrade this to make it update the list instead. 450 if ( $tree->GetChildrenCount($cursor) ) { 451 return; 452 } 453 454 # Add the files to the cursor 455 while ( @_ ) { 456 my $path = shift; 457 my $image = $path->type ? 'folder' : 'package'; 458 459 # Add the child to the parent 460 $tree->AppendItem( 461 $cursor, # Parent node 462 $path->name, # Label 463 $tree->{images}->{$image}, # Icon 464 -1, # Wx Identifier 465 Wx::TreeItemData->new($path), # Embedded data 466 ); 467 } 468 469 return 1; 470 } 471 472 sub browse_finish { 473 TRACE( $_[0] ) if DEBUG; 474 my $self = shift; 475 my $task = shift; 396 476 } 397 477 -
trunk/Padre/lib/Padre/Wx/Directory/Path.pm
r12251 r12378 33 33 return bless [ 34 34 DIRECTORY, 35 File::Spec::Unix->catfile( @_),35 File::Spec::Unix->catfile( @_ ? @_ : ('') ), 36 36 @_, 37 37 ], $class; -
trunk/Padre/lib/Padre/Wx/Directory/TreeCtrl.pm
r12251 r12378 6 6 use File::Spec (); 7 7 use Padre::Constant (); 8 use Padre::Wx ();8 use Padre::Wx::TreeCtrl (); 9 9 use Padre::Wx::Role::Main (); 10 10 use Padre::Wx::Directory::Path (); … … 13 13 our @ISA = qw{ 14 14 Padre::Wx::Role::Main 15 Wx::TreeCtrl15 Padre::Wx::TreeCtrl 16 16 }; 17 17 -
trunk/Padre/t/61-directory-path.t
r11727 r12378 3 3 use strict; 4 4 use warnings; 5 use Test::More tests => 18;5 use Test::More tests => 25; 6 6 use Test::NoWarnings; 7 7 use Storable (); … … 62 62 is_deeply( $file, $round, 'File round-trips ok' ); 63 63 } 64 65 66 67 68 69 ###################################################################### 70 # Test the null directory case 71 72 SCOPE: { 73 my $directory = Padre::Wx::Directory::Path->directory; 74 isa_ok( $directory, 'Padre::Wx::Directory::Path' ); 75 is( $directory->type, Padre::Wx::Directory::Path::DIRECTORY, '->type ok' ); 76 is( $directory->name, '', '->name ok' ); 77 is( $directory->unix, '', '->unix ok' ); 78 is_deeply( [ $directory->path ], [ ], '->path ok' ); 79 is( $directory->is_file, 0, '->is_file ok' ); 80 is( $directory->is_directory, 1, '->is_directory ok' ); 81 }
Note: See TracChangeset
for help on using the changeset viewer.
