Refactoring InstallApacheFlex.mxml -- Broke Out AIR Runtime parsing and Flash Player Parsing from XML into external classes.
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 @@
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 @@
*
*/
[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 @@
*
*/
[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 @@
_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 @@
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 @@
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 @@
}
}
- // private function devBuildFilterFunction(o:Object):Boolean
- // {
- // return !o.devBuild;
- // }
-
private function debugModeHandler(event:Event):void
{
debugMode = true;
@@ -777,6 +780,8 @@
var keepGoing:Boolean = true;
if (firstTime)
{
+ setupUI();
+
firstTime = false;
_latestVersion = data.version.latest.toString();
@@ -786,21 +791,6 @@
_mirrorURLCGI = data.mirror.(@name == 'MirrorURLCGI').@file.toString();
- 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 @@
}
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 = airVersion.@displayVersion.toString();
- versionString = airVersion.@version.toString();
- versionID = null;
- if (airVersion.@versionID.length() > 0)
- {
- versionID = airVersion.@versionID.toString();
- }
- 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 @@
}
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 = flashVersion.@displayVersion.toString();
- versionString = flashVersion.@version.toString();
- versionID = null;
- if (flashVersion.@versionID.length() > 0)
- {
- versionID = flashVersion.@versionID.toString();
- }
- 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 @@
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;
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 " + airVersion.@displayVersion.toString();
+ newAIRVersion.version = airVersion.@version.toString();
+ newAIRVersion.path = airVersion.path.toString();
+ newAIRVersion.file = airVersion.file.toString();
+ newAIRVersion.versionID = null;
+ if (airVersion.@versionID.length() > 0)
+ {
+ newAIRVersion.versionID = airVersion.@versionID.toString();
+ }
+ if (newAIRVersion.version == _defaultVersion)
+ {
+ defaultVersionIndex = this.length;
+ }
+ this.addItem(newAIRVersion);
+ }
+
+
+ }
+ }
+}
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()
+ {
+ }
+ }
+}
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()
+ {
+ }
+ }
+}
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 = flashVersion.@version.toString();
+ if (!isLinux || Number(newFlashVersion.version) <= MAX_LINUX_FLASH_VERSION)
+ {
+ newFlashVersion.label = "Flash Player " + flashVersion.@displayVersion.toString();
+ newFlashVersion.versionID = null;
+ newFlashVersion.swfVersion = flashVersion.swfversion.toString();
+ newFlashVersion.path = flashVersion.path.toString();
+ newFlashVersion.file = flashVersion.file.toString();
+
+ if (flashVersion.@versionID.length() > 0)
+ {
+ newFlashVersion.versionID = flashVersion.@versionID.toString();
+ }
+
+ if (newFlashVersion.version == _defaultVersion)
+ {
+ defaultVersionIndex = this.length;
+ }
+
+ this.addItem(newFlashVersion);
+ }
+ }
+
+ }
+ }
+}
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 @@
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 @@
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 @@
{
var newFlexVersion:AvailableFlexVersion = new AvailableFlexVersion();
newFlexVersion.shortName = productVersion.@file.toString();
- 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(productData.@prefix.toString().length).split("-")[0];
newFlexVersion.label = productData.@name.toString() + " " + productVersion.@version.toString();
newFlexVersion.path = productVersion.@path.toString();
@@ -68,7 +67,7 @@
newFlexVersion.icon = productData.@icon.toString();
if (productVersion["@default"].length() == 1)
{
- defaultVersion = this.length;
+ defaultVersionIndex = this.length;
}
this.addItem(newFlexVersion);
}