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;
// 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
// serializing
@Override
- public JsonElement getParamsForSerializing(IdentifierGetter idGetter)
+ public Object getParamsForSerializing(IdentifierGetter idGetter)
{
- return JsonNull.INSTANCE;
+ return null;
}
// listeners