Skip to content

Commit

Permalink
geojson editor now fills name and keytype fields when opening a file
Browse files Browse the repository at this point in the history
Change-Id: I3ed30bc8c60b739b65f8a036ec1ea0ea3597dae5
  • Loading branch information
adufilie committed Sep 14, 2014
1 parent 7c8d314 commit 3133914
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion WeaveUI/src/weave/editors/CSVDataSourceEditor.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
{
try
{
if(_fileLoader == null)
if (_fileLoader == null)
{
_fileLoader = new FileReference();
_fileLoader.addEventListener(Event.SELECT, csvFileSelectedHandler);
Expand Down
34 changes: 22 additions & 12 deletions WeaveUI/src/weave/editors/GeoJSONDataSourceEditor.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -156,30 +156,40 @@
return target;
}
private function openFile(target:TextInputWithPrompt, ...fileFilters):void
private function openFile(textInput:TextInputWithPrompt, ...fileFilters):void
{
try
{
var _fileLoader:FileReference = new FileReference();
_fileLoader.addEventListener(Event.SELECT, function(event:Event):void{
var file:FileReference = new FileReference();
file.addEventListener(Event.SELECT, function(event:Event):void{
busyIndicator.visible = true;
_fileLoader.load();
WeaveAPI.ProgressIndicator.addTask(_fileLoader);
file.load();
WeaveAPI.ProgressIndicator.addTask(file);
});
_fileLoader.addEventListener(ProgressEvent.PROGRESS, function(event:ProgressEvent):void{
WeaveAPI.ProgressIndicator.updateTask(_fileLoader, event.bytesLoaded / event.bytesTotal);
file.addEventListener(ProgressEvent.PROGRESS, function(event:ProgressEvent):void{
WeaveAPI.ProgressIndicator.updateTask(file, event.bytesLoaded / event.bytesTotal);
});
_fileLoader.addEventListener(Event.COMPLETE, function(event:Event):void{
target.text = WeaveAPI.URLRequestUtils.saveLocalFile(_fileLoader.name, _fileLoader.data);
file.addEventListener(Event.COMPLETE, function(event:Event):void{
if (sourceName.editable)
{
var nameEqualsKeyType:Boolean = sourceName.text == keyTypeSelector.selectedKeyType;
sourceName.text = file.name;
if (nameEqualsKeyType)
{
keyTypeSelector.addKeyTypeToMenu(file.name);
keyTypeSelector.selectedKeyType = file.name;
}
}
textInput.text = WeaveAPI.URLRequestUtils.saveLocalFile(file.name, file.data);
busyIndicator.visible = false;
WeaveAPI.ProgressIndicator.removeTask(_fileLoader);
WeaveAPI.ProgressIndicator.removeTask(file);
});
_fileLoader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void{
file.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void{
busyIndicator.visible = false;
reportError(event);
});
_fileLoader.browse(fileFilters);
file.browse(fileFilters);
}
catch (e:Error)
{
Expand Down

0 comments on commit 3133914

Please sign in to comment.