1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
5 horizontalAlign="center" title="Save Changes"
6 width="350" height="330" verticalGap="0">
8 <mx:ArrayCollection id="changesetTags">
9 <mx:Object k="created_by" v="Potlatch 2"/>
10 <mx:Object k="version" v="{Application.application.version}"/>
11 <mx:Object k="comment" v=""/>
14 <mx:ViewStack id="processSequence" width="100%" height="100%">
16 <!-- section for entering tags -->
17 <mx:VBox width="100%" height="100%" verticalGap="0">
18 <mx:ViewStack id="tagStack" width="100%" height="100%">
19 <mx:VBox width="100%" height="100%" label="Simple">
20 <mx:Text width="100%">
22 Please enter a description of your edits. This will be used to give other
23 mappers an idea of what changes you are making.
26 <mx:Label text="Comment:"/>
27 <mx:TextArea id="comment" width="100%" height="100%" change="commentChanged(event);" />
30 <mx:VBox width="100%" height="100%" label="Advanced">
31 <mx:Label text="Changeset tags:"/>
32 <mx:DataGrid editable="true" width="100%" id="advancedTagGrid"
33 dataProvider="{changesetTags}">
35 <mx:DataGridColumn editable="true" dataField="k" headerText="Key"/>
36 <mx:DataGridColumn editable="true" dataField="v" headerText="Value"/>
39 <mx:HBox horizontalAlign="right" width="100%">
40 <mx:LinkButton label="Delete" click="removeTag()" enabled="{advancedTagGrid.selectedItem != null? true : false}"/>
41 <mx:LinkButton label="Add" click="addNewTag()"/>
43 <mx:HRule width="100%" />
46 <mx:LinkBar dataProvider="{tagStack}"/>
49 <mx:VBox width="100%" height="100%" id="createChangesetTab">
50 <mx:VBox width="100%" height="100%" id="infoBox"/>
51 <mx:Spacer height="100%"/>
52 <mx:ProgressBar label="Creating changeset" labelPlacement="bottom" width="100%"
53 indeterminate="true" id="saveProgress"/>
56 <mx:VBox width="100%" height="100%" id="failureTab">
57 <mx:Text width="100%" styleName="failText" text="{failureText}"/>
60 <mx:VBox width="100%" height="100%" id="successTab">
61 <mx:Text width="100%">
62 <mx:htmlText><![CDATA[<b>All data uploaded!</b>]]></mx:htmlText>
68 <mx:Spacer width="100%"/>
69 <mx:Button id="cancelButton" label="Cancel" click="close();"/>
70 <mx:Button id="saveButton" label="Save >" click="startSave();"/>
76 import mx.managers.PopUpManager;
77 import mx.core.Application;
79 import net.systemeD.halcyon.connection.*;
81 private var conn:Connection = Connection.getConnectionInstance();
84 private var failureText:String = "";
86 private function commentChanged(event:Event):void {
87 for (var i:int=changesetTags.length-1; i>0; i--) {
88 if (changesetTags[i]['k']=='comment') { changesetTags.removeItemAt(i); }
90 changesetTags.addItem( { k:'comment', v: event.target.text } );
93 private function addNewTag():void {
94 changesetTags.addItem( { k:'(new key)', v:'(new value)' } );
95 advancedTagGrid.editedItemPosition = { rowIndex: changesetTags.length-1, columnIndex: 0 };
98 private function removeTag():void {
99 changesetTags.removeItemAt(advancedTagGrid.selectedIndex);
102 private function startSave():void {
104 // move to next sequence
105 processSequence.selectedChild = createChangesetTab;
106 saveButton.enabled = false;
108 var tags:Object = new Object();
109 for each (var tag:Object in changesetTags) {
110 tags[tag['k']] = tag['v'];
114 conn.addEventListener(Connection.NEW_CHANGESET, changesetCreated);
115 conn.addEventListener(Connection.NEW_CHANGESET_ERROR, changesetError);
116 conn.createChangeset(tags);
119 private function changesetCreated(event:EntityEvent):void {
120 var changeset:Changeset = conn.getActiveChangeset();
121 addStatus("Changeset created (id: "+changeset.id+")");
123 saveProgress.label = "Uploading changes";
124 conn.addEventListener(Connection.SAVE_COMPLETED, saveCompleted);
125 conn.uploadChanges();
128 private function changesetError(event:Event):void {
129 fail("Error creating changeset");
132 private function saveCompleted(event:SaveCompleteEvent):void {
134 succeed("All Data Saved!");
136 fail("Failure when uploading data");
138 saveButton.parent.removeChild(saveButton);
139 cancelButton.label = "Close";
142 private function addStatus(text:String):void {
143 var label:Text = new Text();
146 infoBox.addChild(label);
149 private function succeed(text:String):void {
150 processSequence.selectedChild = successTab;
153 private function fail(text:String):void {
154 processSequence.selectedChild = failureTab;
158 private function close():void {
159 conn.removeEventListener(Connection.NEW_CHANGESET, changesetCreated);
160 conn.removeEventListener(Connection.NEW_CHANGESET_ERROR, changesetError);
161 conn.removeEventListener(Connection.SAVE_COMPLETED, saveCompleted);
162 PopUpManager.removePopUp(this);