import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
+import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.snippets.SnippetDefinintion;
import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.HighLevelStateHandlerContext;
+import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers;
public class DelegatingSubcomponentHighLevelStateHandler implements SubcomponentHighLevelStateHandler
{
{
if (delegateTarget == null)
this.delegateTarget = parentComponent;
- else if (!parentComponent.submodel.getComponentsByName().containsValue(delegateTarget))
+ else if (parentComponent.submodel.getComponentsByName().get(delegateTarget.name) != delegateTarget)
throw new IllegalArgumentException(
"Can only set components belonging to the submodel of the parent component of this handler as the delegate target");
this.delegateTarget = delegateTarget;
return prefix == null ? subStateID : prefix + '.' + subStateID;
}
+ @Override
+ public DelegatingSubcomponentHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter)
+ {
+ DelegatingSubcomponentHighLevelStateHandlerParams params = new DelegatingSubcomponentHighLevelStateHandlerParams();
+ params.delegateTarget = delegateTarget.name;
+ params.prefix = prefix;
+ return params;
+ }
+
public static class DelegatingSubcomponentHighLevelStateHandlerParams
{
public String delegateTarget;
public String prefix;
}
+
+ static
+ {
+ StandardHighLevelStateHandlerSnippetSuppliers.subcomponentHandlerSupplier
+ .setSnippetSupplier(DelegatingSubcomponentHighLevelStateHandler.class.getCanonicalName(), SnippetDefinintion
+ .create(DelegatingSubcomponentHighLevelStateHandlerParams.class, DelegatingSubcomponentHighLevelStateHandler::new));
+ }
}
\ No newline at end of file