JAL-3631 Important change to Execution Level in Windows. Some disabled attempts at...
authorBen Soares <b.soares@dundee.ac.uk>
Tue, 6 Aug 2024 18:02:25 +0000 (19:02 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Tue, 6 Aug 2024 18:02:25 +0000 (19:02 +0100)
utils/install4j/install4j10_template.install4j

index 0c20fc9..b3bf0a9 100644 (file)
   </files>
   <launchers>
     <launcher name="Jalview User Launcher" id="2823" customizedId="JALVIEW" menuName="${compiler:JALVIEW_APPLICATION_NAME}" icnsFile="${compiler:JALVIEW_DIR}/${compiler:ICONS_DIR}/${compiler:MAC_ICONS_FILE}" customMacBundleIdentifier="true" macBundleIdentifier="${compiler:BUNDLE_ID}" fileset="734" addMacApplicationCategory="true" macApplicationCategory="public.app-category.education" useCustomMacosExecutableName="true" customMacosExecutableName="${compiler:JALVIEW_APPLICATION_NAME}">
-      <executable name="${compiler:EXECUTABLE_NAME}" iconSet="true" iconFile="${compiler:JALVIEW_DIR}/${compiler:ICONS_DIR}/${compiler:WINDOWS_ICONS_FILE}" stderrFile="~/.${compiler:LOG_FILE}" redirectStdout="true" stdoutFile="~/.${compiler:LOG_FILE}" executableMode="gui" changeWorkingDirectory="false" singleInstance="true" executionLevel="highestAvailable" checkConsoleParameter="true">
+      <executable name="${compiler:EXECUTABLE_NAME}" iconSet="true" iconFile="${compiler:JALVIEW_DIR}/${compiler:ICONS_DIR}/${compiler:WINDOWS_ICONS_FILE}" stderrFile="~/.${compiler:LOG_FILE}" redirectStdout="true" stdoutFile="~/.${compiler:LOG_FILE}" executableMode="gui" changeWorkingDirectory="false" singleInstance="true" checkConsoleParameter="true">
         <versionInfo include="true" fileDescription="${compiler:sys.fullName}" legalCopyright="${compiler:COPYRIGHT_MESSAGE}" internalName="${compiler:INTERNAL_ID}" productName="${compiler:sys.fullName}" />
       </executable>
       <splashScreen width="640" height="480" bitmapFile="${compiler:JALVIEW_DIR}/${compiler:BACKGROUND}" textOverlay="true">
     </launcher>
   </launchers>
   <installerGui autoUpdateDescriptorUrl="https://www.jalview.org/install4j/updates.xml">
-    <staticMembers>public static String getOsAppDataPath(Context context) {
+    <staticMembers>/*
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.IntrospectionException;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Array;
+
+  public static String printDataType(Object o) {
+    return printDataType("", o);
+  }
+  
+  public static String printDataType(String prefix, Object o) {
+      return printDataType(prefix, o, 1);
+  }
+  public static String printDataType(String prefix, Object o, int iter) {
+      StringBuilder stringRep = new StringBuilder();
+    
+      try {
+        if (o != null) {
+          Class objectType = o.getClass();
+          if (objectType.isPrimitive() ||
+              objectType.equals(String.class) ||
+              objectType.equals(Date.class)) {
+            stringRep.append(prefix + " (" + objectType.getSimpleName() + 
+              ") = " + o.toString() + "\n");
+          } else if (objectType.isArray()) {
+            if (Array.getLength(o) == 0)  {
+              stringRep.append(prefix + " = empty array\n");
+            }
+            if (objectType.getComponentType().isPrimitive() ||
+              objectType.getComponentType().equals(String.class) ||
+                objectType.getComponentType().equals(Date.class))  {
+              for (int i = 0; i &lt; Array.getLength(o); i++) {
+                stringRep.append(prefix + "[" + i + "] = " + 
+                  Array.get(o, i).toString() + "\n");
+              }
+            } else {
+              for (int i = 0; i &lt; Array.getLength(o); i++) {
+                stringRep.append(printDataType(prefix + "[" + i + "]", 
+                  Array.get(o, i), iter + 1));
+              }
+            }
+          } else if (o instanceof Iterable) {
+            int i = 0;
+            Iterator it = ((Iterable) o).iterator();
+            if (!it.hasNext()) {
+              stringRep.append(prefix + " = empty set\n");
+            }
+            while (it.hasNext()) {
+              stringRep.append(printDataType(prefix + "[" + i++ + "]", 
+                it.next(), iter + 1));
+            }
+          } else if (o instanceof Map)  {
+            Set&lt;Object&gt; keys = ((Map) o).keySet();
+            if (keys.isEmpty()) {
+              stringRep.append(prefix + " = empty map\n");
+            }
+            for (Object key : keys)  {
+              stringRep.append(printDataType(prefix + "[" + key.toString() + "]", 
+                ((Map) o).get(key), iter + 1));
+            }
+          } else if (o instanceof Class) {
+            // Do nothing otherwise the stack blows up
+          } else {
+            Method[] methods = objectType.getMethods();
+    
+            for (Method method : methods)  {
+              if (method.getName().startsWith("get") &amp;&amp;
+                method.getParameterCount() == 0)  {
+                String propertyName = method.getName().substring(3,4).toLowerCase() + 
+                  method.getName().substring(4);
+                Object value = method.invoke(o, new Object[] {} );
+                // value.getClass().isPrimitive returns false, even if 
+                // method.getReturnType().isPrimitive returns true
+                if (method.getReturnType().isPrimitive())  {
+                  stringRep.append(prefix + "." + propertyName + " (" + 
+                    method.getReturnType().getSimpleName() + ") = " + 
+                    value.toString() + "\n");
+                } else {
+                  if (iter &lt; 10) {
+                    stringRep.append(printDataType(prefix + "." + propertyName, value, iter + 1));
+                  } else {
+                    stringRep.append("...");
+                  }
+                }
+              } else if (method.getName().startsWith("is") &amp;&amp;
+                    method.getParameterCount() == 0 &amp;&amp;
+                    method.getReturnType().equals(boolean.class))  {
+                String propertyName = method.getName().substring(2,3).toLowerCase() + 
+                  method.getName().substring(3);
+                stringRep.append(prefix + "." + propertyName + " (boolean) = " +
+                    (method.invoke(o, new Object[] {}).equals(true) ? "true" : "false") + "\n");
+              }
+            }
+          }
+        } else {
+          return prefix + " = null\n";
+        }
+      } catch (Exception e)  {
+        //e.printStackTrace();
+        //return e.toString();
+        stringRep.append("Exception("+e.getMessage()+")");
+      }
+    
+      return stringRep.toString();
+    }
+
+*/
+
+public static String getOsAppDataPath(Context context) {
   Map&lt;String, String&gt; osAppDataPathMap = new HashMap&lt;&gt;();
   osAppDataPathMap.put("macos", "Library/Application Support/Jalview-Desktop");
   osAppDataPathMap.put("linux", ".local/share/jalview-desktop");
@@ -819,7 +931,7 @@ return console.askOkCancel(message, true);
               </formComponent>
             </formComponents>
           </screen>
-          <screen id="8" beanClass="com.install4j.runtime.beans.screens.InstallationDirectoryScreen" rollbackBarrierExitCode="0">
+          <screen id="8" customizedId="LOCATION_SCREEN" beanClass="com.install4j.runtime.beans.screens.InstallationDirectoryScreen" rollbackBarrierExitCode="0">
             <condition>!context.getBooleanVariable("sys.confirmedUpdateInstallation")</condition>
             <actions>
               <action id="11" beanClass="com.install4j.runtime.beans.actions.misc.LoadResponseFileAction" rollbackBarrierExitCode="0" multiExec="true">
@@ -876,6 +988,36 @@ return console.askOkCancel(message, true);
                   <property name="labelText" type="string">${i18n:SelectAssociationsLabel}</property>
                 </serializedBean>
               </formComponent>
+              <formComponent id="3069" beanClass="com.install4j.runtime.beans.formcomponents.ButtonComponent" enabled="false" commentSet="true" comment="This button is desirable but not working.&#xA;The best that can be done is&#xA;&#xA;Screen s = formEnvironment.getScreen();&#xA;context.gotoScreen(s);&#xA;&#xA;but this adds extra &quot;File Association&quot; screens into the &quot;Back&quot; history (but not the &quot;Next&quot; stack).">
+                <serializedBean>
+                  <property name="actionScript">
+                    <object class="com.install4j.api.beans.ScriptProperty">
+                      <property name="value" type="string">Screen s = formEnvironment.getScreen();
+
+FormComponent fc = formEnvironment.getFormComponentById("FILE_ASSOCIATIONS_SELECTOR");
+com.install4j.api.actions.Action a0 = context.getActionById("FA_FILEASSOCIATION-CIF-false");
+Screen s2 = context.getScreenById("EXTENSIONS_REPLACED_BY_GRADLE_PARENT_GROUP");
+
+for (com.install4j.api.actions.Action a : context.getActions(s2)) {
+    String aid = context.getId(a);
+    if (aid.startsWith("FA_FILEASSOCIATION-")) {
+        com.install4j.runtime.beans.actions.desktop.CreateFileAssociationAction aa = (com.install4j.runtime.beans.actions.desktop.CreateFileAssociationAction) a;
+        boolean set = aid.endsWith("-true");
+        boolean got = aa.isSelected();
+        aa.setSelected(set);
+        System.err.println("##### Setting '"+aid+"' from "+got+" to "+set);
+    }
+}
+
+//context.gotoScreen(s);
+//boolean b = formEnvironment.saveFormComponents();
+//System.err.println("##### saveFormComponents was "+b);
+formEnvironment.reinitializeFormComponents();</property>
+                    </object>
+                  </property>
+                  <property name="buttonText" type="string">Reset</property>
+                </serializedBean>
+              </formComponent>
               <formComponent id="1694" customizedId="FILE_ASSOCIATIONS_SELECTOR" beanClass="com.install4j.runtime.beans.formcomponents.FileAssociationsComponent" useExternalParametrization="true" externalParametrizationName="File Associations" externalParametrizationMode="include">
                 <serializedBean>
                   <property name="fillVertical" type="boolean" value="true" />
@@ -1406,7 +1548,7 @@ return context.getBooleanVariable("allowUserDefaultAppdirUpdates") &amp;&amp; co
               </group>
             </formComponents>
           </screen>
-          <screen id="15" beanClass="com.install4j.runtime.beans.screens.InstallationScreen" rollbackBarrier="true" rollbackBarrierExitCode="0">
+          <screen id="15" customizedId="INSTALLATION" beanClass="com.install4j.runtime.beans.screens.InstallationScreen" rollbackBarrier="true" rollbackBarrierExitCode="0">
             <actions>
               <action id="17" beanClass="com.install4j.runtime.beans.actions.InstallFilesAction" rollbackBarrierExitCode="0" failureStrategy="quit" errorMessage="${i18n:FileCorrupted}" />
               <action name="Create program group (RELEASE)" id="18" customizedId="PROGRAM_GROUP_RELEASE" beanClass="com.install4j.runtime.beans.actions.desktop.CreateProgramGroupAction" actionElevationType="elevated" rollbackBarrierExitCode="0">
@@ -1444,7 +1586,7 @@ return context.getBooleanVariable("allowUserDefaultAppdirUpdates") &amp;&amp; co
                   <property name="itemName" type="string">${compiler:sys.fullName} ${compiler:sys.version}</property>
                 </serializedBean>
               </action>
-              <group name="File Associations" id="2251" beanClass="com.install4j.runtime.beans.groups.ActionGroup">
+              <group name="File Associations" id="2251" customizedId="FA_SCREEN" beanClass="com.install4j.runtime.beans.groups.ActionGroup">
                 <beans>
                   <action id="2253" beanClass="com.install4j.runtime.beans.actions.control.SetMessageAction" actionElevationType="none" rollbackBarrierExitCode="0">
                     <serializedBean>