line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::ebug::Wx::Service::ConfigurationManager; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1020
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
4
|
use base qw(Devel::ebug::Wx::Service::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
5
|
1
|
|
|
1
|
|
4
|
use Devel::ebug::Wx::Plugin qw(:plugin); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
111
|
|
6
|
1
|
|
|
1
|
|
438
|
use Devel::ebug::Wx::ServiceManager::Holder; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw(_configurations) ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub service_name : Service { 'configuration_manager' } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %configurators; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub initialize { |
15
|
|
|
|
|
|
|
my( $self, $manager ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
foreach my $class ( Devel::ebug::Wx::Plugin->configuration_classes ) { |
18
|
|
|
|
|
|
|
$configurators{$class->tag} = $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
my @configurations; |
21
|
|
|
|
|
|
|
foreach my $configurable ( Devel::ebug::Wx::Plugin->configurables ) { |
22
|
|
|
|
|
|
|
my $cfg = $configurable->(); |
23
|
|
|
|
|
|
|
$cfg->{configurator_class} = $configurators{$cfg->{configurator}}; |
24
|
|
|
|
|
|
|
push @configurations, $cfg; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
$self->_configurations( \@configurations ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub show_configuration { |
30
|
|
|
|
|
|
|
my( $self, $parent ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $dlg = Devel::ebug::Wx::Service::ConfigurationManager::Dialog |
33
|
|
|
|
|
|
|
->new( $parent, $self ); |
34
|
|
|
|
|
|
|
$dlg->Show; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub command : Command { |
38
|
|
|
|
|
|
|
my( $class, $wxebug ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return ( 'configure', |
41
|
|
|
|
|
|
|
{ sub => \&_configure, |
42
|
|
|
|
|
|
|
menu => 'view', |
43
|
|
|
|
|
|
|
label => 'Configure', |
44
|
|
|
|
|
|
|
priority => 600, |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _configure { |
50
|
|
|
|
|
|
|
my( $wx ) = @_; |
51
|
|
|
|
|
|
|
my $cm = $wx->configuration_manager_service; |
52
|
|
|
|
|
|
|
$cm->show_configuration( $wx ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package Devel::ebug::Wx::Service::ConfigurationManager::Dialog; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use strict; |
58
|
|
|
|
|
|
|
use base qw(Wx::Frame Class::Accessor::Fast); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Wx qw(:id :sizer); |
61
|
|
|
|
|
|
|
use Wx::Event qw(EVT_BUTTON EVT_CLOSE); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub new { |
64
|
|
|
|
|
|
|
my( $class, $parent, $cm ) = @_; |
65
|
|
|
|
|
|
|
my $self = $class->SUPER::new( $parent, -1, 'Configuration' ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $nb = Wx::Notebook->new( $self, -1 ); |
68
|
|
|
|
|
|
|
my $sm = $cm->service_manager; |
69
|
|
|
|
|
|
|
my $configurations = $cm->_configurations; |
70
|
|
|
|
|
|
|
foreach my $configuration ( @$configurations ) { |
71
|
|
|
|
|
|
|
my $attrs = $configuration->{configurable} |
72
|
|
|
|
|
|
|
->get_configuration( $sm ); |
73
|
|
|
|
|
|
|
my $view = $configuration->{configurator_class}->new( $nb, $attrs ); |
74
|
|
|
|
|
|
|
$configuration->{view} = $view; |
75
|
|
|
|
|
|
|
$nb->AddPage( $view, $attrs->{label} ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $sz = Wx::BoxSizer->new( wxVERTICAL ); |
79
|
|
|
|
|
|
|
my $btnsz = Wx::StdDialogButtonSizer->new; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $ok = Wx::Button->new( $self, wxID_OK, 'Ok' ); |
82
|
|
|
|
|
|
|
my $cancel = Wx::Button->new( $self, wxID_CANCEL, 'Cancel' ); |
83
|
|
|
|
|
|
|
my $apply = Wx::Button->new( $self, wxID_APPLY, 'Apply' ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$btnsz->AddButton( $ok ); |
86
|
|
|
|
|
|
|
$btnsz->AddButton( $cancel ); |
87
|
|
|
|
|
|
|
$btnsz->AddButton( $apply ); |
88
|
|
|
|
|
|
|
$btnsz->Realize; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$sz->Add( $nb, 1, wxGROW ); |
91
|
|
|
|
|
|
|
$sz->Add( $btnsz, 0, wxGROW ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$self->SetSizerAndFit( $sz ); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
EVT_CLOSE( $self, |
96
|
|
|
|
|
|
|
sub { |
97
|
|
|
|
|
|
|
undef $_->{view} foreach @$configurations; |
98
|
|
|
|
|
|
|
$self->Destroy; |
99
|
|
|
|
|
|
|
} ); |
100
|
|
|
|
|
|
|
EVT_BUTTON( $self, $ok, sub { |
101
|
|
|
|
|
|
|
$self->apply_configuration( $cm ); |
102
|
|
|
|
|
|
|
$self->Close; |
103
|
|
|
|
|
|
|
} ); |
104
|
|
|
|
|
|
|
EVT_BUTTON( $self, $apply, sub { |
105
|
|
|
|
|
|
|
$self->apply_configuration( $cm ); |
106
|
|
|
|
|
|
|
} ); |
107
|
|
|
|
|
|
|
EVT_BUTTON( $self, $cancel, sub { |
108
|
|
|
|
|
|
|
$self->Close; |
109
|
|
|
|
|
|
|
} ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
return $self; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub apply_configuration { |
115
|
|
|
|
|
|
|
my( $self, $cm ) = @_; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $configurations = $cm->_configurations; |
118
|
|
|
|
|
|
|
my $sm = $cm->service_manager; |
119
|
|
|
|
|
|
|
foreach my $configuration ( @$configurations ) { |
120
|
|
|
|
|
|
|
$configuration->{view}->retrieve_data; |
121
|
|
|
|
|
|
|
$configuration->{configurable} |
122
|
|
|
|
|
|
|
->set_configuration( $sm, $configuration->{view}->attributes ); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |