-Delay exit until DB closed
git-svn-id: https://svn.apache.org/repos/asf/flex/whiteboard@1448561 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/infrastructure/command/ExitUICommand.as b/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/infrastructure/command/ExitUICommand.as
index 502fb84..241ce09 100644
--- a/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/infrastructure/command/ExitUICommand.as
+++ b/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/infrastructure/command/ExitUICommand.as
@@ -1,6 +1,7 @@
package org.apache.flex.utilities.developerToolSuite.infrastructure.command {
import flash.data.SQLResult;
import flash.errors.SQLError;
+ import flash.events.SQLEvent;
import mx.utils.ObjectUtil;
@@ -13,6 +14,7 @@
public class ExitUICommand extends AbstractDBCommand {
private var _msg:RequestExitApplicationMessage;
+ private var _terminateCommand:Function;
public function execute(msg:RequestExitApplicationMessage):void {
log.debug("Executing Command with message: " + ObjectUtil.toString(msg));
@@ -32,10 +34,12 @@
override protected function result(result:SQLResult, terminateCommand:Boolean = true):void {
super.result(result, false);
- dispatch(new ApplicationExitReadyMessage());
+ db.addEventListener(SQLEvent.CLOSE, onDBClosed);
if (terminateCommand) {
- callback(new CommandCallBackResult(result));
+ _terminateCommand = function ():void {
+ callback(new CommandCallBackResult(result));
+ }
}
}
@@ -48,5 +52,13 @@
callback(new CommandCallBackError(error.message, error.detailID));
}
}
+
+ private function onDBClosed(event:SQLEvent):void {
+ dispatch(new ApplicationExitReadyMessage());
+
+ if (_terminateCommand) {
+ _terminateCommand();
+ }
+ }
}
}
diff --git a/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/application/database/ApplicationDB.as b/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/application/database/ApplicationDB.as
index 1a5ba51..7de7fa0 100644
--- a/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/application/database/ApplicationDB.as
+++ b/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/application/database/ApplicationDB.as
@@ -19,6 +19,7 @@
import flash.data.SQLResult;
import flash.data.SQLStatement;
import flash.errors.SQLError;
+ import flash.events.EventDispatcher;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.File;
@@ -29,7 +30,7 @@
import org.apache.flex.utilities.developerToolSuite.executor.application.util.LogUtil;
- public class ApplicationDB {
+ public class ApplicationDB extends EventDispatcher{
public static const DB_VERSION:uint = 1;
@@ -82,6 +83,7 @@
protected function closedHandler(event:SQLEvent):void {
LOG.debug("the database was closed successfully");
+ dispatchEvent(event);
}
protected function errorHandler(event:SQLErrorEvent):void {
@@ -100,7 +102,7 @@
}
private function result(result:SQLResult):void {
- _isBusy = false
+ _isBusy = false;
if (_resultCallback) {
_resultCallback(result);
_resultCallback = null;
@@ -127,13 +129,5 @@
}
}
}
-
- public function get isReady():Boolean {
- return _isReady;
- }
-
- public function get isBusy():Boolean {
- return _isBusy;
- }
}
}
diff --git a/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractDBCommand.as b/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractDBCommand.as
index 1ecfdf9..21dcec3 100644
--- a/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractDBCommand.as
+++ b/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractDBCommand.as
@@ -27,7 +27,7 @@
public class AbstractDBCommand {
- protected var log:ILogger = LogUtil.getLogger(this);
+ protected var log:ILogger;
[MessageDispatcher]
public var dispatch:Function;
@@ -40,6 +40,10 @@
protected var sql:String;
protected var stmt:SQLStatement = new SQLStatement();
+ function AbstractDBCommand():void {
+ log = LogUtil.getLogger(this);
+ }
+
protected function executeAsync():void {
db.connect(prepareSql);
}