X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fcomponents%2FGUIComponent.java;h=63582600833759c73be6384a34e81786331c3dca;hb=0a04a4ed66ecebd4254541c4977599f6052c115a;hp=60e8fb2a782e2dcd2d0f2c01f69094cc932e83fd;hpb=e8e95e2e345f4d9c5927aa78f5c0fb607d352a97;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/GUIComponent.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/GUIComponent.java index 60e8fb2a..63582600 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/GUIComponent.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/GUIComponent.java @@ -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.
+ * 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