import net.mograsim.logic.model.model.LogicModel;
import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.model.components.submodels.SubmodelInterface;
-import net.mograsim.logic.model.model.wires.ModelWireCrossPoint;
+import net.mograsim.logic.model.snippets.highlevelstatehandlers.DefaultHighLevelStateHandler;
import net.mograsim.preferences.Preferences;
/**
*/
public class LogicUICanvas extends ZoomableCanvas
{
- private static final boolean OPEN_DEBUG_SETHIGHLEVELSTATE_SHELL = false;
-
private final LogicModel model;
public LogicUICanvas(Composite parent, int style, LogicModel model)
addListener(SWT.MouseDown, this::mouseDown);
- if (OPEN_DEBUG_SETHIGHLEVELSTATE_SHELL)
+ if (Preferences.current().getBoolean("net.mograsim.logic.model.debug.openhlsshell"))
openDebugSetHighLevelStateShell(model);
}
private void mouseDown(Event e)
{
- if (e.button == 1)
+ if (e.button == Preferences.current().getInt("net.mograsim.logic.model.button.action"))
{
Point click = canvasToWorldCoords(e.x, e.y);
for (ModelComponent component : model.getComponentsByName().values())
get.addListener(SWT.Selection, getAction);
stateIDText.addListener(SWT.DefaultSelection, getAction);
debugShell.open();
+ addDisposeListener(e -> debugShell.dispose());
}
private void compsChanged(Consumer<? super ModelComponent> compAdded, Consumer<? super ModelComponent> compRemoved, ModelComponent c,
recalculateQueued.set(false);
componentsByItemIndex.clear();
componentSelector.setItems();
- addComponentSelectorItems(componentsByItemIndex, "", componentSelector, model);
+ addComponentSelectorItems(componentsByItemIndex, "", componentSelector, model,
+ Preferences.current().getInt("net.mograsim.logic.model.debug.hlsshelldepth") - 1);
}
private void addComponentSelectorItems(List<ModelComponent> componentsByItemIndex, String base, Combo componentSelector,
- LogicModel model)
+ LogicModel model, int depth)
{
model.getComponentsByName().values().stream().sorted((c1, c2) -> c1.getName().compareTo(c2.getName())).forEach(c ->
{
- if (!(c instanceof ModelWireCrossPoint || c instanceof SubmodelInterface))
+ if (!(c.getHighLevelStateHandler() instanceof DefaultHighLevelStateHandler))
{
String item = base + c.getName();
componentsByItemIndex.add(c);
componentSelector.add(item);
- if (c instanceof SubmodelComponent)
- addComponentSelectorItems(componentsByItemIndex, item + " -> ", componentSelector, ((SubmodelComponent) c).submodel);
+ // this causes negative numbers to result in infinite depth
+ if (depth != 0 && c instanceof SubmodelComponent)
+ addComponentSelectorItems(componentsByItemIndex, item + " -> ", componentSelector, ((SubmodelComponent) c).submodel,
+ depth - 1);
}
});
}