Changeset 466 in tmcsimulator for trunk/src/tmcsim/cadsimulator/Coordinator.java
- Timestamp:
- 07/27/2019 02:06:02 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/cadsimulator/Coordinator.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/Coordinator.java
r465 r466 3 3 import java.io.File; 4 4 import java.io.FileWriter; 5 import java.io.IOException; 5 6 import java.io.PrintWriter; 7 import java.nio.file.Files; 8 import java.nio.file.Path; 9 import java.nio.file.Paths; 10 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; 6 11 import java.rmi.RemoteException; 7 12 import java.rmi.server.UnicastRemoteObject; … … 77 82 import tmcsim.interfaces.SimulationManagerInterface; 78 83 import tmcsim.simulationmanager.SimulationManagerView; 84 import tmcsim.simulationmanager.actions.LoadScriptAction; 79 85 80 86 /** … … 107 113 private String kCADcommentLog; 108 114 /** 115 * Filename where copy of incident script is written to be used by 116 * EI notebook. The same path as kSimClockFilename is used. 117 */ 118 private final static String kIncidentScriptFilename = "incident_script.xml"; 119 /** 109 120 * Error logger. 110 121 */ … … 540 551 } 541 552 } 542 553 /** Helper method to copy a file. 554 * 555 * @param selectedFile is the name of source file (without a path). 556 * The path will be extracted from kSimClockFilename and prefixed to the 557 * selectedFile. Fixes #178. 558 */ 559 private void copyXMLfile(String selectedFile) 560 { 561 int ptr = kSimClockFilename.lastIndexOf(System.getProperty("file.separator")); 562 String foldername = kSimClockFilename.substring(0, ptr+1); 563 try { 564 Path destination = Paths.get(foldername + kIncidentScriptFilename); 565 Path source = Paths.get(selectedFile); 566 Files.copy(source, destination,REPLACE_EXISTING); 567 Logger.getLogger(Coordinator.class.getName()).log(Level.INFO, 568 "Loaded script copied to " + destination); 569 } catch (IOException ex) { 570 Logger.getLogger(Coordinator.class.getName()).log(Level.SEVERE, null, ex); 571 } 572 } 573 574 /** Load and parse the XML script from the given file */ 543 575 public void loadScriptFile(File scriptFile) throws RemoteException, ScriptException 544 576 { 545 546 577 // Make a copy of the xml file to be used by EI notebook. 578 copyXMLfile(scriptFile.getPath()); 547 579 try 548 580 {
Note: See TracChangeset
for help on using the changeset viewer.
