From 99449c096aed862fb24e97fc8585d928887ab33a Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 6 Aug 2024 19:02:25 +0100 Subject: [PATCH] JAL-3631 Important change to Execution Level in Windows. Some disabled attempts at File Association Reset. --- utils/install4j/install4j10_template.install4j | 152 +++++++++++++++++++++++- 1 file changed, 147 insertions(+), 5 deletions(-) diff --git a/utils/install4j/install4j10_template.install4j b/utils/install4j/install4j10_template.install4j index 0c20fc9..b3bf0a9 100644 --- a/utils/install4j/install4j10_template.install4j +++ b/utils/install4j/install4j10_template.install4j @@ -142,7 +142,7 @@ - + @@ -184,7 +184,119 @@ - public static String getOsAppDataPath(Context context) { + /* + +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 < Array.getLength(o); i++) { + stringRep.append(prefix + "[" + i + "] = " + + Array.get(o, i).toString() + "\n"); + } + } else { + for (int i = 0; i < 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<Object> 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") && + 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 < 10) { + stringRep.append(printDataType(prefix + "." + propertyName, value, iter + 1)); + } else { + stringRep.append("..."); + } + } + } else if (method.getName().startsWith("is") && + method.getParameterCount() == 0 && + 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<String, String> osAppDataPathMap = new HashMap<>(); osAppDataPathMap.put("macos", "Library/Application Support/Jalview-Desktop"); osAppDataPathMap.put("linux", ".local/share/jalview-desktop"); @@ -819,7 +931,7 @@ return console.askOkCancel(message, true); - + !context.getBooleanVariable("sys.confirmedUpdateInstallation") @@ -876,6 +988,36 @@ return console.askOkCancel(message, true); ${i18n:SelectAssociationsLabel} + + + + + 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(); + + + Reset + + @@ -1406,7 +1548,7 @@ return context.getBooleanVariable("allowUserDefaultAppdirUpdates") && co - + @@ -1444,7 +1586,7 @@ return context.getBooleanVariable("allowUserDefaultAppdirUpdates") && co ${compiler:sys.fullName} ${compiler:sys.version} - + -- 1.7.10.2