hackedteam/rcs-console

View on GitHub
src/it/ht/rcs/console/operations/view/filetransfer/FileTransferView.mxml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:transfer="it.ht.rcs.console.operations.view.filetransfer.*"
          width="100%" height="100%" addedToStage="onAddedToStage()"
          removedFromStage="onRemovedFromStage()">

  <fx:Script>
    <![CDATA[
      import it.ht.rcs.console.agent.controller.AgentManager;
      import it.ht.rcs.console.events.RefreshEvent;
      import it.ht.rcs.console.operations.view.OperationsSection;
      
      import mx.collections.ArrayCollection;
      import mx.core.FlexGlobals;
      import mx.rpc.events.ResultEvent;
      
      [Bindable]
      public var section:OperationsSection;
      
      private function onAddedToStage():void
      {
        FlexGlobals.topLevelApplication.addEventListener(RefreshEvent.REFRESH, onRefresh);
        onRefresh();
      }
      
      private function onRefresh(e:RefreshEvent=null):void
      {
        uploadActionBar.selectedObject = downloadActionBar.selectedObject = null;
        AgentManager.instance.getDownloads(section.stateManager.selectedAgent, onDownloadsResult);
        AgentManager.instance.getUploads(section.stateManager.selectedAgent, onUploadsResult);
      }
      
      private function onDownloadsResult(e:ResultEvent):void
      {
        downloads.dataProvider = e.result as ArrayCollection;
      }
      
      private function onUploadsResult(e:ResultEvent):void
      {
        uploads.dataProvider = e.result as ArrayCollection;
      }

      private function onRemovedFromStage():void
      {
        FlexGlobals.topLevelApplication.removeEventListener(RefreshEvent.REFRESH, onRefresh);
      }
    ]]>
  </fx:Script>
  
  <transfer:UploadActionBar id="uploadActionBar" section="{section}" selectedObject="{uploads.selectedItem}"/>
  
  <transfer:UploadGrid id="uploads"/>
  
  <transfer:DownloadActionBar id="downloadActionBar" section="{section}" selectedObject="{downloads.selectedItem}"/>
  
  <transfer:DownloadGrid id="downloads"/>

</s:VGroup>