Ignore:
Timestamp:
Dec 10, 2009, 9:04:35 PM (14 years ago)
Author:
ronosman
Message:

Code factorization for properties management : use an inherited class instead of a module.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm

    r4467 r4469  
    22use strict;
    33
     4use base qw/
     5               Class::Accessor::Fast
     6           /;
     7
     8__PACKAGE__->mk_accessors(     
     9    qw/
     10        properties
     11      /
     12);
     13
     14
    415sub SetProperties {
    5     my ($dlg, $properties ) = @_;
     16    my ( $self ) = @_;
    617       
    718        map {
    8         my $ctrl =$dlg->FindWindow($_);
     19        my $ctrl =$self->FindWindow($_);
    920        #printf("ctrl %s : %s\n", $_, $ctrl);           
    1021        if(defined $ctrl){
    1122                # checkbox, static text
    1223                $ctrl->SetLabel(
    13            $dlg->properties->{$_}->{label}
    14                 ) if exists$dlg->properties->{$_}->{label};
     24           $self->properties->{$_}->{label}
     25                ) if exists$self->properties->{$_}->{label};
    1526
    1627        $ctrl->SetValue(
    17            $dlg->properties->{$_}->{value}->()
    18                 ) if exists$dlg->properties->{$_}->{value};
     28           $self->properties->{$_}->{value}->()
     29                ) if exists$self->properties->{$_}->{value};
    1930
    2031        # radiobox
    21         my $labels =$dlg->properties->{$_}->{labels};
     32        my $labels =$self->properties->{$_}->{labels};
    2233                $labels||=[];
    2334                for(my $i=0; $i < scalar @$labels ; $i++){
     
    2637                # only works for control with items
    2738                $ctrl->SetSelection(
    28                     $dlg->properties->{$_}->{selection}->()                     
    29                 ) if exists $dlg->properties->{$_}->{selection};
     39                    $self->properties->{$_}->{selection}->()                   
     40                ) if exists $self->properties->{$_}->{selection};
    3041               
    3142                }
    3243    }
    33         keys %$properties;
     44        keys %{$self->properties};
    3445}
    3546
    3647sub GetProperties {
    37     my ($dlg, $properties ) = @_;
     48    my ( $self ) = @_;
    3849
    3950        map {
    40         my $ctrl =$dlg->FindWindow($_);
     51        my $ctrl = $self->FindWindow($_);
    4152        #printf("ctrl %s : %s\n", $_, $ctrl);           
    4253        if(defined $ctrl){
    4354                # checkbox, static text
    4455
    45         $dlg->properties->{$_}->{value}->(
     56        $self->properties->{$_}->{value}->(
    4657            $ctrl->GetValue()
    47                 ) if exists$dlg->properties->{$_}->{value};
     58                ) if exists $self->properties->{$_}->{value};
    4859
    49         $dlg->properties->{$_}->{selection}->(
     60        $self->properties->{$_}->{selection}->(
    5061                    $ctrl->GetSelection()                       
    51                 ) if exists $dlg->properties->{$_}->{selection};
     62                ) if exists $self->properties->{$_}->{selection};
    5263               
    5364                }
    5465    }
    55         keys %$properties;
     66        keys %{$self->properties};
    5667}
    57681;
Note: See TracChangeset for help on using the changeset viewer.