diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index ea8a0ff6..9d286560 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -35,7 +35,6 @@ import cpp.NativeSys; import haxe.io.Path; import superhuman.components.browsers.SetupBrowserPage; import superhuman.browser.Browsers; -import superhuman.components.browsers.BrowsersPage; import superhuman.config.SuperHumanHashes; import champaign.core.logging.Logger; import feathers.controls.Alert; @@ -139,7 +138,6 @@ class SuperHumanInstaller extends GenesisApplication { var _serverRolesCollection:Array; var _settingsPage:SettingsPage; var _vagrantFile:String; - var _browsersPage:BrowsersPage; var _setupBrowserPage:SetupBrowserPage; var _browsersCollection:Array; @@ -223,10 +221,6 @@ class SuperHumanInstaller extends GenesisApplication { } - if (_config.browsers == null) { - _config.browsers = _defaultConfig.browsers; - } - } else { _config = _defaultConfig; @@ -234,6 +228,8 @@ class SuperHumanInstaller extends GenesisApplication { } + Browsers.normaliseConfigBrowsersWithDefaultBrowsers(); + for ( s in _config.servers ) { var server = ServerManager.getInstance().createServer( s ); @@ -350,13 +346,6 @@ class SuperHumanInstaller extends GenesisApplication { _rolePage.addEventListener( SuperHumanApplicationEvent.CLOSE_ROLES, _closeRolePage ); this.addPage( _rolePage, PAGE_ROLES ); - /*_browsersPage = new BrowsersPage(); - _browsersPage.addEventListener(SuperHumanApplicationEvent.CONFIGURE_BROWSER, _configureBrowserPage); - _browsersPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS, _closeBrowsersPage ); - _browsersPage.addEventListener( SuperHumanApplicationEvent.REFRESH_DEFAULT_BROWSER, _refreshDefaultBrowser); - _browsersPage.addEventListener( SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE, _refreshBrowsersPage); - this.addPage( _browsersPage, PAGE_BROWSERS );*/ - _setupBrowserPage = new SetupBrowserPage(); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.REFRESH_DEFAULT_BROWSER, _refreshDefaultBrowser); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE, _refreshBrowsersPage); @@ -753,12 +742,7 @@ class SuperHumanInstaller extends GenesisApplication { this.selectedPageId = this.previousPageId; } - function _closeBrowsersPage(e:SuperHumanApplicationEvent) { - this.selectedPageId = PAGE_SETTINGS; - } - function _initializeBrowsersCollection() { - //this.previousPageId != PAGE_BROWSERS && if (this.previousPageId != PAGE_SETUP_BROWSERS) { _browsersCollection = new Array(); for (index => element in _config.browsers) diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index abe77ca9..ced7d700 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -12,12 +12,13 @@ class BrowserData { public var exists:Bool; public var downloadUrl:String; - public function new(browserType:String, isDefault:Bool = false, browserName:String = "", executablePath:String = "", exists:Bool = false) { + public function new(browserType:String, isDefault:Bool = false, browserName:String = "", executablePath:String = "", exists:Bool = false, downloadUrl:String = "") { this.browserType = browserType; this.isDefault = isDefault; this.browserName = browserName; this.executablePath = executablePath; this.exists = exists; + this.downloadUrl = downloadUrl; _setDefaultValues(browserType); } diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx index a2e13668..e764e962 100644 --- a/Source/superhuman/browser/Browsers.hx +++ b/Source/superhuman/browser/Browsers.hx @@ -28,13 +28,39 @@ class Browsers #end ]; - public static function getDefaultBrowser():Dynamic { + public static function normaliseConfigBrowsersWithDefaultBrowsers() { var config = SuperHumanInstaller.getInstance().config; - if (config.browsers == null) + if (config.browsers == null) { config.browsers = DEFAULT_BROWSERS_LIST; } - + else + { + var configBrowsers:Array = []; + for (c => e in config.browsers) + { + var bConfig:Dynamic = e; + configBrowsers.push(new BrowserData(bConfig.browserType, bConfig.isDefault, bConfig.browserName, + bConfig.executablePath, bConfig.exists, bConfig.downloadUrl)); + } + + config.browsers = configBrowsers; + + for (index => element in DEFAULT_BROWSERS_LIST) + { + var defaultBrowser = DEFAULT_BROWSERS_LIST[index]; + var configBrowser = config.browsers.filter(f -> f.browserType == defaultBrowser.browserType); + if (configBrowser == null || configBrowser.length == 0) + { + config.browsers.push(defaultBrowser); + } + } + } + } + + public static function getDefaultBrowser():Dynamic { + var config = SuperHumanInstaller.getInstance().config; + var defaultBrowser = null; for (index => element in config.browsers) { diff --git a/Source/superhuman/components/SettingsPage.hx b/Source/superhuman/components/SettingsPage.hx index 54d88c30..1e0c84e6 100644 --- a/Source/superhuman/components/SettingsPage.hx +++ b/Source/superhuman/components/SettingsPage.hx @@ -173,9 +173,6 @@ class SettingsPage extends Page { this.addChild( _buttonGroup ); updateData(); - - // var defaultBrowser:Dynamic = Browsers.getDefaultBrowser(); - //updateDefaultBrowser(defaultBrowser); } public function updateData() { diff --git a/Source/superhuman/components/browsers/BrowsersPage.hx b/Source/superhuman/components/browsers/BrowsersPage.hx deleted file mode 100644 index 85103f9a..00000000 --- a/Source/superhuman/components/browsers/BrowsersPage.hx +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2016-present Prominic.NET, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * - * http://www.mongodb.com/licensing/server-side-public-license - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the Server Side Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ -package superhuman.components.browsers; - -import openfl.events.MouseEvent; -import superhuman.components.browsers.BrowsersList.BrowserItem; -import openfl.events.Event; -import feathers.layout.VerticalAlign; -import feathers.controls.Label; -import feathers.layout.HorizontalAlign; -import superhuman.events.SuperHumanApplicationEvent; -import genesis.application.managers.LanguageManager; -import feathers.controls.Button; -import feathers.layout.HorizontalLayout; -import genesis.application.theme.GenesisApplicationTheme; -import feathers.layout.VerticalLayoutData; -import genesis.application.components.HLine; -import genesis.application.components.Page; -import feathers.controls.LayoutGroup; -import feathers.layout.VerticalLayout; -import feathers.layout.HorizontalLayoutData; -import feathers.data.ArrayCollection; -import superhuman.browser.BrowserData; -import feathers.events.TriggerEvent; -import feathers.skins.RectangleSkin; - -class BrowsersPage extends Page { - - final _width:Float = GenesisApplicationTheme.GRID * 100; - var _titleGroup:LayoutGroup; - var _titleLabel:Label; - - var _hintGroup:LayoutGroup; - var _hintLabel:Label; - - var _browsersList:BrowsersList; - - var _buttonGroup:LayoutGroup; - var _buttonGroupLayout:HorizontalLayout; - var _buttonClose:Button; - - var _browsers:ArrayCollection; - - public function new() { - - super(); - } - - override function initialize() { - - super.initialize(); - - var skin = new RectangleSkin(); - skin.border = SolidColor(1.0, 0x999999); - skin.fill = SolidColor(0xcccccc); - - var titleGroupLayout = new VerticalLayout(); - titleGroupLayout.horizontalAlign = HorizontalAlign.LEFT; - titleGroupLayout.verticalAlign = VerticalAlign.MIDDLE; - - _titleGroup = new LayoutGroup(); - _titleGroup.layout = titleGroupLayout; - _titleGroup.width = _width; - this.addChild( _titleGroup ); - - _titleLabel = new Label(); - _titleLabel.text = LanguageManager.getInstance().getString( 'settingspage.browser.titlesetupbrowser' ); - _titleLabel.variant = GenesisApplicationTheme.LABEL_LARGE; - _titleLabel.layoutData = new HorizontalLayoutData( 100 ); - _titleGroup.addChild( _titleLabel ); - - var line = new HLine(); - line.width = _width; - this.addChild( line ); - - titleGroupLayout = new VerticalLayout(); - titleGroupLayout.horizontalAlign = HorizontalAlign.RIGHT; - titleGroupLayout.verticalAlign = VerticalAlign.MIDDLE; - - _hintGroup = new LayoutGroup(); - _hintGroup.layout = titleGroupLayout; - _hintGroup.width = _width; - this.addChild(_hintGroup); - - _hintLabel = new Label(); - _hintLabel.text = LanguageManager.getInstance().getString('settingspage.browser.browserlisthint'); - _hintLabel.variant = GenesisApplicationTheme.LABEL_COPYRIGHT; - _hintGroup.addChild(_hintLabel); - - _browsersList = new BrowsersList(_browsers); - _browsersList.addEventListener(SuperHumanApplicationEvent.CONFIGURE_BROWSER, _configureBrowser ); - _browsersList.addEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); - _browsersList.width = _width; - this.addChild(_browsersList); - - line = new HLine(); - line.width = _width; - this.addChild( line ); - - _buttonGroup = new LayoutGroup(); - _buttonGroupLayout = new HorizontalLayout(); - _buttonGroupLayout.gap = GenesisApplicationTheme.GRID * 2; - _buttonGroupLayout.horizontalAlign = HorizontalAlign.CENTER; - _buttonGroup.layout = _buttonGroupLayout; - this.addChild( _buttonGroup ); - - _buttonClose = new Button( LanguageManager.getInstance().getString( 'rolepage.buttons.close' ) ); - _buttonClose.addEventListener( TriggerEvent.TRIGGER, _buttonCloseTriggered ); - _buttonGroup.addChild( _buttonClose ); - } - - public function refreshBrowsers() { - _browsersList.dataProvider.updateAll(); - } - - public function setBrowsers(browsers:Array) { - _browsers = new ArrayCollection(browsers); - if (_browsersList != null) { - _browsersList.dataProvider = _browsers; - } - } - - function _configureBrowser(e:SuperHumanApplicationEvent) { - this._forwardEvent(e); - } - - function _browserItemChange(e:SuperHumanApplicationEvent) { - //refresh state of default browser for the rest of items - var refreshDefaultBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.REFRESH_DEFAULT_BROWSER); - refreshDefaultBrowserEvent.browserData = e.browserData; - this.dispatchEvent(refreshDefaultBrowserEvent); - - var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE); - setupBrowserEvent.browserData = e.browserData; - - this.dispatchEvent( setupBrowserEvent ); - } - - function _buttonCloseTriggered( e:TriggerEvent ) { - this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.CLOSE_BROWSERS ) ); - } -} \ No newline at end of file diff --git a/Source/superhuman/events/SuperHumanApplicationEvent.hx b/Source/superhuman/events/SuperHumanApplicationEvent.hx index 0da8cd15..0e9c8f60 100644 --- a/Source/superhuman/events/SuperHumanApplicationEvent.hx +++ b/Source/superhuman/events/SuperHumanApplicationEvent.hx @@ -44,7 +44,6 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { public static final CANCEL_PAGE:String = "cancelPage"; public static final CLOSE_CONSOLE:String = "closeConsole"; public static final CLOSE_ROLES:String = "closeRoles"; - public static final CLOSE_BROWSERS:String = "closeBrowsers"; public static final REFRESH_DEFAULT_BROWSER:String = "refreshDefaultBrowser"; public static final REFRESH_BROWSERS_PAGE:String = "refreshBrowsersPage"; public static final CONFIGURE_BROWSER:String = "configureBrowser";