Repository: flex-utilities
Updated Branches:
  refs/heads/develop 8320e470f -> 543bdd06e


FLEX-34446 give warning when trying to write to director you don't have 
permission to do so


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/543bdd06
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/543bdd06
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/543bdd06

Branch: refs/heads/develop
Commit: 543bdd06ec90a5364beb0bd2ee73d303fef1a833
Parents: 8320e47
Author: Justin Mclean <jmcl...@apache.org>
Authored: Sat Oct 11 08:33:51 2014 +1100
Committer: Justin Mclean <jmcl...@apache.org>
Committed: Sat Oct 11 08:33:51 2014 +1100

----------------------------------------------------------------------
 installer/src/InstallApacheFlex.mxml      | 56 +++++++++++++++++++++-----
 installer/src/properties/en_US.properties |  1 +
 2 files changed, 48 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/543bdd06/installer/src/InstallApacheFlex.mxml
----------------------------------------------------------------------
diff --git a/installer/src/InstallApacheFlex.mxml 
b/installer/src/InstallApacheFlex.mxml
index 0b76f4c..bbb9220 100644
--- a/installer/src/InstallApacheFlex.mxml
+++ b/installer/src/InstallApacheFlex.mxml
@@ -1096,14 +1096,27 @@ variables are not required because the locations of 
these pieces are known.
                 loader.addEventListener(ErrorEvent.ERROR, 
handleInstallerXMLError);
                 loader.addEventListener(IOErrorEvent.IO_ERROR, 
handleInstallerXMLError);
                 
-                loader.load(req);          
+                loader.load(req);
             }
             else {
                 showDirectoryState();
-                       }
-               }
-               
-               protected function 
handleFirstStepNextBtnClick(event:MouseEvent):void {
+            }
+        }
+        
+        protected function handleFirstStepNextBtnClick(event:MouseEvent):void
+        {
+            // Quick check to see if the selected directory is writable
+            try {
+                var f:File = new File(_flexHome + File.separator + "flex.txt");
+                checkDirWritable(f);
+            } catch (e:Error) {
+                
log(_viewResourceConstants.ERROR_UNABLE_TO_CREATE_TEMP_DIRECTORY);
+                flexSDKTxtInput.errorString = 
_viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS;
+                flexSDKTxtInput.prompt = 
_viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS;
+                
updateActivityStep(_viewResourceConstants.STEP_CREATE_DIRECTORIES, 
StepItem.ERROR);
+                return;
+            }
+            
             showOptionsState();
         }
         
@@ -1313,10 +1326,34 @@ variables are not required because the locations of 
these pieces are known.
                        file.addEventListener(Event.SELECT, flexSDKDirSelected, 
false, 0, true);
                        
file.browseForDirectory(_viewResourceConstants.INFO_SELECT_DIRECTORY);
                }
-               
-               protected function flexSDKDirSelected(event:Event):void {
-                       var selectedDir:File = File(event.target);
+        
+        protected function checkDirWritable(file:File):void
+        {
+            var ba:ByteArray = new ByteArray();
+            ba.writeUTFBytes("1");
+            writeFileToDirectory(file, ba);
+            file.deleteFile();
+        }
+        
+        protected function flexSDKDirSelected(event:Event):void
+        {
+               var selectedDir:File = File(event.target);
                        var overlay:Boolean = flexVersion.selectedItem.overlay;
+            
+                       // Quick check to see if the selected directory is 
writable
+            try {
+                var f:File = new File(selectedDir.nativePath + File.separator 
+ "flex.txt");
+                checkDirWritable(f);
+            } catch (e:Error) {
+                
log(_viewResourceConstants.ERROR_UNABLE_TO_CREATE_TEMP_DIRECTORY);
+                log(_viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS);
+                flexSDKTxtInput.text = selectedDir.nativePath;
+                flexSDKTxtInput.errorString = 
_viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS + " : " + 
selectedDir.nativePath; // tooltip
+                flexSDKTxtInput.prompt = 
_viewResourceConstants.ERROR_DIR_REQUIRE_ADMIN_RIGHTS; // field
+                
updateActivityStep(_viewResourceConstants.STEP_CREATE_DIRECTORIES, 
StepItem.ERROR);
+                return;
+            }
+           
             overlaying = overlay;
                        if (!overlay)
             {
@@ -1329,7 +1366,8 @@ variables are not required because the locations of these 
pieces are known.
                                flexSDKTxtInput.prompt = 
_viewResourceConstants.SELECT_PATH_PROMPT;
                        } else {
                                nextBtn.enabled = false;
-                               flexSDKTxtInput.errorString = 
_viewResourceConstants.ERROR_DIR_NOT_EMPTY;
+                    flexSDKTxtInput.text = selectedDir.nativePath;
+                    flexSDKTxtInput.errorString = 
_viewResourceConstants.ERROR_DIR_NOT_EMPTY + " : " + selectedDir.nativePath;
                                flexSDKTxtInput.prompt = 
_viewResourceConstants.ERROR_DIR_NOT_EMPTY;
                        }
             }

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/543bdd06/installer/src/properties/en_US.properties
----------------------------------------------------------------------
diff --git a/installer/src/properties/en_US.properties 
b/installer/src/properties/en_US.properties
index 0bf9bb7..9432443 100644
--- a/installer/src/properties/en_US.properties
+++ b/installer/src/properties/en_US.properties
@@ -36,6 +36,7 @@ BTN_DISCLAIMER=Disclaimer
 BTN_LABEL_OPEN_APACHE_FLEX_FOLDER=OPEN APACHE FLEX FOLDER
 ERROR_CONFIG_XML_LOAD=Error while trying to load XML configuration file: 
 ERROR_DIR_NOT_EMPTY=The selected directory is not empty
+ERROR_DIR_REQUIRE_ADMIN_RIGHTS=The selected directory requires Administrator 
rights to write files
 ERROR_INVALID_AIR_SDK_URL_MAC=Adobe AIR SDK URL for Mac invalid in 
configuration file
 ERROR_INVALID_AIR_SDK_URL_WINDOWS=Adobe AIR SDK URL for Windows invalid in 
configuration file
 ERROR_INVALID_FLASH_PLAYER_SWC_URL=Flash Player swc URL invalid in 
configuration file

Reply via email to