Merge branch 'javafx' of https://github.com/huanghongxun/HMCL into javafx

This commit is contained in:
huanghongxun 2018-12-02 20:03:15 +08:00
commit b78f9c8cd5
4 changed files with 23 additions and 14 deletions

View File

@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.ui.download;
import static org.jackhuang.hmcl.util.Logging.LOG;
import com.jfoenix.controls.JFXCheckBox;
import com.jfoenix.controls.JFXListView;
import com.jfoenix.controls.JFXSpinner;
@ -38,6 +40,7 @@ import org.jackhuang.hmcl.ui.wizard.WizardPage;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.stream.Collectors;
public final class VersionsPage extends StackPane implements WizardPage, Refreshable {
@ -139,6 +142,7 @@ public final class VersionsPage extends StackPane implements WizardPage, Refresh
}
});
} else {
LOG.log(Level.WARNING, "Failed to fetch versions list", (Throwable) variables.get("lastException"));
Platform.runLater(() -> {
transitionHandler.setContent(failedPane, ContainerAnimations.FADE.getAnimationProducer());
});

View File

@ -30,7 +30,7 @@ import java.util.Map;
*
* @author huangyuhui
*/
@JsonAdapter(Argument.Serializer.class)
@JsonAdapter(Argument.Deserializer.class)
@Immutable
public interface Argument extends Cloneable {
@ -43,7 +43,7 @@ public interface Argument extends Cloneable {
*/
List<String> toString(Map<String, String> keys, Map<String, Boolean> features);
class Serializer implements JsonDeserializer<Argument>, JsonSerializer<Argument> {
class Deserializer implements JsonDeserializer<Argument> {
@Override
public Argument deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (json.isJsonPrimitive())
@ -51,16 +51,5 @@ public interface Argument extends Cloneable {
else
return context.deserialize(json, RuledArgument.class);
}
@Override
public JsonElement serialize(Argument src, Type typeOfSrc, JsonSerializationContext context) {
if (src instanceof StringArgument)
return new JsonPrimitive(((StringArgument) src).getArgument());
else if (src instanceof RuledArgument)
return context.serialize(src, RuledArgument.class);
else
throw new AssertionError("Unrecognized argument type: " + src);
}
}
}

View File

@ -19,6 +19,13 @@ package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.util.Immutable;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.annotations.JsonAdapter;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -29,6 +36,7 @@ import java.util.regex.Pattern;
*
* @author huangyuhui
*/
@JsonAdapter(StringArgument.Serializer.class)
@Immutable
public final class StringArgument implements Argument {
@ -58,4 +66,11 @@ public final class StringArgument implements Argument {
public String toString() {
return argument;
}
public class Serializer implements JsonSerializer<StringArgument> {
@Override
public JsonElement serialize(StringArgument src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.getArgument());
}
}
}

View File

@ -281,7 +281,8 @@ public final class FileUtils {
}
public static boolean makeDirectory(File directory) {
return directory.isDirectory() || directory.mkdirs();
directory.mkdirs();
return directory.isDirectory();
}
public static boolean makeFile(File file) {