From 018b5222c2c3affca9cea79897ccce765f5ecf88 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Thu, 13 Jul 2023 14:09:02 +0200 Subject: [PATCH 01/26] Fix type in CHANGELOG 0.8.17 (reference #80 ) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 007d4166..5c944697 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ This release upgrade [demo-tasks](https://github.com/DominoVagrant/demo-tasks) p ### Added -* Add MD5 hashes for newest version of installer Nomad-Web and Traveler ([#77](https://github.com/Moonshine-IDE/Super.Human.Installer/issues/77) +* Add MD5 hashes for newest version of installer Nomad-Web and Traveler ([#77](https://github.com/Moonshine-IDE/Super.Human.Installer/issues/77)) ### Changed From 65787a4c9518c277acdf9fccf7df08c95cc1d13d Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Thu, 13 Jul 2023 16:37:19 +0200 Subject: [PATCH 02/26] Update version to 0.8.18 --- project.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.xml b/project.xml index 013ba04c..cb17ed0e 100644 --- a/project.xml +++ b/project.xml @@ -5,7 +5,7 @@ - + From 2242c0278aebdadd45ac136a1440fdb7684862ba Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Fri, 14 Jul 2023 12:49:57 +0200 Subject: [PATCH 03/26] Bring back Open Terminal/Folder and Delete server buttons from debug mode - Open Terminal/Folder is visible when status server is: Start/Stopped or Running - more need to be investigated (reference #74 ) --- Source/superhuman/components/ServerList.hx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/superhuman/components/ServerList.hx b/Source/superhuman/components/ServerList.hx index f6aca3ea..a355986b 100644 --- a/Source/superhuman/components/ServerList.hx +++ b/Source/superhuman/components/ServerList.hx @@ -30,6 +30,7 @@ package superhuman.components; +import champaign.core.logging.Logger; import champaign.core.primitives.Property; import feathers.controls.Label; import feathers.controls.LayoutGroup; @@ -299,13 +300,13 @@ class ServerItem extends LayoutGroupItemRenderer { _buttonOpenDir.icon = new AdvancedAssetLoader( GenesisApplicationTheme.getAssetPath( GenesisApplicationTheme.ICON_FOLDER ) ); _buttonOpenDir.toolTip = LanguageManager.getInstance().getString( 'serverpage.server.directory' ); _buttonOpenDir.addEventListener( TriggerEvent.TRIGGER, _buttonOpenDirTriggered ); - #if debug _buttonGroup.addChild( _buttonOpenDir ); #end + _buttonGroup.addChild( _buttonOpenDir ); _buttonDelete = new GenesisButton(); _buttonDelete.icon = new AdvancedAssetLoader( GenesisApplicationTheme.getAssetPath( GenesisApplicationTheme.ICON_DELETE ) ); _buttonDelete.toolTip = LanguageManager.getInstance().getString( 'serverpage.server.delete' ); _buttonDelete.addEventListener( TriggerEvent.TRIGGER, _buttonDeleteTriggered ); - #if debug _buttonGroup.addChild( _buttonDelete ); #end + _buttonGroup.addChild( _buttonDelete ); _spacer = new LayoutGroup(); _spacer.layoutData = new HorizontalLayoutData( 100 ); @@ -429,15 +430,11 @@ class ServerItem extends LayoutGroupItemRenderer { } function _buttonOpenDirTriggered( e:TriggerEvent ) { - - #if debug - + var event = new SuperHumanApplicationEvent( SuperHumanApplicationEvent.OPEN_SERVER_DIRECTORY ); event.server = _server; this.dispatchEvent( event ); - - #end - + } function _buttonProvisionTriggered( e:TriggerEvent ) { @@ -570,6 +567,7 @@ class ServerItem extends LayoutGroupItemRenderer { _buttonDelete.enabled = _buttonDelete.includeInLayout = _buttonDelete.visible = false; _buttonDestroy.enabled = _buttonDestroy.includeInLayout = _buttonDestroy.visible = false; _buttonOpenBrowser.enabled = _buttonOpenBrowser.includeInLayout = _buttonOpenBrowser.visible = false; + _buttonOpenDir.enabled = _buttonOpenDir.includeInLayout = _buttonOpenDir.visible = false; _buttonProvision.enabled = _buttonProvision.includeInLayout = _buttonProvision.visible = false; _buttonSSH.enabled = _buttonSSH.includeInLayout = _buttonSSH.visible = false; _buttonStart.enabled = _buttonStart.includeInLayout = _buttonStart.visible = false; @@ -584,6 +582,8 @@ class ServerItem extends LayoutGroupItemRenderer { if ( !Vagrant.getInstance().exists || !VirtualBox.getInstance().exists ) return; + Logger.info('${this}: _updateServer Server status: ${_server.status.value}'); + Logger.info('${this}: _updateServer Server provisioned: ${_server.provisioned}'); switch ( _server.status.value ) { case ServerStatus.Stopped( hasError ): @@ -591,13 +591,14 @@ class ServerItem extends LayoutGroupItemRenderer { _buttonDestroy.enabled = _buttonDestroy.includeInLayout = _buttonDestroy.visible = _server.provisioned; _buttonDelete.enabled = _buttonDelete.includeInLayout = _buttonDelete.visible = !_server.provisioned; _buttonStart.visible = _buttonStart.includeInLayout = _buttonStart.enabled = true; + _buttonOpenDir.enabled = _buttonOpenDir.includeInLayout = _buttonOpenDir.visible = true; _statusLabel.text = ( hasError ) ? LanguageManager.getInstance().getString( 'serverpage.server.status.stoppedwitherrors' ) : LanguageManager.getInstance().getString( 'serverpage.server.status.stopped', ( _server.provisioned ) ? '(${LanguageManager.getInstance().getString( 'serverpage.server.status.provisioned' )})' : '' ); case ServerStatus.Stopping( forced ): _statusLabel.text = ( forced ) ? LanguageManager.getInstance().getString( 'serverpage.server.status.stoppingforced' ) : LanguageManager.getInstance().getString( 'serverpage.server.status.stopping' ); case ServerStatus.Start( provisionedBefore ): - + _buttonOpenDir.enabled = _buttonOpenDir.includeInLayout = _buttonOpenDir.visible = true; if ( provisionedBefore ) { _statusLabel.text = LanguageManager.getInstance().getString( 'serverpage.server.status.start' ); @@ -616,6 +617,7 @@ class ServerItem extends LayoutGroupItemRenderer { _statusLabel.text = LanguageManager.getInstance().getString( 'serverpage.server.status.initializing' ); case ServerStatus.Running( hasError ): + _buttonOpenDir.enabled = _buttonOpenDir.includeInLayout = _buttonOpenDir.visible = true; _buttonOpenBrowser.enabled = _buttonOpenBrowser.includeInLayout = _buttonOpenBrowser.visible = true; _buttonSSH.enabled = _buttonSSH.includeInLayout = _buttonSSH.visible = true; _buttonStop.includeInLayout = _buttonStop.visible = _buttonStop.enabled = true; From b2304f49878173b3f3c09ee53077fbd836bba1f5 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 25 Jul 2023 11:56:22 +0200 Subject: [PATCH 04/26] Browsers: Add UI to apply default web Browser used to open links in application - Browsers are not saved to configuration yet (reference #81) --- Assets/text/en_US.json | 11 ++ .../theme/GenesisApplicationTheme.hx | 2 + Source/SuperHumanInstaller.hx | 49 +++++- Source/superhuman/browser/BrowserData.hx | 88 ++++++++++ Source/superhuman/browser/Browsers.hx | 13 ++ Source/superhuman/components/SettingsPage.hx | 34 +++- .../components/browsers/BrowsersList.hx | 135 ++++++++++++++++ .../components/browsers/BrowsersPage.hx | 132 +++++++++++++++ .../components/browsers/SetupBrowserPage.hx | 152 ++++++++++++++++++ .../events/SuperHumanApplicationEvent.hx | 7 + 10 files changed, 614 insertions(+), 9 deletions(-) create mode 100644 Source/superhuman/browser/BrowserData.hx create mode 100644 Source/superhuman/browser/Browsers.hx create mode 100644 Source/superhuman/components/browsers/BrowsersList.hx create mode 100644 Source/superhuman/components/browsers/BrowsersPage.hx create mode 100644 Source/superhuman/components/browsers/SetupBrowserPage.hx diff --git a/Assets/text/en_US.json b/Assets/text/en_US.json index f29e7cb3..9c297668 100644 --- a/Assets/text/en_US.json +++ b/Assets/text/en_US.json @@ -374,6 +374,17 @@ "buttons":{ "save": "Save", "cancel": "Cancel" + }, + "browser": { + "title": "Browser", + "defaultbrowser": "Setup default Browser", + "currentdefaultbrowser": "Current default Browser:", + "titlesetupbrowser": "Browsers", + "titlebrowserpath": "Setup %1 path", + "browsername": "Browser name", + "executablebrowserpath": "Executable Browser path", + "locatebrowser": "Locate Browser", + "defaultbrowser": "Default Browser" } } } \ No newline at end of file diff --git a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx index 0eb9198f..1e11581c 100644 --- a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx +++ b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx @@ -249,6 +249,7 @@ class GenesisApplicationTheme extends ClassVariantTheme { Button : new TextFormat( "_sans", 14, _themeColors.BtnText ), ButtonWarning : new TextFormat( "_sans", 14, _themeColors.BtnWarningText ), + Check: new TextFormat( "_sans", 14, White), ConsoleText: new TextFormat( "_typewriter", 14, _themeColors.TextConsole ), ConsoleTextError: new TextFormat( "_typewriter", 14, _themeColors.Error ), ConsoleTextSelected: new TextFormat( "_typewriter", 14, _themeColors.TextConsole ), @@ -970,6 +971,7 @@ typedef Typography = { var Button:TextFormat; var ButtonWarning:TextFormat; + var Check:TextFormat; var ConsoleText:TextFormat; var ConsoleTextError:TextFormat; var ConsoleTextSelected:TextFormat; diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 3025688a..b2d416e2 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -30,6 +30,9 @@ package; +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; @@ -71,6 +74,7 @@ import superhuman.server.CombinedVirtualMachine; import superhuman.server.Server; import superhuman.server.ServerStatus; import superhuman.server.data.RoleData; +import superhuman.browser.BrowserData; import superhuman.server.data.ServerData; import superhuman.server.roles.ServerRoleImpl; import superhuman.theme.SuperHumanInstallerTheme; @@ -98,6 +102,8 @@ class SuperHumanInstaller extends GenesisApplication { static public final PAGE_ROLES = "page-roles"; static public final PAGE_SERVER = "page-server"; static public final PAGE_SETTINGS = "page-settings"; + static public final PAGE_BROWSERS = "page-browsers"; + static public final PAGE_SETUP_BROWSERS = "page-setup-browsers"; static public final DEMO_TASKS_PATH:String = "assets/vagrant/demo-tasks/"; @@ -130,6 +136,9 @@ class SuperHumanInstaller extends GenesisApplication { var _serverRolesCollection:Array; var _settingsPage:SettingsPage; var _vagrantFile:String; + var _browsersPage:BrowsersPage; + var _setupBrowserPage:SetupBrowserPage; + var _browsersCollection:Array; public var config( get, never ):SuperHumanConfig; function get_config() return _config; @@ -140,6 +149,9 @@ class SuperHumanInstaller extends GenesisApplication { public var serverRolesCollection( get, never ):Array; function get_serverRolesCollection() return _serverRolesCollection; + public var browsersCollection( get, never ):Array; + function get_browsersCollection() return _browsersCollection; + public function new() { super( #if showlogin true #end ); @@ -177,6 +189,13 @@ class SuperHumanInstaller extends GenesisApplication { ]; + _browsersCollection = [ + new BrowserData(Browsers.Mozilla_Firefox), + new BrowserData(Browsers.Google_Chrome), + new BrowserData(Browsers.Brave), + new BrowserData(Browsers.Safari) + ]; + if ( FileSystem.exists( '${System.applicationStorageDirectory}${_CONFIG_FILE}' ) ) { try { @@ -323,6 +342,7 @@ class SuperHumanInstaller extends GenesisApplication { this.addPage( _advancedConfigPage, PAGE_CONFIG_ADVANCED ); _settingsPage = new SettingsPage(); + _settingsPage.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSERS_SETUP, _openBrowsersSetup ); _settingsPage.addEventListener( SuperHumanApplicationEvent.CANCEL_PAGE, _cancelSettings ); _settingsPage.addEventListener( SuperHumanApplicationEvent.SAVE_APP_CONFIGURATION, _saveAppConfiguration ); this.addPage( _settingsPage, PAGE_SETTINGS ); @@ -331,6 +351,15 @@ class SuperHumanInstaller extends GenesisApplication { _rolePage.addEventListener( SuperHumanApplicationEvent.CLOSE_ROLES, _closeRolePage ); this.addPage( _rolePage, PAGE_ROLES ); + _browsersPage = new BrowsersPage(_browsersCollection); + _browsersPage.addEventListener(SuperHumanApplicationEvent.SETUP_BROWSER, _setBrowserPage); + _browsersPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS, _closeBrowsersPage ); + this.addPage( _browsersPage, PAGE_BROWSERS ); + + _setupBrowserPage = new SetupBrowserPage(); + _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP, _closeBrowsersPage ); + this.addPage( _setupBrowserPage, PAGE_SETUP_BROWSERS ); + _navigator.validateNow(); this.selectedPageId = PAGE_LOADING; @@ -510,10 +539,12 @@ class SuperHumanInstaller extends GenesisApplication { } + function _openBrowsersSetup(e:SuperHumanApplicationEvent) { + this.selectedPageId = PAGE_BROWSERS; + } + function _cancelSettings( e:SuperHumanApplicationEvent ) { - - this.selectedPageId = this.previousPageId; - + this.selectedPageId = PAGE_SERVER; } function _saveAppConfiguration( e:SuperHumanApplicationEvent ) { @@ -523,7 +554,7 @@ class SuperHumanInstaller extends GenesisApplication { ToastManager.getInstance().showToast( LanguageManager.getInstance().getString( 'toast.settingssaved' ) ); } - + function _downloadVagrant( e:SuperHumanApplicationEvent ) { Shell.getInstance().open( [ SuperHumanGlobals.VAGRANT_DOWNLOAD_URL ] ); @@ -685,6 +716,15 @@ class SuperHumanInstaller extends GenesisApplication { } + function _setBrowserPage(e:SuperHumanApplicationEvent) { + this.selectedPageId = PAGE_SETUP_BROWSERS; + _setupBrowserPage.setBrowserData(e.browserData); + } + + function _closeBrowsersPage(e:SuperHumanApplicationEvent) { + this.selectedPageId = this.previousPageId; + } + function _saveAdvancedServerConfiguration( e:SuperHumanApplicationEvent ) { e.server.saveHostsFile(); @@ -794,6 +834,7 @@ class SuperHumanInstaller extends GenesisApplication { function _openServerDir( e:SuperHumanApplicationEvent ) { + Logger.info('${this}: _openServerDir path: ${e.server.path.value}'); Shell.getInstance().open( [ e.server.path.value ] ); Shell.getInstance().openTerminal( e.server.path.value, false ); diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx new file mode 100644 index 00000000..f06907aa --- /dev/null +++ b/Source/superhuman/browser/BrowserData.hx @@ -0,0 +1,88 @@ +package superhuman.browser; + +import haxe.io.Path; + +class BrowserData { + + var _browserType:Browsers; + + var _browserName:String; + public var browserName( get, set ):String; + function get_browserName() return _browserName; + function set_browserName(value) { + if (_browserName != value) { + _browserName = value; + } + return _browserName; + } + + var _executablePath:String; + public var executablePath( get, set ):String; + function get_executablePath() return _executablePath; + function set_executablePath(value) { + if (_executablePath != value) { + _executablePath = value; + } + return _executablePath; + } + + var _isDefault:Bool; + public var isDefault( get, set ):Bool; + function get_isDefault() return _isDefault; + function set_isDefault(value) { + if (_isDefault != value) { + _isDefault = value; + } + return _isDefault; + } + + public function new(browserType:Browsers, isDefault:Bool = false, browserName:String = "", executablePath:String = "") { + _browserType = browserType; + _isDefault = isDefault; + _browserName = browserName; + _executablePath = executablePath; + + _setDefaultValues(browserType); + } + + function _setDefaultValues(browserType:Browsers) { + if (this.browserName == "") { + this.browserName = StringTools.replace(browserType.getName(), "_", " "); + } + + if (executablePath == "") { + switch browserType { + case Google_Chrome: + #if linux + + #elseif mac + this.executablePath = "/Applications/Google Chrome.app"; + #elseif windows + this.exeexecutablePath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; + #end + case Brave: + #if linux + + #elseif mac + this.executablePath = "/Applications/Brave Browser.app"; + #elseif windows + this.exeexecutablePath = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"; + #end + case Safari: + this.executablePath = "/Applications/Safari.app"; + case Chromium: + case Opera: + case Internet_Explorer: + default: + #if linux + + #elseif mac + this.executablePath = "/Applications/Firefox.app"; + #elseif windows + this.exeexecutablePath = "C:/Program Files/Mozilla Firefox/firefox.exe"; + #end + isDefault = true; + } + } + } +} \ No newline at end of file diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx new file mode 100644 index 00000000..d8371269 --- /dev/null +++ b/Source/superhuman/browser/Browsers.hx @@ -0,0 +1,13 @@ +package superhuman.browser; + +enum Browsers +{ + Mozilla_Firefox; + Google_Chrome; + Chromium; + Microsoft_Edge; + Brave; + Opera; + Safari; + Internet_Explorer; +} \ No newline at end of file diff --git a/Source/superhuman/components/SettingsPage.hx b/Source/superhuman/components/SettingsPage.hx index fe11a1ef..1dcd9760 100644 --- a/Source/superhuman/components/SettingsPage.hx +++ b/Source/superhuman/components/SettingsPage.hx @@ -48,7 +48,7 @@ import superhuman.events.SuperHumanApplicationEvent; class SettingsPage extends Page { - final _w:Float = GenesisApplicationTheme.GRID * 100; + final _width:Float = GenesisApplicationTheme.GRID * 100; var _buttonCancel:GenesisFormButton; var _buttonGroup:LayoutGroup; @@ -66,6 +66,10 @@ class SettingsPage extends Page { var _rowKeepFailedServersRunning:GenesisFormRow; var _rowKeepServersRunning:GenesisFormRow; var _rowProvision:GenesisFormRow; + var _rowBrowsers:GenesisFormRow; + var _rowBrowsersDefault:GenesisFormRow; + var _buttonDefaultBrowser:GenesisFormButton; + var _labelDefaultBrowser:Label; var _titleGroup:LayoutGroup; public function new() { @@ -83,7 +87,7 @@ class SettingsPage extends Page { _titleGroupLayout.horizontalAlign = HorizontalAlign.LEFT; _titleGroupLayout.verticalAlign = VerticalAlign.MIDDLE; _titleGroup.layout = _titleGroupLayout; - _titleGroup.width = _w; + _titleGroup.width = _width; this.addChild( _titleGroup ); _label = new Label(); @@ -93,7 +97,7 @@ class SettingsPage extends Page { _titleGroup.addChild( _label ); var line = new HLine(); - line.width = _w; + line.width = _width; this.addChild( line ); _form = new GenesisForm(); @@ -108,7 +112,7 @@ class SettingsPage extends Page { _form.addChild( _rowApplicationWindow ); var spacer = new LayoutGroup(); - spacer.height = GenesisApplicationTheme.GRID * 4; + spacer.height = GenesisApplicationTheme.GRID * 2; _form.addChild( spacer ); _rowProvision = new GenesisFormRow(); @@ -133,9 +137,25 @@ class SettingsPage extends Page { _cbKeepFailedServersRunning = new GenesisFormCheckBox( LanguageManager.getInstance().getString( 'settingspage.advanced.keepfailedserversrunning' ) ); _rowKeepFailedServersRunning.content.addChild( _cbKeepFailedServersRunning ); _form.addChild( _rowKeepFailedServersRunning ); + + spacer = new LayoutGroup(); + spacer.height = GenesisApplicationTheme.GRID * 2; + _form.addChild( spacer ); + + _rowBrowsersDefault = new GenesisFormRow(); + _rowBrowsersDefault.text = LanguageManager.getInstance().getString( 'settingspage.browser.title' ); + _labelDefaultBrowser = new Label(LanguageManager.getInstance().getString( 'settingspage.browser.currentdefaultbrowser' ) + "Firefox"); + _rowBrowsersDefault.content.addChild(_labelDefaultBrowser); + _form.addChild(_rowBrowsersDefault); + + _rowBrowsers = new GenesisFormRow(); + _buttonDefaultBrowser = new GenesisFormButton( LanguageManager.getInstance().getString( 'settingspage.browser.defaultbrowser' ) ); + _buttonDefaultBrowser.addEventListener( TriggerEvent.TRIGGER, _setDefaultBrowserButtonTrigger ); + _rowBrowsers.content.addChild(_buttonDefaultBrowser); + _form.addChild(_rowBrowsers); var line = new HLine(); - line.width = _w; + line.width = _width; this.addChild( line ); _buttonGroup = new LayoutGroup(); @@ -182,5 +202,9 @@ class SettingsPage extends Page { this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.SAVE_APP_CONFIGURATION ) ); } + + function _setDefaultBrowserButtonTrigger(e:TriggerEvent) { + this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.OPEN_BROWSERS_SETUP ) ); + } } \ No newline at end of file diff --git a/Source/superhuman/components/browsers/BrowsersList.hx b/Source/superhuman/components/browsers/BrowsersList.hx new file mode 100644 index 00000000..b412ccd5 --- /dev/null +++ b/Source/superhuman/components/browsers/BrowsersList.hx @@ -0,0 +1,135 @@ +/* + * 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 feathers.layout.VerticalListLayout; +import feathers.layout.VerticalLayout; +import feathers.layout.HorizontalLayoutData; +import feathers.layout.VerticalLayoutData; +import feathers.layout.VerticalAlign; +import genesis.application.theme.GenesisApplicationTheme; +import feathers.data.ListViewItemState; +import feathers.controls.dataRenderers.LayoutGroupItemRenderer; +import feathers.controls.Label; +import feathers.controls.Check; +import feathers.controls.LayoutGroup; +import feathers.controls.ListView; +import feathers.layout.HorizontalLayout; +import superhuman.browser.BrowserData; +import feathers.data.IFlatCollection; +import superhuman.events.SuperHumanApplicationEvent; +import feathers.utils.DisplayObjectRecycler; + +@:styleContext +class BrowsersList extends ListView { + + public function new( ?dataProvider:IFlatCollection ) { + + super( dataProvider ); + + this.layout = new VerticalListLayout(); + + var recycler = DisplayObjectRecycler.withFunction( () -> { + + var item = new BrowserItem(); + return item; + + } ); + + recycler.update = ( item:BrowserItem, state:ListViewItemState) -> { + item.updateBroswer(state.data); + }; + + recycler.reset = ( item:BrowserItem, state:ListViewItemState) -> { + + + + }; + + recycler.destroy = ( item:BrowserItem ) -> { + + + + }; + + this.itemRendererRecycler = recycler; + + } + + function _forwardEvent( e:SuperHumanApplicationEvent ) { + + this.dispatchEvent( e ); + + } + +} + +@:styleContext +class BrowserItem extends LayoutGroupItemRenderer { + + var _labelBrowserGroupLayout:HorizontalLayout; + var _labelBrowserGroup:LayoutGroup; + var _labelBrowserName:Label; + + var _checkBrowserStatus:Check; + + public function new() { + + super(); + + } + + override function initialize() { + + super.initialize(); + + var horizontalLayout = new HorizontalLayout(); + horizontalLayout.paddingRight = 5; + horizontalLayout.paddingLeft = 5; + horizontalLayout.paddingTop = 5; + horizontalLayout.paddingBottom = 5; + horizontalLayout.verticalAlign = VerticalAlign.MIDDLE; + + this.layout = horizontalLayout; + + _labelBrowserName = new Label(); + _labelBrowserName.layoutData = new HorizontalLayoutData(100); + this.addChild(_labelBrowserName); + + _checkBrowserStatus = new Check(); + _checkBrowserStatus.enabled = false; + this.addChild(_checkBrowserStatus); + } + + public function updateBroswer(browserData:BrowserData) { + _labelBrowserName.text = browserData.browserName; + } +} \ No newline at end of file diff --git a/Source/superhuman/components/browsers/BrowsersPage.hx b/Source/superhuman/components/browsers/BrowsersPage.hx new file mode 100644 index 00000000..98fd67cd --- /dev/null +++ b/Source/superhuman/components/browsers/BrowsersPage.hx @@ -0,0 +1,132 @@ +/* + * 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.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 _labelTitle:Label; + + var _browsersList:BrowsersList; + + var _buttonGroup:LayoutGroup; + var _buttonGroupLayout:HorizontalLayout; + var _buttonClose:Button; + + var _browsers:ArrayCollection; + + public function new( browsers:Array ) { + + super(); + + _browsers = new ArrayCollection(browsers); + } + + override function initialize() { + + super.initialize(); + + var skin = new RectangleSkin(); + skin.border = SolidColor(1.0, 0x999999); + skin.fill = SolidColor(0xcccccc); + + var titleGroupLayout = new HorizontalLayout(); + titleGroupLayout.horizontalAlign = HorizontalAlign.RIGHT; + titleGroupLayout.verticalAlign = VerticalAlign.MIDDLE; + + _titleGroup = new LayoutGroup(); + _titleGroup.layout = titleGroupLayout; + _titleGroup.width = _width; + this.addChild( _titleGroup ); + + _labelTitle = new Label(); + _labelTitle.text = LanguageManager.getInstance().getString( 'settingspage.browser.titlesetupbrowser' ); + _labelTitle.variant = GenesisApplicationTheme.LABEL_LARGE; + _labelTitle.layoutData = new HorizontalLayoutData( 100 ); + _titleGroup.addChild( _labelTitle ); + + var line = new HLine(); + line.width = _width; + this.addChild( line ); + + _browsersList = new BrowsersList(_browsers); + _browsersList.addEventListener( Event.CHANGE, _browserListChanged ); + _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 ); + } + + function _browserListChanged(e:Event) { + var browserData:BrowserData = _browsersList.selectedItem; + var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SETUP_BROWSER); + setupBrowserEvent.browserData = 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/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx new file mode 100644 index 00000000..3bea64ba --- /dev/null +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -0,0 +1,152 @@ +package superhuman.components.browsers; + +import superhuman.theme.SuperHumanInstallerTheme; +import feathers.text.TextFormat; +import feathers.controls.Check; +import feathers.controls.Button; +import genesis.application.components.GenesisFormButton; +import superhuman.browser.BrowserData; +import feathers.controls.Label; +import superhuman.events.SuperHumanApplicationEvent; +import feathers.events.TriggerEvent; +import feathers.layout.HorizontalAlign; +import genesis.application.components.HLine; +import feathers.layout.HorizontalLayoutData; +import feathers.layout.VerticalAlign; +import feathers.layout.VerticalLayoutData; +import genesis.application.managers.LanguageManager; +import feathers.layout.HorizontalLayout; +import genesis.application.theme.GenesisApplicationTheme; +import feathers.layout.VerticalLayout; +import feathers.controls.LayoutGroup; +import feathers.controls.TextInput; +import genesis.application.components.Page; + +class SetupBrowserPage extends Page { + + final _width:Float = GenesisApplicationTheme.GRID * 100; + + var _titleGroup:LayoutGroup; + var _labelTitle:Label; + + var _browserNameGroup:LayoutGroup; + var _textInputBrowserName:TextInput; + + var _execPathGroup:LayoutGroup; + var _textInputPath:TextInput; + var _locatePath:Button; + + var _defaultBrowserGroup:LayoutGroup; + var _checkDefaultBrowser:Check; + + var _buttonGroup:LayoutGroup; + var _buttonGroupLayout:HorizontalLayout; + var _buttonSave:GenesisFormButton; + var _buttonClose:GenesisFormButton; + + var _browserData:BrowserData; + + public function new() + { + super(); + + var titleGroupLayout = new HorizontalLayout(); + titleGroupLayout.horizontalAlign = HorizontalAlign.RIGHT; + titleGroupLayout.verticalAlign = VerticalAlign.MIDDLE; + + _titleGroup = new LayoutGroup(); + _titleGroup.layout = titleGroupLayout; + _titleGroup.width = _width; + this.addChild( _titleGroup ); + + _labelTitle = new Label(); + _labelTitle.variant = GenesisApplicationTheme.LABEL_LARGE; + _labelTitle.layoutData = new HorizontalLayoutData( 100 ); + _titleGroup.addChild( _labelTitle ); + + var line = new HLine(); + line.width = _width; + this.addChild( line ); + + var horizontalGroupLayout = new HorizontalLayout(); + horizontalGroupLayout.verticalAlign = VerticalAlign.MIDDLE; + + _browserNameGroup = new LayoutGroup(); + _browserNameGroup.width = _width; + _browserNameGroup.layout = horizontalGroupLayout; + this.addChild(_browserNameGroup); + + _textInputBrowserName = new TextInput( "", LanguageManager.getInstance().getString( 'settingspage.browser.browsername' ) ); + _textInputBrowserName.layoutData = new HorizontalLayoutData(100); + _browserNameGroup.addChild(_textInputBrowserName); + + horizontalGroupLayout = new HorizontalLayout(); + horizontalGroupLayout.verticalAlign = VerticalAlign.MIDDLE; + horizontalGroupLayout.gap = 4; + + _execPathGroup = new LayoutGroup(); + _execPathGroup.width = _width; + _execPathGroup.layout = horizontalGroupLayout; + this.addChild(_execPathGroup); + + _textInputPath = new TextInput("", LanguageManager.getInstance().getString('settingspage.browser.executablebrowserpath')); + _textInputPath.layoutData = new HorizontalLayoutData(100); + _textInputPath.enabled = false; + _execPathGroup.addChild(_textInputPath); + + _locatePath = new Button(LanguageManager.getInstance().getString('settingspage.browser.locatebrowser')); + _locatePath.variant = GenesisApplicationTheme.BUTTON_SELECT_FILE; + _execPathGroup.addChild(_locatePath); + + horizontalGroupLayout = new HorizontalLayout(); + horizontalGroupLayout.verticalAlign = VerticalAlign.MIDDLE; + + _defaultBrowserGroup = new LayoutGroup(); + _defaultBrowserGroup.width = _width; + _defaultBrowserGroup.layout = horizontalGroupLayout; + this.addChild(_defaultBrowserGroup); + + _checkDefaultBrowser = new Check(LanguageManager.getInstance().getString('settingspage.browser.defaultbrowser')); + _checkDefaultBrowser.variant = GenesisApplicationTheme.CHECK_MEDIUM; + _defaultBrowserGroup.addChild(_checkDefaultBrowser); + + var 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 ); + + _buttonSave = new GenesisFormButton( LanguageManager.getInstance().getString( 'settingspage.buttons.save' ) ); + _buttonSave.addEventListener( TriggerEvent.TRIGGER, _saveButtonTriggered ); + _buttonGroup.addChild(_buttonSave); + + _buttonClose = new GenesisFormButton( LanguageManager.getInstance().getString( 'settingspage.buttons.cancel' ) ); + _buttonClose.addEventListener( TriggerEvent.TRIGGER, _buttonCloseTriggered ); + _buttonGroup.addChild( _buttonClose ); + } + + public function setBrowserData(data:BrowserData) { + _browserData = data; + _labelTitle.text = LanguageManager.getInstance().getString( 'settingspage.browser.titlebrowserpath', data.browserName ); + _textInputBrowserName.text = data.browserName; + _textInputPath.text = data.executablePath; + } + + function _saveButtonTriggered(e:TriggerEvent) { + var superHumanAppEvent:SuperHumanApplicationEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION); + superHumanAppEvent.browserData = _browserData; + + this.dispatchEvent(superHumanAppEvent); + } + + function _buttonCloseTriggered( e:TriggerEvent ) { + + this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP ) ); + + } +} \ No newline at end of file diff --git a/Source/superhuman/events/SuperHumanApplicationEvent.hx b/Source/superhuman/events/SuperHumanApplicationEvent.hx index b9768eea..d0b35481 100644 --- a/Source/superhuman/events/SuperHumanApplicationEvent.hx +++ b/Source/superhuman/events/SuperHumanApplicationEvent.hx @@ -30,6 +30,7 @@ package superhuman.events; +import superhuman.browser.BrowserData; import genesis.application.events.GenesisApplicationEvent; import superhuman.components.Console; import superhuman.server.Server; @@ -43,6 +44,9 @@ 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 SETUP_BROWSER:String = "setupBrowser"; + public static final CLOSE_BROWSERS_SETUP:String = "closeBrowsersSetup"; public static final CONFIGURE_ROLES:String = "configureRoles"; public static final CONFIGURE_SERVER:String = "configureServer"; public static final COPY_TO_CLIPBOARD:String = "copyToClipboard"; @@ -52,6 +56,7 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { public static final DOWNLOAD_VAGRANT:String = "downloadVagrant"; public static final DOWNLOAD_VIRTUALBOX:String = "downloadVirtualBox"; public static final OPEN_BROWSER:String = "openBrowser"; + public static final OPEN_BROWSERS_SETUP:String = "openBrowsersSetup"; public static final OPEN_CONSOLE:String = "openConsole"; public static final OPEN_SERVER_DIRECTORY:String = "openServerDirectory"; public static final OPEN_VAGRANT_SSH:String = "openVagrantSSH"; @@ -61,6 +66,7 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { public static final RESET_SERVER:String = "resetServer"; public static final SAVE_ADVANCED_SERVER_CONFIGURATION:String = "saveAdvancedServerConfiguration"; public static final SAVE_APP_CONFIGURATION:String = "saveAppConfiguration"; + public static final SAVE_APP_BROWSERS_CONFIGURATION:String = "saveAppBrowsersConfiguration"; public static final SAVE_SERVER_CONFIGURATION:String = "saveServerConfiguration"; public static final START_SERVER:String = "startServer"; public static final STOP_SERVER:String = "stopServer"; @@ -74,6 +80,7 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { public var provisionerType:ProvisionerType; public var server:Server; public var text:String; + public var browserData:BrowserData; public function new( type:String ) { From ad5ec89662b4d87a0d9e3aa049c57566934e7a6b Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 25 Jul 2023 12:59:24 +0200 Subject: [PATCH 05/26] Browsers: Save browsers states to app config (reference #81) --- Source/SuperHumanInstaller.hx | 38 ++++++++++---- Source/superhuman/browser/BrowserData.hx | 50 ++++--------------- .../components/browsers/SetupBrowserPage.hx | 1 + Source/superhuman/config/SuperHumanConfig.hx | 3 +- 4 files changed, 42 insertions(+), 50 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index b2d416e2..18f5fcc9 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -120,6 +120,7 @@ class SuperHumanInstaller extends GenesisApplication { servers : [], user: {}, preferences: { keepserversrunning: true, savewindowposition: false, provisionserversonstart:false, disablevagrantlogging: false, keepfailedserversrunning: false }, + browsers: [] } var _advancedConfigPage:AdvancedConfigPage; @@ -138,7 +139,7 @@ class SuperHumanInstaller extends GenesisApplication { var _vagrantFile:String; var _browsersPage:BrowsersPage; var _setupBrowserPage:SetupBrowserPage; - var _browsersCollection:Array; + //var _browsersCollection:Array; public var config( get, never ):SuperHumanConfig; function get_config() return _config; @@ -149,8 +150,8 @@ class SuperHumanInstaller extends GenesisApplication { public var serverRolesCollection( get, never ):Array; function get_serverRolesCollection() return _serverRolesCollection; - public var browsersCollection( get, never ):Array; - function get_browsersCollection() return _browsersCollection; + /*public var browsersCollection( get, never ):Array; + function get_browsersCollection() return _browsersCollection;*/ public function new() { @@ -189,8 +190,8 @@ class SuperHumanInstaller extends GenesisApplication { ]; - _browsersCollection = [ - new BrowserData(Browsers.Mozilla_Firefox), + _defaultConfig.browsers = [ + new BrowserData(Browsers.Mozilla_Firefox, true), new BrowserData(Browsers.Google_Chrome), new BrowserData(Browsers.Brave), new BrowserData(Browsers.Safari) @@ -351,13 +352,13 @@ class SuperHumanInstaller extends GenesisApplication { _rolePage.addEventListener( SuperHumanApplicationEvent.CLOSE_ROLES, _closeRolePage ); this.addPage( _rolePage, PAGE_ROLES ); - _browsersPage = new BrowsersPage(_browsersCollection); + _browsersPage = new BrowsersPage(_defaultConfig.browsers); _browsersPage.addEventListener(SuperHumanApplicationEvent.SETUP_BROWSER, _setBrowserPage); _browsersPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS, _closeBrowsersPage ); this.addPage( _browsersPage, PAGE_BROWSERS ); _setupBrowserPage = new SetupBrowserPage(); - _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP, _closeBrowsersPage ); + _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP, _closeSetupBrowserPage ); this.addPage( _setupBrowserPage, PAGE_SETUP_BROWSERS ); _navigator.validateNow(); @@ -544,13 +545,21 @@ class SuperHumanInstaller extends GenesisApplication { } function _cancelSettings( e:SuperHumanApplicationEvent ) { - this.selectedPageId = PAGE_SERVER; + if (this.previousPageId != PAGE_BROWSERS) { + this.selectedPageId = this.previousPageId; + } else { + this.selectedPageId = PAGE_SERVER; + } } function _saveAppConfiguration( e:SuperHumanApplicationEvent ) { _saveConfig(); - this.selectedPageId = this.previousPageId; + if (this.previousPageId != PAGE_BROWSERS) { + this.selectedPageId = this.previousPageId; + } else { + this.selectedPageId = PAGE_SERVER; + } ToastManager.getInstance().showToast( LanguageManager.getInstance().getString( 'toast.settingssaved' ) ); } @@ -678,8 +687,13 @@ class SuperHumanInstaller extends GenesisApplication { } + if (_config.browsers == null) { + _config.browsers = _defaultConfig.browsers; + } + try { + var conf = Json.stringify( _config, ( SuperHumanGlobals.PRETTY_PRINT ) ? "\t" : null ); File.saveContent( '${System.applicationStorageDirectory}${_CONFIG_FILE}', Json.stringify( _config, ( SuperHumanGlobals.PRETTY_PRINT ) ? "\t" : null ) ); Logger.debug( '${this}: Configuration saved to: ${System.applicationStorageDirectory}${_CONFIG_FILE}' ); @@ -721,10 +735,14 @@ class SuperHumanInstaller extends GenesisApplication { _setupBrowserPage.setBrowserData(e.browserData); } - function _closeBrowsersPage(e:SuperHumanApplicationEvent) { + function _closeSetupBrowserPage(e:SuperHumanApplicationEvent) { this.selectedPageId = this.previousPageId; } + function _closeBrowsersPage(e:SuperHumanApplicationEvent) { + this.selectedPageId = PAGE_SETTINGS; + } + function _saveAdvancedServerConfiguration( e:SuperHumanApplicationEvent ) { e.server.saveHostsFile(); diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index f06907aa..b64a85e1 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -4,43 +4,16 @@ import haxe.io.Path; class BrowserData { - var _browserType:Browsers; - - var _browserName:String; - public var browserName( get, set ):String; - function get_browserName() return _browserName; - function set_browserName(value) { - if (_browserName != value) { - _browserName = value; - } - return _browserName; - } - - var _executablePath:String; - public var executablePath( get, set ):String; - function get_executablePath() return _executablePath; - function set_executablePath(value) { - if (_executablePath != value) { - _executablePath = value; - } - return _executablePath; - } - - var _isDefault:Bool; - public var isDefault( get, set ):Bool; - function get_isDefault() return _isDefault; - function set_isDefault(value) { - if (_isDefault != value) { - _isDefault = value; - } - return _isDefault; - } + public var browserType:Browsers; + public var browserName:String; + public var executablePath:String; + public var isDefault:Bool; public function new(browserType:Browsers, isDefault:Bool = false, browserName:String = "", executablePath:String = "") { - _browserType = browserType; - _isDefault = isDefault; - _browserName = browserName; - _executablePath = executablePath; + this.browserType = browserType; + this.isDefault = isDefault; + this.browserName = browserName; + this.executablePath = executablePath; _setDefaultValues(browserType); } @@ -58,7 +31,7 @@ class BrowserData { #elseif mac this.executablePath = "/Applications/Google Chrome.app"; #elseif windows - this.exeexecutablePath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; + this.executablePath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; #end case Brave: #if linux @@ -66,7 +39,7 @@ class BrowserData { #elseif mac this.executablePath = "/Applications/Brave Browser.app"; #elseif windows - this.exeexecutablePath = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"; + this.executablePath = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"; #end case Safari: this.executablePath = "/Applications/Safari.app"; @@ -79,9 +52,8 @@ class BrowserData { #elseif mac this.executablePath = "/Applications/Firefox.app"; #elseif windows - this.exeexecutablePath = "C:/Program Files/Mozilla Firefox/firefox.exe"; + this.executablePath = "C:/Program Files/Mozilla Firefox/firefox.exe"; #end - isDefault = true; } } } diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index 3bea64ba..0622dc9c 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -135,6 +135,7 @@ class SetupBrowserPage extends Page { _labelTitle.text = LanguageManager.getInstance().getString( 'settingspage.browser.titlebrowserpath', data.browserName ); _textInputBrowserName.text = data.browserName; _textInputPath.text = data.executablePath; + _checkDefaultBrowser.selected = data.isDefault; } function _saveButtonTriggered(e:TriggerEvent) { diff --git a/Source/superhuman/config/SuperHumanConfig.hx b/Source/superhuman/config/SuperHumanConfig.hx index 00474280..022a339a 100644 --- a/Source/superhuman/config/SuperHumanConfig.hx +++ b/Source/superhuman/config/SuperHumanConfig.hx @@ -30,6 +30,7 @@ package superhuman.config; +import superhuman.browser.BrowserData; import superhuman.config.SuperHumanPreferences; import superhuman.config.SuperHumanUserConfig; import superhuman.server.data.ServerData; @@ -39,5 +40,5 @@ typedef SuperHumanConfig = { preferences:SuperHumanPreferences, servers:Array, user:SuperHumanUserConfig, - + browsers:Array } \ No newline at end of file From 113ac3c12060c93fda03ef7406f6383c9399e898 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Wed, 26 Jul 2023 12:50:18 +0200 Subject: [PATCH 06/26] Browsers: Improve saving default browser settings to configuration file - Add hint on Browsers page to double click (reference #81) --- Assets/text/en_US.json | 5 ++- Source/SuperHumanInstaller.hx | 37 +++++++++++++++--- Source/superhuman/browser/BrowserData.hx | 20 +++++----- Source/superhuman/browser/Browsers.hx | 31 ++++++++++----- Source/superhuman/components/SettingsPage.hx | 11 ++++-- .../components/browsers/BrowsersList.hx | 16 +++++--- .../components/browsers/BrowsersPage.hx | 39 +++++++++++++++---- .../components/browsers/SetupBrowserPage.hx | 4 +- 8 files changed, 119 insertions(+), 44 deletions(-) diff --git a/Assets/text/en_US.json b/Assets/text/en_US.json index 9c297668..43459307 100644 --- a/Assets/text/en_US.json +++ b/Assets/text/en_US.json @@ -378,13 +378,14 @@ "browser": { "title": "Browser", "defaultbrowser": "Setup default Browser", - "currentdefaultbrowser": "Current default Browser:", + "currentdefaultbrowser": "Current default Browser: %1", "titlesetupbrowser": "Browsers", "titlebrowserpath": "Setup %1 path", "browsername": "Browser name", "executablebrowserpath": "Executable Browser path", "locatebrowser": "Locate Browser", - "defaultbrowser": "Default Browser" + "defaultbrowser": "Default Browser", + "doubleclickhint": "Double click to open any row for more details" } } } \ No newline at end of file diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 18f5fcc9..4f6e13c1 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -191,10 +191,10 @@ class SuperHumanInstaller extends GenesisApplication { ]; _defaultConfig.browsers = [ - new BrowserData(Browsers.Mozilla_Firefox, true), - new BrowserData(Browsers.Google_Chrome), - new BrowserData(Browsers.Brave), - new BrowserData(Browsers.Safari) + new BrowserData(Browsers.MOZILLA_FIREFOX, true), + new BrowserData(Browsers.GOOGLE_CHROME), + new BrowserData(Browsers.BRAVE), + new BrowserData(Browsers.SAFARI) ]; if ( FileSystem.exists( '${System.applicationStorageDirectory}${_CONFIG_FILE}' ) ) { @@ -230,7 +230,19 @@ class SuperHumanInstaller extends GenesisApplication { for ( v in a ) if ( !b.contains( v ) ) s.roles.push( _defaultRoles.get( v ) ); } - + + if (_config.browsers == null) { + _config.browsers = _defaultConfig.browsers; + } else { + var bdBrowsers = new Array(); + for (index => element in _config.browsers) { + var bd:Dynamic = _config.browsers[index]; + var newBd = new BrowserData(bd.browserType, bd.isDefault, bd.browserName, bd.executablePath); + bdBrowsers.push(newBd); + } + _config.browsers = bdBrowsers.length == 0 ? _defaultConfig.browsers : bdBrowsers; + } + } else { _config = _defaultConfig; @@ -352,12 +364,13 @@ class SuperHumanInstaller extends GenesisApplication { _rolePage.addEventListener( SuperHumanApplicationEvent.CLOSE_ROLES, _closeRolePage ); this.addPage( _rolePage, PAGE_ROLES ); - _browsersPage = new BrowsersPage(_defaultConfig.browsers); + _browsersPage = new BrowsersPage(_config.browsers != null ? _config.browsers : _defaultConfig.browsers); _browsersPage.addEventListener(SuperHumanApplicationEvent.SETUP_BROWSER, _setBrowserPage); _browsersPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS, _closeBrowsersPage ); this.addPage( _browsersPage, PAGE_BROWSERS ); _setupBrowserPage = new SetupBrowserPage(); + _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION, _saveSetupBrowserPage); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP, _closeSetupBrowserPage ); this.addPage( _setupBrowserPage, PAGE_SETUP_BROWSERS ); @@ -735,6 +748,18 @@ class SuperHumanInstaller extends GenesisApplication { _setupBrowserPage.setBrowserData(e.browserData); } + function _saveSetupBrowserPage(e:SuperHumanApplicationEvent) { + for (b in _config.browsers) { + if (b != e.browserData) { + b.isDefault = false; + } + } + + this.selectedPageId = PAGE_BROWSERS; + _browsersPage.refreshBrowsers(); + _saveConfig(); + } + function _closeSetupBrowserPage(e:SuperHumanApplicationEvent) { this.selectedPageId = this.previousPageId; } diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index b64a85e1..d5d9a97b 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -4,12 +4,12 @@ import haxe.io.Path; class BrowserData { - public var browserType:Browsers; + public var browserType:String; public var browserName:String; public var executablePath:String; public var isDefault:Bool; - public function new(browserType:Browsers, isDefault:Bool = false, browserName:String = "", executablePath:String = "") { + public function new(browserType:String, isDefault:Bool = false, browserName:String = "", executablePath:String = "") { this.browserType = browserType; this.isDefault = isDefault; this.browserName = browserName; @@ -18,14 +18,14 @@ class BrowserData { _setDefaultValues(browserType); } - function _setDefaultValues(browserType:Browsers) { + function _setDefaultValues(browserType:String) { if (this.browserName == "") { - this.browserName = StringTools.replace(browserType.getName(), "_", " "); + this.browserName = browserType; } if (executablePath == "") { switch browserType { - case Google_Chrome: + case Browsers.GOOGLE_CHROME: #if linux #elseif mac @@ -33,7 +33,7 @@ class BrowserData { #elseif windows this.executablePath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; #end - case Brave: + case Browsers.BRAVE: #if linux #elseif mac @@ -41,11 +41,11 @@ class BrowserData { #elseif windows this.executablePath = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"; #end - case Safari: + case Browsers.SAFARI: this.executablePath = "/Applications/Safari.app"; - case Chromium: - case Opera: - case Internet_Explorer: + case Browsers.CHROMIUM: + case Browsers.OPERA: + case Browsers.INTERNET_EXPLORER: default: #if linux diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx index d8371269..3168d2c3 100644 --- a/Source/superhuman/browser/Browsers.hx +++ b/Source/superhuman/browser/Browsers.hx @@ -1,13 +1,26 @@ package superhuman.browser; -enum Browsers +class Browsers { - Mozilla_Firefox; - Google_Chrome; - Chromium; - Microsoft_Edge; - Brave; - Opera; - Safari; - Internet_Explorer; + public static final MOZILLA_FIREFOX:String = "Mozilla Firefox"; + public static final GOOGLE_CHROME:String = "Google Chrome"; + public static final CHROMIUM:String = "Chromium"; + public static final MICROSOFT_EDGE:String = "Microsoft Edge"; + public static final BRAVE:String = "Brave"; + public static final OPERA:String = "Opera"; + public static final SAFARI:String = "Safari"; + public static final INTERNET_EXPLORER:String = "Internet Explorer"; + + public static function getDefaultBrowser():BrowserData { + var config = SuperHumanInstaller.getInstance().config; + + var defaultBrowser = config.browsers.filter(b -> b.isDefault); + + if (defaultBrowser.length > 0) { + return defaultBrowser[0]; + } + + defaultBrowser = config.browsers.filter(b -> b.browserType == MOZILLA_FIREFOX); + return defaultBrowser[0]; + } } \ No newline at end of file diff --git a/Source/superhuman/components/SettingsPage.hx b/Source/superhuman/components/SettingsPage.hx index 1dcd9760..3f426016 100644 --- a/Source/superhuman/components/SettingsPage.hx +++ b/Source/superhuman/components/SettingsPage.hx @@ -30,6 +30,7 @@ package superhuman.components; +import superhuman.browser.Browsers; import feathers.controls.Label; import feathers.controls.LayoutGroup; import feathers.events.TriggerEvent; @@ -141,10 +142,10 @@ class SettingsPage extends Page { spacer = new LayoutGroup(); spacer.height = GenesisApplicationTheme.GRID * 2; _form.addChild( spacer ); - + _rowBrowsersDefault = new GenesisFormRow(); _rowBrowsersDefault.text = LanguageManager.getInstance().getString( 'settingspage.browser.title' ); - _labelDefaultBrowser = new Label(LanguageManager.getInstance().getString( 'settingspage.browser.currentdefaultbrowser' ) + "Firefox"); + _labelDefaultBrowser = new Label(); _rowBrowsersDefault.content.addChild(_labelDefaultBrowser); _form.addChild(_rowBrowsersDefault); @@ -188,7 +189,11 @@ class SettingsPage extends Page { _cbKeepFailedServersRunning.selected = SuperHumanInstaller.getInstance().config.preferences.keepfailedserversrunning; } - + + if (_labelDefaultBrowser != null) { + var defaultBrowser = Browsers.getDefaultBrowser(); + _labelDefaultBrowser.text = LanguageManager.getInstance().getString( 'settingspage.browser.currentdefaultbrowser', defaultBrowser.browserName); + } } function _saveButtonTriggered( e:TriggerEvent ) { diff --git a/Source/superhuman/components/browsers/BrowsersList.hx b/Source/superhuman/components/browsers/BrowsersList.hx index b412ccd5..a78b902e 100644 --- a/Source/superhuman/components/browsers/BrowsersList.hx +++ b/Source/superhuman/components/browsers/BrowsersList.hx @@ -56,7 +56,7 @@ class BrowsersList extends ListView { super( dataProvider ); this.layout = new VerticalListLayout(); - + var recycler = DisplayObjectRecycler.withFunction( () -> { var item = new BrowserItem(); @@ -69,9 +69,7 @@ class BrowsersList extends ListView { }; recycler.reset = ( item:BrowserItem, state:ListViewItemState) -> { - - - + item.updateBroswer(state.data); }; recycler.destroy = ( item:BrowserItem ) -> { @@ -87,7 +85,6 @@ class BrowsersList extends ListView { function _forwardEvent( e:SuperHumanApplicationEvent ) { this.dispatchEvent( e ); - } } @@ -125,11 +122,20 @@ class BrowserItem extends LayoutGroupItemRenderer { this.addChild(_labelBrowserName); _checkBrowserStatus = new Check(); + _checkBrowserStatus.iconPosition = RIGHT; + _checkBrowserStatus.variant = GenesisApplicationTheme.CHECK_MEDIUM; _checkBrowserStatus.enabled = false; this.addChild(_checkBrowserStatus); } public function updateBroswer(browserData:BrowserData) { _labelBrowserName.text = browserData.browserName; + if (browserData.isDefault) { + _checkBrowserStatus.text = "Default Browser"; + _checkBrowserStatus.selected = true; + } else { + _checkBrowserStatus.text = ""; + _checkBrowserStatus.selected = false; + } } } \ No newline at end of file diff --git a/Source/superhuman/components/browsers/BrowsersPage.hx b/Source/superhuman/components/browsers/BrowsersPage.hx index 98fd67cd..41913bff 100644 --- a/Source/superhuman/components/browsers/BrowsersPage.hx +++ b/Source/superhuman/components/browsers/BrowsersPage.hx @@ -53,7 +53,10 @@ class BrowsersPage extends Page { final _width:Float = GenesisApplicationTheme.GRID * 100; var _titleGroup:LayoutGroup; - var _labelTitle:Label; + var _titleLabel:Label; + + var _hintGroup:LayoutGroup; + var _hintLabel:Label; var _browsersList:BrowsersList; @@ -78,8 +81,8 @@ class BrowsersPage extends Page { skin.border = SolidColor(1.0, 0x999999); skin.fill = SolidColor(0xcccccc); - var titleGroupLayout = new HorizontalLayout(); - titleGroupLayout.horizontalAlign = HorizontalAlign.RIGHT; + var titleGroupLayout = new VerticalLayout(); + titleGroupLayout.horizontalAlign = HorizontalAlign.LEFT; titleGroupLayout.verticalAlign = VerticalAlign.MIDDLE; _titleGroup = new LayoutGroup(); @@ -87,16 +90,30 @@ class BrowsersPage extends Page { _titleGroup.width = _width; this.addChild( _titleGroup ); - _labelTitle = new Label(); - _labelTitle.text = LanguageManager.getInstance().getString( 'settingspage.browser.titlesetupbrowser' ); - _labelTitle.variant = GenesisApplicationTheme.LABEL_LARGE; - _labelTitle.layoutData = new HorizontalLayoutData( 100 ); - _titleGroup.addChild( _labelTitle ); + _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.doubleclickhint'); + _hintLabel.variant = GenesisApplicationTheme.LABEL_COPYRIGHT; + _hintGroup.addChild(_hintLabel); + _browsersList = new BrowsersList(_browsers); _browsersList.addEventListener( Event.CHANGE, _browserListChanged ); _browsersList.width = _width; @@ -118,8 +135,14 @@ class BrowsersPage extends Page { _buttonGroup.addChild( _buttonClose ); } + public function refreshBrowsers() { + _browsersList.dataProvider.updateAll(); + } + function _browserListChanged(e:Event) { var browserData:BrowserData = _browsersList.selectedItem; + if (browserData == null) return; + var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SETUP_BROWSER); setupBrowserEvent.browserData = browserData; diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index 0622dc9c..3a24b7e8 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -137,8 +137,10 @@ class SetupBrowserPage extends Page { _textInputPath.text = data.executablePath; _checkDefaultBrowser.selected = data.isDefault; } - + function _saveButtonTriggered(e:TriggerEvent) { + _browserData.isDefault = _checkDefaultBrowser.selected; + var superHumanAppEvent:SuperHumanApplicationEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION); superHumanAppEvent.browserData = _browserData; From 31bfd5a0ff0269652f2709f62cd363b7769b4a7f Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Wed, 26 Jul 2023 15:38:09 +0200 Subject: [PATCH 07/26] Browsers: Open url on server page in specific selected as default browser (reference #81) --- Source/SuperHumanInstaller.hx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 4f6e13c1..ef997e55 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -673,17 +673,23 @@ class SuperHumanInstaller extends GenesisApplication { function _openBrowser( e:SuperHumanApplicationEvent ) { - var a = e.server.webAddress; - - if ( a == null || a.length == 0 ) { + var defaultBrowser = Browsers.getDefaultBrowser(); + var a = [e.server.webAddress]; + #if mac + a = ["-a" + defaultBrowser.executablePath, e.server.webAddress]; + #elseif windows + a = [defaultBrowser.executablePath + " " + e.server.webAddress]; + #end + + if ( e.server.webAddress == null || e.server.webAddress.length == 0 ) { - if ( e.server.console != null ) e.server.console.appendText( LanguageManager.getInstance().getString( 'serverpage.server.console.webaddressinvalid', '[${a}]' ), true ); - Logger.error( '${this}: Web address is invalid: \"${a}\"' ); + if ( e.server.console != null ) e.server.console.appendText( LanguageManager.getInstance().getString( 'serverpage.server.console.webaddressinvalid', '[${e.server.webAddress}]' ), true ); + Logger.error( '${this}: Web address is invalid: \"${e.server.webAddress}\"' ); return; } - Shell.getInstance().open( [ '${a}' ] ); + Shell.getInstance().open( a ); } From f8a71e12e89f7306edb0c62050060279c41903cb Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Wed, 26 Jul 2023 18:18:27 +0200 Subject: [PATCH 08/26] Using Float instead Int for size in File related files (reference #81) --- Source/openfl/filesystem/File.hx | 2 +- Source/openfl/filesystem/FileStream.hx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/openfl/filesystem/File.hx b/Source/openfl/filesystem/File.hx index 581f9c8c..30e062d3 100644 --- a/Source/openfl/filesystem/File.hx +++ b/Source/openfl/filesystem/File.hx @@ -1772,7 +1772,7 @@ class File extends FileReference return name; } - @:noCompletion override private function get_size():Int + @:noCompletion override private function get_size():Float { if (__fileStatsDirty) { diff --git a/Source/openfl/filesystem/FileStream.hx b/Source/openfl/filesystem/FileStream.hx index 5d9182ff..71b6b5ae 100644 --- a/Source/openfl/filesystem/FileStream.hx +++ b/Source/openfl/filesystem/FileStream.hx @@ -366,7 +366,7 @@ class FileStream extends EventDispatcher implements IDataInput implements IDataO if (fileMode == READ) { - __buffer = new ByteArray(file.size); + __buffer = new ByteArray(Std.int(file.size)); __fileStreamWorker.doWork.add(function(m:Dynamic) { var inputBytesAvailable:Int = 0; From 03cd882e733df4b1ff504d2abb40b579edac0f5b Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Thu, 27 Jul 2023 04:29:40 -0700 Subject: [PATCH 09/26] Browsers: Open url in specific default browser on Windows (reference #81) --- Source/SuperHumanInstaller.hx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index ef997e55..2b20be3d 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -30,6 +30,8 @@ package; +import cpp.NativeSys; +import haxe.io.Path; import superhuman.components.browsers.SetupBrowserPage; import superhuman.browser.Browsers; import superhuman.components.browsers.BrowsersPage; @@ -678,7 +680,7 @@ class SuperHumanInstaller extends GenesisApplication { #if mac a = ["-a" + defaultBrowser.executablePath, e.server.webAddress]; #elseif windows - a = [defaultBrowser.executablePath + " " + e.server.webAddress]; + a = ["start", '""', '"${defaultBrowser.executablePath}"', '"${e.server.webAddress}"']; #end if ( e.server.webAddress == null || e.server.webAddress.length == 0 ) { @@ -688,9 +690,13 @@ class SuperHumanInstaller extends GenesisApplication { return; } - + + #if windows + var trim = StringTools.trim( a.join( " " )); + NativeSys.sys_command(trim); + #else Shell.getInstance().open( a ); - + #end } function _saveConfig() { From 4cf17fd1193362fe2ea817235c60caa39320e11a Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Thu, 27 Jul 2023 14:51:46 +0200 Subject: [PATCH 10/26] Browsers: Make Toggle buttons for changing default browsers clickable (reference #81) --- Source/SuperHumanInstaller.hx | 1 + .../components/browsers/BrowsersList.hx | 30 +++++++++++++++---- .../components/browsers/BrowsersPage.hx | 13 +++++++- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 2b20be3d..15239f82 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -369,6 +369,7 @@ class SuperHumanInstaller extends GenesisApplication { _browsersPage = new BrowsersPage(_config.browsers != null ? _config.browsers : _defaultConfig.browsers); _browsersPage.addEventListener(SuperHumanApplicationEvent.SETUP_BROWSER, _setBrowserPage); _browsersPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS, _closeBrowsersPage ); + _browsersPage.addEventListener( SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION, _saveSetupBrowserPage); this.addPage( _browsersPage, PAGE_BROWSERS ); _setupBrowserPage = new SetupBrowserPage(); diff --git a/Source/superhuman/components/browsers/BrowsersList.hx b/Source/superhuman/components/browsers/BrowsersList.hx index a78b902e..fe0086af 100644 --- a/Source/superhuman/components/browsers/BrowsersList.hx +++ b/Source/superhuman/components/browsers/BrowsersList.hx @@ -30,6 +30,8 @@ package superhuman.components.browsers; +import feathers.events.TriggerEvent; +import openfl.events.Event; import feathers.layout.VerticalListLayout; import feathers.layout.VerticalLayout; import feathers.layout.HorizontalLayoutData; @@ -60,6 +62,7 @@ class BrowsersList extends ListView { var recycler = DisplayObjectRecycler.withFunction( () -> { var item = new BrowserItem(); + item.addEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); return item; } ); @@ -73,9 +76,7 @@ class BrowsersList extends ListView { }; recycler.destroy = ( item:BrowserItem ) -> { - - - + item.removeEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); }; this.itemRendererRecycler = recycler; @@ -86,18 +87,25 @@ class BrowsersList extends ListView { this.dispatchEvent( e ); } - + + function _browserItemChange(e:SuperHumanApplicationEvent) { + _forwardEvent(e); + } } @:styleContext class BrowserItem extends LayoutGroupItemRenderer { + public static final BROWSER_ITEM_CHANGE:String = "browserItemChange"; + var _labelBrowserGroupLayout:HorizontalLayout; var _labelBrowserGroup:LayoutGroup; var _labelBrowserName:Label; var _checkBrowserStatus:Check; - + + var _browserData:BrowserData; + public function new() { super(); @@ -124,11 +132,12 @@ class BrowserItem extends LayoutGroupItemRenderer { _checkBrowserStatus = new Check(); _checkBrowserStatus.iconPosition = RIGHT; _checkBrowserStatus.variant = GenesisApplicationTheme.CHECK_MEDIUM; - _checkBrowserStatus.enabled = false; + _checkBrowserStatus.addEventListener(TriggerEvent.TRIGGER, _checkBrowserStatusChange); this.addChild(_checkBrowserStatus); } public function updateBroswer(browserData:BrowserData) { + _browserData = browserData; _labelBrowserName.text = browserData.browserName; if (browserData.isDefault) { _checkBrowserStatus.text = "Default Browser"; @@ -138,4 +147,13 @@ class BrowserItem extends LayoutGroupItemRenderer { _checkBrowserStatus.selected = false; } } + + function _checkBrowserStatusChange(event:Event) { + _browserData.isDefault = _checkBrowserStatus.selected; + + var browserItemEvent = new SuperHumanApplicationEvent(BrowserItem.BROWSER_ITEM_CHANGE); + browserItemEvent.browserData = _browserData; + + this.dispatchEvent(browserItemEvent); + } } \ No newline at end of file diff --git a/Source/superhuman/components/browsers/BrowsersPage.hx b/Source/superhuman/components/browsers/BrowsersPage.hx index 41913bff..915d3eeb 100644 --- a/Source/superhuman/components/browsers/BrowsersPage.hx +++ b/Source/superhuman/components/browsers/BrowsersPage.hx @@ -29,6 +29,8 @@ */ 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; @@ -115,7 +117,9 @@ class BrowsersPage extends Page { _hintGroup.addChild(_hintLabel); _browsersList = new BrowsersList(_browsers); - _browsersList.addEventListener( Event.CHANGE, _browserListChanged ); + _browsersList.doubleClickEnabled = true; + _browsersList.addEventListener( MouseEvent.DOUBLE_CLICK, _browserListChanged ); + _browsersList.addEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); _browsersList.width = _width; this.addChild(_browsersList); @@ -149,6 +153,13 @@ class BrowsersPage extends Page { this.dispatchEvent( setupBrowserEvent ); } + function _browserItemChange(e:SuperHumanApplicationEvent) { + var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION); + setupBrowserEvent.browserData = e.browserData; + + this.dispatchEvent( setupBrowserEvent ); + } + function _buttonCloseTriggered( e:TriggerEvent ) { this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.CLOSE_BROWSERS ) ); } From 815d4d30ecea268df1a7f6769216be6de691d4ff Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Thu, 27 Jul 2023 14:54:15 +0200 Subject: [PATCH 11/26] Revert back: Using Float instead Int for size in File related files (reference #81) --- Source/openfl/filesystem/File.hx | 2 +- Source/openfl/filesystem/FileStream.hx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/openfl/filesystem/File.hx b/Source/openfl/filesystem/File.hx index 30e062d3..581f9c8c 100644 --- a/Source/openfl/filesystem/File.hx +++ b/Source/openfl/filesystem/File.hx @@ -1772,7 +1772,7 @@ class File extends FileReference return name; } - @:noCompletion override private function get_size():Float + @:noCompletion override private function get_size():Int { if (__fileStatsDirty) { diff --git a/Source/openfl/filesystem/FileStream.hx b/Source/openfl/filesystem/FileStream.hx index 71b6b5ae..5d9182ff 100644 --- a/Source/openfl/filesystem/FileStream.hx +++ b/Source/openfl/filesystem/FileStream.hx @@ -366,7 +366,7 @@ class FileStream extends EventDispatcher implements IDataInput implements IDataO if (fileMode == READ) { - __buffer = new ByteArray(Std.int(file.size)); + __buffer = new ByteArray(file.size); __fileStreamWorker.doWork.add(function(m:Dynamic) { var inputBytesAvailable:Int = 0; From 2544e43478db324063cd0e93e39e6b23eba5ae8b Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Fri, 28 Jul 2023 16:08:23 +0200 Subject: [PATCH 12/26] Browsers: Save browser settings only if user click on Save general settings (reference #81 ) --- Source/SuperHumanInstaller.hx | 72 +++++++++++-------- Source/superhuman/browser/Browsers.hx | 9 +++ Source/superhuman/components/SettingsPage.hx | 16 +++-- .../components/browsers/BrowsersPage.hx | 13 ++-- .../components/browsers/SetupBrowserPage.hx | 2 +- .../events/SuperHumanApplicationEvent.hx | 2 +- 6 files changed, 73 insertions(+), 41 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 15239f82..de319cd0 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -122,7 +122,12 @@ class SuperHumanInstaller extends GenesisApplication { servers : [], user: {}, preferences: { keepserversrunning: true, savewindowposition: false, provisionserversonstart:false, disablevagrantlogging: false, keepfailedserversrunning: false }, - browsers: [] + browsers: [ + new BrowserData(Browsers.MOZILLA_FIREFOX, true), + new BrowserData(Browsers.GOOGLE_CHROME), + new BrowserData(Browsers.BRAVE), + new BrowserData(Browsers.SAFARI) + ] } var _advancedConfigPage:AdvancedConfigPage; @@ -141,7 +146,7 @@ class SuperHumanInstaller extends GenesisApplication { var _vagrantFile:String; var _browsersPage:BrowsersPage; var _setupBrowserPage:SetupBrowserPage; - //var _browsersCollection:Array; + var _browsersCollection:Array; public var config( get, never ):SuperHumanConfig; function get_config() return _config; @@ -152,9 +157,6 @@ class SuperHumanInstaller extends GenesisApplication { public var serverRolesCollection( get, never ):Array; function get_serverRolesCollection() return _serverRolesCollection; - /*public var browsersCollection( get, never ):Array; - function get_browsersCollection() return _browsersCollection;*/ - public function new() { super( #if showlogin true #end ); @@ -192,13 +194,6 @@ class SuperHumanInstaller extends GenesisApplication { ]; - _defaultConfig.browsers = [ - new BrowserData(Browsers.MOZILLA_FIREFOX, true), - new BrowserData(Browsers.GOOGLE_CHROME), - new BrowserData(Browsers.BRAVE), - new BrowserData(Browsers.SAFARI) - ]; - if ( FileSystem.exists( '${System.applicationStorageDirectory}${_CONFIG_FILE}' ) ) { try { @@ -235,14 +230,6 @@ class SuperHumanInstaller extends GenesisApplication { if (_config.browsers == null) { _config.browsers = _defaultConfig.browsers; - } else { - var bdBrowsers = new Array(); - for (index => element in _config.browsers) { - var bd:Dynamic = _config.browsers[index]; - var newBd = new BrowserData(bd.browserType, bd.isDefault, bd.browserName, bd.executablePath); - bdBrowsers.push(newBd); - } - _config.browsers = bdBrowsers.length == 0 ? _defaultConfig.browsers : bdBrowsers; } } else { @@ -366,14 +353,14 @@ class SuperHumanInstaller extends GenesisApplication { _rolePage.addEventListener( SuperHumanApplicationEvent.CLOSE_ROLES, _closeRolePage ); this.addPage( _rolePage, PAGE_ROLES ); - _browsersPage = new BrowsersPage(_config.browsers != null ? _config.browsers : _defaultConfig.browsers); + _browsersPage = new BrowsersPage(); _browsersPage.addEventListener(SuperHumanApplicationEvent.SETUP_BROWSER, _setBrowserPage); _browsersPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS, _closeBrowsersPage ); - _browsersPage.addEventListener( SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION, _saveSetupBrowserPage); + _browsersPage.addEventListener( SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE, _refreshBrowsersPage); this.addPage( _browsersPage, PAGE_BROWSERS ); _setupBrowserPage = new SetupBrowserPage(); - _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION, _saveSetupBrowserPage); + _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE, _refreshBrowsersPage); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP, _closeSetupBrowserPage ); this.addPage( _setupBrowserPage, PAGE_SETUP_BROWSERS ); @@ -713,9 +700,15 @@ class SuperHumanInstaller extends GenesisApplication { } - if (_config.browsers == null) { + if (_config.browsers == null) + { _config.browsers = _defaultConfig.browsers; + } + else if (_browsersCollection != null) + { + _config.browsers = _browsersCollection; } + _browsersCollection = null; try { @@ -761,8 +754,8 @@ class SuperHumanInstaller extends GenesisApplication { _setupBrowserPage.setBrowserData(e.browserData); } - function _saveSetupBrowserPage(e:SuperHumanApplicationEvent) { - for (b in _config.browsers) { + function _refreshBrowsersPage(e:SuperHumanApplicationEvent) { + for (b in _browsersCollection) { if (b != e.browserData) { b.isDefault = false; } @@ -770,7 +763,7 @@ class SuperHumanInstaller extends GenesisApplication { this.selectedPageId = PAGE_BROWSERS; _browsersPage.refreshBrowsers(); - _saveConfig(); + _settingsPage.updateDefaultBrowser(e.browserData); } function _closeSetupBrowserPage(e:SuperHumanApplicationEvent) { @@ -781,6 +774,23 @@ class SuperHumanInstaller extends GenesisApplication { this.selectedPageId = PAGE_SETTINGS; } + function _initializeBrowsersCollection() { + if (this.previousPageId != PAGE_BROWSERS && this.previousPageId != PAGE_SETUP_BROWSERS) { + _browsersCollection = new Array(); + for (index => element in _config.browsers) + { + var bd:Dynamic = _config.browsers[index]; + var newBd = new BrowserData(bd.browserType, bd.isDefault, bd.browserName, bd.executablePath); + _browsersCollection.push(newBd); + } + + if (_settingsPage != null) { + var defaultBrowser = Browsers.getDefaultBrowser(); + _settingsPage.updateDefaultBrowser(defaultBrowser); + } + } + } + function _saveAdvancedServerConfiguration( e:SuperHumanApplicationEvent ) { e.server.saveHostsFile(); @@ -955,8 +965,12 @@ class SuperHumanInstaller extends GenesisApplication { super._pageChanged(); - if ( _selectedPageId == PAGE_SETTINGS ) _settingsPage.updateData(); - + if ( _selectedPageId == PAGE_SETTINGS ) + { + _initializeBrowsersCollection(); + _browsersPage.setBrowsers(_browsersCollection); + _settingsPage.updateData(); + } } function _deleteServer( e:SuperHumanApplicationEvent ) { diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx index 3168d2c3..04a96835 100644 --- a/Source/superhuman/browser/Browsers.hx +++ b/Source/superhuman/browser/Browsers.hx @@ -13,6 +13,15 @@ class Browsers public static function getDefaultBrowser():BrowserData { var config = SuperHumanInstaller.getInstance().config; + if (config.browsers == null) + { + config.browsers = [ + new BrowserData(Browsers.MOZILLA_FIREFOX, true), + new BrowserData(Browsers.GOOGLE_CHROME), + new BrowserData(Browsers.BRAVE), + new BrowserData(Browsers.SAFARI) + ]; + } var defaultBrowser = config.browsers.filter(b -> b.isDefault); diff --git a/Source/superhuman/components/SettingsPage.hx b/Source/superhuman/components/SettingsPage.hx index 3f426016..d5b2a1ad 100644 --- a/Source/superhuman/components/SettingsPage.hx +++ b/Source/superhuman/components/SettingsPage.hx @@ -30,6 +30,7 @@ package superhuman.components; +import superhuman.browser.BrowserData; import superhuman.browser.Browsers; import feathers.controls.Label; import feathers.controls.LayoutGroup; @@ -175,7 +176,9 @@ class SettingsPage extends Page { this.addChild( _buttonGroup ); updateData(); - + + var defaultBrowser = Browsers.getDefaultBrowser(); + updateDefaultBrowser(defaultBrowser); } public function updateData() { @@ -189,13 +192,14 @@ class SettingsPage extends Page { _cbKeepFailedServersRunning.selected = SuperHumanInstaller.getInstance().config.preferences.keepfailedserversrunning; } - - if (_labelDefaultBrowser != null) { - var defaultBrowser = Browsers.getDefaultBrowser(); - _labelDefaultBrowser.text = LanguageManager.getInstance().getString( 'settingspage.browser.currentdefaultbrowser', defaultBrowser.browserName); - } } + public function updateDefaultBrowser(browserData:Dynamic) { + if (_labelDefaultBrowser != null) { + _labelDefaultBrowser.text = LanguageManager.getInstance().getString('settingspage.browser.currentdefaultbrowser', browserData.browserName); + } + } + function _saveButtonTriggered( e:TriggerEvent ) { SuperHumanInstaller.getInstance().config.preferences.savewindowposition = _cbApplicationWindow.selected; diff --git a/Source/superhuman/components/browsers/BrowsersPage.hx b/Source/superhuman/components/browsers/BrowsersPage.hx index 915d3eeb..9e91f68f 100644 --- a/Source/superhuman/components/browsers/BrowsersPage.hx +++ b/Source/superhuman/components/browsers/BrowsersPage.hx @@ -68,11 +68,9 @@ class BrowsersPage extends Page { var _browsers:ArrayCollection; - public function new( browsers:Array ) { + public function new() { super(); - - _browsers = new ArrayCollection(browsers); } override function initialize() { @@ -139,6 +137,13 @@ class BrowsersPage extends Page { _buttonGroup.addChild( _buttonClose ); } + public function setBrowsers(browsers:Array) { + _browsers = new ArrayCollection(browsers); + if (_browsersList != null) { + _browsersList.dataProvider = _browsers; + } + } + public function refreshBrowsers() { _browsersList.dataProvider.updateAll(); } @@ -154,7 +159,7 @@ class BrowsersPage extends Page { } function _browserItemChange(e:SuperHumanApplicationEvent) { - var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION); + var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE); setupBrowserEvent.browserData = e.browserData; this.dispatchEvent( setupBrowserEvent ); diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index 3a24b7e8..ac778ce5 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -141,7 +141,7 @@ class SetupBrowserPage extends Page { function _saveButtonTriggered(e:TriggerEvent) { _browserData.isDefault = _checkDefaultBrowser.selected; - var superHumanAppEvent:SuperHumanApplicationEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SAVE_APP_BROWSERS_CONFIGURATION); + var superHumanAppEvent:SuperHumanApplicationEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE); superHumanAppEvent.browserData = _browserData; this.dispatchEvent(superHumanAppEvent); diff --git a/Source/superhuman/events/SuperHumanApplicationEvent.hx b/Source/superhuman/events/SuperHumanApplicationEvent.hx index d0b35481..313fd402 100644 --- a/Source/superhuman/events/SuperHumanApplicationEvent.hx +++ b/Source/superhuman/events/SuperHumanApplicationEvent.hx @@ -45,6 +45,7 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { 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_BROWSERS_PAGE:String = "refreshBrowsersPage"; public static final SETUP_BROWSER:String = "setupBrowser"; public static final CLOSE_BROWSERS_SETUP:String = "closeBrowsersSetup"; public static final CONFIGURE_ROLES:String = "configureRoles"; @@ -66,7 +67,6 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { public static final RESET_SERVER:String = "resetServer"; public static final SAVE_ADVANCED_SERVER_CONFIGURATION:String = "saveAdvancedServerConfiguration"; public static final SAVE_APP_CONFIGURATION:String = "saveAppConfiguration"; - public static final SAVE_APP_BROWSERS_CONFIGURATION:String = "saveAppBrowsersConfiguration"; public static final SAVE_SERVER_CONFIGURATION:String = "saveServerConfiguration"; public static final START_SERVER:String = "startServer"; public static final STOP_SERVER:String = "stopServer"; From 2c2085d81212ae68888b54b6e6221d8a62892408 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Mon, 31 Jul 2023 14:30:28 +0200 Subject: [PATCH 13/26] Browsers: Make sure browsers are saving properly to config (reference #81) --- Source/SuperHumanInstaller.hx | 28 ++++++++++++++----- Source/superhuman/browser/Browsers.hx | 23 ++++++++------- Source/superhuman/components/SettingsPage.hx | 4 ++- .../components/browsers/BrowsersList.hx | 13 +++++---- .../components/browsers/BrowsersPage.hx | 5 ++++ .../components/browsers/SetupBrowserPage.hx | 17 ++++++++--- .../events/SuperHumanApplicationEvent.hx | 1 + 7 files changed, 64 insertions(+), 27 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index de319cd0..71c11418 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -30,6 +30,7 @@ package; +import genesis.application.events.GenesisApplicationEvent; import cpp.NativeSys; import haxe.io.Path; import superhuman.components.browsers.SetupBrowserPage; @@ -356,10 +357,12 @@ class SuperHumanInstaller extends GenesisApplication { _browsersPage = new BrowsersPage(); _browsersPage.addEventListener(SuperHumanApplicationEvent.SETUP_BROWSER, _setBrowserPage); _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); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP, _closeSetupBrowserPage ); this.addPage( _setupBrowserPage, PAGE_SETUP_BROWSERS ); @@ -754,18 +757,23 @@ class SuperHumanInstaller extends GenesisApplication { _setupBrowserPage.setBrowserData(e.browserData); } - function _refreshBrowsersPage(e:SuperHumanApplicationEvent) { + function _refreshDefaultBrowser(e:SuperHumanApplicationEvent) { for (b in _browsersCollection) { if (b != e.browserData) { b.isDefault = false; } } - this.selectedPageId = PAGE_BROWSERS; + _updateDefaultBrowserSettingsPage(); + } + + function _refreshBrowsersPage(e:SuperHumanApplicationEvent) { + + //this.selectedPageId = PAGE_BROWSERS; _browsersPage.refreshBrowsers(); - _settingsPage.updateDefaultBrowser(e.browserData); + _updateDefaultBrowserSettingsPage(); } - + function _closeSetupBrowserPage(e:SuperHumanApplicationEvent) { this.selectedPageId = this.previousPageId; } @@ -784,9 +792,15 @@ class SuperHumanInstaller extends GenesisApplication { _browsersCollection.push(newBd); } - if (_settingsPage != null) { - var defaultBrowser = Browsers.getDefaultBrowser(); - _settingsPage.updateDefaultBrowser(defaultBrowser); + _updateDefaultBrowserSettingsPage(); + } + } + + function _updateDefaultBrowserSettingsPage() { + if (_settingsPage != null) { + var defaultBrowser = _browsersCollection.filter(b -> b.isDefault); + if (defaultBrowser.length > 0) { + _settingsPage.updateDefaultBrowser(defaultBrowser[0]); } } } diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx index 04a96835..88b34e2e 100644 --- a/Source/superhuman/browser/Browsers.hx +++ b/Source/superhuman/browser/Browsers.hx @@ -11,7 +11,7 @@ class Browsers public static final SAFARI:String = "Safari"; public static final INTERNET_EXPLORER:String = "Internet Explorer"; - public static function getDefaultBrowser():BrowserData { + public static function getDefaultBrowser():Dynamic { var config = SuperHumanInstaller.getInstance().config; if (config.browsers == null) { @@ -22,14 +22,17 @@ class Browsers new BrowserData(Browsers.SAFARI) ]; } - - var defaultBrowser = config.browsers.filter(b -> b.isDefault); - - if (defaultBrowser.length > 0) { - return defaultBrowser[0]; - } - - defaultBrowser = config.browsers.filter(b -> b.browserType == MOZILLA_FIREFOX); - return defaultBrowser[0]; + + var defaultBrowser = null; + for (index => element in config.browsers) + { + var b:Dynamic = config.browsers[index]; + if (b.isDefault == true) + { + defaultBrowser = b; + } + } + + return defaultBrowser; } } \ No newline at end of file diff --git a/Source/superhuman/components/SettingsPage.hx b/Source/superhuman/components/SettingsPage.hx index d5b2a1ad..7d8b8d6d 100644 --- a/Source/superhuman/components/SettingsPage.hx +++ b/Source/superhuman/components/SettingsPage.hx @@ -177,7 +177,7 @@ class SettingsPage extends Page { updateData(); - var defaultBrowser = Browsers.getDefaultBrowser(); + var defaultBrowser:Dynamic = Browsers.getDefaultBrowser(); updateDefaultBrowser(defaultBrowser); } @@ -195,6 +195,8 @@ class SettingsPage extends Page { } public function updateDefaultBrowser(browserData:Dynamic) { + if (browserData.isDefault == false) return; + if (_labelDefaultBrowser != null) { _labelDefaultBrowser.text = LanguageManager.getInstance().getString('settingspage.browser.currentdefaultbrowser', browserData.browserName); } diff --git a/Source/superhuman/components/browsers/BrowsersList.hx b/Source/superhuman/components/browsers/BrowsersList.hx index fe0086af..7a9b94b5 100644 --- a/Source/superhuman/components/browsers/BrowsersList.hx +++ b/Source/superhuman/components/browsers/BrowsersList.hx @@ -30,7 +30,6 @@ package superhuman.components.browsers; -import feathers.events.TriggerEvent; import openfl.events.Event; import feathers.layout.VerticalListLayout; import feathers.layout.VerticalLayout; @@ -68,11 +67,11 @@ class BrowsersList extends ListView { } ); recycler.update = ( item:BrowserItem, state:ListViewItemState) -> { - item.updateBroswer(state.data); + item.updateBrowser(state.data); }; recycler.reset = ( item:BrowserItem, state:ListViewItemState) -> { - item.updateBroswer(state.data); + item.updateBrowser(state.data); }; recycler.destroy = ( item:BrowserItem ) -> { @@ -132,11 +131,13 @@ class BrowserItem extends LayoutGroupItemRenderer { _checkBrowserStatus = new Check(); _checkBrowserStatus.iconPosition = RIGHT; _checkBrowserStatus.variant = GenesisApplicationTheme.CHECK_MEDIUM; - _checkBrowserStatus.addEventListener(TriggerEvent.TRIGGER, _checkBrowserStatusChange); + _checkBrowserStatus.addEventListener(Event.CHANGE, _checkBrowserStatusChange); this.addChild(_checkBrowserStatus); } - public function updateBroswer(browserData:BrowserData) { + public function updateBrowser(browserData:BrowserData) { + _checkBrowserStatus.removeEventListener(Event.CHANGE, _checkBrowserStatusChange); + _browserData = browserData; _labelBrowserName.text = browserData.browserName; if (browserData.isDefault) { @@ -146,6 +147,8 @@ class BrowserItem extends LayoutGroupItemRenderer { _checkBrowserStatus.text = ""; _checkBrowserStatus.selected = false; } + + _checkBrowserStatus.addEventListener(Event.CHANGE, _checkBrowserStatusChange); } function _checkBrowserStatusChange(event:Event) { diff --git a/Source/superhuman/components/browsers/BrowsersPage.hx b/Source/superhuman/components/browsers/BrowsersPage.hx index 9e91f68f..68555107 100644 --- a/Source/superhuman/components/browsers/BrowsersPage.hx +++ b/Source/superhuman/components/browsers/BrowsersPage.hx @@ -159,6 +159,11 @@ class BrowsersPage extends Page { } 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; diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index ac778ce5..d538c3ed 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -1,5 +1,6 @@ package superhuman.components.browsers; +import openfl.events.Event; import superhuman.theme.SuperHumanInstallerTheme; import feathers.text.TextFormat; import feathers.controls.Check; @@ -139,14 +140,22 @@ class SetupBrowserPage extends Page { } function _saveButtonTriggered(e:TriggerEvent) { - _browserData.isDefault = _checkDefaultBrowser.selected; + if (_browserData.isDefault != _checkDefaultBrowser.selected) + { + _browserData.isDefault = _checkDefaultBrowser.selected; + var refreshDefaultBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.REFRESH_DEFAULT_BROWSER); + refreshDefaultBrowserEvent.browserData = _browserData; + this.dispatchEvent(refreshDefaultBrowserEvent); + } - var superHumanAppEvent:SuperHumanApplicationEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE); + _browserData.browserName = _textInputBrowserName.text; + var superHumanAppEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE); superHumanAppEvent.browserData = _browserData; - this.dispatchEvent(superHumanAppEvent); + + this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP ) ); } - + function _buttonCloseTriggered( e:TriggerEvent ) { this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP ) ); diff --git a/Source/superhuman/events/SuperHumanApplicationEvent.hx b/Source/superhuman/events/SuperHumanApplicationEvent.hx index 313fd402..79392b41 100644 --- a/Source/superhuman/events/SuperHumanApplicationEvent.hx +++ b/Source/superhuman/events/SuperHumanApplicationEvent.hx @@ -45,6 +45,7 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { 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 SETUP_BROWSER:String = "setupBrowser"; public static final CLOSE_BROWSERS_SETUP:String = "closeBrowsersSetup"; From 06c1cd0cb20f7226b5e488be1025d5a9545d6302 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Mon, 31 Jul 2023 19:09:28 +0200 Subject: [PATCH 14/26] Browsers: Add more default browsers (reference #81) --- Genesis/Source/prominic/sys/tools/SysTools.hx | 11 +++++++++ Source/SuperHumanInstaller.hx | 7 +----- Source/superhuman/browser/BrowserData.hx | 15 +++++++++++- Source/superhuman/browser/Browsers.hx | 24 ++++++++++++------- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Genesis/Source/prominic/sys/tools/SysTools.hx b/Genesis/Source/prominic/sys/tools/SysTools.hx index a556932d..e8243d5c 100644 --- a/Genesis/Source/prominic/sys/tools/SysTools.hx +++ b/Genesis/Source/prominic/sys/tools/SysTools.hx @@ -109,6 +109,17 @@ class SysTools { } + public static function getWindowsUserName() { + var envs = Sys.environment(); + if (envs.exists("USERNAME")) { + return envs["USERNAME"]; + } + + if (envs.exists("USER")) { + return envs["USER"]; + } + return null; + } } enum CPUArchitecture { diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 71c11418..b627f9d7 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -123,12 +123,7 @@ class SuperHumanInstaller extends GenesisApplication { servers : [], user: {}, preferences: { keepserversrunning: true, savewindowposition: false, provisionserversonstart:false, disablevagrantlogging: false, keepfailedserversrunning: false }, - browsers: [ - new BrowserData(Browsers.MOZILLA_FIREFOX, true), - new BrowserData(Browsers.GOOGLE_CHROME), - new BrowserData(Browsers.BRAVE), - new BrowserData(Browsers.SAFARI) - ] + browsers: Browsers.DEFAULT_BROWSERS_LIST } var _advancedConfigPage:AdvancedConfigPage; diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index d5d9a97b..f8c49b86 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -1,5 +1,6 @@ package superhuman.browser; +import prominic.sys.tools.SysTools; import haxe.io.Path; class BrowserData { @@ -41,10 +42,22 @@ class BrowserData { #elseif windows this.executablePath = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"; #end + case Browsers.OPERA: + #if linux + + #elseif mac + this.executablePath = "/Applications/Opera.app"; + #elseif windows + var userName = SysTools.getWindowsUserName(); + this.executablePath = "C:/Users/${userName}/AppData/Local/Programs/Opera/launcher.exe"; + #end + case Browsers.MICROSOFT_EDGE: + #if windows + this.executablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"; + #end case Browsers.SAFARI: this.executablePath = "/Applications/Safari.app"; case Browsers.CHROMIUM: - case Browsers.OPERA: case Browsers.INTERNET_EXPLORER: default: #if linux diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx index 88b34e2e..3e6126d5 100644 --- a/Source/superhuman/browser/Browsers.hx +++ b/Source/superhuman/browser/Browsers.hx @@ -4,23 +4,31 @@ class Browsers { public static final MOZILLA_FIREFOX:String = "Mozilla Firefox"; public static final GOOGLE_CHROME:String = "Google Chrome"; + public static final BRAVE:String = "Brave Browser"; + public static final OPERA:String = "Opera"; public static final CHROMIUM:String = "Chromium"; public static final MICROSOFT_EDGE:String = "Microsoft Edge"; - public static final BRAVE:String = "Brave"; - public static final OPERA:String = "Opera"; public static final SAFARI:String = "Safari"; public static final INTERNET_EXPLORER:String = "Internet Explorer"; + public static final DEFAULT_BROWSERS_LIST:Array = [ + new BrowserData(Browsers.MOZILLA_FIREFOX, true), + new BrowserData(Browsers.GOOGLE_CHROME), + new BrowserData(Browsers.BRAVE), + new BrowserData(Browsers.OPERA), + #if windows + new BrowserData(Browsers.MICROSOFT_EDGE), + #end + #if mac + new BrowserData(Browsers.SAFARI) + #end + ]; + public static function getDefaultBrowser():Dynamic { var config = SuperHumanInstaller.getInstance().config; if (config.browsers == null) { - config.browsers = [ - new BrowserData(Browsers.MOZILLA_FIREFOX, true), - new BrowserData(Browsers.GOOGLE_CHROME), - new BrowserData(Browsers.BRAVE), - new BrowserData(Browsers.SAFARI) - ]; + config.browsers = DEFAULT_BROWSERS_LIST; } var defaultBrowser = null; From 93d5946b8676e81fe008ccee99829864eda5bc34 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Mon, 31 Jul 2023 21:46:07 +0200 Subject: [PATCH 15/26] Browser: Detect whether default browser exists - Add warning button to indicates for lack of browser (reference #81) --- .../theme/GenesisApplicationTheme.hx | 7 ++++++ Source/superhuman/browser/BrowserData.hx | 8 +++++-- .../components/browsers/BrowsersList.hx | 23 ++++++++++++++++--- .../components/browsers/SetupBrowserPage.hx | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx index 1e11581c..06b80baf 100644 --- a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx +++ b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx @@ -95,6 +95,7 @@ class GenesisApplicationTheme extends ClassVariantTheme { public static final BUTTON_SMALL:String = "button-small"; public static final BUTTON_TINY:String = "button-tiny"; public static final BUTTON_WARNING:String = "button-warning"; + public static final BUTTON_BROWSER_WARNING:String = "button-browser-warning"; public static final CHECK_LARGE:String = "check-large"; public static final CHECK_MEDIUM:String = "check-medium"; public static final INVALID:String = "invalid"; @@ -277,6 +278,7 @@ class GenesisApplicationTheme extends ClassVariantTheme { this.styleProvider.setStyleFunction( Button, BUTTON_SMALL, _setButtonSmallStyles ); this.styleProvider.setStyleFunction( Button, BUTTON_TINY, _setButtonTinyStyles ); this.styleProvider.setStyleFunction( Button, BUTTON_WARNING, _setButtonWarningStyles ); + this.styleProvider.setStyleFunction( Button, BUTTON_BROWSER_WARNING, _setButtonNoBackgrounIconStyles ); this.styleProvider.setStyleFunction( Button, GenesisFormPupUpListView.CHILD_VARIANT_BUTTON, _setPopUpListViewButtonStyles ); this.styleProvider.setStyleFunction( Button, GenesisFormPupUpListView.CHILD_VARIANT_BUTTON_INVALID, _setPopUpListViewInvalidButtonStyles ); this.styleProvider.setStyleFunction( Button, PopUpListView.CHILD_VARIANT_BUTTON, _setPopUpListViewButtonStyles ); @@ -406,6 +408,11 @@ class GenesisApplicationTheme extends ClassVariantTheme { button.setSkinForState( ButtonState.DISABLED, disabledSkin ); } + + function _setButtonNoBackgrounIconStyles( button:Button ) { + var defaultSkin = new RectangleSkin( FillStyle.SolidColor( _themeColors.BtnWarning, 0 ) ); + button.backgroundSkin = defaultSkin; + } function _setButtonSelectFileStyles( button:Button ) { diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index f8c49b86..a6548d1c 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -1,7 +1,7 @@ package superhuman.browser; import prominic.sys.tools.SysTools; -import haxe.io.Path; +import sys.FileSystem; class BrowserData { @@ -9,12 +9,14 @@ class BrowserData { public var browserName:String; public var executablePath:String; public var isDefault:Bool; + public var exists:Bool; - public function new(browserType:String, isDefault:Bool = false, browserName:String = "", executablePath:String = "") { + public function new(browserType:String, isDefault:Bool = false, browserName:String = "", executablePath:String = "", exists:Bool = false) { this.browserType = browserType; this.isDefault = isDefault; this.browserName = browserName; this.executablePath = executablePath; + this.exists = exists; _setDefaultValues(browserType); } @@ -69,5 +71,7 @@ class BrowserData { #end } } + + this.exists = FileSystem.exists(this.executablePath); } } \ No newline at end of file diff --git a/Source/superhuman/components/browsers/BrowsersList.hx b/Source/superhuman/components/browsers/BrowsersList.hx index 7a9b94b5..08b0223e 100644 --- a/Source/superhuman/components/browsers/BrowsersList.hx +++ b/Source/superhuman/components/browsers/BrowsersList.hx @@ -30,6 +30,8 @@ package superhuman.components.browsers; +import genesis.application.components.AdvancedAssetLoader; +import feathers.controls.Button; import openfl.events.Event; import feathers.layout.VerticalListLayout; import feathers.layout.VerticalLayout; @@ -97,12 +99,13 @@ class BrowserItem extends LayoutGroupItemRenderer { public static final BROWSER_ITEM_CHANGE:String = "browserItemChange"; - var _labelBrowserGroupLayout:HorizontalLayout; - var _labelBrowserGroup:LayoutGroup; var _labelBrowserName:Label; var _checkBrowserStatus:Check; + var _statusGroup:LayoutGroup; + var _buttonIconExists:Button; + var _browserData:BrowserData; public function new() { @@ -128,17 +131,31 @@ class BrowserItem extends LayoutGroupItemRenderer { _labelBrowserName.layoutData = new HorizontalLayoutData(100); this.addChild(_labelBrowserName); + horizontalLayout = new HorizontalLayout(); + horizontalLayout.verticalAlign = VerticalAlign.MIDDLE; + + _statusGroup = new LayoutGroup(); + _statusGroup.layout = horizontalLayout; + this.addChild(_statusGroup); + _checkBrowserStatus = new Check(); _checkBrowserStatus.iconPosition = RIGHT; _checkBrowserStatus.variant = GenesisApplicationTheme.CHECK_MEDIUM; _checkBrowserStatus.addEventListener(Event.CHANGE, _checkBrowserStatusChange); - this.addChild(_checkBrowserStatus); + _statusGroup.addChild(_checkBrowserStatus); + + _buttonIconExists = new Button(); + _buttonIconExists.variant = GenesisApplicationTheme.BUTTON_BROWSER_WARNING; + _buttonIconExists.icon = new AdvancedAssetLoader( GenesisApplicationTheme.getAssetPath( GenesisApplicationTheme.ICON_WARNING ) ); + _buttonIconExists.visible = _buttonIconExists.includeInLayout = false; + _statusGroup.addChild(_buttonIconExists); } public function updateBrowser(browserData:BrowserData) { _checkBrowserStatus.removeEventListener(Event.CHANGE, _checkBrowserStatusChange); _browserData = browserData; + _buttonIconExists.visible = _buttonIconExists.includeInLayout = browserData.exists == false; _labelBrowserName.text = browserData.browserName; if (browserData.isDefault) { _checkBrowserStatus.text = "Default Browser"; diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index d538c3ed..6fb6af69 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -97,6 +97,7 @@ class SetupBrowserPage extends Page { _locatePath = new Button(LanguageManager.getInstance().getString('settingspage.browser.locatebrowser')); _locatePath.variant = GenesisApplicationTheme.BUTTON_SELECT_FILE; + _locatePath.visible = _locatePath.includeInLayout = false; _execPathGroup.addChild(_locatePath); horizontalGroupLayout = new HorizontalLayout(); From 406314f12e554775d752080619b9d4f1fd9b5570 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 1 Aug 2023 08:12:39 +0200 Subject: [PATCH 16/26] Browsers: Add Download button in browsers setup page (reference #81) --- Source/SuperHumanInstaller.hx | 47 +++++--- Source/superhuman/browser/BrowserData.hx | 114 +++++++++++------- Source/superhuman/components/ServerList.hx | 6 +- Source/superhuman/components/ServerPage.hx | 2 +- .../components/browsers/SetupBrowserPage.hx | 19 ++- .../events/SuperHumanApplicationEvent.hx | 3 +- 6 files changed, 123 insertions(+), 68 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index b627f9d7..5db34d71 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -311,7 +311,7 @@ class SuperHumanInstaller extends GenesisApplication { _serverPage.addEventListener( SuperHumanApplicationEvent.DESTROY_SERVER, _destroyServer ); _serverPage.addEventListener( SuperHumanApplicationEvent.DOWNLOAD_VAGRANT, _downloadVagrant ); _serverPage.addEventListener( SuperHumanApplicationEvent.DOWNLOAD_VIRTUALBOX, _downloadVirtualBox ); - _serverPage.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSER, _openBrowser ); + _serverPage.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSER_SERVER_ADDRESS, _openBrowserServerAddress ); _serverPage.addEventListener( SuperHumanApplicationEvent.OPEN_SERVER_DIRECTORY, _openServerDir ); _serverPage.addEventListener( SuperHumanApplicationEvent.OPEN_VAGRANT_SSH, _openVagrantSSH ); _serverPage.addEventListener( SuperHumanApplicationEvent.OPEN_VIRTUALBOX_GUI, _openVirtualBoxGUI ); @@ -359,6 +359,7 @@ class SuperHumanInstaller extends GenesisApplication { _setupBrowserPage = new SetupBrowserPage(); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.REFRESH_DEFAULT_BROWSER, _refreshDefaultBrowser); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.REFRESH_BROWSERS_PAGE, _refreshBrowsersPage); + _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.OPEN_DOWNLOAD_BROWSER, _openDownloadBrowser); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP, _closeSetupBrowserPage ); this.addPage( _setupBrowserPage, PAGE_SETUP_BROWSERS ); @@ -659,32 +660,42 @@ class SuperHumanInstaller extends GenesisApplication { } - function _openBrowser( e:SuperHumanApplicationEvent ) { + function _openBrowserServerAddress( e:SuperHumanApplicationEvent ) { + if ( e.server.webAddress == null || e.server.webAddress.length == 0 ) + { + if ( e.server.console != null ) + { + e.server.console.appendText( LanguageManager.getInstance().getString( 'serverpage.server.console.webaddressinvalid', '[${e.server.webAddress}]' ), true ); + } + } + _openBrowser(e.server.webAddress); + } - var defaultBrowser = Browsers.getDefaultBrowser(); - var a = [e.server.webAddress]; - #if mac - a = ["-a" + defaultBrowser.executablePath, e.server.webAddress]; - #elseif windows - a = ["start", '""', '"${defaultBrowser.executablePath}"', '"${e.server.webAddress}"']; - #end - - if ( e.server.webAddress == null || e.server.webAddress.length == 0 ) { + function _openBrowser(webAddress:String) { + + if ( webAddress == null || webAddress.length == 0 ) { - if ( e.server.console != null ) e.server.console.appendText( LanguageManager.getInstance().getString( 'serverpage.server.console.webaddressinvalid', '[${e.server.webAddress}]' ), true ); - Logger.error( '${this}: Web address is invalid: \"${e.server.webAddress}\"' ); + Logger.error( '${this}: Web address is invalid: \"${webAddress}\"' ); return; } + var defaultBrowser = Browsers.getDefaultBrowser(); + var a = [webAddress]; + #if mac + a = ["-a" + defaultBrowser.executablePath, webAddress]; + #elseif windows + a = ["start", '""', '"${defaultBrowser.executablePath}"', '"${webAddress}"']; + #end + #if windows var trim = StringTools.trim( a.join( " " )); NativeSys.sys_command(trim); #else Shell.getInstance().open( a ); - #end + #end } - + function _saveConfig() { Server.keepFailedServersRunning = _config.preferences.keepfailedserversrunning; @@ -763,12 +774,14 @@ class SuperHumanInstaller extends GenesisApplication { } function _refreshBrowsersPage(e:SuperHumanApplicationEvent) { - - //this.selectedPageId = PAGE_BROWSERS; _browsersPage.refreshBrowsers(); _updateDefaultBrowserSettingsPage(); } + function _openDownloadBrowser(e:SuperHumanApplicationEvent) { + _openBrowser(e.browserData.downloadUrl); + } + function _closeSetupBrowserPage(e:SuperHumanApplicationEvent) { this.selectedPageId = this.previousPageId; } diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index a6548d1c..bffaacc2 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -10,6 +10,7 @@ class BrowserData { public var executablePath:String; public var isDefault:Bool; public var exists:Bool; + public var downloadUrl:String; public function new(browserType:String, isDefault:Bool = false, browserName:String = "", executablePath:String = "", exists:Bool = false) { this.browserType = browserType; @@ -26,50 +27,77 @@ class BrowserData { this.browserName = browserType; } - if (executablePath == "") { - switch browserType { - case Browsers.GOOGLE_CHROME: + switch browserType { + case Browsers.GOOGLE_CHROME: + if (this.executablePath == "") + { + #if linux + + #elseif mac + this.executablePath = "/Applications/Google Chrome.app"; + #elseif windows + this.executablePath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; + #end + } + + this.downloadUrl = "https://www.google.com/intl/en/chrome/"; + case Browsers.BRAVE: + if (this.executablePath == "") + { + #if linux + + #elseif mac + this.executablePath = "/Applications/Brave Browser.app"; + #elseif windows + this.executablePath = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"; + #end + } + + this.downloadUrl = "https://brave.com/"; + case Browsers.OPERA: + if (this.executablePath == "") + { + #if linux + + #elseif mac + this.executablePath = "/Applications/Opera.app"; + #elseif windows + var userName = SysTools.getWindowsUserName(); + this.executablePath = "C:/Users/${userName}/AppData/Local/Programs/Opera/launcher.exe"; + #end + } + + this.downloadUrl = "https://www.opera.com/"; + case Browsers.MICROSOFT_EDGE: + if (this.executablePath == "") + { + #if windows + this.executablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"; + #end + } + + this.downloadUrl = "https://www.microsoft.com/en-us/edge"; + case Browsers.SAFARI: + if (this.executablePath == "") + { + this.executablePath = "/Applications/Safari.app"; + } + + this.downloadUrl = "https://www.apple.com/safari/"; + case Browsers.CHROMIUM: + case Browsers.INTERNET_EXPLORER: + default: + if (this.executablePath == "") + { #if linux - - #elseif mac - this.executablePath = "/Applications/Google Chrome.app"; - #elseif windows - this.executablePath = "C:/Program Files/Google/Chrome/Application/chrome.exe"; - #end - case Browsers.BRAVE: - #if linux - - #elseif mac - this.executablePath = "/Applications/Brave Browser.app"; - #elseif windows - this.executablePath = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"; - #end - case Browsers.OPERA: - #if linux - - #elseif mac - this.executablePath = "/Applications/Opera.app"; - #elseif windows - var userName = SysTools.getWindowsUserName(); - this.executablePath = "C:/Users/${userName}/AppData/Local/Programs/Opera/launcher.exe"; - #end - case Browsers.MICROSOFT_EDGE: - #if windows - this.executablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"; - #end - case Browsers.SAFARI: - this.executablePath = "/Applications/Safari.app"; - case Browsers.CHROMIUM: - case Browsers.INTERNET_EXPLORER: - default: - #if linux - - #elseif mac - this.executablePath = "/Applications/Firefox.app"; - #elseif windows - this.executablePath = "C:/Program Files/Mozilla Firefox/firefox.exe"; - #end - } + + #elseif mac + this.executablePath = "/Applications/Firefox.app"; + #elseif windows + this.executablePath = "C:/Program Files/Mozilla Firefox/firefox.exe"; + #end + } + this.downloadUrl = "https://www.mozilla.org/en-US/firefox/new/"; } this.exists = FileSystem.exists(this.executablePath); diff --git a/Source/superhuman/components/ServerList.hx b/Source/superhuman/components/ServerList.hx index a355986b..d40249d2 100644 --- a/Source/superhuman/components/ServerList.hx +++ b/Source/superhuman/components/ServerList.hx @@ -73,7 +73,7 @@ class ServerList extends ListView { item.addEventListener( SuperHumanApplicationEvent.COPY_TO_CLIPBOARD, _forwardEvent ); item.addEventListener( SuperHumanApplicationEvent.DELETE_SERVER, _forwardEvent ); item.addEventListener( SuperHumanApplicationEvent.DESTROY_SERVER, _forwardEvent ); - item.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSER, _forwardEvent ); + item.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSER_SERVER_ADDRESS, _forwardEvent ); item.addEventListener( SuperHumanApplicationEvent.OPEN_CONSOLE, _forwardEvent ); item.addEventListener( SuperHumanApplicationEvent.OPEN_VAGRANT_SSH, _forwardEvent ); item.addEventListener( SuperHumanApplicationEvent.PROVISION_SERVER, _forwardEvent ); @@ -108,7 +108,7 @@ class ServerList extends ListView { item.removeEventListener( SuperHumanApplicationEvent.COPY_TO_CLIPBOARD, _forwardEvent ); item.removeEventListener( SuperHumanApplicationEvent.DELETE_SERVER, _forwardEvent ); item.removeEventListener( SuperHumanApplicationEvent.DESTROY_SERVER, _forwardEvent ); - item.removeEventListener( SuperHumanApplicationEvent.OPEN_BROWSER, _forwardEvent ); + item.removeEventListener( SuperHumanApplicationEvent.OPEN_BROWSER_SERVER_ADDRESS, _forwardEvent ); item.removeEventListener( SuperHumanApplicationEvent.OPEN_CONSOLE, _forwardEvent ); item.removeEventListener( SuperHumanApplicationEvent.OPEN_VAGRANT_SSH, _forwardEvent ); item.removeEventListener( SuperHumanApplicationEvent.PROVISION_SERVER, _forwardEvent ); @@ -423,7 +423,7 @@ class ServerItem extends LayoutGroupItemRenderer { function _buttonOpenBrowserTriggered( e:TriggerEvent ) { - var event = new SuperHumanApplicationEvent( SuperHumanApplicationEvent.OPEN_BROWSER ); + var event = new SuperHumanApplicationEvent( SuperHumanApplicationEvent.OPEN_BROWSER_SERVER_ADDRESS ); event.server = _server; this.dispatchEvent( event ); diff --git a/Source/superhuman/components/ServerPage.hx b/Source/superhuman/components/ServerPage.hx index c4926f14..0dbcdbdd 100644 --- a/Source/superhuman/components/ServerPage.hx +++ b/Source/superhuman/components/ServerPage.hx @@ -206,7 +206,7 @@ class ServerPage extends Page { _serverList.addEventListener( SuperHumanApplicationEvent.CONFIGURE_SERVER, _forwardEvent ); _serverList.addEventListener( SuperHumanApplicationEvent.DELETE_SERVER, _forwardEvent ); _serverList.addEventListener( SuperHumanApplicationEvent.DESTROY_SERVER, _forwardEvent ); - _serverList.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSER, _forwardEvent ); + _serverList.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSER_SERVER_ADDRESS, _forwardEvent ); _serverList.addEventListener( SuperHumanApplicationEvent.OPEN_CONSOLE, _openConsole ); _serverList.addEventListener( SuperHumanApplicationEvent.OPEN_VAGRANT_SSH, _forwardEvent ); _serverList.addEventListener( SuperHumanApplicationEvent.PROVISION_SERVER, _forwardEvent ); diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index 6fb6af69..53627d7c 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -1,5 +1,6 @@ package superhuman.components.browsers; +import genesis.application.components.GenesisButton; import openfl.events.Event; import superhuman.theme.SuperHumanInstallerTheme; import feathers.text.TextFormat; @@ -39,6 +40,7 @@ class SetupBrowserPage extends Page { var _defaultBrowserGroup:LayoutGroup; var _checkDefaultBrowser:Check; + var _buttonDownloadBrowser:GenesisButton; var _buttonGroup:LayoutGroup; var _buttonGroupLayout:HorizontalLayout; @@ -110,8 +112,13 @@ class SetupBrowserPage extends Page { _checkDefaultBrowser = new Check(LanguageManager.getInstance().getString('settingspage.browser.defaultbrowser')); _checkDefaultBrowser.variant = GenesisApplicationTheme.CHECK_MEDIUM; + _checkDefaultBrowser.layoutData = new HorizontalLayoutData(100); _defaultBrowserGroup.addChild(_checkDefaultBrowser); + _buttonDownloadBrowser = new GenesisButton(LanguageManager.getInstance().getString( 'updatepage.buttondownload' )); + _buttonDownloadBrowser.addEventListener(TriggerEvent.TRIGGER, _buttonDownloadBrowserTriggered); + _defaultBrowserGroup.addChild(_buttonDownloadBrowser); + var line = new HLine(); line.width = _width; this.addChild( line ); @@ -138,6 +145,7 @@ class SetupBrowserPage extends Page { _textInputBrowserName.text = data.browserName; _textInputPath.text = data.executablePath; _checkDefaultBrowser.selected = data.isDefault; + _buttonDownloadBrowser.visible = _buttonDownloadBrowser.includeInLayout = data.downloadUrl != null; } function _saveButtonTriggered(e:TriggerEvent) { @@ -156,10 +164,15 @@ class SetupBrowserPage extends Page { this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP ) ); } - + + function _buttonDownloadBrowserTriggered(e:TriggerEvent) { + var superHumanAppEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.OPEN_DOWNLOAD_BROWSER); + superHumanAppEvent.browserData = _browserData; + + this.dispatchEvent(superHumanAppEvent); + } + function _buttonCloseTriggered( e:TriggerEvent ) { - this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.CLOSE_BROWSERS_SETUP ) ); - } } \ No newline at end of file diff --git a/Source/superhuman/events/SuperHumanApplicationEvent.hx b/Source/superhuman/events/SuperHumanApplicationEvent.hx index 79392b41..de560752 100644 --- a/Source/superhuman/events/SuperHumanApplicationEvent.hx +++ b/Source/superhuman/events/SuperHumanApplicationEvent.hx @@ -57,7 +57,8 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { public static final DESTROY_SERVER:String = "destroyServer"; public static final DOWNLOAD_VAGRANT:String = "downloadVagrant"; public static final DOWNLOAD_VIRTUALBOX:String = "downloadVirtualBox"; - public static final OPEN_BROWSER:String = "openBrowser"; + public static final OPEN_BROWSER_SERVER_ADDRESS:String = "openBrowserServerAddress"; + public static final OPEN_DOWNLOAD_BROWSER:String = "openDownloadBrowser"; public static final OPEN_BROWSERS_SETUP:String = "openBrowsersSetup"; public static final OPEN_CONSOLE:String = "openConsole"; public static final OPEN_SERVER_DIRECTORY:String = "openServerDirectory"; From 163e4a473bf6c9b8d95fda12dbbf2c593ebf4ccb Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Wed, 2 Aug 2023 07:55:53 +0200 Subject: [PATCH 17/26] Browsers: Add text error in browser edit detail when browser is not detected (reference #81) --- .../theme/GenesisApplicationTheme.hx | 6 ++++++ .../components/browsers/SetupBrowserPage.hx | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx index 06b80baf..8fb99f6c 100644 --- a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx +++ b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx @@ -108,6 +108,7 @@ class GenesisApplicationTheme extends ClassVariantTheme { public static final LABEL_LINK_SMALL:String = "label-link-small"; public static final LABEL_SMALL_CENTERED:String = "label-small-centered"; public static final LABEL_TITLE:String = "label-title"; + public static final LABEL_ERROR:String = "label-error"; public static final LAYOUT_GROUP_CREATE_ACCOUNT:String = "layout-group-create-account"; public static final LAYOUT_GROUP_FOOTER:String = "layout-group-footer"; public static final LAYOUT_GROUP_HEADER:String = "layout-group-header"; @@ -310,6 +311,7 @@ class GenesisApplicationTheme extends ClassVariantTheme { this.styleProvider.setStyleFunction( Label, LABEL_LINK_SMALL, _setLabelLinkSmallStyles ); this.styleProvider.setStyleFunction( Label, LABEL_SMALL_CENTERED, _setLabelSmallCenteredStyles ); this.styleProvider.setStyleFunction( Label, LABEL_TITLE, _setLabelTitleStyles ); + this.styleProvider.setStyleFunction( Label, LABEL_ERROR, _setLabelErrorStyles ); this.styleProvider.setStyleFunction( Label, null, _setLabelStyles ); this.styleProvider.setStyleFunction( LayoutGroup, APPLICATION, _setApplicationLayoutGroupStyles ); this.styleProvider.setStyleFunction( LayoutGroup, LAYOUT_GROUP_CREATE_ACCOUNT, _setLayoutGroupCreateAccountStyles ); @@ -617,6 +619,10 @@ class GenesisApplicationTheme extends ClassVariantTheme { } + function _setLabelErrorStyles( label:Label ) { + label.textFormat = _themeTypography.ConsoleTextError; + } + function _setLabelHugeStyles( label:Label ) { label.textFormat = _themeTypography.Huge; diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index 53627d7c..86254aba 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -31,6 +31,9 @@ class SetupBrowserPage extends Page { var _titleGroup:LayoutGroup; var _labelTitle:Label; + var _browserNotDetectedGroup:LayoutGroup; + var _labelBrowserNotDetectedError:Label; + var _browserNameGroup:LayoutGroup; var _textInputBrowserName:TextInput; @@ -70,7 +73,21 @@ class SetupBrowserPage extends Page { var line = new HLine(); line.width = _width; this.addChild( line ); + + titleGroupLayout = new HorizontalLayout(); + titleGroupLayout.horizontalAlign = HorizontalAlign.CENTER; + titleGroupLayout.verticalAlign = VerticalAlign.MIDDLE; + _browserNotDetectedGroup = new LayoutGroup(); + _browserNotDetectedGroup.layout = titleGroupLayout; + _browserNotDetectedGroup.width = _width; + _browserNotDetectedGroup.visible = _browserNotDetectedGroup.includeInLayout = false; + this.addChild(_browserNotDetectedGroup); + + _labelBrowserNotDetectedError = new Label(); + _labelBrowserNotDetectedError.variant = GenesisApplicationTheme.LABEL_ERROR; + _browserNotDetectedGroup.addChild(_labelBrowserNotDetectedError); + var horizontalGroupLayout = new HorizontalLayout(); horizontalGroupLayout.verticalAlign = VerticalAlign.MIDDLE; @@ -146,6 +163,8 @@ class SetupBrowserPage extends Page { _textInputPath.text = data.executablePath; _checkDefaultBrowser.selected = data.isDefault; _buttonDownloadBrowser.visible = _buttonDownloadBrowser.includeInLayout = data.downloadUrl != null; + _labelBrowserNotDetectedError.text = LanguageManager.getInstance().getString('settingspage.browser.browsernotdetected', data.browserName); + _browserNotDetectedGroup.visible = _browserNotDetectedGroup.includeInLayout = data.exists == false; } function _saveButtonTriggered(e:TriggerEvent) { From b0f6dec0143cf029a961264326fbaa865d616849 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Wed, 2 Aug 2023 10:57:43 +0200 Subject: [PATCH 18/26] Browsers: Update with missing text for hing when there is no browser detected (reference #81) --- Assets/text/en_US.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/text/en_US.json b/Assets/text/en_US.json index 43459307..95c09886 100644 --- a/Assets/text/en_US.json +++ b/Assets/text/en_US.json @@ -385,7 +385,8 @@ "executablebrowserpath": "Executable Browser path", "locatebrowser": "Locate Browser", "defaultbrowser": "Default Browser", - "doubleclickhint": "Double click to open any row for more details" + "doubleclickhint": "Double click to open any row for more details", + "browsernotdetected": "%1 not detected" } } } \ No newline at end of file From 2c0a5bb067435d5c61798dae67bbf98cdf6d8d64 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Fri, 4 Aug 2023 13:22:05 +0200 Subject: [PATCH 19/26] Browsers: Remove double click from Browsers list - exchange it with Configuration button to get more clearance (reference #81) --- Assets/text/en_US.json | 5 +- Source/SuperHumanInstaller.hx | 4 +- .../components/browsers/BrowsersList.hx | 52 +++++++++++++------ .../components/browsers/BrowsersPage.hx | 25 ++++----- .../events/SuperHumanApplicationEvent.hx | 2 +- .../theme/SuperHumanInstallerTheme.hx | 3 ++ 6 files changed, 54 insertions(+), 37 deletions(-) diff --git a/Assets/text/en_US.json b/Assets/text/en_US.json index 95c09886..94576042 100644 --- a/Assets/text/en_US.json +++ b/Assets/text/en_US.json @@ -385,8 +385,9 @@ "executablebrowserpath": "Executable Browser path", "locatebrowser": "Locate Browser", "defaultbrowser": "Default Browser", - "doubleclickhint": "Double click to open any row for more details", - "browsernotdetected": "%1 not detected" + "browserlisthint": "Select default Browser", + "browsernotdetected": "%1 not detected", + "configurebrowser": "Configure" } } } \ No newline at end of file diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 5db34d71..999755c9 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -350,7 +350,7 @@ class SuperHumanInstaller extends GenesisApplication { this.addPage( _rolePage, PAGE_ROLES ); _browsersPage = new BrowsersPage(); - _browsersPage.addEventListener(SuperHumanApplicationEvent.SETUP_BROWSER, _setBrowserPage); + _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); @@ -758,7 +758,7 @@ class SuperHumanInstaller extends GenesisApplication { } - function _setBrowserPage(e:SuperHumanApplicationEvent) { + function _configureBrowserPage(e:SuperHumanApplicationEvent) { this.selectedPageId = PAGE_SETUP_BROWSERS; _setupBrowserPage.setBrowserData(e.browserData); } diff --git a/Source/superhuman/components/browsers/BrowsersList.hx b/Source/superhuman/components/browsers/BrowsersList.hx index 08b0223e..48c8dc10 100644 --- a/Source/superhuman/components/browsers/BrowsersList.hx +++ b/Source/superhuman/components/browsers/BrowsersList.hx @@ -30,13 +30,16 @@ package superhuman.components.browsers; +import superhuman.theme.SuperHumanInstallerTheme; +import feathers.events.TriggerEvent; +import genesis.application.managers.LanguageManager; +import genesis.application.components.GenesisButton; +import feathers.skins.RectangleSkin; import genesis.application.components.AdvancedAssetLoader; import feathers.controls.Button; import openfl.events.Event; import feathers.layout.VerticalListLayout; -import feathers.layout.VerticalLayout; import feathers.layout.HorizontalLayoutData; -import feathers.layout.VerticalLayoutData; import feathers.layout.VerticalAlign; import genesis.application.theme.GenesisApplicationTheme; import feathers.data.ListViewItemState; @@ -61,9 +64,11 @@ class BrowsersList extends ListView { this.layout = new VerticalListLayout(); var recycler = DisplayObjectRecycler.withFunction( () -> { - + var item = new BrowserItem(); - item.addEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); + item.addEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); + item.addEventListener(SuperHumanApplicationEvent.CONFIGURE_BROWSER, _configureBrowser); + return item; } ); @@ -78,10 +83,10 @@ class BrowsersList extends ListView { recycler.destroy = ( item:BrowserItem ) -> { item.removeEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); + item.removeEventListener(SuperHumanApplicationEvent.CONFIGURE_BROWSER, _configureBrowser); }; this.itemRendererRecycler = recycler; - } function _forwardEvent( e:SuperHumanApplicationEvent ) { @@ -92,6 +97,10 @@ class BrowsersList extends ListView { function _browserItemChange(e:SuperHumanApplicationEvent) { _forwardEvent(e); } + + function _configureBrowser(e:SuperHumanApplicationEvent) { + _forwardEvent(e); + } } @:styleContext @@ -100,11 +109,12 @@ class BrowserItem extends LayoutGroupItemRenderer { public static final BROWSER_ITEM_CHANGE:String = "browserItemChange"; var _labelBrowserName:Label; - + var _checkBrowserStatus:Check; var _statusGroup:LayoutGroup; var _buttonIconExists:Button; + var _buttonConfigure:GenesisButton; var _browserData:BrowserData; @@ -132,23 +142,27 @@ class BrowserItem extends LayoutGroupItemRenderer { this.addChild(_labelBrowserName); horizontalLayout = new HorizontalLayout(); - horizontalLayout.verticalAlign = VerticalAlign.MIDDLE; - + horizontalLayout.horizontalAlign = RIGHT; + horizontalLayout.gap = 4; + _statusGroup = new LayoutGroup(); - _statusGroup.layout = horizontalLayout; + _statusGroup.layout = horizontalLayout; this.addChild(_statusGroup); - _checkBrowserStatus = new Check(); - _checkBrowserStatus.iconPosition = RIGHT; - _checkBrowserStatus.variant = GenesisApplicationTheme.CHECK_MEDIUM; - _checkBrowserStatus.addEventListener(Event.CHANGE, _checkBrowserStatusChange); - _statusGroup.addChild(_checkBrowserStatus); - _buttonIconExists = new Button(); _buttonIconExists.variant = GenesisApplicationTheme.BUTTON_BROWSER_WARNING; _buttonIconExists.icon = new AdvancedAssetLoader( GenesisApplicationTheme.getAssetPath( GenesisApplicationTheme.ICON_WARNING ) ); _buttonIconExists.visible = _buttonIconExists.includeInLayout = false; _statusGroup.addChild(_buttonIconExists); + + _checkBrowserStatus = new Check(); + _checkBrowserStatus.iconPosition = RIGHT; + _checkBrowserStatus.variant = GenesisApplicationTheme.CHECK_MEDIUM; + _statusGroup.addChild(_checkBrowserStatus); + + _buttonConfigure = new GenesisButton(LanguageManager.getInstance().getString("settingspage.browser.configurebrowser")); + _buttonConfigure.addEventListener(TriggerEvent.TRIGGER, _buttonConfigureTriggered); + _statusGroup.addChild(_buttonConfigure); } public function updateBrowser(browserData:BrowserData) { @@ -168,7 +182,7 @@ class BrowserItem extends LayoutGroupItemRenderer { _checkBrowserStatus.addEventListener(Event.CHANGE, _checkBrowserStatusChange); } - function _checkBrowserStatusChange(event:Event) { + public function _checkBrowserStatusChange(event:Event) { _browserData.isDefault = _checkBrowserStatus.selected; var browserItemEvent = new SuperHumanApplicationEvent(BrowserItem.BROWSER_ITEM_CHANGE); @@ -176,4 +190,10 @@ class BrowserItem extends LayoutGroupItemRenderer { this.dispatchEvent(browserItemEvent); } + + function _buttonConfigureTriggered(event:TriggerEvent) { + var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.CONFIGURE_BROWSER); + setupBrowserEvent.browserData = _browserData; + this.dispatchEvent(setupBrowserEvent); + } } \ No newline at end of file diff --git a/Source/superhuman/components/browsers/BrowsersPage.hx b/Source/superhuman/components/browsers/BrowsersPage.hx index 68555107..85103f9a 100644 --- a/Source/superhuman/components/browsers/BrowsersPage.hx +++ b/Source/superhuman/components/browsers/BrowsersPage.hx @@ -110,13 +110,12 @@ class BrowsersPage extends Page { this.addChild(_hintGroup); _hintLabel = new Label(); - _hintLabel.text = LanguageManager.getInstance().getString('settingspage.browser.doubleclickhint'); + _hintLabel.text = LanguageManager.getInstance().getString('settingspage.browser.browserlisthint'); _hintLabel.variant = GenesisApplicationTheme.LABEL_COPYRIGHT; _hintGroup.addChild(_hintLabel); _browsersList = new BrowsersList(_browsers); - _browsersList.doubleClickEnabled = true; - _browsersList.addEventListener( MouseEvent.DOUBLE_CLICK, _browserListChanged ); + _browsersList.addEventListener(SuperHumanApplicationEvent.CONFIGURE_BROWSER, _configureBrowser ); _browsersList.addEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); _browsersList.width = _width; this.addChild(_browsersList); @@ -137,25 +136,19 @@ class BrowsersPage extends Page { _buttonGroup.addChild( _buttonClose ); } + public function refreshBrowsers() { + _browsersList.dataProvider.updateAll(); + } + public function setBrowsers(browsers:Array) { _browsers = new ArrayCollection(browsers); if (_browsersList != null) { _browsersList.dataProvider = _browsers; } } - - public function refreshBrowsers() { - _browsersList.dataProvider.updateAll(); - } - - function _browserListChanged(e:Event) { - var browserData:BrowserData = _browsersList.selectedItem; - if (browserData == null) return; - - var setupBrowserEvent = new SuperHumanApplicationEvent(SuperHumanApplicationEvent.SETUP_BROWSER); - setupBrowserEvent.browserData = browserData; - - this.dispatchEvent( setupBrowserEvent ); + + function _configureBrowser(e:SuperHumanApplicationEvent) { + this._forwardEvent(e); } function _browserItemChange(e:SuperHumanApplicationEvent) { diff --git a/Source/superhuman/events/SuperHumanApplicationEvent.hx b/Source/superhuman/events/SuperHumanApplicationEvent.hx index de560752..85d4804e 100644 --- a/Source/superhuman/events/SuperHumanApplicationEvent.hx +++ b/Source/superhuman/events/SuperHumanApplicationEvent.hx @@ -47,7 +47,7 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { 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 SETUP_BROWSER:String = "setupBrowser"; + public static final CONFIGURE_BROWSER:String = "configureBrowser"; public static final CLOSE_BROWSERS_SETUP:String = "closeBrowsersSetup"; public static final CONFIGURE_ROLES:String = "configureRoles"; public static final CONFIGURE_SERVER:String = "configureServer"; diff --git a/Source/superhuman/theme/SuperHumanInstallerTheme.hx b/Source/superhuman/theme/SuperHumanInstallerTheme.hx index 6ac1cf8b..dc1ebbc9 100644 --- a/Source/superhuman/theme/SuperHumanInstallerTheme.hx +++ b/Source/superhuman/theme/SuperHumanInstallerTheme.hx @@ -67,6 +67,9 @@ class SuperHumanInstallerTheme extends GenesisApplicationTheme { public var consoleTextErrorFormat( get, never ):TextFormat; function get_consoleTextErrorFormat() return _themeTypography.ConsoleTextError; + public var themeTypography(get, never):Typography; + function get_themeTypography() return _themeTypography; + public function new( mode:ThemeMode = ThemeMode.Dark ) { super( mode ); From 3dbaff794a0c10b584348a09a357c4cd112117c5 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Mon, 14 Aug 2023 16:41:47 +0200 Subject: [PATCH 20/26] Browsers: Move browsers settings to main settings page to avoid confusion with saving and simplify UI (reference #81 ) --- Source/SuperHumanInstaller.hx | 35 ++++----- Source/superhuman/components/SettingsPage.hx | 72 ++++++++++--------- .../components/browsers/BrowsersList.hx | 12 ++-- .../components/browsers/SetupBrowserPage.hx | 1 + .../events/SuperHumanApplicationEvent.hx | 1 - 5 files changed, 57 insertions(+), 64 deletions(-) diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 999755c9..07caff9b 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -340,21 +340,23 @@ class SuperHumanInstaller extends GenesisApplication { this.addPage( _advancedConfigPage, PAGE_CONFIG_ADVANCED ); _settingsPage = new SettingsPage(); - _settingsPage.addEventListener( SuperHumanApplicationEvent.OPEN_BROWSERS_SETUP, _openBrowsersSetup ); _settingsPage.addEventListener( SuperHumanApplicationEvent.CANCEL_PAGE, _cancelSettings ); _settingsPage.addEventListener( SuperHumanApplicationEvent.SAVE_APP_CONFIGURATION, _saveAppConfiguration ); + _settingsPage.addEventListener(SuperHumanApplicationEvent.CONFIGURE_BROWSER, _configureBrowserPage); + _settingsPage.addEventListener( SuperHumanApplicationEvent.REFRESH_DEFAULT_BROWSER, _refreshDefaultBrowser); + this.addPage( _settingsPage, PAGE_SETTINGS ); _rolePage = new RolePage(); _rolePage.addEventListener( SuperHumanApplicationEvent.CLOSE_ROLES, _closeRolePage ); this.addPage( _rolePage, PAGE_ROLES ); - _browsersPage = new BrowsersPage(); + /*_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 ); + this.addPage( _browsersPage, PAGE_BROWSERS );*/ _setupBrowserPage = new SetupBrowserPage(); _setupBrowserPage.addEventListener( SuperHumanApplicationEvent.REFRESH_DEFAULT_BROWSER, _refreshDefaultBrowser); @@ -547,7 +549,7 @@ class SuperHumanInstaller extends GenesisApplication { } function _cancelSettings( e:SuperHumanApplicationEvent ) { - if (this.previousPageId != PAGE_BROWSERS) { + if (this.previousPageId != PAGE_SETUP_BROWSERS) { this.selectedPageId = this.previousPageId; } else { this.selectedPageId = PAGE_SERVER; @@ -557,7 +559,7 @@ class SuperHumanInstaller extends GenesisApplication { function _saveAppConfiguration( e:SuperHumanApplicationEvent ) { _saveConfig(); - if (this.previousPageId != PAGE_BROWSERS) { + if (this.previousPageId != PAGE_SETUP_BROWSERS) { this.selectedPageId = this.previousPageId; } else { this.selectedPageId = PAGE_SERVER; @@ -769,13 +771,10 @@ class SuperHumanInstaller extends GenesisApplication { b.isDefault = false; } } - - _updateDefaultBrowserSettingsPage(); } function _refreshBrowsersPage(e:SuperHumanApplicationEvent) { - _browsersPage.refreshBrowsers(); - _updateDefaultBrowserSettingsPage(); + _settingsPage.refreshBrowsers(); } function _openDownloadBrowser(e:SuperHumanApplicationEvent) { @@ -791,7 +790,8 @@ class SuperHumanInstaller extends GenesisApplication { } function _initializeBrowsersCollection() { - if (this.previousPageId != PAGE_BROWSERS && this.previousPageId != PAGE_SETUP_BROWSERS) { + //this.previousPageId != PAGE_BROWSERS && + if (this.previousPageId != PAGE_SETUP_BROWSERS) { _browsersCollection = new Array(); for (index => element in _config.browsers) { @@ -799,20 +799,9 @@ class SuperHumanInstaller extends GenesisApplication { var newBd = new BrowserData(bd.browserType, bd.isDefault, bd.browserName, bd.executablePath); _browsersCollection.push(newBd); } - - _updateDefaultBrowserSettingsPage(); } } - - function _updateDefaultBrowserSettingsPage() { - if (_settingsPage != null) { - var defaultBrowser = _browsersCollection.filter(b -> b.isDefault); - if (defaultBrowser.length > 0) { - _settingsPage.updateDefaultBrowser(defaultBrowser[0]); - } - } - } - + function _saveAdvancedServerConfiguration( e:SuperHumanApplicationEvent ) { e.server.saveHostsFile(); @@ -990,7 +979,7 @@ class SuperHumanInstaller extends GenesisApplication { if ( _selectedPageId == PAGE_SETTINGS ) { _initializeBrowsersCollection(); - _browsersPage.setBrowsers(_browsersCollection); + _settingsPage.setBrowsers(_browsersCollection); _settingsPage.updateData(); } } diff --git a/Source/superhuman/components/SettingsPage.hx b/Source/superhuman/components/SettingsPage.hx index 7d8b8d6d..54d88c30 100644 --- a/Source/superhuman/components/SettingsPage.hx +++ b/Source/superhuman/components/SettingsPage.hx @@ -30,6 +30,8 @@ package superhuman.components; +import feathers.data.ArrayCollection; +import superhuman.components.browsers.BrowsersList; import superhuman.browser.BrowserData; import superhuman.browser.Browsers; import feathers.controls.Label; @@ -60,7 +62,6 @@ class SettingsPage extends Page { var _cbDisableVagrantLogging:GenesisFormCheckBox; var _cbKeepFailedServersRunning:GenesisFormCheckBox; var _cbKeepServersRunning:GenesisFormCheckBox; - var _cbProvision:GenesisFormCheckBox; var _form:GenesisForm; var _label:Label; var _rowAdvanced:GenesisFormRow; @@ -69,11 +70,13 @@ class SettingsPage extends Page { var _rowKeepServersRunning:GenesisFormRow; var _rowProvision:GenesisFormRow; var _rowBrowsers:GenesisFormRow; - var _rowBrowsersDefault:GenesisFormRow; - var _buttonDefaultBrowser:GenesisFormButton; - var _labelDefaultBrowser:Label; + + var _browsersList:BrowsersList; + var _titleGroup:LayoutGroup; + var _browsers:ArrayCollection; + public function new() { super(); @@ -120,10 +123,7 @@ class SettingsPage extends Page { _rowProvision = new GenesisFormRow(); _rowProvision.text = LanguageManager.getInstance().getString( 'settingspage.servers.title' ); _form.addChild( _rowProvision ); - - _cbProvision = new GenesisFormCheckBox( LanguageManager.getInstance().getString( 'settingspage.servers.alwaysprovision' ) ); - // _rowProvision.content.addChild( _cbProvision ); - + _rowKeepServersRunning = new GenesisFormRow(); _cbKeepServersRunning = new GenesisFormCheckBox( LanguageManager.getInstance().getString( 'settingspage.servers.keeprunning' ) ); _rowProvision.content.addChild( _cbKeepServersRunning ); @@ -143,17 +143,14 @@ class SettingsPage extends Page { spacer = new LayoutGroup(); spacer.height = GenesisApplicationTheme.GRID * 2; _form.addChild( spacer ); - - _rowBrowsersDefault = new GenesisFormRow(); - _rowBrowsersDefault.text = LanguageManager.getInstance().getString( 'settingspage.browser.title' ); - _labelDefaultBrowser = new Label(); - _rowBrowsersDefault.content.addChild(_labelDefaultBrowser); - _form.addChild(_rowBrowsersDefault); - + _rowBrowsers = new GenesisFormRow(); - _buttonDefaultBrowser = new GenesisFormButton( LanguageManager.getInstance().getString( 'settingspage.browser.defaultbrowser' ) ); - _buttonDefaultBrowser.addEventListener( TriggerEvent.TRIGGER, _setDefaultBrowserButtonTrigger ); - _rowBrowsers.content.addChild(_buttonDefaultBrowser); + _rowBrowsers.text = LanguageManager.getInstance().getString( 'settingspage.browser.titlesetupbrowser' ); + _browsersList = new BrowsersList(_browsers); + _browsersList.width = _width; + _browsersList.addEventListener(SuperHumanApplicationEvent.CONFIGURE_BROWSER, _configureBrowser ); + _browsersList.addEventListener(BrowserItem.BROWSER_ITEM_CHANGE, _browserItemChange); + _rowBrowsers.content.addChild(_browsersList); _form.addChild(_rowBrowsers); var line = new HLine(); @@ -177,8 +174,8 @@ class SettingsPage extends Page { updateData(); - var defaultBrowser:Dynamic = Browsers.getDefaultBrowser(); - updateDefaultBrowser(defaultBrowser); + // var defaultBrowser:Dynamic = Browsers.getDefaultBrowser(); + //updateDefaultBrowser(defaultBrowser); } public function updateData() { @@ -186,7 +183,7 @@ class SettingsPage extends Page { if ( _cbApplicationWindow != null ) { _cbApplicationWindow.selected = SuperHumanInstaller.getInstance().config.preferences.savewindowposition; - _cbProvision.selected = SuperHumanInstaller.getInstance().config.preferences.provisionserversonstart; + // _cbProvision.selected = SuperHumanInstaller.getInstance().config.preferences.provisionserversonstart; _cbKeepServersRunning.selected = SuperHumanInstaller.getInstance().config.preferences.keepserversrunning; _cbDisableVagrantLogging.selected = SuperHumanInstaller.getInstance().config.preferences.disablevagrantlogging; _cbKeepFailedServersRunning.selected = SuperHumanInstaller.getInstance().config.preferences.keepfailedserversrunning; @@ -194,18 +191,34 @@ class SettingsPage extends Page { } } - public function updateDefaultBrowser(browserData:Dynamic) { - if (browserData.isDefault == false) return; - - if (_labelDefaultBrowser != null) { - _labelDefaultBrowser.text = LanguageManager.getInstance().getString('settingspage.browser.currentdefaultbrowser', browserData.browserName); + 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); + + this.refreshBrowsers(); + } + + public function refreshBrowsers() { + _browsersList.dataProvider.updateAll(); + } + function _saveButtonTriggered( e:TriggerEvent ) { SuperHumanInstaller.getInstance().config.preferences.savewindowposition = _cbApplicationWindow.selected; - SuperHumanInstaller.getInstance().config.preferences.provisionserversonstart = _cbProvision.selected; + // SuperHumanInstaller.getInstance().config.preferences.provisionserversonstart = _cbProvision.selected; SuperHumanInstaller.getInstance().config.preferences.keepserversrunning = _cbKeepServersRunning.selected; SuperHumanInstaller.getInstance().config.preferences.disablevagrantlogging = _cbDisableVagrantLogging.selected; SuperHumanInstaller.getInstance().config.preferences.keepfailedserversrunning = _cbKeepFailedServersRunning.selected; @@ -213,9 +226,4 @@ class SettingsPage extends Page { this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.SAVE_APP_CONFIGURATION ) ); } - - function _setDefaultBrowserButtonTrigger(e:TriggerEvent) { - this.dispatchEvent( new SuperHumanApplicationEvent( SuperHumanApplicationEvent.OPEN_BROWSERS_SETUP ) ); - } - } \ No newline at end of file diff --git a/Source/superhuman/components/browsers/BrowsersList.hx b/Source/superhuman/components/browsers/BrowsersList.hx index 48c8dc10..71130ea3 100644 --- a/Source/superhuman/components/browsers/BrowsersList.hx +++ b/Source/superhuman/components/browsers/BrowsersList.hx @@ -169,15 +169,11 @@ class BrowserItem extends LayoutGroupItemRenderer { _checkBrowserStatus.removeEventListener(Event.CHANGE, _checkBrowserStatusChange); _browserData = browserData; - _buttonIconExists.visible = _buttonIconExists.includeInLayout = browserData.exists == false; _labelBrowserName.text = browserData.browserName; - if (browserData.isDefault) { - _checkBrowserStatus.text = "Default Browser"; - _checkBrowserStatus.selected = true; - } else { - _checkBrowserStatus.text = ""; - _checkBrowserStatus.selected = false; - } + + _buttonIconExists.visible = _buttonIconExists.includeInLayout = browserData.exists == false; + _checkBrowserStatus.enabled = browserData.exists; + _checkBrowserStatus.selected = browserData.isDefault; _checkBrowserStatus.addEventListener(Event.CHANGE, _checkBrowserStatusChange); } diff --git a/Source/superhuman/components/browsers/SetupBrowserPage.hx b/Source/superhuman/components/browsers/SetupBrowserPage.hx index 86254aba..1044c239 100644 --- a/Source/superhuman/components/browsers/SetupBrowserPage.hx +++ b/Source/superhuman/components/browsers/SetupBrowserPage.hx @@ -162,6 +162,7 @@ class SetupBrowserPage extends Page { _textInputBrowserName.text = data.browserName; _textInputPath.text = data.executablePath; _checkDefaultBrowser.selected = data.isDefault; + _checkDefaultBrowser.enabled = data.exists; _buttonDownloadBrowser.visible = _buttonDownloadBrowser.includeInLayout = data.downloadUrl != null; _labelBrowserNotDetectedError.text = LanguageManager.getInstance().getString('settingspage.browser.browsernotdetected', data.browserName); _browserNotDetectedGroup.visible = _browserNotDetectedGroup.includeInLayout = data.exists == false; diff --git a/Source/superhuman/events/SuperHumanApplicationEvent.hx b/Source/superhuman/events/SuperHumanApplicationEvent.hx index 85d4804e..0da8cd15 100644 --- a/Source/superhuman/events/SuperHumanApplicationEvent.hx +++ b/Source/superhuman/events/SuperHumanApplicationEvent.hx @@ -59,7 +59,6 @@ class SuperHumanApplicationEvent extends GenesisApplicationEvent { public static final DOWNLOAD_VIRTUALBOX:String = "downloadVirtualBox"; public static final OPEN_BROWSER_SERVER_ADDRESS:String = "openBrowserServerAddress"; public static final OPEN_DOWNLOAD_BROWSER:String = "openDownloadBrowser"; - public static final OPEN_BROWSERS_SETUP:String = "openBrowsersSetup"; public static final OPEN_CONSOLE:String = "openConsole"; public static final OPEN_SERVER_DIRECTORY:String = "openServerDirectory"; public static final OPEN_VAGRANT_SSH:String = "openVagrantSSH"; From 7944d5b33df05e0b537476ccdeeaf84d8abbec1e Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Mon, 14 Aug 2023 17:29:49 +0200 Subject: [PATCH 21/26] Browsers: Open all links in selected default browser (reference #81) --- .../genesis/application/GenesisApplication.hx | 9 +-- Source/SuperHumanInstaller.hx | 73 ++++--------------- Source/superhuman/browser/Browsers.hx | 27 +++++++ .../server/provisioners/DemoTasks.hx | 5 +- 4 files changed, 45 insertions(+), 69 deletions(-) diff --git a/Genesis/Source/genesis/application/GenesisApplication.hx b/Genesis/Source/genesis/application/GenesisApplication.hx index d5767ee2..9d039231 100644 --- a/Genesis/Source/genesis/application/GenesisApplication.hx +++ b/Genesis/Source/genesis/application/GenesisApplication.hx @@ -30,6 +30,7 @@ package genesis.application; +import superhuman.browser.Browsers; import champaign.core.logging.Logger; import champaign.core.primitives.VersionInfo; import champaign.sys.logging.targets.FileTarget; @@ -518,13 +519,7 @@ abstract class GenesisApplication extends Application { } function _visitGenesisDirectory( ?e:Dynamic ) { - - #if linux - Shell.getInstance().open( [ GENESIS_ADDRESS ] ); - #else - System.openURL( GENESIS_ADDRESS ); - #end - + Browsers.openLink(GENESIS_ADDRESS); } function _visitSourceCode( ?e:Dynamic ) {} diff --git a/Source/SuperHumanInstaller.hx b/Source/SuperHumanInstaller.hx index 07caff9b..ea8a0ff6 100644 --- a/Source/SuperHumanInstaller.hx +++ b/Source/SuperHumanInstaller.hx @@ -42,7 +42,7 @@ import feathers.controls.Alert; import feathers.controls.LayoutGroup; import feathers.style.Theme; import genesis.application.GenesisApplication; -import genesis.application.managers.LanguageManager; +import genesis.application.managers.LanguageManager; import genesis.application.managers.ToastManager; import genesis.application.theme.GenesisApplicationTheme; import haxe.Json; @@ -105,7 +105,6 @@ class SuperHumanInstaller extends GenesisApplication { static public final PAGE_ROLES = "page-roles"; static public final PAGE_SERVER = "page-server"; static public final PAGE_SETTINGS = "page-settings"; - static public final PAGE_BROWSERS = "page-browsers"; static public final PAGE_SETUP_BROWSERS = "page-setup-browsers"; static public final DEMO_TASKS_PATH:String = "assets/vagrant/demo-tasks/"; @@ -544,10 +543,6 @@ class SuperHumanInstaller extends GenesisApplication { } - function _openBrowsersSetup(e:SuperHumanApplicationEvent) { - this.selectedPageId = PAGE_BROWSERS; - } - function _cancelSettings( e:SuperHumanApplicationEvent ) { if (this.previousPageId != PAGE_SETUP_BROWSERS) { this.selectedPageId = this.previousPageId; @@ -570,14 +565,12 @@ class SuperHumanInstaller extends GenesisApplication { function _downloadVagrant( e:SuperHumanApplicationEvent ) { - Shell.getInstance().open( [ SuperHumanGlobals.VAGRANT_DOWNLOAD_URL ] ); + Browsers.openLink(SuperHumanGlobals.VAGRANT_DOWNLOAD_URL); } function _downloadVirtualBox( e:SuperHumanApplicationEvent ) { - - Shell.getInstance().open( [ SuperHumanGlobals.VIRTUALBOX_DOWNLOAD_URL ] ); - + Browsers.openLink(SuperHumanGlobals.VIRTUALBOX_DOWNLOAD_URL); } override function _onExit( exitCode:Int ) { @@ -670,34 +663,9 @@ class SuperHumanInstaller extends GenesisApplication { e.server.console.appendText( LanguageManager.getInstance().getString( 'serverpage.server.console.webaddressinvalid', '[${e.server.webAddress}]' ), true ); } } - _openBrowser(e.server.webAddress); + Browsers.openLink(e.server.webAddress); } - function _openBrowser(webAddress:String) { - - if ( webAddress == null || webAddress.length == 0 ) { - - Logger.error( '${this}: Web address is invalid: \"${webAddress}\"' ); - return; - - } - - var defaultBrowser = Browsers.getDefaultBrowser(); - var a = [webAddress]; - #if mac - a = ["-a" + defaultBrowser.executablePath, webAddress]; - #elseif windows - a = ["start", '""', '"${defaultBrowser.executablePath}"', '"${webAddress}"']; - #end - - #if windows - var trim = StringTools.trim( a.join( " " )); - NativeSys.sys_command(trim); - #else - Shell.getInstance().open( a ); - #end - } - function _saveConfig() { Server.keepFailedServersRunning = _config.preferences.keepfailedserversrunning; @@ -778,7 +746,7 @@ class SuperHumanInstaller extends GenesisApplication { } function _openDownloadBrowser(e:SuperHumanApplicationEvent) { - _openBrowser(e.browserData.downloadUrl); + Browsers.openLink(e.browserData.downloadUrl); } function _closeSetupBrowserPage(e:SuperHumanApplicationEvent) { @@ -1075,34 +1043,21 @@ class SuperHumanInstaller extends GenesisApplication { super._visitSourceCode(e); - #if linux - Shell.getInstance().open( [ SuperHumanGlobals.SOURCE_CODE_URL ] ); - #else - System.openURL( SuperHumanGlobals.SOURCE_CODE_URL ); - #end - + Browsers.openLink( SuperHumanGlobals.SOURCE_CODE_URL); } override function _visitSourceCodeIssues(?e:Dynamic) { super._visitSourceCodeIssues(e); - #if linux - Shell.getInstance().open( [ SuperHumanGlobals.SOURCE_CODE_ISSUE_NEW_URL ] ); - #else - System.openURL( SuperHumanGlobals.SOURCE_CODE_ISSUE_NEW_URL ); - #end + Browsers.openLink( SuperHumanGlobals.SOURCE_CODE_ISSUE_NEW_URL ); } override function _visitSourceCodeNewIssue(?e:Dynamic) { super._visitSourceCodeNewIssue(e); - #if linux - Shell.getInstance().open( [ SuperHumanGlobals.SOURCE_CODE_ISSUE_NEW_URL ] ); - #else - System.openURL( SuperHumanGlobals.SOURCE_CODE_ISSUE_NEW_URL ); - #end + Browsers.openLink( SuperHumanGlobals.SOURCE_CODE_ISSUE_NEW_URL ); } function _openVirtualBoxGUI( e:SuperHumanApplicationEvent ) { @@ -1149,22 +1104,22 @@ class SuperHumanInstaller extends GenesisApplication { switch e.text { case _TEXT_LINK_DEVOPS: - Shell.getInstance().open( [ SuperHumanGlobals.DEVOPS_WIKI_URL ] ); + Browsers.openLink(SuperHumanGlobals.DEVOPS_WIKI_URL); case _TEXT_LINK_DOMINO: - Shell.getInstance().open( [ SuperHumanGlobals.DOMINO_WIKI_URL ] ); + Browsers.openLink(SuperHumanGlobals.DOMINO_WIKI_URL); case _TEXT_LINK_GENESIS_DIRECTORY: - Shell.getInstance().open( [ SuperHumanGlobals.GENESIS_DIRECTORY_URL ] ); + Browsers.openLink(SuperHumanGlobals.GENESIS_DIRECTORY_URL); case _TEXT_LINK_VAGRANT: - Shell.getInstance().open( [ SuperHumanGlobals.VAGRANT_URL ] ); + Browsers.openLink(SuperHumanGlobals.VAGRANT_URL); case _TEXT_LINK_VIRTUALBOX: - Shell.getInstance().open( [ SuperHumanGlobals.VIRTUALBOX_URL ] ); + Browsers.openLink(SuperHumanGlobals.VIRTUALBOX_URL); case _TEXT_LINK_YAML: - Shell.getInstance().open( [ SuperHumanGlobals.YAML_WIKI_URL ] ); + Browsers.openLink(SuperHumanGlobals.YAML_WIKI_URL); default: diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx index 3e6126d5..b3ea0d3b 100644 --- a/Source/superhuman/browser/Browsers.hx +++ b/Source/superhuman/browser/Browsers.hx @@ -1,5 +1,8 @@ package superhuman.browser; +import champaign.core.logging.Logger; +import prominic.sys.applications.bin.Shell; + class Browsers { public static final MOZILLA_FIREFOX:String = "Mozilla Firefox"; @@ -43,4 +46,28 @@ class Browsers return defaultBrowser; } + + public static function openLink(webAddress:String) { + if ( webAddress == null || webAddress.length == 0 ) { + + Logger.error( 'Web address is invalid: \"${webAddress}\"' ); + return; + + } + + var defaultBrowser = Browsers.getDefaultBrowser(); + var a = [webAddress]; + #if mac + a = ["-a" + defaultBrowser.executablePath, webAddress]; + #elseif windows + a = ["start", '""', '"${defaultBrowser.executablePath}"', '"${webAddress}"']; + #end + + #if windows + var trim = StringTools.trim( a.join( " " )); + NativeSys.sys_command(trim); + #else + Shell.getInstance().open( a ); + #end + } } \ No newline at end of file diff --git a/Source/superhuman/server/provisioners/DemoTasks.hx b/Source/superhuman/server/provisioners/DemoTasks.hx index a07f8fcc..be380fb5 100644 --- a/Source/superhuman/server/provisioners/DemoTasks.hx +++ b/Source/superhuman/server/provisioners/DemoTasks.hx @@ -30,6 +30,7 @@ package superhuman.server.provisioners; +import superhuman.browser.Browsers; import champaign.core.logging.Logger; import champaign.core.primitives.VersionInfo; import genesis.application.managers.LanguageManager; @@ -286,9 +287,7 @@ class DemoTasks extends AbstractProvisioner { } public function openWelcomePage() { - - System.openURL( _getWebAddress() ); - + Browsers.openLink(_getWebAddress()); } public override function reinitialize( sourcePath:String ) { From bd3683785665b379c1fdfec2509759a21296687a Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Mon, 14 Aug 2023 17:51:57 +0200 Subject: [PATCH 22/26] Browsers: Add missing import (reference #81) --- Source/superhuman/browser/Browsers.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/superhuman/browser/Browsers.hx b/Source/superhuman/browser/Browsers.hx index b3ea0d3b..a2e13668 100644 --- a/Source/superhuman/browser/Browsers.hx +++ b/Source/superhuman/browser/Browsers.hx @@ -2,6 +2,7 @@ package superhuman.browser; import champaign.core.logging.Logger; import prominic.sys.applications.bin.Shell; +import cpp.NativeSys; class Browsers { From 39081fd2e81b28559a3f28e9c03322c190b53f30 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 15 Aug 2023 13:01:31 +0200 Subject: [PATCH 23/26] Browsers: Make label color error Browser not detected more brighter and bold - Make general Red color more brighter (reference #81 ) --- .../genesis/application/theme/GenesisApplicationTheme.hx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx index 8fb99f6c..9265001e 100644 --- a/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx +++ b/Genesis/Source/genesis/application/theme/GenesisApplicationTheme.hx @@ -254,6 +254,7 @@ class GenesisApplicationTheme extends ClassVariantTheme { Check: new TextFormat( "_sans", 14, White), ConsoleText: new TextFormat( "_typewriter", 14, _themeColors.TextConsole ), ConsoleTextError: new TextFormat( "_typewriter", 14, _themeColors.Error ), + LabelTextError: new TextFormat("_typewriter", 14, _themeColors.Error, true), ConsoleTextSelected: new TextFormat( "_typewriter", 14, _themeColors.TextConsole ), Default : new TextFormat( "_sans", 14, _themeColors.Text ), DefaultCentered : new TextFormat( "_sans", 14, _themeColors.Text, null, null, null, null, null, TextFormatAlign.CENTER ), @@ -620,7 +621,7 @@ class GenesisApplicationTheme extends ClassVariantTheme { } function _setLabelErrorStyles( label:Label ) { - label.textFormat = _themeTypography.ConsoleTextError; + label.textFormat = _themeTypography.LabelTextError; } function _setLabelHugeStyles( label:Label ) { @@ -940,7 +941,7 @@ enum abstract Color( Int ) to Int { var GreyD = 0xDDDDDD; var Orange = 0xFFAE00; var OrangeLight = 0xFFC74E; - var Red = 0xff3a3a; + var Red = 0xec2222; var White = 0xFFFFFF; } @@ -987,6 +988,7 @@ typedef Typography = { var Check:TextFormat; var ConsoleText:TextFormat; var ConsoleTextError:TextFormat; + var LabelTextError:TextFormat; var ConsoleTextSelected:TextFormat; var Default:TextFormat; var DefaultCentered:TextFormat; From bd7213e6492166bceb8fcaa34c97af8a07891074 Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 15 Aug 2023 13:35:43 +0200 Subject: [PATCH 24/26] Browsers: Fix backward compatibility in case of brave (reference #81) --- Source/superhuman/browser/BrowserData.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index bffaacc2..49fabcbd 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -41,6 +41,7 @@ class BrowserData { } this.downloadUrl = "https://www.google.com/intl/en/chrome/"; + case "Brave": case Browsers.BRAVE: if (this.executablePath == "") { From e50491223d12c20b4fd18da98b1ec5ff14b464ba Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 15 Aug 2023 15:09:35 +0200 Subject: [PATCH 25/26] Browsers: Fix issue where user name was properly incorporated into created string (reference #81) --- Source/superhuman/browser/BrowserData.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/superhuman/browser/BrowserData.hx b/Source/superhuman/browser/BrowserData.hx index 49fabcbd..abe77ca9 100644 --- a/Source/superhuman/browser/BrowserData.hx +++ b/Source/superhuman/browser/BrowserData.hx @@ -64,7 +64,7 @@ class BrowserData { this.executablePath = "/Applications/Opera.app"; #elseif windows var userName = SysTools.getWindowsUserName(); - this.executablePath = "C:/Users/${userName}/AppData/Local/Programs/Opera/launcher.exe"; + this.executablePath = 'C:/Users/${userName}/AppData/Local/Programs/Opera/launcher.exe'; #end } From 4cf9b518b8f4264d5b49f6bffca2213317a8f31f Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Wed, 16 Aug 2023 13:13:46 +0200 Subject: [PATCH 26/26] Browsers: Make sure that default browsers are applied and fill out missing browsers if doesn't exists after reading config - Small clean up (reference #81 ) --- Source/SuperHumanInstaller.hx | 20 +-- Source/superhuman/browser/BrowserData.hx | 3 +- Source/superhuman/browser/Browsers.hx | 32 +++- Source/superhuman/components/SettingsPage.hx | 3 - .../components/browsers/BrowsersPage.hx | 169 ------------------ .../events/SuperHumanApplicationEvent.hx | 1 - 6 files changed, 33 insertions(+), 195 deletions(-) delete mode 100644 Source/superhuman/components/browsers/BrowsersPage.hx 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";