Renamed core components to have the common prefix Core
[Mograsim.git] / net.mograsim.logic.model.editor / src / net / mograsim / logic / model / editor / Editor.java
index 2cc13c1..b6de1ac 100644 (file)
@@ -1,6 +1,5 @@
 package net.mograsim.logic.model.editor;
 
-import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -13,6 +12,7 @@ import com.google.gson.JsonParser;
 import com.google.gson.JsonSyntaxException;
 
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.mograsim.logic.model.am2900.Am2900Loader;
 import net.mograsim.logic.model.editor.handles.ComponentHandle;
 import net.mograsim.logic.model.editor.handles.Handle;
 import net.mograsim.logic.model.editor.handles.HandleManager;
@@ -24,8 +24,11 @@ import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.GUIWire;
 import net.mograsim.logic.model.serializing.DeserializedSubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
+import net.mograsim.logic.model.snippets.highlevelstatehandlers.DefaultHighLevelStateHandler;
+import net.mograsim.logic.model.snippets.outlinerenderers.DefaultOutlineRenderer;
+import net.mograsim.logic.model.snippets.symbolrenderers.DefaultSymbolRenderer;
 
 public final class Editor
 {
@@ -157,7 +160,8 @@ public final class Editor
                                moveSelection(x, y);
                                successful = true;
                        }
-                       catch (@SuppressWarnings("unused") UnsupportedOperationException | JsonSyntaxException | NumberFormatException e)
+                       catch (@SuppressWarnings("unused") UnsupportedOperationException | JsonSyntaxException | NumberFormatException
+                                       | NullPointerException e)
                        {
                                String result = DialogManager.openMultiLineTextDialog("Add component", "Create", "Cancel", "Parameters:");
                                if (result == null)
@@ -178,7 +182,7 @@ public final class Editor
        {
                if (identifierPerComponent.containsKey(c))
                        return identifierPerComponent.get(c);
-               return new IdentifierGetter().componentIDs.apply(c);
+               return c.getIDForSerializing(new IdentifyParams());
        }
 
        public void duplicate()
@@ -235,9 +239,20 @@ public final class Editor
                }
        }
 
-       public static void main(String[] args) throws IOException
+       public static void main(String[] args)
        {
-               SaveLoadManager.openLoadDialog();
+               Am2900Loader.setup();
+               openNewEditor();
+//             SaveLoadManager.openLoadDialog();
+       }
+
+       public static void openNewEditor()
+       {
+               DeserializedSubmodelComponent toBeEdited = new DeserializedSubmodelComponent(new ViewModelModifiable(), null, null, null);
+               toBeEdited.setOutlineRenderer(new DefaultOutlineRenderer(toBeEdited));
+               toBeEdited.setSymbolRenderer(new DefaultSymbolRenderer(toBeEdited));
+               toBeEdited.setHighLevelStateHandler(new DefaultHighLevelStateHandler());
+               new Editor(toBeEdited);
        }
 
        public Snapping getSnapping()