feat: Add progress gui for downloading JavaFX

This commit is contained in:
huanghongxun
2021-03-07 13:15:44 +08:00
parent 63bd707741
commit d22dae9834
12 changed files with 240 additions and 142 deletions

View File

@@ -231,7 +231,7 @@ public class DefaultLauncher extends Launcher {
}
private final Map<String, Supplier<Boolean>> forbiddens = mapOf(
pair("-Xincgc", () -> options.getJava().getParsedVersion() >= JavaVersion.JAVA_9_AND_LATER)
pair("-Xincgc", () -> options.getJava().getParsedVersion() >= JavaVersion.JAVA_9)
);
protected Map<String, Supplier<Boolean>> getForbiddens() {

View File

@@ -66,7 +66,7 @@ public abstract class TaskExecutor {
return cancelled.get();
}
public int getRunningTasks() {
public int getTaskCount() {
return totTask.get();
}

View File

@@ -17,6 +17,9 @@
*/
package org.jackhuang.hmcl.util;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.function.Predicate;
/**
@@ -24,6 +27,19 @@ import java.util.function.Predicate;
* @author huangyuhui
*/
public final class ReflectionHelper {
private static Method accessible0;
static {
try {
accessible0 = AccessibleObject.class.getDeclaredMethod("setAccessible0", boolean.class);
accessible0.setAccessible(true);
} catch (Throwable ex) {
}
}
public static void setAccessible(AccessibleObject obj) throws InvocationTargetException, IllegalAccessException {
accessible0.invoke(obj, true);
}
/**
* Get caller, this method is caller sensitive.

View File

@@ -80,6 +80,7 @@ public final class JavaVersion {
/**
* The major version of Java installation.
*
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_9
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_8
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_7
* @see org.jackhuang.hmcl.util.platform.JavaVersion#UNKNOWN
@@ -92,15 +93,15 @@ public final class JavaVersion {
private static final Pattern VERSION = Pattern.compile("^(?<version>[0-9]+)");
public static final int UNKNOWN = -1;
public static final int JAVA_7 = 70;
public static final int JAVA_8 = 80;
public static final int JAVA_9_AND_LATER = 90;
public static final int JAVA_7 = 7;
public static final int JAVA_8 = 8;
public static final int JAVA_9 = 9;
private static int parseVersion(String version) {
Matcher matcher = VERSION.matcher(version);
if (matcher.find()) {
int head = Lang.parseInt(matcher.group(), -1);
if (head > 1) return JAVA_9_AND_LATER;
if (head > 1) return head;
}
if (version.contains("1.8"))
return JAVA_8;