hackedteam/rcs-console

View on GitHub
src/it/ht/rcs/console/monitor/view/MonitorActionBar.mxml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<actionbar:ActionBar 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:actionbar="it.ht.rcs.console.main.actionbar.*">
  
  <s:Button label="{R.get('DELETE')}" enabled="{Console.currentSession.user.is_sys() &amp;&amp; selectedObject != null}" click="onDelete(event)"
            icon="@Embed('/img/NEW/delete_32.png')"/>
  
  <actionbar:Separator/>
  
  <s:Button label="{R.get('ALERTING_GROUP')}" click="onAlertingGroup()" enabled="{Console.currentSession.user.is_admin_users()}"
            icon="@Embed('/img/NEW/alert.png')"/>
  
  <actionbar:Separator/>
  
  <s:Button label.collapsed="{R.get('LICENSE_SHOW')}" label.expanded="{R.get('LICENSE_HIDE')}" click="onLicenseHideShow()"
            icon="@Embed('/img/NEW/certificate.png')"/>
  
  
  <s:Button label="{R.get('LICENSE_UPDATE')}" click="onLicenseUpdate()" enabled="{Console.currentSession.user.is_admin_license()}"
            icon="@Embed('/img/NEW/key.png')"/>

  
  <s:Spacer width="100%"/>
  
  <s:TextInput id="searchInput" keyUp="onKeyUp(event)"/>
  
  <actionbar:states>
    
    <s:State name="collapsed"/>
    <s:State name="expanded"/>
    
  </actionbar:states>
  
  <fx:Script>
    <![CDATA[
      import flash.net.dns.AAAARecord;
      
      import it.ht.rcs.console.monitor.controller.LicenseManager;
      import it.ht.rcs.console.monitor.controller.MonitorManager;
      import it.ht.rcs.console.utils.AlertPopUp;
      
      import locale.R;
      
      import mx.controls.Alert;
      import mx.managers.PopUpManager;
      
      private var fileReference:FileReference;
      private var progressAlert:Alert;
      
      private function onAlertingGroup():void
      {
        PopUpManager.centerPopUp(PopUpManager.createPopUp(root, AlertingGroup, true));
      }
      
      private function onLicenseUpdate():void
      {
        trace("updating license");
        browse()
      }
      
      private function browse():void
      {
       
        fileReference = new FileReference();
        fileReference.addEventListener(Event.SELECT, fileSelection);
        fileReference.browse([new FileFilter("RCS License", "*.lic")])
      }
      
      private function fileSelection(event:Event):void
      {
        trace("file selected");
        LicenseManager.instance.updateLicense(fileReference,onLicenseSuccess,onLicenseError,onLicenseProgress);
      }
      
      private function onKeyUp(event:KeyboardEvent):void
      {
        if (view) view.refresh();
      }
      
      protected function onDelete(event:MouseEvent):void
      {
        MonitorManager.instance.removeItem(selectedObject);
      }
      
      private function onLicenseProgress(e:ProgressEvent):void
      {
        trace("license update in progress");
      }
      
      private function onLicenseSuccess(e:Event):void
      {
        LicenseManager.instance.refresh();
        PopUpManager.removePopUp(progressAlert)
        AlertPopUp.show(R.get('LICENSE_UPDATE_SUCCESS'));
        
      }
      
      private function onLicenseError(e:*):void
      {
        AlertPopUp.show(R.get('LICENSE_UPDATE_FAILED'));
      }
      
      private function onLicenseHideShow():void
      {
      if(currentState=="collapsed")
        currentState="expanded"
      else if(currentState=="expanded")
        currentState="collapsed"
      }
      
    ]]>
  </fx:Script>
  
</actionbar:ActionBar>