1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:halcyon="net.systemeD.halcyon.*"
5 backgroundColor="white" borderStyle="inset">
7 <mx:HBox horizontalGap="0">
8 <mx:ToggleButtonBar height="100%" dataProvider="{categoryStack}" direction="vertical"/>
9 <mx:ViewStack id="categoryStack" width="100%" height="100%"
10 creationComplete="setSelectedFeature(_selectedType);">
11 <mx:Repeater id="catRep" dataProvider="{MapFeatures.getInstance().getCategoriesForType(limit)}">
12 <mx:VBox label="{catRep.currentItem.name}">
13 <mx:TileList dataProvider="{catRep.currentItem.getFeaturesForType(limit)}"
14 width="100%" height="100%" change="itemSelected(event);"
15 creationComplete="ensureSelection();">
18 <mx:VBox width="100" height="75"
19 horizontalScrollPolicy="off" verticalScrollPolicy="off"
20 horizontalAlign="center" verticalGap="0">
21 <mx:Image source="{data.image}" height="100%" verticalAlign="middle"/>
22 <mx:Text text="{data.name}"/>
32 <!-- mx:Label id="hoverInfo" text="Hover Info goes here"/>-->
35 import net.systemeD.halcyon.connection.*;
36 import net.systemeD.potlatch2.mapfeatures.*;
39 import mx.containers.*;
41 private var settingSelection:Boolean = false;
42 private var _selectedType:Feature;
43 private var _limit:String;
45 [Bindable(event="selectedType")]
46 public function get selectedType():Feature {
50 [Bindable(event="limitChanged")]
51 public function get limit():String {
55 private function itemSelected(event:Event):void {
56 _selectedType = Feature(TileList(event.currentTarget).selectedItem);
57 if ( !settingSelection )
58 dispatchEvent(new Event("selectedType"));
61 public function setLimitTypes(type:String):void {
63 dispatchEvent(new Event("limitChanged"));
67 * Set the selected feature displayed in the selector.
69 * The tab is switched to the first category the feature
73 public function setSelectedFeature(feature:Feature):void {
74 _selectedType = feature;
76 // check whether stack built yet, if not we get called again when it's made
77 if ( categoryStack == null )
80 if ( feature != null ) {
81 var primaryCategory:Category = feature.findFirstCategory();
83 // set the tab to the selected item's category
84 var index:int = MapFeatures.getInstance().getCategoriesForType(limit).indexOf(primaryCategory);
85 categoryStack.selectedIndex = index;
88 // finalise the item selection
93 * Sets the selected feature on each category page to the current
94 * value of _selectedType. If there is no selected feature then all
95 * panels selection will be blanked.
97 * This function does not change the selected category tab.
99 * Called both from setSelectedFeature, and category tab completion
100 * (so that newly created tabs work as expected)
102 private function ensureSelection():void {
103 settingSelection = true;
104 for (var i:Number = 0; i < categoryStack.numChildren; i++) {
105 var box:Box = Box(categoryStack.getChildAt(i));
106 if ( box == null || box.numChildren == 0 )
108 var tileList:TileList = TileList(box.getChildAt(0));
109 var category:Category = Category(tileList.getRepeaterItem());
110 var selected:Boolean = false;
111 for each( var catFeature:Feature in category.features ) {
112 if ( catFeature == _selectedType ) {
113 tileList.selectedItem = _selectedType;
118 tileList.selectedItem = null;
120 settingSelection = false;