1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
height="100%" xmlns:local="*"
creationComplete="init(event)"
backgroundColor="white"
paddingTop="3"
paddingBottom="3"
>
<mx:Script>
<![CDATA[
import mx.binding.utils.BindingUtils;
import mx.messaging.MessageAgent;
import mx.messaging.config.ConfigMap;
import mx.collections.ArrayCollection;
import mx.controls.List;
import mx.controls.listClasses.BaseListData;
import mx.core.Application;
import mx.events.FlexEvent;
import mx.core.UIComponent;
import mx.containers.ControlBar;
import mx.managers.DragManager;
import mx.events.DragEvent;
import mx.controls.Alert;
import mx.events.CloseEvent;
public function get timeElements():Object {
return (MyGolfPrototype) (this.parentDocument).timeElements;
}
public function getMinuteIndex(dt:Date):int {
return dt.minutes;
}
public function getHourIndex(dt:Date):int {
return dt.hours;
}
public function getDelayIndex(dataProvider:Object, d:int):int {
var list:ArrayCollection = (ArrayCollection) (dataProvider);
for (var x:int = 0; x < list.length; x++) {
if ((int) (list[x]) == d) {
return x;
}
}
return -1;
}
static private var s:ArrayCollection = null;
public function init(event:Event):void {
var mgp:MyGolfPrototype = (MyGolfPrototype) (this.parentDocument);
var f:Function = function() {
cmbHrsTo.dataProvider = cmbHrsFrom.dataProvider = timeElements.listHours;
cmbMinTo.dataProvider = cmbMinFrom.dataProvider = timeElements.listMinutes;
cmbHrsFrom.selectedIndex = getHourIndex(data.startTime);
cmbMinFrom.selectedIndex = getMinuteIndex(data.startTime);
cmbHrsTo.selectedIndex = getHourIndex(data.endTime);
cmbMinTo.selectedIndex = getMinuteIndex(data.endTime);
TreeId.allowMultipleSelection = true;
TreeId.dataProvider = data.provider;
TreeId.height = computeHeight(TreeId);
mgp.ctzMan.selectionReinit();
};
if (s == null) {
s = new ArrayCollection();
var fun:Function = function() {
var func:Function = s.removeItemAt(0) as Function;
func.call();
if (s.length >0) {
setTimeout(fun, 1);
}
}
setTimeout(fun, 100);
}
s.addItem(f);
mgp.endOfSplash();
}
public function fDragEnter(event:DragEvent):void {
(MyGolfPrototype) (Application.application).ctzMan.dragEnter(event, this.data.ctzId);
}
public function fDragDrop(event:DragEvent):void {
(MyGolfPrototype) (Application.application).ctzMan.dragDrop(event, this.data.ctzId);
}
public function fDragComplete(event:DragEvent):void {
(MyGolfPrototype) (Application.application).ctzMan.removeHighlight();
}
protected function applyChange(event:Event):void {
var nCtz:CTZElement = new CTZElement();
nCtz.ctzId = this.data.ctzId;
nCtz.delay = (int) (this.cmbDelay.selectedItem);
nCtz.nPlayersPFlight = (int) (this.cmbPlayers.selectedItem);
nCtz.startTime = new Date(this.dfFrom.selectedDate.getTime());
nCtz.startTime.setHours(this.cmbHrsFrom.selectedItem, this.cmbMinFrom.selectedItem, 0, 0);
nCtz.endTime = new Date(this.dfTo.selectedDate.getTime());
nCtz.endTime.setHours(this.cmbHrsTo.selectedItem, this.cmbMinTo.selectedItem, 0, 0);
(MyGolfPrototype) (Application.application).ctzMan.changeCTZ(nCtz);
}
protected function deleteCTZ(event:Event):void {
Alert.show(GolfMessages.ctzDeleteConfirm, "Confirm Timezone removal", Alert.YES | Alert.NO, this , this.AlertEvtHandler_deleteCTZ, null, Alert.YES);
}
protected function AlertEvtHandler_deleteCTZ(eventObj:CloseEvent):void {
if (eventObj.detail == Alert.YES) {
(MyGolfPrototype) (Application.application).ctzMan.removeCTZ(this.data.ctzId);
}
}
protected function flightsModification(number:int, sens:int, move:Boolean):void {
(MyGolfPrototype) (Application.application).ctzMan.flightsModification(this.data.ctzId, number, sens, move);
}
public function flightsAdvancedModification(number:int, fligthNo:int, sens:int):void {
(MyGolfPrototype) (Application.application).ctzMan.flightsAdvancedModification(this.data.ctzId, number, fligthNo, sens);
}
protected function computeHeight(tr:List):int {
return (tr.dataProvider.length + 1) * tr.rowHeight;
}
public function btnEnabledAddEnd():Boolean {
if (data.maxDate == null) return true;
return new Date(data.endTime.getTime() + 60000 * data.delay) <= data.maxDate;
}
public function btnEnabledAddStart():Boolean {
return new Date(data.startTime.getTime() - 60000 * data.delay) >= data.minDate;
}
private var nbItemRendered:int = 0;
public function getColor():int {
return ((nbItemRendered++) / data.nPlayersPFlight) % 2;
}
]]>
</mx:Script>
<mx:VBox width="100%">
<mx:Grid width="100%">
<mx:GridRow width="100%">
<mx:GridItem width="33%">
<mx:Button label="+ flight ↑" click="flightsModification(1, -1, true);" enabled="{btnEnabledAddStart()}" />
</mx:GridItem>
<mx:GridItem width="34%" horizontalAlign="center">
<mx:Button id="btEditCTZ" label="Edit Timezone" click="MyGolfPrototype.fold(vbEditCTZ, 0)" />
</mx:GridItem>
<mx:GridItem width="33%" horizontalAlign="right">
<mx:Button label="- flight ↓" click="flightsModification(-1, -1, true);" />
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
<mx:VBox width="100%" verticalAlign="top" id="vbEditCTZ" height="0" horizontalAlign="center"
>
<mx:VBox
borderColor="#000000"
borderStyle="solid"
paddingBottom = "4"
paddingLeft = "4"
paddingRight = "4"
paddingTop = "4"
>
<mx:HBox horizontalAlign="left">
<mx:Label text="From" width="40" />
<mx:DateField id="dfFrom" selectedDate="{data.startTime}" formatString="DD-MM-YYYY" />
<mx:ComboBox id="cmbHrsFrom" />
<mx:ComboBox id="cmbMinFrom" />
</mx:HBox>
<mx:HBox horizontalAlign="left">
<mx:Label text="To" width="40" />
<mx:DateField id="dfTo" selectedDate="{data.endTime}" formatString="DD-MM-YYYY" />
<mx:ComboBox id="cmbHrsTo" />
<mx:ComboBox id="cmbMinTo" />
</mx:HBox>
<mx:HBox width="100%" horizontalAlign="left">
<mx:Label text="Delay"/>
<mx:ComboBox id="cmbDelay" selectedIndex="{getDelayIndex(cmbDelay.dataProvider, data.delay)}">
<mx:Number>6</mx:Number>
<mx:Number>7</mx:Number>
<mx:Number>8</mx:Number>
<mx:Number>9</mx:Number>
<mx:Number>10</mx:Number>
<mx:Number>11</mx:Number>
<mx:Number>12</mx:Number>
<mx:Number>13</mx:Number>
<mx:Number>14</mx:Number>
<mx:Number>15</mx:Number>
<mx:Number>16</mx:Number>
<mx:Number>17</mx:Number>
<mx:Number>18</mx:Number>
<mx:Number>19</mx:Number>
<mx:Number>20</mx:Number>
</mx:ComboBox>
<mx:HBox width="100%" horizontalAlign="right">
<mx:Label text="Nb Players"/>
<mx:ComboBox id="cmbPlayers" selectedIndex="{getDelayIndex(cmbPlayers.dataProvider, data.nPlayersPFlight)}">
<mx:Number>2</mx:Number>
<mx:Number>3</mx:Number>
<mx:Number>4</mx:Number>
<mx:Number>6</mx:Number>
<mx:Number>8</mx:Number>
</mx:ComboBox>
</mx:HBox>
</mx:HBox>
<mx:HBox width="100%">
<mx:Button id="btnApply" label="Apply" click="applyChange(event)" />
<mx:HBox width="100%" horizontalAlign="right">
<mx:Button id="btnDelete" label="Delete" click="deleteCTZ(event)"/>
</mx:HBox>
</mx:HBox>
</mx:VBox>
</mx:VBox>
<mx:List id="TreeId"
width="100%"
itemRenderer="CTZMemberElement"
rowHeight="22"
selectable="false"
variableRowHeight="false"
paddingTop="0"
paddingBottom="0"
paddingLeft="0"
paddingRight="0"
dragComplete="fDragComplete(event);"
>
</mx:List>
<mx:HBox width="100%">
<mx:Button label="+ flight ↓" click="flightsModification(1, 1, true);" enabled="{btnEnabledAddEnd()}"/>
<mx:HBox horizontalAlign="right" width="100%">
<mx:Button label="- flight ↑" click="flightsModification(-1, 1, true);" />
</mx:HBox>
</mx:HBox>
</mx:VBox>
</mx:VBox> |
Partager