Made HLSShell component combo box shorter
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 24 Sep 2019 14:21:37 +0000 (16:21 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 24 Sep 2019 14:21:37 +0000 (16:21 +0200)
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/MainPreferencePage.java
plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java

index c4a8c2d..50e6471 100644 (file)
@@ -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<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);
                        }
                });
        }
index 69430ed..b647a08 100644 (file)
@@ -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
index b261003..f3d0b69 100644 (file)
@@ -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);
                }