|
@@ -38,7 +38,13 @@ public class LoadController {
|
|
private NodeController uppC;
|
|
private NodeController uppC;
|
|
private MultiPurposeController mpC;
|
|
private MultiPurposeController mpC;
|
|
private JsonParser parser;
|
|
private JsonParser parser;
|
|
-
|
|
|
|
|
|
+ private static HashMap<String,String> OldTypeNameReplacement = new HashMap<String, String>();
|
|
|
|
+
|
|
|
|
+ static {
|
|
|
|
+ OldTypeNameReplacement.put("CpsNode", "Node");
|
|
|
|
+ OldTypeNameReplacement.put("CpsUpperNode", "GroupNode");
|
|
|
|
+
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* Constructor.
|
|
* Constructor.
|
|
*
|
|
*
|
|
@@ -50,6 +56,7 @@ public class LoadController {
|
|
*/
|
|
*/
|
|
LoadController(Model model, CategoryController cg, CanvasController cvs, ObjectController obj,
|
|
LoadController(Model model, CategoryController cg, CanvasController cvs, ObjectController obj,
|
|
NodeController uppC, MultiPurposeController mp) {
|
|
NodeController uppC, MultiPurposeController mp) {
|
|
|
|
+
|
|
this.model = model;
|
|
this.model = model;
|
|
this.cgC = cg;
|
|
this.cgC = cg;
|
|
this.cvsC = cvs;
|
|
this.cvsC = cvs;
|
|
@@ -159,11 +166,11 @@ public class LoadController {
|
|
if (key.contains("CATEGORY"))
|
|
if (key.contains("CATEGORY"))
|
|
loadCategory(json.get(key));
|
|
loadCategory(json.get(key));
|
|
if (key.contains("CGOBJECT"))
|
|
if (key.contains("CGOBJECT"))
|
|
- loadCategoryObject(json.get(key));
|
|
|
|
|
|
+ loadCategoryObject(json.get(key).getAsJsonObject());
|
|
if (key.contains("CGELEMENT"))
|
|
if (key.contains("CGELEMENT"))
|
|
loadCategoryElements(json.get(key), eleDispatch);//TODO
|
|
loadCategoryElements(json.get(key), eleDispatch);//TODO
|
|
if (key.contains("CVSOBJECT"))
|
|
if (key.contains("CVSOBJECT"))
|
|
- loadCanvasObject(json.get(key), objDispatch);
|
|
|
|
|
|
+ loadCanvasObject(json.get(key).getAsJsonObject(), objDispatch);
|
|
if (key.contains("CVSELEMENT"))
|
|
if (key.contains("CVSELEMENT"))
|
|
loadCanvasElements(json.get(key), objDispatch, eleDispatch);
|
|
loadCanvasElements(json.get(key), objDispatch, eleDispatch);
|
|
if (key.contains("SWUNITGRAPH"))
|
|
if (key.contains("SWUNITGRAPH"))
|
|
@@ -225,8 +232,16 @@ public class LoadController {
|
|
/**
|
|
/**
|
|
* Load a given Object in Category by Deserialization
|
|
* Load a given Object in Category by Deserialization
|
|
*/
|
|
*/
|
|
- private void loadCategoryObject(JsonElement jsonElement) {
|
|
|
|
- AbstractCanvasObject temp = model.getGson().fromJson(jsonElement.getAsJsonObject(), AbstractCanvasObject.class);
|
|
|
|
|
|
+ private void loadCategoryObject(JsonObject jsonObject) {
|
|
|
|
+ AbstractCanvasObject temp;
|
|
|
|
+ replaceOldClassNames(jsonObject);
|
|
|
|
+ try {
|
|
|
|
+ temp = model.getGson().fromJson(jsonObject, AbstractCanvasObject.class);
|
|
|
|
+ }catch (com.google.gson.JsonParseException e){
|
|
|
|
+ System.err.println(jsonObject.get("type").getAsString());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
temp.setImage(checkOS(temp.getImage()));
|
|
temp.setImage(checkOS(temp.getImage()));
|
|
initObjects(temp);
|
|
initObjects(temp);
|
|
if (mpC.searchCatObj(mpC.searchCat(temp.getSav()), temp.getObjName()) != null)
|
|
if (mpC.searchCatObj(mpC.searchCat(temp.getSav()), temp.getObjName()) != null)
|
|
@@ -250,24 +265,20 @@ public class LoadController {
|
|
/**
|
|
/**
|
|
* Load a given Object in Canvas by Deserialization
|
|
* Load a given Object in Canvas by Deserialization
|
|
*/
|
|
*/
|
|
- private void loadCanvasObject(JsonElement jsonElement, HashMap<Integer, AbstractCanvasObject> objDispatch) {
|
|
|
|
|
|
+ private void loadCanvasObject(JsonObject jsonObject, HashMap<Integer, AbstractCanvasObject> objDispatch) {
|
|
AbstractCanvasObject temp = null;
|
|
AbstractCanvasObject temp = null;
|
|
- if(jsonElement.getAsJsonObject().get("type").getAsString().equals("CpsUpperNode")) {
|
|
|
|
- //Change Old Name
|
|
|
|
- jsonElement.getAsJsonObject().addProperty("type", "GroupNode");
|
|
|
|
|
|
+ replaceOldClassNames(jsonObject);
|
|
|
|
+ try {
|
|
|
|
+ temp = model.getGson().fromJson(jsonObject, AbstractCanvasObject.class);
|
|
|
|
+ }catch (com.google.gson.JsonParseException e){
|
|
|
|
+ System.err.println(jsonObject.get("type").getAsString());
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- try{
|
|
|
|
- temp = model.getGson().fromJson(jsonElement.getAsJsonObject(), AbstractCanvasObject.class);
|
|
|
|
- }catch(java.lang.ClassCastException e) {
|
|
|
|
- System.err.println("ClassRenameError");
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
initObjects(temp);
|
|
initObjects(temp);
|
|
temp.setImage(checkOS(temp.getImage()));
|
|
temp.setImage(checkOS(temp.getImage()));
|
|
if (temp instanceof GroupNode) {
|
|
if (temp instanceof GroupNode) {
|
|
- model.getHashcodeMap().put(jsonElement.getAsJsonObject().get("hash").getAsInt(), (GroupNode) temp);
|
|
|
|
- ((GroupNode) temp).setLeftBorder(jsonElement.getAsJsonObject().get("properties").getAsJsonObject().get("leftBorder").getAsInt());
|
|
|
|
|
|
+ model.getHashcodeMap().put(jsonObject.get("hash").getAsInt(), (GroupNode) temp);
|
|
|
|
+ ((GroupNode) temp).setLeftBorder(jsonObject.get("properties").getAsJsonObject().get("leftBorder").getAsInt());
|
|
}
|
|
}
|
|
// if its stored before on the canvas just put it there
|
|
// if its stored before on the canvas just put it there
|
|
if (temp.getSav().equals("CVS")) {
|
|
if (temp.getSav().equals("CVS")) {
|
|
@@ -291,6 +302,15 @@ public class LoadController {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void replaceOldClassNames(JsonObject abstractCanvasClassJsonObject) {
|
|
|
|
+ String type = abstractCanvasClassJsonObject.get("type").getAsString();
|
|
|
|
+ if(OldTypeNameReplacement.containsKey(type)) {
|
|
|
|
+ abstractCanvasClassJsonObject.addProperty("type", OldTypeNameReplacement.get(type));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Load a given Element in Canvas by Deserialization
|
|
* Load a given Element in Canvas by Deserialization
|
|
*/
|
|
*/
|