|
@@ -217,6 +217,8 @@ public class LoadController {
|
|
|
loadUnitGraph(GRAPHTYPE.SWITCH, json.get(key), objDispatch, null);
|
|
|
if (key.contains("ELEUNITGRAPH"))
|
|
|
loadUnitGraph(GRAPHTYPE.ELEMENT, json.get(key), null, eleDispatch);
|
|
|
+ if (key.contains("TRACKED"))
|
|
|
+ loadTracked(json.get(key), objDispatch);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -234,6 +236,7 @@ public class LoadController {
|
|
|
model.setCvsObjIdx(new HashMap<Integer, Integer>());
|
|
|
model.setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
|
|
|
model.setEdgesOnCanvas(new ArrayList<CpsEdge>());
|
|
|
+ model.setTrackingObj(new ArrayList<>());
|
|
|
break;
|
|
|
case PARTIAL:
|
|
|
model.setCvsObjIdx(new HashMap<Integer, Integer>());
|
|
@@ -440,6 +443,22 @@ public class LoadController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void loadTracked(JsonElement jsonElement, HashMap<Integer, AbstractCpsObject> objDispatch) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ JsonObject object = jsonElement.getAsJsonObject();
|
|
|
+ List<String> keys = getKeys(object);
|
|
|
+
|
|
|
+ for (String k : keys) {
|
|
|
+ int id = object.get(k).getAsInt();
|
|
|
+ model.getTrackingObj().add(objDispatch.get(id));
|
|
|
+ model.addObjectsToGraphListeners();
|
|
|
+ if (objDispatch.get(id) instanceof HolonObject) {
|
|
|
+ ((HolonObject) objDispatch.get(id)).updateTrackingInfo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Initialize the Gson with wanted parameters
|
|
|
*/
|
|
@@ -464,7 +483,8 @@ public class LoadController {
|
|
|
|
|
|
ArchiveEntry entry = stream.getNextEntry();
|
|
|
while (entry != null) {
|
|
|
- File file = new File(tmp, entry.getName());
|
|
|
+ String entryName = checkOS(entry.getName());
|
|
|
+ File file = new File(tmp, entryName);
|
|
|
file.getParentFile().mkdirs();
|
|
|
OutputStream output = new FileOutputStream(file);
|
|
|
IOUtils.copy(stream, output);
|
|
@@ -479,6 +499,25 @@ public class LoadController {
|
|
|
return tmp;
|
|
|
}
|
|
|
|
|
|
+ private String checkOS(String entryName) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ String os = System.getProperty("os.name").toLowerCase();
|
|
|
+ String ret = entryName;
|
|
|
+ String partition = null;
|
|
|
+
|
|
|
+ if (os.contains("windows")) {
|
|
|
+ partition = System.getProperty("user.home").substring(0, entryName.indexOf(":"));
|
|
|
+ ret = partition + ret;
|
|
|
+ }
|
|
|
+ if (os.contains("mac")) {
|
|
|
+
|
|
|
+ }
|
|
|
+ if (os.contains("linux")) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Init new Arrays which havent been serialized along the object
|
|
|
*
|