From 8064f1b2ee7cdf5cc5eae55c13cb730acbba2ffe Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 19 Jul 2024 18:47:35 +0100 Subject: [PATCH] JAL-3631 Customise the user-space path in the install4j installation wizard. Not ready yet. --- utils/install4j/install4j10_template.install4j | 402 +++++++++++++++++++----- 1 file changed, 318 insertions(+), 84 deletions(-) diff --git a/utils/install4j/install4j10_template.install4j b/utils/install4j/install4j10_template.install4j index 705a45c..564b1a5 100644 --- a/utils/install4j/install4j10_template.install4j +++ b/utils/install4j/install4j10_template.install4j @@ -183,8 +183,8 @@ - - + + @@ -678,11 +678,12 @@ return console.askOkCancel(message, true); ) - + - Enable advanced options + Enable advanced options for user installation 2980 + 3014 2975 2989 @@ -696,7 +697,7 @@ if (!JCheckBox.class.equals(cl_advancedOptions)) { 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"); +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("US_ALLOW_USER_APPDIR_UPDATES_ADVANCEDITEM"); Class<?> cl_user = fc_userUpdates.getConfigurationObjectClass(); if (!JCheckBox.class.equals(cl_user)) { return; @@ -706,26 +707,31 @@ boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected( boolean showWarning = advancedOptions && (!userUpdates); -formEnvironment.getFormComponentById("US_NO_UPDATES_WARNING").setVisible(showWarning); +FormComponent fc_warning = formEnvironment.getFormComponentById("US_NO_UPDATES_WARNING"); +fc_warning.setVisible(showWarning); -FormComponent fc_label = formEnvironment.getFormComponentById("US_LABEL"); -fc_label.setVisible(advancedOptions); -fc_userUpdates.setVisible(advancedOptions); +for (FormComponent fc: formEnvironment.getFormComponents()) { + if (formEnvironment.getId(fc).contains("ADVANCEDITEM")) { + fc.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> + <html>The following option is <strong>strongly recommended</strong> +to be left as default unless there is a particular +reason to change it.</html> context.getBooleanVariable("advancedOptions") - - + + Allow user-space updates for ${compiler:JALVIEW_APPLICATION_NAME} components <html>This option allows updates to ${compiler:JALVIEW_APPLICATION_NAME} @@ -754,7 +760,7 @@ if (!JCheckBox.class.equals(cl_advancedOptions)) { 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"); +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("US_ALLOW_USER_APPDIR_UPDATES_ADVANCEDITEM"); Class<?> cl_user = fc_userUpdates.getConfigurationObjectClass(); if (!JCheckBox.class.equals(cl_user)) { return; @@ -829,65 +835,88 @@ formEnvironment.getFormComponentById("US_NO_UPDATES_WARNING").setVisible(showWar - + - Enable advanced options + Enable advanced options for system installation 2985 + 3013 + 2986 + 2974 + 2988 FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("SS_ADVANCED_OPTIONS"); -Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); -if (!JCheckBox.class.equals(cl_advancedOptions)) { - return; -} +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_installerUpdates = formEnvironment.getFormComponentById("SS_ALLOW_INSTALLER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_allowUserAppdirPath = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_PATH"); +FormComponent fc_userAppdirPath = formEnvironment.getFormComponentById("SS_USER_APPDIR_PATH"); +LayoutGroup lg = formEnvironment.getLayoutGroupById("SS_SET_USER_APPDIR_PATH"); + +// get boolean status of "Enable advanced options" checkbox JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); -boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); +boolean advancedOptions = 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; -} +// get boolean status of "Allow user-space updates" checkbox JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); -boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); +boolean userUpdates = 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; -} +// get boolean status of "Allow installation updates" checkbox JCheckBox jcb_installer = (JCheckBox) fc_installerUpdates.getConfigurationObject(); -boolean installerUpdates = fc_installerUpdates.isEnabled() && jcb_installer.isSelected(); +boolean installerUpdates = jcb_installer.isSelected(); -boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); +// get boolean status of "Customise the user-space path" checkbox +JCheckBox jcb_allowUserAppdirPath = (JCheckBox) fc_allowUserAppdirPath.getConfigurationObject(); +boolean allowUserAppdirPath = jcb_allowUserAppdirPath.isSelected(); + +// get String value of userAppdirPath text field +JTextField jtf_userAppdirPath = (JTextField) fc_userAppdirPath.getConfigurationObject(); +String userAppdirPath = jtf_userAppdirPath.getText(); + +// set visibility of all "ADVANCEDITEM" components (does not include groups) +for (FormComponent fc: formEnvironment.getFormComponents()) { + String id = formEnvironment.getId(fc); + if (id.contains("ADVANCEDITEM")) { + fc.setVisible(advancedOptions); + } +} +// set visibility of customised user appdir path group (checkbox and text field) +lg.setVisible(advancedOptions); + +// set enabled of userAppdirPath text field +fc_userAppdirPath.setEnabled(advancedOptions && allowUserAppdirPath); -formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING").setVisible(showWarning); +// set enabled of customised user appdir path group +lg.setEnabled(advancedOptions && userUpdates); +// set enabled of allow installation updates checkbox fc_installerUpdates.setEnabled(!userUpdates); -FormComponent fc_label = formEnvironment.getFormComponentById("SS_LABEL"); -fc_label.setVisible(advancedOptions); -fc_userUpdates.setVisible(advancedOptions); -fc_installerUpdates.setVisible(advancedOptions); +// should we show the No updates warning? +boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); +FormComponent fc_warning = formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING"); +fc_warning.setVisible(showWarning); advancedOptions - + - <html>The following options are strongly recommended to be left as default unless there is a particular reason to change them.</html> + <html>The following options are <strong>strongly recommended</strong> 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 + + 3021 + <html>This option allows updates to ${compiler:JALVIEW_APPLICATION_NAME} <br> components to be automatically downloaded @@ -900,42 +929,62 @@ the installation location. <br> <br> On ${installer:osName}, user updates will be installed under -<br> <pre>${installer:userDefaultAppdirBase}</pre> +unless customised below. </html> - FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("SS_ADVANCED_OPTIONS"); -Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); -if (!JCheckBox.class.equals(cl_advancedOptions)) { - return; -} +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_installerUpdates = formEnvironment.getFormComponentById("SS_ALLOW_INSTALLER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_allowUserAppdirPath = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_PATH"); +FormComponent fc_userAppdirPath = formEnvironment.getFormComponentById("SS_USER_APPDIR_PATH"); +LayoutGroup lg = formEnvironment.getLayoutGroupById("SS_SET_USER_APPDIR_PATH"); + +// get boolean status of "Enable advanced options" checkbox JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); -boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); +boolean advancedOptions = 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; -} +// get boolean status of "Allow user-space updates" checkbox JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); -boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); +boolean userUpdates = 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; -} +// get boolean status of "Allow installation updates" checkbox JCheckBox jcb_installer = (JCheckBox) fc_installerUpdates.getConfigurationObject(); -boolean installerUpdates = fc_installerUpdates.isEnabled() && jcb_installer.isSelected(); +boolean installerUpdates = jcb_installer.isSelected(); -boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); +// get boolean status of "Customise the user-space path" checkbox +JCheckBox jcb_allowUserAppdirPath = (JCheckBox) fc_allowUserAppdirPath.getConfigurationObject(); +boolean allowUserAppdirPath = jcb_allowUserAppdirPath.isSelected(); + +// get String value of userAppdirPath text field +JTextField jtf_userAppdirPath = (JTextField) fc_userAppdirPath.getConfigurationObject(); +String userAppdirPath = jtf_userAppdirPath.getText(); -formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING").setVisible(showWarning); +// set visibility of all "ADVANCEDITEM" components (does not include groups) +for (FormComponent fc: formEnvironment.getFormComponents()) { + String id = formEnvironment.getId(fc); + if (id.contains("ADVANCEDITEM")) { + fc.setVisible(advancedOptions); + } +} +// set visibility of customised user appdir path group (checkbox and text field) +lg.setVisible(advancedOptions); + +// set enabled of userAppdirPath text field +fc_userAppdirPath.setEnabled(advancedOptions && allowUserAppdirPath); + +// set enabled of customised user appdir path group +lg.setEnabled(advancedOptions && userUpdates); +// set enabled of allow installation updates checkbox fc_installerUpdates.setEnabled(!userUpdates); + +// should we show the No updates warning? +boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); +FormComponent fc_warning = formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING"); +fc_warning.setVisible(showWarning); @@ -944,7 +993,125 @@ fc_installerUpdates.setEnabled(!userUpdates); context.getBooleanVariable("advancedOptions") - + + + + + 0 + 32 + 0 + 0 + + + + + context.getBooleanVariable("advancedOptions") + + + + + + + + Customise the user-space path + + + FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("SS_ADVANCED_OPTIONS"); +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_installerUpdates = formEnvironment.getFormComponentById("SS_ALLOW_INSTALLER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_allowUserAppdirPath = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_PATH"); +FormComponent fc_userAppdirPath = formEnvironment.getFormComponentById("SS_USER_APPDIR_PATH"); +LayoutGroup lg = formEnvironment.getLayoutGroupById("SS_SET_USER_APPDIR_PATH"); + +// get boolean status of "Enable advanced options" checkbox +JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); +boolean advancedOptions = jcb_advancedOptions.isSelected(); + +// get boolean status of "Allow user-space updates" checkbox +JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); +boolean userUpdates = jcb_user.isSelected(); + +// get boolean status of "Allow installation updates" checkbox +JCheckBox jcb_installer = (JCheckBox) fc_installerUpdates.getConfigurationObject(); +boolean installerUpdates = jcb_installer.isSelected(); + +// get boolean status of "Customise the user-space path" checkbox +JCheckBox jcb_allowUserAppdirPath = (JCheckBox) fc_allowUserAppdirPath.getConfigurationObject(); +boolean allowUserAppdirPath = jcb_allowUserAppdirPath.isSelected(); + +// get String value of userAppdirPath text field +JTextField jtf_userAppdirPath = (JTextField) fc_userAppdirPath.getConfigurationObject(); +String userAppdirPath = jtf_userAppdirPath.getText(); + +// set visibility of all "ADVANCEDITEM" components (does not include groups) +for (FormComponent fc: formEnvironment.getFormComponents()) { + String id = formEnvironment.getId(fc); + if (id.contains("ADVANCEDITEM")) { + fc.setVisible(advancedOptions); + } +} +// set visibility of customised user appdir path group (checkbox and text field) +lg.setVisible(advancedOptions); + +// set enabled of userAppdirPath text field +fc_userAppdirPath.setEnabled(advancedOptions && allowUserAppdirPath); + +// set enabled of customised user appdir path group +lg.setEnabled(advancedOptions && userUpdates); + +// set enabled of allow installation updates checkbox +fc_installerUpdates.setEnabled(!userUpdates); + +// should we show the No updates warning? +boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); +FormComponent fc_warning = formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING"); +fc_warning.setVisible(showWarning); + + + + allowSetUserAppdirPath + + + + + <html>The base path where individual users' updates +<br> +will be stored. +<br> +<strong>Only change this option if you need to!</strong> +<br> +The following substitutions will be made: +<table> +<tr><td>%u</td><td>The user's username</td></tr> +<tr><td>%h</td><td>The user's home directory path</td></tr> +<tr><td>~</td><td>(at start) The user's home directory path</td></tr> +</table> +At least one of the above substitutions should be used. +<br> +The default value on ${installer:osName} is +<br> +<pre>${installer:userDefaultAppdirBase}</pre> +</html> + + + boolean u = text.contains("%u"); +boolean h = text.contains("%h"); +boolean t = text.startsWith("~" + (String)context.getVariable("sys.fileSeparator")); + +boolean valid = text.length() == 0 || u || h || t; + +if (!valid) { + // popup warning? +} +return true; + + + userAppdirPath + + + + + Allow installation updates for ${compiler:JALVIEW_APPLICATION_NAME} components <html>This option allows updates to ${compiler:JALVIEW_APPLICATION_NAME} @@ -973,32 +1140,56 @@ Installation updates will be installed into FormComponent fc_advancedOptions = formEnvironment.getFormComponentById("SS_ADVANCED_OPTIONS"); -Class<?> cl_advancedOptions = fc_advancedOptions.getConfigurationObjectClass(); -if (!JCheckBox.class.equals(cl_advancedOptions)) { - return; -} +FormComponent fc_userUpdates = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_installerUpdates = formEnvironment.getFormComponentById("SS_ALLOW_INSTALLER_APPDIR_UPDATES_ADVANCEDITEM"); +FormComponent fc_allowUserAppdirPath = formEnvironment.getFormComponentById("SS_ALLOW_USER_APPDIR_PATH"); +FormComponent fc_userAppdirPath = formEnvironment.getFormComponentById("SS_USER_APPDIR_PATH"); +LayoutGroup lg = formEnvironment.getLayoutGroupById("SS_SET_USER_APPDIR_PATH"); + +// get boolean status of "Enable advanced options" checkbox JCheckBox jcb_advancedOptions = (JCheckBox) fc_advancedOptions.getConfigurationObject(); -boolean advancedOptions = fc_advancedOptions.isEnabled() && jcb_advancedOptions.isSelected(); +boolean advancedOptions = 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; -} +// get boolean status of "Allow user-space updates" checkbox JCheckBox jcb_user = (JCheckBox) fc_userUpdates.getConfigurationObject(); -boolean userUpdates = fc_userUpdates.isEnabled() && jcb_user.isSelected(); +boolean userUpdates = 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; -} +// get boolean status of "Allow installation updates" checkbox JCheckBox jcb_installer = (JCheckBox) fc_installerUpdates.getConfigurationObject(); -boolean installerUpdates = fc_installerUpdates.isEnabled() && jcb_installer.isSelected(); +boolean installerUpdates = jcb_installer.isSelected(); -boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); +// get boolean status of "Customise the user-space path" checkbox +JCheckBox jcb_allowUserAppdirPath = (JCheckBox) fc_allowUserAppdirPath.getConfigurationObject(); +boolean allowUserAppdirPath = jcb_allowUserAppdirPath.isSelected(); -formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING").setVisible(showWarning); +// get String value of userAppdirPath text field +JTextField jtf_userAppdirPath = (JTextField) fc_userAppdirPath.getConfigurationObject(); +String userAppdirPath = jtf_userAppdirPath.getText(); + +// set visibility of all "ADVANCEDITEM" components (does not include groups) +for (FormComponent fc: formEnvironment.getFormComponents()) { + String id = formEnvironment.getId(fc); + if (id.contains("ADVANCEDITEM")) { + fc.setVisible(advancedOptions); + } +} +// set visibility of customised user appdir path group (checkbox and text field) +lg.setVisible(advancedOptions); + +// set enabled of userAppdirPath text field +fc_userAppdirPath.setEnabled(advancedOptions && allowUserAppdirPath); + +// set enabled of customised user appdir path group +lg.setEnabled(advancedOptions && userUpdates); + +// set enabled of allow installation updates checkbox +fc_installerUpdates.setEnabled(!userUpdates); + +// should we show the No updates warning? +boolean showWarning = advancedOptions && !(userUpdates || installerUpdates); +FormComponent fc_warning = formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING"); +fc_warning.setVisible(showWarning); + allowInstallerAppdirUpdates @@ -1022,6 +1213,22 @@ formEnvironment.getFormComponentById("SS_NO_UPDATES_WARNING").setVisible(showWar || context.getBooleanVariable("allowInstallerAppdirUpdates") ) + + + + + ${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") +) + @@ -1360,6 +1567,22 @@ return advanced ? !allowUser : false; disableUserDefaultAppdirUpdates + + + + + boolean advanced = context.getBooleanVariable("advancedOptions"); +boolean allowUser = context.getBooleanVariable("allowUserDefaultAppdirUpdates"); +boolean allowSetUserAppdirPath = context.getBooleanVariable("allowSetUserAppdirPath"); +String userAppdirPath = (String)context.getVariable("userAppdirPath"); +boolean saneValue = userAppdirPath != null && userAppdirPath.length() > 0; + +return advanced && allowUser && allowSetUserAppdirPath && saneValue ? userAppdirPath : null; + + + setUserAppdirPath + + @@ -1392,6 +1615,17 @@ return advanced ? !( allowUser || allowInstaller ) : false; !context.getBooleanVariable("disableUserDefaultAppdirUpdates") + + + 2823 + + # The following line sets a custom path for user-space updates -- use with caution. + # If unset, the default is ${installer:userDefaultAppdirBase} for ${installer:osName} + -Dsetuserappdirpath=${installer:setUserAppdirPath} + + + (String)context.getVariable("setUserAppdirPath") != null + 2823 -- 1.7.10.2