X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fserializing%2FIndirectGUIComponentCreator.java;h=05e4f2d671ce367dc932fa3498311fce25aa3a92;hb=d6d5c48722671ccc034011d9eba468b23ee53e80;hp=f346d02908d62a24e228d414653820b81147a578;hpb=95a225aed8eae0fc080440dba779abfdf867ff3d;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java index f346d029..05e4f2d6 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectGUIComponentCreator.java @@ -130,8 +130,16 @@ public class IndirectGUIComponentCreator { loader = Objects.requireNonNull(resourceLoaders.get(parts[1])); } - JsonObject jsonContents = JsonHandler.readJson(loader.loadResource(resID), JsonObject.class); - return loadComponentFromJsonObject(model, id, name, jsonContents); + if (resID.endsWith(".json")) + { + JsonObject jsonContents = JsonHandler.readJson(loader.loadResource(resID), JsonObject.class); + return loadComponentFromJsonObject(model, id, name, jsonContents); + } + loader.loadClass(resID); + ComponentSupplier componentSupplier = componentSuppliers.get(resID); + if (componentSupplier != null) + return componentSupplier.create(model, params, name); + throw new IllegalArgumentException("Component supplier not found for ID " + id + " (class cannot initialize?)"); } catch (IOException e) { @@ -139,7 +147,7 @@ public class IndirectGUIComponentCreator } catch (ClassCastException | ReflectiveOperationException e) { - throw new IllegalArgumentException("invaild resource loader specified:" + parts[1], e); + throw new IllegalArgumentException("class not found / invaild resource loader specified:" + parts[1], e); } } else if (resolvedID.startsWith("file:")) {