(Box root, String filename)
| 275 | |
| 276 | String path = ""; |
| 277 | String fn = filename; |
| 278 | if (filename.contains("/")) { |
| 279 | |
| 280 | path = filename.substring(0, filename.lastIndexOf("/")); |
| 281 | fn = filename.substring(filename.lastIndexOf("/") + 1); |
| 282 | } |
| 283 | |
| 284 | IO.Document doc = FieldBox.fieldBox.io.compileDocument(path, root, special); |
| 285 | |
| 286 | FieldBox.fieldBox.io.filesTouched.clear(); |
| 287 | |
| 288 | boolean error = false; |
| 289 | try { |
| 290 | String finalPath = path; |
| 291 | String finalFn = fn; |
| 292 | ThreadSync2.callInMainThreadAndWait(() -> { |
| 293 | |
| 294 | Drawing.notify("Saving...", root, 100); |
| 295 | ThreadSync2.yieldIfPossible(); |
| 296 | FieldBox.fieldBox.io.writeOutDocument(IO.WORKSPACE + "/" + finalPath + "/" + finalFn, doc); |
| 297 | ThreadSync2.yieldIfPossible(); |
| 298 | // if (!error) |
| 299 | { |
| 300 | Log.println("io.debug", " going to notify ..."); |
| 301 | Drawing.notify("Saved to " + filename, root, 200); |
| 302 | Log.println("io.debug", " ... notified "); |
| 303 | } |
| 304 | |
| 305 | return null; |
| 306 | }); |
| 307 | } catch (Exception e) { |
| 308 | e.printStackTrace(); |
| 309 | Drawing.notify("Error saving " + e.getMessage(), root, 200); |
| 310 | error = true; |
| 311 | } |
| 312 | |
| 313 | |
| 314 | } |
| 315 | |
| 316 | private void save() { |
| 317 | save(root, filename); |
| 318 | } |
| 319 | |
| 320 | public boolean saveAsNewFile(Box root, String absoluteFilename) throws IOException { |
| 321 | |
| 322 | Map<Box, String> special = new LinkedHashMap<>(); |
| 323 | |
| 324 | |
| 325 | String filename = new File(absoluteFilename).getName(); |
| 326 | filename = filename + (filename.endsWith(".field2") ? "" : ".field2"); |
| 327 | String tmpWorkspace = new File(absoluteFilename).getParentFile().getAbsolutePath(); |
| 328 |
no test coverage detected