Renamed core components to have the common prefix Core
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / model / components / GUIComponent.java
index 60e8fb2..6358260 100644 (file)
@@ -7,14 +7,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.function.Consumer;
 
-import com.google.gson.JsonElement;
-import com.google.gson.JsonNull;
-
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.JSONSerializable;
 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
 
@@ -70,19 +67,19 @@ public abstract class GUIComponent implements JSONSerializable
 
                // TODO this will crash the high level state debug shell because submodel is not yet set.
                // The same problem exists in ViewModelModifiable.getDefaultComponentName; see there
-               model.componentCreated(this);
+               model.componentCreated(this, this::destroyed);
        }
 
        /**
-        * Destroys this component. This method implicitly calls {@link ViewModelModifiable#componentDestroyed(GUIComponent)
-        * componentDestroyed()} for the model this component is a part of.
+        * Destroys this component. This method is called from {@link ViewModelModifiable#componentDestroyed(GUIComponent) destroyComponent()}
+        * of the model this component is a part of.<br>
+        * When overriding, make sure to also call the original implementation.
         * 
         * @author Daniel Kirschten
         */
-       public void destroy()
+       protected void destroyed()
        {
                pinsByName.values().forEach(p -> pinRemovedListeners.forEach(l -> l.accept(p)));
-               model.componentDestroyed(this);
        }
 
        // pins
@@ -289,9 +286,9 @@ public abstract class GUIComponent implements JSONSerializable
        // serializing
 
        @Override
-       public JsonElement getParamsForSerializing(IdentifierGetter idGetter)
+       public Object getParamsForSerializing(IdentifyParams idParams)
        {
-               return JsonNull.INSTANCE;
+               return null;
        }
 
        // listeners