From: Daniel Kirschten Date: Tue, 24 Sep 2019 14:21:37 +0000 (+0200) Subject: Made HLSShell component combo box shorter X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=bcaa748f1b1522b462822c679d4d8a8bdab16d19;p=Mograsim.git Made HLSShell component combo box shorter --- diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java index c4a8c2d4..50e6471a 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java @@ -27,8 +27,7 @@ import net.mograsim.logic.core.types.BitVector; 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; /** @@ -216,21 +215,24 @@ public class LogicUICanvas extends ZoomableCanvas recalculateQueued.set(false); componentsByItemIndex.clear(); componentSelector.setItems(); - addComponentSelectorItems(componentsByItemIndex, "", componentSelector, model); + addComponentSelectorItems(componentsByItemIndex, "", componentSelector, model, + Preferences.current().getInt("net.mograsim.logic.model.debug.hlsshelldepth")); } private void addComponentSelectorItems(List 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); } }); } diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MainPreferencePage.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MainPreferencePage.java index 69430ed9..b647a088 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MainPreferencePage.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MainPreferencePage.java @@ -2,6 +2,8 @@ package net.mograsim.plugin; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; @@ -21,7 +23,10 @@ public class MainPreferencePage extends FieldEditorPreferencePage implements IWo @Override protected void createFieldEditors() { - addField(new BooleanFieldEditor("net.mograsim.logic.model.debug.openhlsshell", "Open the debug HLS shell", getFieldEditorParent())); + Composite parent = getFieldEditorParent(); + addField(new BooleanFieldEditor("net.mograsim.logic.model.debug.openhlsshell", "Open the debug HLS shell", parent)); + addField(new IntegerFieldEditor("net.mograsim.logic.model.debug.hlsshelldepth", + "Depth of components to list in the debug HLS shell", parent)); // TODO add other preferences } } \ No newline at end of file diff --git a/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java b/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java index b261003d..f3d0b69b 100644 --- a/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java +++ b/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java @@ -23,6 +23,8 @@ public class DefaultPreferences extends Preferences { switch (name) { + case "net.mograsim.logic.model.debug.hlsshelldepth": + return -1; default: throw new IllegalArgumentException("Unknown int preference name: " + name); }