Implemented GUIdff16_invwe
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / examples / ReserializeJSONsSettingUsages.java
index d5faf7e..9ccfd8a 100644 (file)
@@ -11,6 +11,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import net.mograsim.logic.model.am2900.Am2900Loader;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.wires.GUIWire;
 import net.mograsim.logic.model.model.wires.MovablePin;
@@ -24,6 +25,7 @@ public class ReserializeJSONsSettingUsages
 {
        public static void main(String[] args) throws IOException
        {
+               Am2900Loader.setup();
                try (Scanner sysin = new Scanner(System.in))
                {
                        System.out.print("Directory to search for JSONs in / JSON file to reserialize >");
@@ -50,7 +52,7 @@ public class ReserializeJSONsSettingUsages
                try
                {
                        DeserializedSubmodelComponent comp = (DeserializedSubmodelComponent) IndirectGUIComponentCreator
-                                       .createComponent(new ViewModelModifiable(), "file:" + json.toString());
+                                       .createComponent(new ViewModelModifiable(), "jsonfile:" + json.toString());
                        System.out.println("Reserializing " + json);
                        comp.getSupermodelPins().entrySet().stream().sorted(Comparator.comparing(Entry::getKey)).map(Entry::getValue).forEach(pin ->
                        {
@@ -75,7 +77,7 @@ public class ReserializeJSONsSettingUsages
        {
                Set<GUIWire> wiresConnectedToPin = comp.submodel.getWiresByName().values().stream()
                                .filter(w -> w.getPin1() == interfacePin || w.getPin2() == interfacePin).collect(Collectors.toSet());
-               wiresConnectedToPin.forEach(GUIWire::destroy);
+               wiresConnectedToPin.forEach(comp.getSubmodelModifiable()::destroyWire);
                comp.removeSubmodelInterface(interfacePin.name);
                comp.addSubmodelInterface(
                                new MovablePin(comp, interfacePin.name, interfacePin.logicWidth, usage, interfacePin.getRelX(), interfacePin.getRelY()));