GUIComponents now serialize and deserialize parameters (where needed)
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / wires / WireCrossPoint.java
index ea79cc7..1a3f893 100644 (file)
@@ -1,5 +1,8 @@
 package net.mograsim.logic.ui.model.wires;
 
+import com.google.gson.JsonElement;
+import com.google.gson.JsonPrimitive;
+
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.core.LogicObserver;
@@ -105,9 +108,17 @@ public class WireCrossPoint extends GUIComponent implements ConnectionPoint
                return end != null;
        }
 
+       // serializing
+
+       @Override
+       public JsonElement getParams()
+       {
+               return new JsonPrimitive(pin.logicWidth);
+       }
+
        static
        {
-               // TODO read params
-               IndirectGUIComponentCreator.setComponentProvider(WireCrossPoint.class.getCanonicalName(), (m, p) -> new WireCrossPoint(m, 1));
+               IndirectGUIComponentCreator.setComponentProvider(WireCrossPoint.class.getCanonicalName(),
+                               (m, p) -> new WireCrossPoint(m, p.getAsInt()));
        }
 }
\ No newline at end of file