src/it/ht/rcs/console/entities/view/EntitiesSection.mxml
<?xml version="1.0" encoding="utf-8"?>
<main:Section 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:main="it.ht.rcs.console.main.*"
xmlns:operations="it.ht.rcs.console.entities.view.operations.*"
creationComplete="init()" xmlns:view="it.ht.rcs.console.entities.view.*"
>
<fx:Script>
<![CDATA[
import it.ht.rcs.console.entities.controller.EntityManager;
import it.ht.rcs.console.events.SectionEvent;
import it.ht.rcs.console.operation.controller.OperationManager;
import it.ht.rcs.console.operations.view.OperationsSectionStateManager;
[Bindable]
public var stateManager:EntitiesSectionStateManager;
private var eventToManage:SectionEvent = null;
public var linkToHighLight:Object={from:'',to:''};
public var nodeToHighLight:Object;
private function init():void
{
stateManager = new EntitiesSectionStateManager(this);
EntityManager.instance.addEventListener("destroy", onDestroy);
if (eventToManage)
stateManager.manageItemSelection(null, eventToManage);
else
stateManager.setState('allOperations');
}
private function onDestroy(e:Event):void
{
stateManager.setState('singleOperation');
}
private function onUpdate():void
{
entitySheet.entity.name=actionBar.entity.name;
entitySheet.entity.desc=actionBar.entity.desc;
entitySheet.entity.position=actionBar.entity.position;
entitySheet.entity.position_attr=actionBar.entity.position_attr;
entitySheet.drawPosition()
}
public function changeSection(event:SectionEvent):void
{
if (!event.item) return;
if (stateManager)
{
currentState = 'none';
stateManager.setState('none');
}
// This method is called before init if we never entered the operation section,
// so we check if stateManager is present, otherwise we delay the item selection
if (stateManager)
stateManager.manageItemSelection(null, event);
else
eventToManage = event;
}
protected function onEdit():void
{
entitySheet.onEdit()
}
protected function onPopupClose():void
{
entitySheet.onPopupClose()
}
]]>
</fx:Script>
<main:states>
<s:State name="none"/>
<s:State name="allOperations"/>
<s:State name="singleOperation"/>
<s:State name="allEntities"/>
<s:State name="singleEntity"/>
<s:State name="links"/>
<s:State name="map"/>
</main:states>
<main:layout>
<s:VerticalLayout paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5" gap="2"/>
</main:layout>
<view:Breadcrumb section="{this}"/>
<operations:OperationsEntityView includeIn="allOperations" section="{this}"/>
<view:EntitiesView includeIn="singleOperation, allEntities" section="{this}" id="view"/>
<view:EntityActionBar includeIn="singleEntity" entity="{stateManager.selectedEntity}" sheet="{entitySheet}" update="onUpdate()" id="actionBar" section="{this}" edit="onEdit()" popupclose="onPopupClose()"/>
<view:EntitySheet includeIn="singleEntity" entity="{stateManager.selectedEntity}" id="entitySheet" update="onUpdate()" section="{this}"/>
<!--<view:LinkView includeIn="links" entities="{stateManager.selectedEntities}" section="{this}"/>
<view:GeoMapView includeIn="map" entities="{stateManager.selectedEntities}" section="{this}"/>-->
</main:Section>