From: Ben Soares Date: Wed, 17 Jul 2024 15:31:01 +0000 (+0100) Subject: JAL-3631 Extensive working of options in install4j for allowing/disabling user defaul... X-Git-Tag: Release_2_11_4_0~20^2~14 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=970b76576ba3bdd0cc12d0cbe572f8c32fcf2b4b;p=jalview.git JAL-3631 Extensive working of options in install4j for allowing/disabling user default appdir updates, and also allowing/disabling installation appdir updates. Appropriate guidance in tooltips and warnings when no updates will occur are given. A user-space install only allows disabling updates. --- diff --git a/utils/install4j/install4j10_template.install4j b/utils/install4j/install4j10_template.install4j index 6172279..705a45c 100644 --- a/utils/install4j/install4j10_template.install4j +++ b/utils/install4j/install4j10_template.install4j @@ -1,6 +1,6 @@ - + @@ -164,11 +164,7 @@ # For example, to adjust the maximum memory usage to 512 MB, uncomment the following line: # -Xmx512m # To include another file, uncomment the following line: -# -include-options [path to other .vmoption file] - -# Uncomment these two lines to disable user-space automatic updates. -#-Dnouserdefaultappdir=true -#-Dsilent=noupdate +# -include-options [path to other .vmoption file] ${compiler:file("${compiler:INFO_PLIST_FILE_ASSOCIATIONS_FILE}")} @@ -396,6 +392,73 @@ return wrapperLink; Util.isMacOS() && !context.getBooleanVariable("isAdmin") // Admin on macOS will add path to /etc/paths.d in Create File action + + + + + Boolean.TRUE + + + allowUserDefaultAppdirUpdates + + + + + + + Boolean.FALSE + + + allowInstallerAppdirUpdates + + + + + + + Map<String, String> osAppDataPathMap = new HashMap<>(); +osAppDataPathMap.put("macos", "Library/Application Support/Jalview-Desktop"); +osAppDataPathMap.put("linux", ".local/share/jalview-desktop"); +osAppDataPathMap.put("windows", "AppData\\Local\\Jalview-Desktop"); +osAppDataPathMap.put("other", ".jalview-desktop"); +String appDataPath; +String append; +if (Util.isMacOS()) { + appDataPath = osAppDataPathMap.get("macos"); + append = context.getCompilerVariable("JALVIEW_APPLICATION_NAME"); +} else if (Util.isWindows()) { + appDataPath = osAppDataPathMap.get("windows"); + append = context.getCompilerVariable("APPLICATION_FOLDER"); +} else if (Util.isLinux()) { + appDataPath = osAppDataPathMap.get("linux"); + append = context.getCompilerVariable("APPLICATION_FOLDER").toLowerCase(Locale.ROOT); +} else { + appDataPath = osAppDataPathMap.get("other"); + append = context.getCompilerVariable("APPLICATION_FOLDER").toLowerCase(Locale.ROOT); +} +return "~" + File.separator + appDataPath + File.separator + append; + + + userDefaultAppdirBase + + + + + + + if (Util.isWindows()) { + return "Windows"; +} else if (Util.isMacOS()) { + return "macOS"; +} else if (Util.isLinux()) { + return "Linux"; +} +return context.getCompilerVariable("sys.platform"); + + + osName + + @@ -565,7 +628,7 @@ return console.askOkCancel(message, true); - User account + Additional tasks for user installation (${installer:sys.userName}) ${i18n:WizardSelectTasks} !context.getBooleanVariable("isAdmin") @@ -614,11 +677,122 @@ return console.askOkCancel(message, true); ) ) + + + + Enable advanced options + + 2980 + 2975 + 2989 + + + + FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("US_ADVANCED_OPTIONS"); +Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_advancedOptions)) { + return; +} +JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); +boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); + +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("US_ALLOW_USER_APPDIR_UPDATES"); +Class<?> cl_user = fc_userUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_user)) { + return; +} +JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); +boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); + +boolean showWarning = advancedOptions && (!userUpdates); + +formEnvironment.getFormComponentById("US_NO_UPDATES_WARNING").setVisible(showWarning); + +FormComponent fc_label = formEnvironment.getFormComponentById("US_LABEL"); +fc_label.setVisible(advancedOptions); +fc_userUpdates.setVisible(advancedOptions); + + + + advancedOptions + + + + + <html>The following option is strongly recommended to be left as default unless there is a particular reason to change them.</html> + + context.getBooleanVariable("advancedOptions") + + + + + + Allow user-space updates for ${compiler:JALVIEW_APPLICATION_NAME} components + <html>This option allows updates to ${compiler:JALVIEW_APPLICATION_NAME} +<br> +components to be automatically downloaded +<br> +under the user's home space, separately from +<br> +the installation location. +<br> +<strong>This option is strongly recommended.</strong> +<br> +<br> +On ${installer:osName}, user updates will be installed under +<br> +<pre>${installer:userDefaultAppdirBase}</pre> +</html> + + + + FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("US_ADVANCED_OPTIONS"); +Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_advancedOptions)) { + return; +} +JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); +boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); + +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("US_ALLOW_USER_APPDIR_UPDATES"); +Class<?> cl_user = fc_userUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_user)) { + return; +} +JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); +boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); + +boolean showWarning = advancedOptions && (!userUpdates); + +formEnvironment.getFormComponentById("US_NO_UPDATES_WARNING").setVisible(showWarning); + + + allowUserDefaultAppdirUpdates + + context.getBooleanVariable("advancedOptions") + + + + + + + ${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/warning.png + + + No automatic updates will occur when Jalview is launched + + context.getBooleanVariable("advancedOptions") +&& +!( + context.getBooleanVariable("allowUserDefaultAppdirUpdates") + || context.getBooleanVariable("allowInstallerAppdirUpdates") +) + - System + Additional tasks for administrator installation ${i18n:WizardSelectTasks} context.getBooleanVariable("isAdmin") @@ -654,6 +828,200 @@ return console.askOkCancel(message, true); ) + + + + Enable advanced options + + 2985 + + + + FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("SS_ADVANCED_OPTIONS"); +Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_advancedOptions)) { + return; +} +JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); +boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); + +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_UPDATES"); +Class<?> cl_user = fc_userUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_user)) { + return; +} +JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); +boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); + +FormComponent fc_installerUpdates = formEnvironment.getFormComponentById("SS_ALLOW_INSTALLER_APPDIR_UPDATES"); +Class<?> cl_installer = fc_installerUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_installer)) { + return; +} +JCheckBox jcb_installer = (JCheckBox) fc_installerUpdates.getConfigurationObject(); +boolean installerUpdates = fc_installerUpdates.isEnabled() && jcb_installer.isSelected(); + +boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); + +formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING").setVisible(showWarning); + +fc_installerUpdates.setEnabled(!userUpdates); + +FormComponent fc_label = formEnvironment.getFormComponentById("SS_LABEL"); +fc_label.setVisible(advancedOptions); +fc_userUpdates.setVisible(advancedOptions); +fc_installerUpdates.setVisible(advancedOptions); + + + + advancedOptions + + + + + <html>The following options are strongly recommended to be left as default unless there is a particular reason to change them.</html> + + context.getBooleanVariable("advancedOptions") + + + + + + Allow user-space updates for ${compiler:JALVIEW_APPLICATION_NAME} components + <html>This option allows updates to ${compiler:JALVIEW_APPLICATION_NAME} +<br> +components to be automatically downloaded +<br> +under the user's home space, separately from +<br> +the installation location. +<br> +<strong>This option is strongly recommended.</strong> +<br> +<br> +On ${installer:osName}, user updates will be installed under +<br> +<pre>${installer:userDefaultAppdirBase}</pre> +</html> + + + + + FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("SS_ADVANCED_OPTIONS"); +Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_advancedOptions)) { + return; +} +JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); +boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); + +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_UPDATES"); +Class<?> cl_user = fc_userUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_user)) { + return; +} +JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); +boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); + +FormComponent fc_installerUpdates = formEnvironment.getFormComponentById("SS_ALLOW_INSTALLER_APPDIR_UPDATES"); +Class<?> cl_installer = fc_installerUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_installer)) { + return; +} +JCheckBox jcb_installer = (JCheckBox) fc_installerUpdates.getConfigurationObject(); +boolean installerUpdates = fc_installerUpdates.isEnabled() && jcb_installer.isSelected(); + +boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); + +formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING").setVisible(showWarning); + +fc_installerUpdates.setEnabled(!userUpdates); + + + + allowUserDefaultAppdirUpdates + + context.getBooleanVariable("advancedOptions") + + + + + Allow installation updates for ${compiler:JALVIEW_APPLICATION_NAME} components + <html>This option allows updates to ${compiler:JALVIEW_APPLICATION_NAME} +<br> +components to be automatically downloaded +<br> +into the installation location. +<br> +If you are installing into a system location, +<br> +a non-administrator user may have problems +<br> +launching ${compiler:JALVIEW_APPLICATION_NAME}. +<br> +<strong> +It is strongly recommended to use the +<br> +user-space updates option above. +</strong> +<br> +<br> +Installation updates will be installed into +<br> +<pre>${installer:sys.contentDir}</pre> +</html> + + + FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("SS_ADVANCED_OPTIONS"); +Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_advancedOptions)) { + return; +} +JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); +boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); + +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_UPDATES"); +Class<?> cl_user = fc_userUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_user)) { + return; +} +JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); +boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); + +FormComponent fc_installerUpdates = formEnvironment.getFormComponentById("SS_ALLOW_INSTALLER_APPDIR_UPDATES"); +Class<?> cl_installer = fc_installerUpdates.getConfigurationObjectClass(); +if (!JCheckBox.class.equals(cl_installer)) { + return; +} +JCheckBox jcb_installer = (JCheckBox) fc_installerUpdates.getConfigurationObject(); +boolean installerUpdates = fc_installerUpdates.isEnabled() && jcb_installer.isSelected(); + +boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); + +formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING").setVisible(showWarning); + + + allowInstallerAppdirUpdates + + context.getBooleanVariable("advancedOptions") + + + + + + + ${compiler:JALVIEW_DIR}/${compiler:INSTALL4J_UTILS_DIR}/warning.png + + + No automatic updates will occur when Jalview is launched + + context.getBooleanVariable("advancedOptions") +&& +!( + context.getBooleanVariable("allowUserDefaultAppdirUpdates") + || context.getBooleanVariable("allowInstallerAppdirUpdates") +) + @@ -728,11 +1096,23 @@ return console.askOkCancel(message, true); - + + + + ${i18n:FinishedHeadingLabel(${compiler:JALVIEW_APPLICATION_NAME})} + + + + + + + + + @@ -965,6 +1345,85 @@ context.getBooleanVariable("addToDockAction") + + + + + + + boolean advanced = context.getBooleanVariable("advancedOptions"); +boolean allowUser = context.getBooleanVariable("allowUserDefaultAppdirUpdates"); + +return advanced ? !allowUser : false; + + + disableUserDefaultAppdirUpdates + + + + + + + boolean advanced = context.getBooleanVariable("advancedOptions"); +boolean allowUser = context.getBooleanVariable("allowUserDefaultAppdirUpdates"); +boolean allowInstaller = context.getBooleanVariable("allowInstallerAppdirUpdates"); + +return advanced ? !( allowUser || allowInstaller ) : false; + + + disableUpdates + + + + + 2823 + + # Jalview specific options below + + + + + + 2823 + + # Uncomment the following line to disable user-space updates + #-Dnouserdefaultappdir=true + + + !context.getBooleanVariable("disableUserDefaultAppdirUpdates") + + + + 2823 + + # Comment out the following line to allow user-space updates + -Dnouserdefaultappdir=true + + + context.getBooleanVariable("disableUserDefaultAppdirUpdates") + + + + 2823 + + # Uncomment the following line to also disable all updates + #-Dsilent=noupdate + + + !context.getBooleanVariable("disableUpdates") + + + + 2823 + + # Comment out the following line to enable updates + -Dsilent=noupdate + + + context.getBooleanVariable("disableUpdates") + + + @@ -1059,6 +1518,11 @@ context.getBooleanVariable("addToDockAction") + + + + + diff --git a/utils/install4j/warning.png b/utils/install4j/warning.png new file mode 100644 index 0000000..2063df2 Binary files /dev/null and b/utils/install4j/warning.png differ