Refactoring InstallApacheFlex.mxml -- Broke Out AIR Runtime parsing and Flash Player Parsing from XML into external classes.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/56e3bd07 Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/56e3bd07 Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/56e3bd07 Branch: refs/heads/InstallerRefactor Commit: 56e3bd07d7af7f3ada3b159a7cb0d0104a32a23b Parents: cb68cb5 Author: quetwo <[email protected]> Authored: Wed Feb 11 00:03:25 2015 -0500 Committer: quetwo <[email protected]> Committed: Wed Feb 11 00:03:25 2015 -0500 ---------------------------------------------------------------------- installer/src/InstallApacheFlex.mxml | 104 ++++++------------- .../flex/packageflexsdk/model/AirVersions.as | 60 +++++++++++ .../packageflexsdk/model/AvailableAirVersion.as | 35 +++++++ .../model/AvailableFlashVersion.as | 35 +++++++ .../flex/packageflexsdk/model/FlashVersions.as | 67 ++++++++++++ .../flex/packageflexsdk/model/FlexVersions.as | 9 +- 6 files changed, 234 insertions(+), 76 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/56e3bd07/installer/src/InstallApacheFlex.mxml ---------------------------------------------------------------------- diff --git a/installer/src/InstallApacheFlex.mxml b/installer/src/InstallApacheFlex.mxml index 4c57f7b..3f58b66 100644 --- a/installer/src/InstallApacheFlex.mxml +++ b/installer/src/InstallApacheFlex.mxml @@ -62,6 +62,9 @@ variables are not required because the locations of these pieces are known. import mx.rpc.http.HTTPService; import mx.utils.StringUtil; + import org.apache.flex.packageflexsdk.model.AirVersions; + import org.apache.flex.packageflexsdk.model.FlashVersions; + import org.apache.flex.packageflexsdk.model.FlexVersions; import org.apache.flex.packageflexsdk.view.components.CacheDialog; @@ -163,7 +166,7 @@ variables are not required because the locations of these pieces are known. * */ [Bindable] - private var AIR_VERSIONS:ArrayCollection = new ArrayCollection(); + private var AIR_VERSIONS:AirVersions = new AirVersions(); private var AIR_VERSION:String = "14.0"; private var ADOBE_AIR_SDK_WIN_FILE:String; private var ADOBE_AIR_SDK_WIN_URL:String; @@ -179,7 +182,7 @@ variables are not required because the locations of these pieces are known. * */ [Bindable] - private var FLASH_PLAYER_VERSIONS:ArrayCollection = new ArrayCollection(); + private var FLASH_PLAYER_VERSIONS:FlashVersions = new FlashVersions(); private var FLASH_PLAYER_VERSION:String = "11.1"; private var FLASH_PLAYER_SWF_VERSION:String = "14"; private var ADOBE_FB_GLOBALPLAYER_SWC_FILE:String; @@ -340,6 +343,9 @@ variables are not required because the locations of these pieces are known. _standardButtonWidth = calc.maxButtonWidth([installBtn, browseBtn, closeBtn, nextBtn, firstStepBackBtn, secondStepBackBtn]); } + /** + * This function parses the command-line properties passed into the app and loads prefs into memory + */ private function parseArgs(event:InvokeEvent):void { for each (var s:String in event.arguments) @@ -376,6 +382,9 @@ variables are not required because the locations of these pieces are known. userDefaultLanguage = so.data.userDefaultLanguage; } + /** + * This function is called when the application finishes drawing the UI. + */ protected function handleApplicationComplete(event:FlexEvent):void { CursorManager.setBusyCursor(); @@ -659,7 +668,6 @@ variables are not required because the locations of these pieces are known. else { request = new URLRequest(Constants.APACHE_FLEX_URL + Constants.CONFIG_XML_NAME); - //request = new URLRequest(Constants.CONFIG_XML_NAME); } _loader = new URLLoader(); @@ -717,11 +725,6 @@ variables are not required because the locations of these pieces are known. } } - // private function devBuildFilterFunction(o:Object):Boolean - // { - // return !o.devBuild; - // } - private function debugModeHandler(event:Event):void { debugMode = true; @@ -777,6 +780,8 @@ variables are not required because the locations of these pieces are known. var keepGoing:Boolean = true; if (firstTime) { + setupUI(); + firstTime = false; _latestVersion = data.version.latest.toString(); @@ -786,21 +791,6 @@ variables are not required because the locations of these pieces are known. _mirrorURLCGI = data.mirror.(@name == 'MirrorURLCGI')[email protected](); - customMenuItem1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, devBuildShowHandler); - customMenuItem2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, downloadCacheHandler); - customMenuItem3.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, debugModeHandler); - customMenuItem4.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, debugProgressHandler); - - var contextMenuCustomItems:Array = ContextMenu(contextMenu).customItems; - contextMenuCustomItems.push(customMenuItem1); - contextMenuCustomItems.push(customMenuItem2); - contextMenuCustomItems.push(customMenuItem3); - contextMenuCustomItems.push(customMenuItem4); - - var name:String; - var versionString:String; - var versionID:String; - var languages:XMLList = data.languages.children(); for each (var lang:XML in languages) { @@ -813,42 +803,23 @@ variables are not required because the locations of these pieces are known. } var airData:XMLList = data.airsdk[_os.os].versions; - var airVersionList:XMLList = airData[0].children(); - var airVersions:Array = []; - var selected:String = airData[0]["@default"].toString(); - for each (var airVersion:XML in airVersionList) - { - var displayVersion:String = [email protected](); - versionString = [email protected](); - versionID = null; - if ([email protected]() > 0) - { - versionID = [email protected](); - } - airVersions.push(versionString); - var airPath:String = airVersion.path.toString(); - var airFile:String = airVersion.file.toString(); - AIR_VERSIONS.addItem({ - label: "AIR " + displayVersion, version: versionString, versionID: versionID, - path: airPath, file: airFile - }); - } + AIR_VERSIONS.processXML(airData); if (this.airVersion.selectedIndex == -1) { - this.airVersion.selectedIndex = airVersions.indexOf(selected); + this.airVersion.selectedIndex = AIR_VERSIONS.defaultVersionIndex; } var flexData:XMLList = data.products.children(); - FLEX_VERSIONS.processXML(flexData); + FLEX_VERSIONS.processXML(flexData, _os.isWindows()); FLEX_VERSIONS.hideDevBuilds(); flexVersionSelectList.validateNow(); if (this.flexVersionSelectList.selectedIndex == -1) { - this.flexVersionSelectList.selectedIndex = FLEX_VERSIONS.defaultVersion; + this.flexVersionSelectList.selectedIndex = FLEX_VERSIONS.defaultVersionIndex; } var selectedFlexVersionObject:Object = this.flexVersionSelectList.selectedItem; @@ -861,34 +832,11 @@ variables are not required because the locations of these pieces are known. } var flashData:XMLList = data.flashsdk.versions; - var flashVersionList:XMLList = flashData[0].children(); - var flashPlayerVersions:Array = []; - selected = flashData[0]["@default"].toString(); - for each (var flashVersion:XML in flashVersionList) - { - displayVersion = [email protected](); - versionString = [email protected](); - versionID = null; - if ([email protected]() > 0) - { - versionID = [email protected](); - } - flashPlayerVersions.push(versionString); - if (!_os.isLinux() || Number(versionString) <= 11.2) - { - var swfVersion:String = flashVersion.swfversion.toString(); - var flashPath:String = flashVersion.path.toString(); - var flashFile:String = flashVersion.file.toString(); - FLASH_PLAYER_VERSIONS.addItem({ - label: "Flash Player " + displayVersion, version: versionString, swfVersion: swfVersion, - versionID: versionID, path: flashPath, file: flashFile - }); - } - } + FLASH_PLAYER_VERSIONS.processXML(flashData, _os.isLinux()); if (this.flashPlayerVersion.selectedIndex == -1) { - this.flashPlayerVersion.selectedIndex = flashPlayerVersions.indexOf(selected); + this.flashPlayerVersion.selectedIndex = FLASH_PLAYER_VERSIONS.defaultVersionIndex; } } @@ -965,6 +913,20 @@ variables are not required because the locations of these pieces are known. return keepGoing; } + protected function setupUI():void + { + customMenuItem1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, devBuildShowHandler); + customMenuItem2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, downloadCacheHandler); + customMenuItem3.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, debugModeHandler); + customMenuItem4.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, debugProgressHandler); + + var contextMenuCustomItems:Array = ContextMenu(contextMenu).customItems; + contextMenuCustomItems.push(customMenuItem1); + contextMenuCustomItems.push(customMenuItem2); + contextMenuCustomItems.push(customMenuItem3); + contextMenuCustomItems.push(customMenuItem4); + } + protected function updateFlexVersionStrings(selectedFlexVersionObject:Object):void { APACHE_FLEX_BIN_DISTRO_FILE_SHORT = selectedFlexVersionObject.shortName; http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/56e3bd07/installer/src/org/apache/flex/packageflexsdk/model/AirVersions.as ---------------------------------------------------------------------- diff --git a/installer/src/org/apache/flex/packageflexsdk/model/AirVersions.as b/installer/src/org/apache/flex/packageflexsdk/model/AirVersions.as new file mode 100644 index 0000000..8a20dd5 --- /dev/null +++ b/installer/src/org/apache/flex/packageflexsdk/model/AirVersions.as @@ -0,0 +1,60 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.packageflexsdk.model +{ + import mx.collections.ArrayCollection; + + public class AirVersions extends ArrayCollection + { + + public var defaultVersionIndex:int = -1; + + public function AirVersions() + { + } + + public function processXML(airData:XMLList):void + { + var airVersionList:XMLList = airData[0].children(); + var _defaultVersion:String = airData[0]["@default"].toString(); + var newAIRVersion:AvailableAirVersion; + for each (var airVersion:XML in airVersionList) + { + newAIRVersion = new AvailableAirVersion(); + newAIRVersion.label = "AIR " + [email protected](); + newAIRVersion.version = [email protected](); + newAIRVersion.path = airVersion.path.toString(); + newAIRVersion.file = airVersion.file.toString(); + newAIRVersion.versionID = null; + if ([email protected]() > 0) + { + newAIRVersion.versionID = [email protected](); + } + if (newAIRVersion.version == _defaultVersion) + { + defaultVersionIndex = this.length; + } + this.addItem(newAIRVersion); + } + + + } + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/56e3bd07/installer/src/org/apache/flex/packageflexsdk/model/AvailableAirVersion.as ---------------------------------------------------------------------- diff --git a/installer/src/org/apache/flex/packageflexsdk/model/AvailableAirVersion.as b/installer/src/org/apache/flex/packageflexsdk/model/AvailableAirVersion.as new file mode 100644 index 0000000..413b1ab --- /dev/null +++ b/installer/src/org/apache/flex/packageflexsdk/model/AvailableAirVersion.as @@ -0,0 +1,35 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.packageflexsdk.model +{ + public class AvailableAirVersion + { + + public var label:String; + public var version:String; + public var versionID:String; + public var path:String; + public var file:String; + + public function AvailableAirVersion() + { + } + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/56e3bd07/installer/src/org/apache/flex/packageflexsdk/model/AvailableFlashVersion.as ---------------------------------------------------------------------- diff --git a/installer/src/org/apache/flex/packageflexsdk/model/AvailableFlashVersion.as b/installer/src/org/apache/flex/packageflexsdk/model/AvailableFlashVersion.as new file mode 100644 index 0000000..db53d5c --- /dev/null +++ b/installer/src/org/apache/flex/packageflexsdk/model/AvailableFlashVersion.as @@ -0,0 +1,35 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.packageflexsdk.model +{ + public class AvailableFlashVersion + { + public var label:String; + public var version:String; + public var swfVersion:String; + public var versionID:String; + public var path:String; + public var file:String; + + public function AvailableFlashVersion() + { + } + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/56e3bd07/installer/src/org/apache/flex/packageflexsdk/model/FlashVersions.as ---------------------------------------------------------------------- diff --git a/installer/src/org/apache/flex/packageflexsdk/model/FlashVersions.as b/installer/src/org/apache/flex/packageflexsdk/model/FlashVersions.as new file mode 100644 index 0000000..3921b8e --- /dev/null +++ b/installer/src/org/apache/flex/packageflexsdk/model/FlashVersions.as @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.flex.packageflexsdk.model +{ + import mx.collections.ArrayCollection; + + public class FlashVersions extends ArrayCollection + { + public const MAX_LINUX_FLASH_VERSION:Number = 11.2; + + public var defaultVersionIndex:int = -1; + + public function FlashVersions() + { + } + + public function processXML(flashData:XMLList, isLinux:Boolean):void + { + var flashVersionList:XMLList = flashData[0].children(); + var _defaultVersion:String = flashData[0]["@default"].toString(); + var newFlashVersion:AvailableFlashVersion; + for each (var flashVersion:XML in flashVersionList) + { + newFlashVersion = new AvailableFlashVersion(); + newFlashVersion.version = [email protected](); + if (!isLinux || Number(newFlashVersion.version) <= MAX_LINUX_FLASH_VERSION) + { + newFlashVersion.label = "Flash Player " + [email protected](); + newFlashVersion.versionID = null; + newFlashVersion.swfVersion = flashVersion.swfversion.toString(); + newFlashVersion.path = flashVersion.path.toString(); + newFlashVersion.file = flashVersion.file.toString(); + + if ([email protected]() > 0) + { + newFlashVersion.versionID = [email protected](); + } + + if (newFlashVersion.version == _defaultVersion) + { + defaultVersionIndex = this.length; + } + + this.addItem(newFlashVersion); + } + } + + } + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/56e3bd07/installer/src/org/apache/flex/packageflexsdk/model/FlexVersions.as ---------------------------------------------------------------------- diff --git a/installer/src/org/apache/flex/packageflexsdk/model/FlexVersions.as b/installer/src/org/apache/flex/packageflexsdk/model/FlexVersions.as index 16be550..56f836c 100644 --- a/installer/src/org/apache/flex/packageflexsdk/model/FlexVersions.as +++ b/installer/src/org/apache/flex/packageflexsdk/model/FlexVersions.as @@ -25,8 +25,7 @@ package org.apache.flex.packageflexsdk.model public class FlexVersions extends ArrayCollection { - public var defaultVersion:int = -1; - private var _os:OS = new OS(); + public var defaultVersionIndex:int = -1; public function FlexVersions() { @@ -45,7 +44,7 @@ package org.apache.flex.packageflexsdk.model this.refresh(); } - public function processXML(flexData:XMLList):void + public function processXML(flexData:XMLList, isWindows:Boolean):void { for each (var productData:XML in flexData) { @@ -55,7 +54,7 @@ package org.apache.flex.packageflexsdk.model { var newFlexVersion:AvailableFlexVersion = new AvailableFlexVersion(); newFlexVersion.shortName = [email protected](); - newFlexVersion.fileName = newFlexVersion.shortName + (_os.isWindows() ? Constants.ARCHIVE_EXTENSION_WIN : Constants.ARCHIVE_EXTENSION_MAC); + newFlexVersion.fileName = newFlexVersion.shortName + (isWindows ? Constants.ARCHIVE_EXTENSION_WIN : Constants.ARCHIVE_EXTENSION_MAC); newFlexVersion.version = newFlexVersion.fileName.substr([email protected]().length).split("-")[0]; newFlexVersion.label = [email protected]() + " " + [email protected](); newFlexVersion.path = [email protected](); @@ -68,7 +67,7 @@ package org.apache.flex.packageflexsdk.model newFlexVersion.icon = [email protected](); if (productVersion["@default"].length() == 1) { - defaultVersion = this.length; + defaultVersionIndex = this.length; } this.addItem(newFlexVersion); }
