src/it/ht/rcs/console/system/view/nia/NIA.mxml
<?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:nia="it.ht.rcs.console.system.view.nia.*"
width="100%"
height="100%"
addedToStage="onAddedToStage()"
creationComplete="init()"
removedFromStage="onRemovedFromStage()">
<fx:Script>
<![CDATA[
import com.greensock.TweenMax;
import it.ht.rcs.console.network.controller.InjectorManager;
import it.ht.rcs.console.network.model.Injector;
import it.ht.rcs.console.network.model.InjectorRule;
import mx.collections.ListCollectionView;
import spark.events.GridSelectionEvent;
import spark.events.IndexChangeEvent;
[Bindable]
private var view:ListCollectionView;
private function init():void
{
view=InjectorManager.instance.getView(null, searchFilterFunction);
}
private function onAddedToStage():void
{
InjectorManager.instance.listenRefresh();
}
private function onRemovedFromStage():void
{
InjectorManager.instance.unlistenRefresh();
}
private function searchFilterFunction(item:Object):Boolean
{
try
{
return item.name.toLowerCase().indexOf(actionBar.searchInput.text.toLowerCase()) != -1;
}
catch (e:Error)
{
}
return true;
}
private function nias_changeHandler(event:IndexChangeEvent):void
{
rulesActionBar.selectedInjector=nias.selectedItem;
rulesActionBar.selectedRule=null;
onRulesShow()
}
private function onRulesShow():void
{
trace("show effect ")
rulesBox.percentHeight=1;
TweenMax.to(rulesBox, 0.4, {percentHeight: 100})
}
private function onRulesHide():void
{
trace("hide effect ")
}
]]>
</fx:Script>
<mx:VBox id="niasBox"
width="100%"
height="100%">
<nia:NIAActionBar id="actionBar"
selectedObject="{nias.selectedItem}"
view="{view}"/>
<nia:NIAList id="nias"
dataProvider="{view}"
change="nias_changeHandler(event)"/>
</mx:VBox>
<mx:VBox id="rulesBox"
visible="{nias.selectedItem!=null}"
includeInLayout="{nias.selectedItem!=null}"
width="100%"
height="100%"
show="onRulesShow()"
hide="onRulesHide()">
<nia:RulesActionBar id="rulesActionBar"
selectedInjector="{nias.selectedItem as Injector}"
selectedRule="{rules.selectedItem as InjectorRule}"/>
<nia:RulesGrid id="rules"
dataProvider="{Console.currentSession.user.is_tech_ni_rules() ? nias.selectedItem.rules : null}"/>
</mx:VBox>
</s:VGroup>