Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
public class DisplayEmployeePopUpCommand extends SimpleCommand { override public function execute(notification:INotification):void { //get the mediator of the component I want to display, or instantiate it if (!facade.hasMediator(DisplayEmployeePopUpMediator.NAME)) { //I create the actual viewComponent inside DisplayEmployeePopUpMediator facade.registerMediator(new DisplayEmployeePopUpMediator()); } var viewComponent:Object = facade.retriveMediator(DisplayEmployeePopUpMediator.NAME).viewComponent; sendNotification(ApplicationConstants.SHOW_POPUP, viewComponent); //any other necessary business logic can be handled by this command. }}
public class AddPopUpCommand extends SimpleCommand { public function AddPopUpCommand() { super(); } override public function execute(notification:INotification):void { var popUp:UIComponent = UIComponent(notification.getBody()); var mainViewMediator:IMediator = facade.retrieveMediator(MainViewMediator.NAME); var mainView:UIComponent = UIComponent(mainViewMediator.getViewComponent()); if (popUp.parent == mainView.systemManager) { PopUpManager.bringToFront(popUp); } else { PopUpManager.addPopUp(popUp, mainView); } PopUpManager.centerPopUp(popUp); } }
public class RemovePopUpCommand extends SimpleCommand { public function RemovePopUpCommand() { super(); } override public function execute(notification:INotification):void { var popUp:UIComponent = UIComponent(notification.getBody()); var mainViewMediator:IMediator = facade.retrieveMediator(MainViewMediator.NAME); var mainView:UIComponent = UIComponent(mainViewMediator.getViewComponent()); if (popUp.parent == mainView.systemManager) { PopUpManager.removePopUp(popUp); } } }
public class ShowMyPopUpCommand extends SimpleCommand { public function ShowMyPopUpCommand() { super(); } override public function execute(notification:INotification):void { //frequently changing business logic goes here... //most people can get by without defering Proxy and Mediator instantiation like this... if (!facade.hasProxy(MyPopUpDataProxy.NAME)) { facade.registerProxy(new MyPopUpDataProxy()); } if (!facade.hasMediator(MyPopUpMediator.NAME)) { facade.registerMediator(new MyPopUpMediator()); } var myPopUpMediator:IMediator = facade.retrieveMediator(MyPopUpMediator.NAME); sendNotification(ApplicationConstants.SHOW_POP_UP, myPopUpMediator.getViewComponent()); //this can also be in the Mediator's onRegister() method } }