- Timestamp:
- 02/09/10 18:26:36 (21 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/FileActions.java
r1519 r1520 21 21 * For further information, see <http://www.neutron.anl.gov/NeXus/> 22 22 * 23 * File LoadingActions.java23 * FileActions.java 24 24 * 25 25 */ … … 27 27 28 28 import java.io.File; 29 import java.io.FileInputStream; 30 import java.io.FileOutputStream; 29 31 import java.io.IOException; 32 import java.io.InputStream; 33 import java.io.OutputStream; 30 34 import java.util.ArrayList; 35 import java.util.Enumeration; 31 36 import java.util.ResourceBundle; 32 37 import org.w3c.dom.Document; … … 44 49 * @author Stephen Rankin 45 50 */ 46 public class File LoadingActions implements Runnable {51 public class FileActions implements Runnable { 47 52 48 53 private File nxsFile = null; … … 51 56 private File resultsFile = null; 52 57 private File nxconvertFile = null; 58 private File saveDirectory = null; 53 59 private DocumentBuilderFactory factory = null; 54 60 private DocumentBuilder builder = null; … … 71 77 private boolean isNotBulk = false; 72 78 73 public File LoadingActions(NXvalidateFrame frame, JTree jTree,79 public FileActions(NXvalidateFrame frame, JTree jTree, 74 80 DocumentBuilder builder, NXReducedToTree domTree, 75 81 NXNodeMapper root) { … … 134 140 public void setDataFileList(ArrayList<String> dataFileList) { 135 141 this.dataFileList = dataFileList; 142 } 143 144 public File getSaveDirectory() { 145 return saveDirectory; 146 } 147 148 public void setSaveDirectory(File saveDirectory) { 149 this.saveDirectory = saveDirectory; 136 150 } 137 151 … … 159 173 //Do the validation. 160 174 if (nxconvertFile != null) { 161 validator = new ValidatorUtils(nx convertFile);175 validator = new ValidatorUtils(nxsFile,nxconvertFile); 162 176 } else { 163 177 dialogReportProblem.showMessageDialog( … … 232 246 } catch (InterruptedException ex) { 233 247 Logger.getLogger( 234 NXvalidateFrame.class.getName()).log(Level.SEVERE,248 FileActions.class.getName()).log(Level.SEVERE, 235 249 null, ex); 236 250 } catch (SAXException ex) { 237 251 Logger.getLogger( 238 NXvalidateFrame.class.getName()).log(Level.SEVERE,252 FileActions.class.getName()).log(Level.SEVERE, 239 253 null, ex); 240 254 } catch (IOException ex) { 241 255 Logger.getLogger( 242 NXvalidateFrame.class.getName()).log(Level.SEVERE,256 FileActions.class.getName()).log(Level.SEVERE, 243 257 null, ex); 244 258 } … … 316 330 } 317 331 332 } 333 334 private void copy(File src, File dst) throws IOException { 335 InputStream in = new FileInputStream(src); 336 OutputStream out = new FileOutputStream(dst); 337 338 byte[] buf = new byte[1024]; 339 int len; 340 while ((len = in.read(buf)) > 0) { 341 out.write(buf, 0, len); 342 } 343 in.close(); 344 out.close(); 345 } 346 347 public void saveResults(File directory){ 348 349 NXNodeMapper tmpNode = null; 350 File tmpReduced = null; 351 File tmpResults = null; 352 Enumeration children = root.children(); 353 354 while(children.hasMoreElements()){ 355 356 tmpNode = (NXNodeMapper)children.nextElement(); 357 358 if(tmpNode.getReducedFile()!=null){ 359 360 tmpReduced = new File(directory.getAbsolutePath() + 361 directory.separator + tmpNode.getReducedFile().getName()); 362 tmpResults = new File(directory.getAbsolutePath() + 363 directory.separator + tmpNode.getResultsFile().getName()); 364 try{ 365 copy(tmpNode.getReducedFile(),tmpReduced); 366 copy(tmpNode.getResultsFile(),tmpResults); 367 } catch (IOException ex) { 368 Logger.getLogger( 369 FileActions.class.getName()).log(Level.SEVERE, null, ex); 370 } 371 } 372 } 318 373 } 319 374 … … 336 391 }else if (which == 5) { 337 392 bulkValidate(); 338 } 339 393 } else if (which == 6) { 394 saveResults(saveDirectory); 395 } 340 396 } 341 397 }
Note: See TracChangeset
for help on using the changeset viewer.
