JAL-3631 Made an isAdmin flag to work in Windows Admin mode installation
authorBen Soares <b.soares@dundee.ac.uk>
Fri, 28 Jun 2024 17:18:51 +0000 (18:18 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Fri, 28 Jun 2024 17:18:51 +0000 (18:18 +0100)
utils/install4j/install4j10_template.install4j

index 0c78c38..e7133ce 100644 (file)
                 <serializedBean>
                   <property name="failIfNotObtainedMac" type="boolean" value="false" />
                   <property name="failIfNotObtainedWin" type="boolean" value="false" />
-                  <property name="obtainIfAdminMac" type="boolean" value="true" />
+                </serializedBean>
+              </action>
+              <action name="BOTHSPACE: Set isAdmin flag" id="2970" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" actionElevationType="elevated" rollbackBarrierExitCode="0">
+                <serializedBean>
+                  <property name="script">
+                    <object class="com.install4j.api.beans.ScriptProperty">
+                      <property name="value" type="string">Util.hasFullAdminRights() // this doesn't seem to work in some conditionals so creating our own boolean</property>
+                    </object>
+                  </property>
+                  <property name="variableName" type="string">isAdmin</property>
                 </serializedBean>
               </action>
               <action name="BOTHSPACE: Set makeSymbolicLink boolean variable?" id="2853" beanClass="com.install4j.runtime.beans.actions.control.SetVariableAction" rollbackBarrierExitCode="0">
@@ -385,7 +394,7 @@ return wrapperLink;
                   </property>
                   <property name="variableName" type="string">macWrapperLinkLocation</property>
                 </serializedBean>
-                <condition>Util.isMacOS() &amp;&amp; !Util.hasFullAdminRights() // Admin on macOS will add path to /etc/paths.d in Create File action</condition>
+                <condition>Util.isMacOS() &amp;&amp; !context.getBooleanVariable("isAdmin") // Admin on macOS will add path to /etc/paths.d in Create File action</condition>
               </action>
             </actions>
           </screen>
@@ -559,7 +568,7 @@ return console.askOkCancel(message, true);
               <property name="subTitle" type="string">User account</property>
               <property name="title" type="string">${i18n:WizardSelectTasks}</property>
             </serializedBean>
-            <condition>!Util.hasFullAdminRights()</condition>
+            <condition>!context.getBooleanVariable("isAdmin")</condition>
             <formComponents>
               <formComponent id="2894" beanClass="com.install4j.runtime.beans.formcomponents.MultilineLabelComponent" insetBottom="10">
                 <serializedBean>
@@ -603,8 +612,7 @@ return console.askOkCancel(message, true);
           ( Util.isMacOS() &amp;&amp; !Util.hasFullAdminRights() ) // Admin on macOS will add path to /etc/paths.d
           &amp;&amp; context.getVariable("macWrapperLinkLocation") != null
         )
-    )
-</visibilityScript>
+    )</visibilityScript>
               </formComponent>
             </formComponents>
           </screen>
@@ -613,7 +621,7 @@ return console.askOkCancel(message, true);
               <property name="subTitle" type="string">System</property>
               <property name="title" type="string">${i18n:WizardSelectTasks}</property>
             </serializedBean>
-            <condition>Util.hasFullAdminRights()</condition>
+            <condition>context.getBooleanVariable("isAdmin")</condition>
             <formComponents>
               <formComponent id="2904" beanClass="com.install4j.runtime.beans.formcomponents.MultilineLabelComponent" insetBottom="10">
                 <serializedBean>
@@ -759,11 +767,11 @@ return console.askOkCancel(message, true);
                   </action>
                 </beans>
               </group>
-              <group name="USERSPACE: Actions" id="2921" beanClass="com.install4j.runtime.beans.groups.ActionGroup">
+              <group name="USERSPACE: Actions" id="2921" beanClass="com.install4j.runtime.beans.groups.ActionGroup" actionElevationType="none">
                 <serializedBean>
                   <property name="conditionExpression">
                     <object class="com.install4j.api.beans.ScriptProperty">
-                      <property name="value" type="string">!Util.hasFullAdminRights()</property>
+                      <property name="value" type="string">!context.getBooleanVariable("isAdmin")</property>
                     </object>
                   </property>
                 </serializedBean>
@@ -858,11 +866,11 @@ context.getBooleanVariable("addToDockAction")</condition>
                   </action>
                 </beans>
               </group>
-              <group name="SYSTEMSPACE: Actions" id="2954" beanClass="com.install4j.runtime.beans.groups.ActionGroup">
+              <group name="SYSTEMSPACE: Actions" id="2954" beanClass="com.install4j.runtime.beans.groups.ActionGroup" actionElevationType="elevated">
                 <serializedBean>
                   <property name="conditionExpression">
                     <object class="com.install4j.api.beans.ScriptProperty">
-                      <property name="value" type="string">Util.hasFullAdminRights()</property>
+                      <property name="value" type="string">context.getBooleanVariable("isAdmin")</property>
                     </object>
                   </property>
                 </serializedBean>
@@ -936,7 +944,7 @@ context.getBooleanVariable("addToDockAction")</condition>
                   </action>
                 </beans>
               </group>
-              <group name="BOTHSPACE: Actions" id="2956" beanClass="com.install4j.runtime.beans.groups.ActionGroup">
+              <group name="BOTHSPACE: Actions" id="2956" beanClass="com.install4j.runtime.beans.groups.ActionGroup" actionElevationType="elevated">
                 <beans>
                   <action name="BOTHSPACE: Create Linux/Unix user symbolic link to jalview.sh in system bin" id="2955" beanClass="com.install4j.runtime.beans.actions.files.CreateSymlinkAction" rollbackBarrierExitCode="0" errorMessage="Could not make a ${compiler:WRAPPER_LINK} symbolic link in ~/${installer:unixBinDir}">
                     <serializedBean>
@@ -1060,7 +1068,7 @@ context.getBooleanVariable("addToDockAction")</condition>
               </formComponent>
             </formComponents>
           </screen>
-          <screen id="20" beanClass="com.install4j.runtime.beans.screens.FinishedScreen" actionElevationType="elevated" rollbackBarrierExitCode="0" finishScreen="true">
+          <screen id="20" beanClass="com.install4j.runtime.beans.screens.FinishedScreen" rollbackBarrierExitCode="0" finishScreen="true">
             <formComponents>
               <formComponent id="21" beanClass="com.install4j.runtime.beans.formcomponents.MultilineLabelComponent" insetBottom="10">
                 <serializedBean>