c75fe08535a041382870ea913a5ef27378d20e4a
[potlatch2.git] / net / systemeD / potlatch2 / dialogs / OptionsDialog.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <s:TitleWindow
3         xmlns:fx="http://ns.adobe.com/mxml/2009"
4         xmlns:mx="library://ns.adobe.com/flex/mx"
5         xmlns:s="library://ns.adobe.com/flex/spark"
6         title="Options"
7         width="350" height="250">
8
9     <s:layout>
10       <s:VerticalLayout
11           paddingLeft="5" paddingRight="5"
12           paddingTop="5" paddingBottom="5" />
13     </s:layout>
14
15         <s:CheckBox width="100%" label="Show toolbox" selected="true" id="tbcheck"
16             change="FlexGlobals.topLevelApplication.toolbox.toggle()" />
17
18         <s:CheckBox width="100%" label="Use custom cursors" selected="true" id="cursorcheck"
19             change="FlexGlobals.topLevelApplication.theController.cursorsEnabled=cursorcheck.selected" />
20
21     <s:CheckBox width="100%" label="Highlight unedited TIGER (US roads)" selected="false" id="tigercheck"
22         change="tigerToggle()" />
23
24         <s:CheckBox width="100%" label="Show mouse latitude/longitude" selected="false" id="latlongcheck"
25                 change="FlexGlobals.topLevelApplication.coordsbox.visible=latlongcheck.selected" />
26
27     <s:CheckBox width="100%" label="Show licence status" selected="false" id="licencecheck"
28         change="licenceToggle()" />
29
30         <s:HGroup width="100%" verticalAlign="middle">
31       <s:Label text="Simplify accuracy: "/>
32       <mx:HSlider id="simplifyslider"
33                 minimum="1" maximum="5"
34                 dataTipPlacement="top" tickColor="black" labels="[High,Low]"
35                 snapInterval="1" tickInterval="1"
36                 allowTrackClick="true" liveDragging="true"
37                 change="simplifySet();"/>
38         </s:HGroup>
39
40     <s:controlBarContent>
41       <s:Button id="ok" label="OK" click="PopUpManager.removePopUp(this);" styleName="titleWindowButton" />
42     </s:controlBarContent>
43
44     <s:controlBarLayout>
45       <s:HorizontalLayout horizontalAlign="right"
46           paddingLeft="5" paddingRight="5"
47           paddingTop="5" paddingBottom="5" />
48     </s:controlBarLayout>
49
50   <fx:Script><![CDATA[
51     import mx.managers.PopUpManager;
52     import mx.events.CloseEvent;
53     import mx.core.Application;
54     import mx.core.FlexGlobals;
55     import net.systemeD.halcyon.Globals;
56     import net.systemeD.halcyon.Map;
57     import net.systemeD.halcyon.connection.Connection;
58     import net.systemeD.halcyon.connection.StatusFetcher;
59
60         private var userState:SharedObject=SharedObject.getLocal("user_state","/");
61     
62     public function init():void {
63         PopUpManager.addPopUp(this, Application(FlexGlobals.topLevelApplication), true);
64         PopUpManager.centerPopUp(this);
65         this.addEventListener(CloseEvent.CLOSE, optionsDialog_close);
66
67         tbcheck.selected = FlexGlobals.topLevelApplication.toolbox.visible;
68         cursorcheck.selected = FlexGlobals.topLevelApplication.theController.cursorsEnabled;
69         tigercheck.selected = userState.data['tiger_highlighted'];
70         latlongcheck.selected = FlexGlobals.topLevelApplication.coordsbox.visible;
71                 licencecheck.selected = Map(Globals.vars.root).editableLayer.connection.statusFetcher!=null;
72                 simplifyslider.value = userState.data['simplify_tolerance'] ? userState.data['simplify_tolerance']/0.00001 : 5;
73     }
74     
75     private function optionsDialog_close(evt:CloseEvent):void {
76         PopUpManager.removePopUp(this);
77     }
78
79     private function tigerToggle():void {
80         Globals.vars.highlightTiger = tigercheck.selected;
81         FlexGlobals.topLevelApplication.theMap.redraw();
82
83         userState.setProperty("tiger_highlighted",tigercheck.selected);
84         userState.flush();
85     }
86
87         private function simplifySet():void {
88         userState.setProperty("simplify_tolerance",simplifyslider.value*0.00001);
89         userState.flush();
90         }
91
92         private function licenceToggle():void {
93                 // ** FIXME: this is an inelegant patch for the short-term issue of highlighting licensing status
94                 var conn:Connection=Map(Globals.vars.root).editableLayer.connection;
95                 if (conn.statusFetcher) {
96                         conn.statusFetcher=null;
97                         userState.setProperty("licence_status",false);
98                 } else {
99                         conn.statusFetcher=new StatusFetcher("http://wtfe.gryph.de/api/0.6/problems",conn);
100                         conn.statusFetcher.fetch(conn.getAllLoadedEntities());
101                         userState.setProperty("licence_status",true);
102                         // ** FIXME: needs to also switch map style
103                 }
104         }
105         
106               ]]>
107   </fx:Script>
108 </s:TitleWindow>