Return-Path: X-Original-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0BC84E09C for ; Thu, 6 Dec 2012 07:19:27 +0000 (UTC) Received: (qmail 38734 invoked by uid 500); 6 Dec 2012 07:19:26 -0000 Delivered-To: apmail-incubator-flex-commits-archive@incubator.apache.org Received: (qmail 38496 invoked by uid 500); 6 Dec 2012 07:19:24 -0000 Mailing-List: contact flex-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-commits@incubator.apache.org Received: (qmail 38443 invoked by uid 99); 6 Dec 2012 07:19:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 07:19:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 07:19:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9E0E62388906; Thu, 6 Dec 2012 07:18:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1417750 - in /incubator/flex/whiteboard/fthomas/developerToolSuite/trunk: org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/behavior/settingsPanel/ org.apache... Date: Thu, 06 Dec 2012 07:18:51 -0000 To: flex-commits@incubator.apache.org From: fthomas@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121206071852.9E0E62388906@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fthomas Date: Thu Dec 6 07:18:48 2012 New Revision: 1417750 URL: http://svn.apache.org/viewvc?rev=1417750&view=rev Log: - The tools validate process now check the Java, Ant and Maven versions installed on windows, mac and linux computer (still have to test for the 2 lasts but it's well prepared at least). - Remove the mx.rpc.Responder usage going thru binding Added: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeShellHelper.as - copied, changed from r1417721, incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeProcessHelper.as Removed: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/behavior/settingsPanel/ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeProcessHelper.as Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/config/SettingsContext.mxml incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/graphic/settings/GeneralSettings.mxml incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/graphic/settings/formItem/ToolHomeFormItem.mxml incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/domain/SettingModel.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractShellCommand.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ChangeLanguageCommand.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/GetEnvironmentVariablesCommand.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateAntHomePathCommand.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateJavaHomePathCommand.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateMavenHomePathCommand.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateAntHomePathMessage.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateJavaHomePathMessage.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateMavenHomePathMessage.as incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/test/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/CommandLineProcessTest.as Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/config/SettingsContext.mxml URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/config/SettingsContext.mxml?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/config/SettingsContext.mxml (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/config/SettingsContext.mxml Thu Dec 6 07:18:48 2012 @@ -17,7 +17,6 @@ limitations under the License. --> @@ -25,7 +24,6 @@ limitations under the License. - Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/graphic/settings/GeneralSettings.mxml URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/graphic/settings/GeneralSettings.mxml?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/graphic/settings/GeneralSettings.mxml (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.component-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/presentation/graphic/settings/GeneralSettings.mxml Thu Dec 6 07:18:48 2012 @@ -50,9 +50,9 @@ limitations under the License. - - - + + + @@ -62,8 +62,8 @@ limitations under the License. @@ -57,12 +57,12 @@ limitations under the License. import mx.rpc.Responder; import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.message.SaveSettingMessage; + import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.nativeProcess.NativeShellHelper; import spark.events.TextOperationEvent; private var _file:File; - private var _toolHomePathValidated:Boolean; - private var _validateToolResponder:mx.rpc.Responder; + private var _installationPathValidated:Boolean; [Bindable] public var propertyName:String; @@ -86,16 +86,15 @@ limitations under the License. public var dispatch:Function; private function creationCompleteHandler(event:FlexEvent):void { - _validateToolResponder = new mx.rpc.Responder(toolHomePathResult, toolHomePathValidatedError); toolHomeLocation.text = propertyValue; - dispatch(new validateToolMessageClass(propertyValue, _validateToolResponder)); + dispatch(new validateToolMessageClass(propertyValue)); } private function browseButton_clickHandler(event:MouseEvent):void { try { - _file = new File(toolHomeLocation.text.replace("\\", "/")); + _file = new File(NativeShellHelper.formatPath(toolHomeLocation.text)); } catch (err:Error) { _file = new File(); } @@ -106,33 +105,21 @@ limitations under the License. private function file_select(evt:Event):void { toolHomeLocation.text = _file.nativePath; - dispatch(new validateToolMessageClass(toolHomeLocation.text, _validateToolResponder)); + dispatch(new validateToolMessageClass(toolHomeLocation.text)); } private function toolHomeLocation_changeHandler(event:TextOperationEvent):void { - dispatch(new validateToolMessageClass(toolHomeLocation.text, _validateToolResponder)); - } - - // Result handlers for the commands which check if the path of the tool is good - private function toolHomePathResult(result:Boolean):void { - toolHomePathValidated = true; - - if (toolHomePathValidated) { - dispatch(new SaveSettingMessage(propertyName, toolHomeLocation.text)); - } - } - - private function toolHomePathValidatedError(result:Boolean):void { - toolHomePathValidated = false; + dispatch(new validateToolMessageClass(toolHomeLocation.text)); } // Result handlers for the SaveSettingCommand - public function get toolHomePathValidated():Boolean { - return _toolHomePathValidated; + public function get installationPathValidated():Boolean { + return _installationPathValidated; } - public function set toolHomePathValidated(value:Boolean):void { - _toolHomePathValidated = value; + [Bindable] + public function set installationPathValidated(value:Boolean):void { + _installationPathValidated = value; validator.validate(); } ]]> Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/domain/SettingModel.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/domain/SettingModel.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/domain/SettingModel.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/domain/SettingModel.as Thu Dec 6 07:18:48 2012 @@ -17,12 +17,31 @@ package org.apache.flex.utilities.developerToolSuite.executor.domain { import flash.utils.Dictionary; + import mx.collections.ArrayCollection; + + import org.apache.flex.utilities.developerToolSuite.LocaleUtil; + [Bindable] public class SettingModel { + + public function get availableLanguages():ArrayCollection { + return new ArrayCollection(LocaleUtil.AVAILABLE_LANGUAGES); + } + + public function get currentLanguage():Object { + return LocaleUtil.getDefaultLanguage(locale); + } + public var environmentVariables:Dictionary; + public var locale:String; + public var JAVA_HOME:String; public var ANT_HOME:String; public var MAVEN_HOME:String; + + public var javaEnabled:Boolean; + public var antEnabled:Boolean; + public var mavenEnabled:Boolean; } } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractShellCommand.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractShellCommand.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractShellCommand.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/AbstractShellCommand.as Thu Dec 6 07:18:48 2012 @@ -21,7 +21,7 @@ package org.apache.flex.utilities.develo import mx.logging.ILogger; - import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.nativeProcess.NativeProcessHelper; + import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.nativeProcess.NativeShellHelper; import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.util.LogUtil; public class AbstractShellCommand { @@ -30,18 +30,22 @@ package org.apache.flex.utilities.develo public var callback:Function; - protected var shell:NativeProcessHelper; + protected var shell:NativeShellHelper; - protected var command:String; - protected var args:Vector. = new Vector.(); + protected var shellPath:String; + protected var command:Vector. = new Vector.(); - protected var output:String; + protected var standardOutput:String; + protected var standardError:String; + + public function AbstractShellCommand() { + shell = new NativeShellHelper(); + } protected function executeCommand():void { - shell = new NativeProcessHelper(); addShellListeners(); - shell.run(command, args); + shell.run(command, shellPath); } private function addShellListeners():void { @@ -61,33 +65,33 @@ package org.apache.flex.utilities.develo } protected function outputDataHandler(event:ProgressEvent):void { - var shell:NativeProcessHelper = event.currentTarget as NativeProcessHelper; - output = shell.process.standardOutput.readUTFBytes(shell.process.standardOutput.bytesAvailable); - log.debug("Reading standard output: \n" + output); + var shell:NativeShellHelper = event.currentTarget as NativeShellHelper; + standardOutput = shell.process.standardOutput.readUTFBytes(shell.process.standardOutput.bytesAvailable); + log.debug("Reading standard output: \n" + standardOutput); } protected function errorDataHandler(event:ProgressEvent):void { - var shell:NativeProcessHelper = event.currentTarget as NativeProcessHelper; - log.error("ERROR -" + shell.process.standardError.readUTFBytes(shell.process.standardError.bytesAvailable)); - returnError(event); + var shell:NativeShellHelper = event.currentTarget as NativeShellHelper; + standardError = shell.process.standardError.readUTFBytes(shell.process.standardError.bytesAvailable); + log.debug("Reading standard error: \n" + standardError); } protected function IOErrorHandler(event:IOErrorEvent):void { log.error(event.toString()); - returnError(event); + error(event); } protected function exitHandler(event:NativeProcessExitEvent):void { - log.debug("Process exited with ", event.exitCode); + log.debug("Process exited with ", event.exitCode.toString()); removeShellListeners(); } - protected function returnSuccess(result:Object):void { + protected function result(result:Object):void { shell.process.exit(); callback(result); } - protected function returnError(error:Object):void { + protected function error(error:Object):void { shell.process.exit(); callback(error); } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ChangeLanguageCommand.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ChangeLanguageCommand.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ChangeLanguageCommand.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ChangeLanguageCommand.as Thu Dec 6 07:18:48 2012 @@ -31,7 +31,7 @@ package org.apache.flex.utilities.develo public function execute(msg:ChangeLanguageMessage):void { log.debug("Executing Command with message: " + ObjectUtil.toString(msg)); - this._msg = msg; + _msg = msg; executeAsync(); } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/GetEnvironmentVariablesCommand.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/GetEnvironmentVariablesCommand.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/GetEnvironmentVariablesCommand.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/GetEnvironmentVariablesCommand.as Thu Dec 6 07:18:48 2012 @@ -30,10 +30,9 @@ package org.apache.flex.utilities.develo } override protected function executeCommand():void { - command = "C:\\Windows\\System32\\cmd.exe"; - args.push("/C"); - args.push("set"); + command.push("/C"); + command.push("set"); super.executeCommand(); } @@ -46,12 +45,12 @@ package org.apache.flex.utilities.develo var tuple:Array = row.split("="); settings.environmentVariables[tuple[0]] = tuple[1]; } - returnSuccess(settings.environmentVariables); + result(settings.environmentVariables); } override protected function outputDataHandler(event:ProgressEvent):void { super.outputDataHandler(event); - extractVariables(output); + extractVariables(standardOutput); } } } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateAntHomePathCommand.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateAntHomePathCommand.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateAntHomePathCommand.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateAntHomePathCommand.as Thu Dec 6 07:18:48 2012 @@ -15,34 +15,86 @@ limitations under the License. */ package org.apache.flex.utilities.developerToolSuite.executor.infrastructure.command { + import flash.events.ProgressEvent; import flash.filesystem.File; import mx.logging.ILogger; import mx.utils.ObjectUtil; + import org.apache.flex.utilities.developerToolSuite.executor.domain.SettingModel; + import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.message.ValidateAntHomePathMessage; import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.util.LogUtil; - public class ValidateAntHomePathCommand { + public class ValidateAntHomePathCommand extends AbstractShellCommand{ private static var LOG:ILogger = LogUtil.getLogger(ValidateAntHomePathCommand); - public function ValidateAntHomePathCommand(msg:ValidateAntHomePathMessage) { + private var _msg:ValidateAntHomePathMessage; + + [Inject] + public var settings:SettingModel; + + private var _done:Boolean; + + public function execute(msg:ValidateAntHomePathMessage):void { LOG.debug("Executing Command with message: " + ObjectUtil.toString(msg)); + _msg = msg; + executeCommand(); + } + + override protected function executeCommand():void { + LOG.debug("Executing Command with message: " + ObjectUtil.toString(_msg)); + + var file:File; try { - var file:File = new File(msg.path.replace("\\", "/")); - if (!file.resolvePath("lib/ant.jar").exists) { + file = new File(shell.formatPath(_msg.path)); + if (!file.resolvePath("bin/ant.bat").exists) { LOG.error("Error resolving ANT_HOME"); - msg.responder.fault(false); - return + error(false); + return; } } catch (err:Error) { LOG.error(ObjectUtil.toString(err)); - msg.responder.fault(false); - return + error(false); + return; + } + ; + + var ant:String = shell.formatPath(file.resolvePath("bin/ant.bat").nativePath); + + if (shell.OS == "win") + command.push("/C"); + + command.push(ant); + command.push("-version"); + + super.executeCommand(); + } + + private function extractVersion(output:String):void { + + if (_done) + return; + + _done = true; + if (output.indexOf("Apache Ant(TM) version") > -1) { + settings.antEnabled = true; + result(true); + } else { + settings.antEnabled = false; + error(false); } - LOG.debug("Successfully executed shell") - msg.responder.result(true); + } + + override protected function outputDataHandler(event:ProgressEvent):void { + super.outputDataHandler(event); + extractVersion(standardOutput); + } + + override protected function errorDataHandler(event:ProgressEvent):void { + super.errorDataHandler(event); + extractVersion(standardError); } } } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateJavaHomePathCommand.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateJavaHomePathCommand.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateJavaHomePathCommand.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateJavaHomePathCommand.as Thu Dec 6 07:18:48 2012 @@ -15,34 +15,86 @@ limitations under the License. */ package org.apache.flex.utilities.developerToolSuite.executor.infrastructure.command { + import flash.events.ProgressEvent; import flash.filesystem.File; import mx.logging.ILogger; import mx.utils.ObjectUtil; + import org.apache.flex.utilities.developerToolSuite.executor.domain.SettingModel; + import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.message.ValidateJavaHomePathMessage; import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.util.LogUtil; - public class ValidateJavaHomePathCommand { + public class ValidateJavaHomePathCommand extends AbstractShellCommand { private static var LOG:ILogger = LogUtil.getLogger(ValidateAntHomePathCommand); - public function ValidateJavaHomePathCommand(msg:ValidateJavaHomePathMessage) { + private var _msg:ValidateJavaHomePathMessage; + + [Inject] + public var settings:SettingModel; + + private var _done:Boolean; + + public function execute(msg:ValidateJavaHomePathMessage):void { LOG.debug("Executing Command with message: " + ObjectUtil.toString(msg)); + _msg = msg; + executeCommand(); + } + + override protected function executeCommand():void { + LOG.debug("Executing Command with message: " + ObjectUtil.toString(_msg)); + + var file:File; try { - var file:File = new File(msg.path.replace("\\", "/")); + file = new File(shell.formatPath(_msg.path)); if (!file.resolvePath("lib/tools.jar").exists) { - LOG.error("Error resolving ANT_HOME"); - msg.responder.fault(false); - return + LOG.error("Error resolving JAVA_HOME"); + error(false); + return; } } catch (err:Error) { LOG.error(ObjectUtil.toString(err)); - msg.responder.fault(false); - return + error(false); + return; + } + ; + + var java:String = shell.formatPath(file.resolvePath("bin/java.exe").nativePath); + + if (shell.OS == "win") + command.push("/C"); + + command.push(java); + command.push("-version"); + + super.executeCommand(); + } + + private function extractVersion(output:String):void { + + if (_done) + return; + + _done = true; + if (output.indexOf("1.6.") > -1) { + settings.javaEnabled = true; + result(true); + } else { + settings.javaEnabled = false; + error(false); } - LOG.info("Successfully executed shell") - msg.responder.result(true); + } + + override protected function outputDataHandler(event:ProgressEvent):void { + super.outputDataHandler(event); + extractVersion(standardOutput); + } + + override protected function errorDataHandler(event:ProgressEvent):void { + super.errorDataHandler(event); + extractVersion(standardError); } } } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateMavenHomePathCommand.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateMavenHomePathCommand.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateMavenHomePathCommand.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/command/ValidateMavenHomePathCommand.as Thu Dec 6 07:18:48 2012 @@ -15,34 +15,88 @@ limitations under the License. */ package org.apache.flex.utilities.developerToolSuite.executor.infrastructure.command { + import flash.events.ProgressEvent; import flash.filesystem.File; import mx.logging.ILogger; import mx.utils.ObjectUtil; + import org.apache.flex.utilities.developerToolSuite.executor.domain.SettingModel; + import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.message.ValidateMavenHomePathMessage; import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.util.LogUtil; - public class ValidateMavenHomePathCommand { + public class ValidateMavenHomePathCommand extends AbstractShellCommand { private static var LOG:ILogger = LogUtil.getLogger(ValidateMavenHomePathCommand); - public function ValidateMavenHomePathCommand(msg:ValidateMavenHomePathMessage) { + private var _msg:ValidateMavenHomePathMessage; + + [Inject] + public var settings:SettingModel; + + private var _done:Boolean; + + public function execute(msg:ValidateMavenHomePathMessage):void { LOG.debug("Executing Command with message: " + ObjectUtil.toString(msg)); + _msg = msg; + executeCommand(); + } + + override protected function executeCommand():void { + + LOG.debug("Executing Command with message: " + ObjectUtil.toString(_msg)); + + var file:File; try { - var file:File = new File(msg.path.replace("\\", "/")); + file = new File(shell.formatPath(_msg.path)); if (!file.resolvePath("bin/mvn.bat").exists) { - LOG.error("Error resolving MAVEN_HOME"); - msg.responder.fault(false); - return + LOG.error("Error resolving ANT_HOME"); + error(false); + return; } } catch (err:Error) { LOG.error(ObjectUtil.toString(err)); - msg.responder.fault(false); - return + error(false); + return; + } + ; + + var mvn:String = shell.formatPath(file.resolvePath("bin/mvn.bat").nativePath); + + if (shell.OS == "win") + command.push("/C"); + + command.push(mvn); + command.push("-version"); + + super.executeCommand(); + } + + private function extractVersion(output:String):void { + + if (_done) + return; + + _done = true; + + if (output.indexOf("Apache Maven 3.") > -1) { + settings.mavenEnabled = true; + result(true); + } else { + settings.mavenEnabled = false; + error(false); } - LOG.info("Successfully executed shell") - msg.responder.result(true); + } + + override protected function outputDataHandler(event:ProgressEvent):void { + super.outputDataHandler(event); + extractVersion(standardOutput); + } + + override protected function errorDataHandler(event:ProgressEvent):void { + super.errorDataHandler(event); + extractVersion(standardError); } } } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateAntHomePathMessage.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateAntHomePathMessage.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateAntHomePathMessage.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateAntHomePathMessage.as Thu Dec 6 07:18:48 2012 @@ -20,19 +20,13 @@ package org.apache.flex.utilities.develo public class ValidateAntHomePathMessage { private var _path:String; - private var _responder:Responder; - public function ValidateAntHomePathMessage(path:String, responder:Responder) { + public function ValidateAntHomePathMessage(path:String) { _path = path; - _responder = responder; } public function get path():String { return _path; } - - public function get responder():Responder { - return _responder; - } } } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateJavaHomePathMessage.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateJavaHomePathMessage.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateJavaHomePathMessage.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateJavaHomePathMessage.as Thu Dec 6 07:18:48 2012 @@ -20,19 +20,13 @@ package org.apache.flex.utilities.develo public class ValidateJavaHomePathMessage { private var _path:String; - private var _responder:Responder; - public function ValidateJavaHomePathMessage(path:String, responder:Responder) { + public function ValidateJavaHomePathMessage(path:String) { _path = path; - _responder = responder; } public function get path():String { return _path; } - - public function get responder():Responder { - return _responder; - } } } Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateMavenHomePathMessage.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateMavenHomePathMessage.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateMavenHomePathMessage.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/message/ValidateMavenHomePathMessage.as Thu Dec 6 07:18:48 2012 @@ -20,19 +20,13 @@ package org.apache.flex.utilities.develo public class ValidateMavenHomePathMessage { private var _path:String; - private var _responder:Responder; - public function ValidateMavenHomePathMessage(path:String, responder:Responder) { + public function ValidateMavenHomePathMessage(path:String) { _path = path; - _responder = responder; } public function get path():String { return _path; } - - public function get responder():Responder { - return _responder; - } } } Copied: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeShellHelper.as (from r1417721, incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeProcessHelper.as) URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeShellHelper.as?p2=incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeShellHelper.as&p1=incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeProcessHelper.as&r1=1417721&r2=1417750&rev=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeProcessHelper.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/main/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/NativeShellHelper.as Thu Dec 6 07:18:48 2012 @@ -7,12 +7,13 @@ package org.apache.flex.utilities.develo import flash.events.NativeProcessExitEvent; import flash.events.ProgressEvent; import flash.filesystem.File; + import flash.system.Capabilities; import mx.logging.ILogger; import org.apache.flex.utilities.developerToolSuite.executor.infrastructure.util.LogUtil; - public class NativeProcessHelper extends EventDispatcher { + public class NativeShellHelper extends EventDispatcher { // Use trace during tests as AIR thru Maven doesn't support resource xml config files for logging. private static var LOG:ILogger; @@ -24,12 +25,14 @@ package org.apache.flex.utilities.develo private var _isLogEnabled:Boolean; - public function NativeProcessHelper() { + public function NativeShellHelper() { super(); - if (!LOG) - LOG = LogUtil.getLogger(NativeProcessHelper); - if (!_gcLocker) + if (!LOG) { + LOG = LogUtil.getLogger(NativeShellHelper); + } + if (!_gcLocker) { _gcLocker = new GCLocker(); + } _process = new NativeProcess(); } @@ -41,7 +44,7 @@ package org.apache.flex.utilities.develo return _isRunning; } - public function run(command:String, args:Vector. = null):void { + public function run(command:Vector. = null, shell:String = null):void { if (_isRunning) { throw new Error("NativeProcessHelper is currently busy"); @@ -52,11 +55,16 @@ package org.apache.flex.utilities.develo //Avoid the garbage collection _gcLocker.lock(this); + if (!shell) + shell = getShellPath(); + + LOG.debug("Executing: " + shell + " " + command.join(" ")); + var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); - var file:File = File.applicationDirectory.resolvePath(command); + var file:File = File.applicationDirectory.resolvePath(shell); nativeProcessStartupInfo.executable = file; - nativeProcessStartupInfo.arguments = args; + nativeProcessStartupInfo.arguments = command; _process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, dispatch2, false, 0, true); _process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, dispatch2, false, 0, true); @@ -110,6 +118,77 @@ package org.apache.flex.utilities.develo _isRunning = false; this.dispatchEvent(e); } + + public static function get OS():String { + var os:String; + + if (Capabilities.os.toLowerCase().indexOf("win") > -1) { + os = "win"; + } else if (Capabilities.os.toLowerCase().indexOf("mac") > -1) { + os = "mac"; + } else if (Capabilities.os.toLowerCase().indexOf("linux") > -1) { + os = "linux"; + } + + return os; + } + + public function get OS():String { + return NativeShellHelper.OS; + } + + public function getShellPath():String { + var shellPath:String; + + if (OS == "win") { + shellPath = "C:/Windows/System32/cmd.exe"; + } else if (OS == "mac") { + shellPath = "/Applications/Utilities/Terminal.app"; + } else if (OS == "linux") { + + var file:File; + try { + file = new File("/bin/bash"); + if (file.exists) + shellPath = file.nativePath; + } catch (err:Error) { + } + ; + + if (!shellPath) { + try { + file = new File("/bin/bsh"); + if (file.exists) + shellPath = file.nativePath; + } catch (err:Error) { + } + ; + } + + if (!shellPath) { + try { + file = new File("/bin/csh"); + if (file.exists) + shellPath = file.nativePath; + } catch (err:Error) { + } + ; + } + } + if (!shellPath) { + throw new Error("Unsupported System"); + } + + return shellPath; + } + + public static function formatPath(path:String):String { + return path.replace(/\\/g, "/"); + } + + public function formatPath(path:String):String { + return NativeShellHelper.formatPath(path); + } } } internal class GCLocker { Modified: incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/test/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/CommandLineProcessTest.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/test/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/CommandLineProcessTest.as?rev=1417750&r1=1417749&r2=1417750&view=diff ============================================================================== --- incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/test/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/CommandLineProcessTest.as (original) +++ incubator/flex/whiteboard/fthomas/developerToolSuite/trunk/org.apache.flex.utilities.developerToolSuite.executor-lib/src/test/flex/org/apache/flex/utilities/developerToolSuite/executor/infrastructure/nativeProcess/CommandLineProcessTest.as Thu Dec 6 07:18:48 2012 @@ -9,11 +9,11 @@ package org.apache.flex.utilities.develo public class CommandLineProcessTest { - private var command:NativeProcessHelper; + private var command:NativeShellHelper; [Before] public function setUp():void { - command = new NativeProcessHelper(); + command = new NativeShellHelper(); command.logMessages(); } @@ -31,7 +31,7 @@ package org.apache.flex.utilities.develo } private function outputDataLogHandler(event:ProgressEvent, passThroughData:Object):void { - var command:NativeProcessHelper = event.currentTarget as NativeProcessHelper; + var command:NativeShellHelper = event.currentTarget as NativeShellHelper; var result:String = command.process.standardOutput.readUTFBytes(command.process.standardOutput.bytesAvailable); trace("res: ", command.process.standardOutput.readUTFBytes(command.process.standardOutput.bytesAvailable)); assertNotNull(result);