| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package com.imt.intimamedia.commands.initialization
- {
- import com.adobe.cairngorm.control.CairngormEvent;
- import com.imt.flex.cairngormExtended.command.SuperCommand;
- import com.imt.intimamedia.business.InitializationDelegate;
- import com.imt.intimamedia.model.ApplicationModelLocator;
- import com.imt.intimamedia.views.common.ImtToaster;
- import com.imt.intimamedia.vo.GenericObject;
-
- import mx.collections.ArrayCollection;
- import mx.collections.Sort;
- import mx.collections.SortField;
- import mx.resources.ResourceManager;
- import mx.rpc.events.FaultEvent;
- import mx.rpc.events.ResultEvent;
- import mx.utils.ObjectUtil;
-
- /**
- * Commande de récupération des ethnies
- */
- public class GetEthnicCommand extends SuperCommand
- {
- [Bindable]
- private var _model : ApplicationModelLocator = ApplicationModelLocator.getInstance();
- /**
- * Execution de la commande
- *
- * @param event Evénement de type CairngormEvent
- * @return void
- */
- override public function execute( event : CairngormEvent ) : void
- {
- super.execute( event );
-
- var delegate : InitializationDelegate = new InitializationDelegate( this );
- delegate.getEthnic();
- }
-
- /**
- * Résultat de la commande
- *
- * @param result Un objet
- * @return void
- */
- override public function result( result : Object ) : void
- {
- super.result( result );
-
- var resultEvent : ResultEvent = ResultEvent( result );
- var ethnic : ArrayCollection = new ArrayCollection();
-
- for each( var code : String in (resultEvent.result as Array) )
- {
- var item : GenericObject = new GenericObject();
-
- item.code = code
- item.label = ResourceManager.getInstance().getString( "ethnic", code );
-
- ethnic.addItem( item );
- }
-
- _model.ethnic = ObjectUtil.copy( ethnic ) as ArrayCollection;
-
- var dataSortField : SortField = new SortField();
- dataSortField.name = "label";
- dataSortField.numeric = false;
-
- var sort : Sort = new Sort();
- sort.fields = [ dataSortField ];
-
- _model.ethnic.sort = sort;
- _model.ethnic.refresh();
- }
-
- /**
- * Résultat de la commande
- *
- * @param result Un objet
- * @return void
- */
- override public function fault( fault : Object ) : void
- {
- super.fault( fault );
-
- var toastMessage : ImtToaster = new ImtToaster();
-
- toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'error.title');
- toastMessage.message = ResourceManager.getInstance().getString('labels', 'error.questions') + " (" + ResourceManager.getInstance().getString('errors', ( fault as FaultEvent ).fault.faultString) +")";
- toastMessage.level = ImtToaster.ERROR;
-
- _model.toaster.toast( toastMessage );
- }
- }
- }
|