From 5b03338ff3e41e43a328b60c89a2c6f853c4fe56 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Sat, 5 Sep 2015 12:34:37 +0200 Subject: Fixed factories initialization --- lib/ManaTools/Shared/GUI/Dialog.pm | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/ManaTools/Shared/GUI/Dialog.pm b/lib/ManaTools/Shared/GUI/Dialog.pm index 7650507f..e5a0a884 100644 --- a/lib/ManaTools/Shared/GUI/Dialog.pm +++ b/lib/ManaTools/Shared/GUI/Dialog.pm @@ -114,25 +114,43 @@ has 'module' => ( ); has 'factory' => ( - is => 'rw', + is => 'ro', isa => 'Maybe[yui::YWidgetFactory]', lazy => 1, init_arg => undef, default => sub { - return undef; + return yui::YUI::widgetFactory; }, ); has 'optFactory' => ( - is => 'rw', + is => 'ro', isa => 'Maybe[yui::YOptionalWidgetFactory]', lazy => 1, init_arg => undef, default => sub { - return undef; + return yui::YUI::optionalWidgetFactory; }, ); +has 'mgaExternalFactory' => ( + is => 'ro', + isa => 'Maybe[yui::YMGAWidgetFactory]', + lazy => 1, + init_arg => undef, + builder => '_MGAFactoryInitialize' +); + +sub _MGAFactoryInitialize { + my $self = shift(); + + $self->factory(); # just to be sure default factory is initialized first + + my $mageiaPlugin = "mga"; + my $mgaFactory = yui::YExternalWidgets::externalWidgetFactory($mageiaPlugin); + return yui::YMGAWidgetFactory::getYMGAWidgetFactory($mgaFactory); +} + has 'dialog' => ( is => 'rw', isa => 'Maybe[yui::YDialog]', @@ -386,9 +404,6 @@ sub call { ## set icon if not already set by external launcher yui::YUI::app()->setApplicationIcon($self->icon()); - $self->factory(yui::YUI::widgetFactory); - $self->optFactory(yui::YUI::optionalWidgetFactory); - ## required fields die "required widgets missing from YOptionalFactory" if (!$self->checkFields()); -- cgit v1.2.1