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=1cf7460f81af679671497161b7962a38bf653909;hb=8f521cfac8a4276204f0a01d30bc3858bff1052c;hp=4baf33527e8f8907c0889fdf35ae78cd894c5b8c;hpb=9e9a77976efe36de6ae82e74a013cd07a17dd352;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 4baf3352..1cf7460f 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 @@ -31,7 +31,7 @@ public abstract class GUIComponent */ protected final ViewModelModifiable model; /** - * The name of this component. Is unique in its model. + * The name of this component. Is unique for all components in its model. */ public final String name; private final Rectangle bounds; @@ -51,6 +51,9 @@ public abstract class GUIComponent private final List redrawListeners; private final Runnable redrawListenerForSubcomponents; + + private HighLevelStateHandler highLevelStateHandler; + // creation and destruction public GUIComponent(ViewModelModifiable model, String name) @@ -149,18 +152,11 @@ public abstract class GUIComponent // high-level access /** - * Sets the given high-level state to the given value.
- * See {@link HighLevelStateHandler} for an explanation of high-level state IDs. - * - * @see #getHighLevelState(String) - * @see HighLevelStateHandler#setHighLevelState(String, Object) - * * @author Daniel Kirschten */ - @SuppressWarnings({ "static-method", "unused" }) // this method is intended to be overridden - public void setHighLevelState(String stateID, Object newState) + protected void setHighLevelStateHandler(HighLevelStateHandler highLevelStateHandler) { - throw new IllegalArgumentException("No high level state with ID " + stateID); + this.highLevelStateHandler = highLevelStateHandler; } /** @@ -172,10 +168,23 @@ public abstract class GUIComponent * * @author Daniel Kirschten */ - @SuppressWarnings("static-method") // this method is intended to be overridden public Object getHighLevelState(String stateID) { - throw new IllegalArgumentException("No high level state with ID " + stateID); + return highLevelStateHandler.getHighLevelState(stateID); + } + + /** + * Sets the given high-level state to the given value.
+ * See {@link HighLevelStateHandler} for an explanation of high-level state IDs. + * + * @see #getHighLevelState(String) + * @see HighLevelStateHandler#setHighLevelState(String, Object) + * + * @author Daniel Kirschten + */ + public void setHighLevelState(String stateID, Object newState) + { + highLevelStateHandler.setHighLevelState(stateID, newState); } // "graphical" operations