X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.editor%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Feditor%2FSaveLoadManager.java;h=96aad40a98b02baae493becb6b73dff74d4cdfb0;hb=ec0a13e824a9058dc41ba0952fdf8ad99fb19772;hp=5b19d3d639362d0df6152b20426f2e038ca1cd28;hpb=c5c0d07286a29994a11ba8b01eaffb21964b6c1b;p=Mograsim.git diff --git a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/SaveLoadManager.java b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/SaveLoadManager.java index 5b19d3d6..96aad40a 100644 --- a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/SaveLoadManager.java +++ b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/SaveLoadManager.java @@ -2,7 +2,10 @@ package net.mograsim.logic.model.editor; import java.io.IOException; -import net.mograsim.logic.model.editor.ui.DialogManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; + import net.mograsim.logic.model.model.ViewModelModifiable; import net.mograsim.logic.model.serializing.DeserializedSubmodelComponent; import net.mograsim.logic.model.serializing.SubmodelComponentSerializer; @@ -27,10 +30,15 @@ public class SaveLoadManager public void openSaveAsDialog() { - String result[] = DialogManager.openMultiTextDialog("Save as...", "Save", "Cancel", "Path"); - if(result != null) + Shell fdShell = new Shell(); + FileDialog fd = new FileDialog(fdShell, SWT.SAVE); + fd.setText("Save as..."); + fd.setFilterExtensions(new String[] { "*.json" }); + String result = fd.open(); + fdShell.dispose(); + if (result != null) { - savePath = result[0]; + savePath = result; innerSave(); } } @@ -39,13 +47,14 @@ public class SaveLoadManager { try { - SubmodelComponentSerializer.serialize(editor.toBeEdited,c -> + SubmodelComponentSerializer.serialize(editor.toBeEdited, c -> { if (Editor.identifierPerComponent.containsKey(c)) return Editor.identifierPerComponent.get(c); return "class:" + c.getClass().getCanonicalName(); }, savePath); - } catch (IOException e) + } + catch (IOException e) { savePath = null; System.err.println("Failed to save component!"); @@ -55,10 +64,15 @@ public class SaveLoadManager public static void openLoadDialog() throws IOException { - String[] result = DialogManager.openMultiTextDialog("Load Component...", "Load", "Cancel", "Path"); - if(result != null) + Shell fdShell = new Shell(); + FileDialog fd = new FileDialog(fdShell, SWT.OPEN); + fd.setText("Load component..."); + fd.setFilterExtensions(new String[] { "*.json" }); + String result = fd.open(); + fdShell.dispose(); + if (result != null) { - new Editor((DeserializedSubmodelComponent) SubmodelComponentSerializer.deserialize(new ViewModelModifiable(), result[0])); + new Editor((DeserializedSubmodelComponent) SubmodelComponentSerializer.deserialize(new ViewModelModifiable(), result)); } } }