(Box root, String absoluteFilename)
| 329 | String workspaceWas = FieldBox.fieldBox.io.getDefaultDirectory(); // no sure we reset that... |
| 330 | |
| 331 | FieldBox.fieldBox.io.setDefaultDirectory(tmpWorkspace); |
| 332 | |
| 333 | |
| 334 | IO.uniqify(root); |
| 335 | |
| 336 | String path = IO.WORKSPACE + "/" + filename + "/"; |
| 337 | |
| 338 | special.put(root, ">>root<<"); |
| 339 | |
| 340 | List<Runnable> undo = new LinkedList<>(); |
| 341 | |
| 342 | IO.Document doc = FieldBox.fieldBox.io.compileDocument("", root, x -> { |
| 343 | undo.add(IO.uniqify(x)); |
| 344 | return true; |
| 345 | }, special); |
| 346 | |
| 347 | Map<String, String> remap = new LinkedHashMap<String, String>(); |
| 348 | |
| 349 | doc.externalList.forEach(x -> { |
| 350 | String nid = Box.newID(); |
| 351 | remap.put(x.id, nid); |
| 352 | x.id = nid; |
| 353 | }); |
| 354 | |
| 355 | doc.externalList.forEach(x -> { |
| 356 | x.children = x.children.stream().map(y -> remap.getOrDefault(y, y)).filter(y -> y != null).collect(Collectors.toList()); |
| 357 | x.parents = x.parents.stream().map(y -> remap.getOrDefault(y, y)).filter(y -> y != null).collect(Collectors.toList()); |
| 358 | }); |
| 359 | |
| 360 | |
| 361 | boolean error = false; |
| 362 | try { |
| 363 | FieldBox.fieldBox.io.writeOutDocument(IO.WORKSPACE + "/" + filename, doc); |
| 364 | } catch (IOException e) { |
| 365 | e.printStackTrace(); |
| 366 | Drawing.notify("Error saving " + e.getMessage(), root, 200); |
| 367 | error = true; |
| 368 | } |
| 369 | |
| 370 | for (Runnable r : undo) |
| 371 | r.run(); |
| 372 | |
| 373 | |
| 374 | this.filename = filename; |
| 375 | |
| 376 | return true; |
| 377 | } |
| 378 | |
| 379 | private boolean isNothingSelected() { |
| 380 | |
| 381 | return !find(Mouse.isSelected, both()).filter(x -> x.booleanValue()) |
| 382 | .findFirst() |
| 383 | .isPresent(); |
| 384 | } |
| 385 | |
| 386 | } |
no test coverage detected