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.IdentifierGetter;
import net.mograsim.logic.model.serializing.SubmodelComponentSerializer;
public class SaveLoadManager
public void openSaveAsDialog()
{
- String result[] = DialogManager.openMultiTextDialog("Save as...", "Save", "Cancel", "Path");
+ 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();
}
}
{
try
{
- SubmodelComponentSerializer.serialize(editor.toBeEdited, c ->
+ IdentifierGetter idGetter = new IdentifierGetter();
+ idGetter.componentIDs = c ->
{
if (Editor.identifierPerComponent.containsKey(c))
return Editor.identifierPerComponent.get(c);
return "class:" + c.getClass().getCanonicalName();
- }, savePath);
+ };
+ SubmodelComponentSerializer.serialize(editor.toBeEdited, idGetter, savePath);
}
catch (IOException e)
{
public static void openLoadDialog() throws IOException
{
- String[] result = DialogManager.openMultiTextDialog("Load Component...", "Load", "Cancel", "Path");
+ 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));
}
}
}