- Timestamp:
- 02/09/10 18:26:36 (17 months ago)
- Location:
- trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate
- Files:
-
- 13 edited
- 1 moved
-
BulkLoadFilesFrame.java (modified) (4 diffs)
-
CheckNexusFileType.java (modified) (6 diffs)
-
FileActions.java (moved) (moved from trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/FileLoadingActions.java) (10 diffs)
-
NXLoadFilesDialog.form (modified) (1 diff)
-
NXLoadFilesDialog.java (modified) (6 diffs)
-
NXNodeMapper.java (modified) (12 diffs)
-
NXschematron.java (modified) (6 diffs)
-
NXvalidate.java (modified) (1 diff)
-
NXvalidateFrame.form (modified) (2 diffs)
-
NXvalidateFrame.java (modified) (11 diffs)
-
TextPaneStyle.java (modified) (2 diffs)
-
ValidatorUtils.java (modified) (3 diffs)
-
exceptions/NXvalidateException.java (modified) (1 diff)
-
resources/nxvalidate.properties (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/BulkLoadFilesFrame.java
r1507 r1520 45 45 private File nxdlFile = null; 46 46 private ArrayList<String> dataFileList = null; 47 private File LoadingActions fileLoadingActions = null;47 private FileActions fileLoadingActions = null; 48 48 private boolean badFiles = false; 49 49 private ResourceBundle bundle = null; 50 50 private ArrayList<String> dataFileSelectedList = null; 51 private CheckNexusFileType check = null; 51 52 52 53 /** Creates new form BulkLoadFilesFrame */ 53 public BulkLoadFilesFrame(File LoadingActions fileLoadingActions) {54 public BulkLoadFilesFrame(FileActions fileLoadingActions) { 54 55 initComponents(); 55 56 this.fileLoadingActions = fileLoadingActions; 56 57 bundle = ResourceBundle.getBundle( 57 58 "org/nexusformat/nxvalidate/resources/nxvalidate"); 59 check = new CheckNexusFileType(); 58 60 59 61 } … … 63 65 bundle = ResourceBundle.getBundle( 64 66 "org/nexusformat/nxvalidate/resources/nxvalidate"); 67 check = new CheckNexusFileType(); 65 68 } 66 69 … … 213 216 if (returnVal == jFileChooser1.APPROVE_OPTION) { 214 217 nxdlFile = jFileChooser1.getSelectedFile(); 215 nxdcFileNameTextField.setText(nxdlFile.getAbsolutePath()); 216 nxdcFileNameTextField.setToolTipText(nxdlFile.getAbsolutePath()); 218 219 if(check.checkNXDLFile(nxdlFile)){ 220 221 nxdcFileNameTextField.setText(nxdlFile.getAbsolutePath()); 222 nxdcFileNameTextField.setToolTipText(nxdlFile.getAbsolutePath()); 223 224 } else{ 225 nxdlFile = null; 226 problemOptionPane.showMessageDialog(this, 227 bundle.getString("notNXDLFileMessage")); 228 } 229 230 217 231 } else { 218 232 nxdlFile = null; … … 253 267 254 268 private void updateTable() throws FileNotFoundException, IOException { 255 256 257 CheckNexusFileType check = new CheckNexusFileType();258 269 259 270 DefaultTableModel tableModel = new DefaultTableModel(new Object[][]{ -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/CheckNexusFileType.java
r1507 r1520 56 56 builder = factory.newDocumentBuilder(); 57 57 } catch (ParserConfigurationException ex) { 58 Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.SEVERE, null, ex); 58 Logger.getLogger(CheckNexusFileType.class.getName()).log( 59 Level.SEVERE, null, ex); 59 60 } 60 61 } … … 68 69 * @throws IOException 69 70 */ 70 public boolean checkNexusFile(File file) throws FileNotFoundException, IOException { 71 72 if (checkHDF5(file)) { 73 return true; 74 } else if (checkHDF4(file)) { 75 return true; 76 } else if (checkNexusXML(file)) { 77 return true; 78 } 79 71 public boolean checkNexusFile(File file) { 72 try { 73 if (checkHDF5(file)) { 74 return true; 75 } else if (checkHDF4(file)) { 76 return true; 77 } else if (checkNexusXML(file)) { 78 return true; 79 } 80 } catch (FileNotFoundException ex) { 81 Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.SEVERE, null, ex); 82 } catch (IOException ex) { 83 Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.SEVERE, null, ex); 84 } 80 85 return false; 81 82 86 } 83 87 … … 89 93 * @throws IOException 90 94 */ 91 public boolean checkHDF5(File file) throws FileNotFoundException, IOException { 95 public boolean checkHDF5(File file) throws FileNotFoundException, 96 IOException { 92 97 93 98 byte[] b = new byte[7]; … … 121 126 * @throws IOException 122 127 */ 123 public boolean checkHDF4(File file) throws FileNotFoundException, IOException { 128 public boolean checkHDF4(File file) throws FileNotFoundException, 129 IOException { 124 130 125 131 byte[] b = new byte[4]; … … 148 154 * @throws IOException 149 155 */ 150 private boolean checkNexusXML(File file) throws FileNotFoundException, IOException{156 private boolean checkNexusXML(File file) { 151 157 152 158 boolean result = false; … … 186 192 187 193 } 194 195 /** 196 * Checks to see if a file is a Nexus definition file and returns true if 197 * it is. 198 * @param file the input file to check. 199 * @return boolean which is true if the file is a Nexus definition file. 200 * @throws FileNotFoundException 201 * @throws IOException 202 */ 203 public boolean checkNXDLFile(File file) { 204 205 boolean result = false; 206 207 try { 208 Document resultsDoc = builder.parse(file); 209 if (resultsDoc.getDocumentElement().getNodeName().equals("definition")) { 210 result = true; 211 } 212 } catch (SAXException ex) { 213 //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 214 // "SAXException: " + file.getAbsolutePath(), ex); 215 return result; 216 } catch (MalformedByteSequenceException ex) { 217 // Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 218 // "MalformedByteSequenceException: " + file.getAbsolutePath(), ex); 219 return result; 220 } catch (ConnectException ex) { 221 //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 222 // "ConnectException: " + file.getAbsolutePath(), ex); 223 return result; 224 } catch (MalformedURLException ex) { 225 //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 226 // "MalformedURLException: " + file.getAbsolutePath(), ex); 227 return result; 228 } catch (FileNotFoundException ex) { 229 //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 230 // "FileNotFoundException: " + file.getAbsolutePath(), ex); 231 return result; 232 } catch (IOException ex) { 233 //Logger.getLogger(CheckNexusFileType.class.getName()).log(Level.INFO, 234 // "IOException: " + file.getAbsolutePath(), ex); 235 return result; 236 } 237 238 return result; 239 240 } 241 188 242 } -
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 } -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXLoadFilesDialog.form
r1504 r1520 4 4 <NonVisualComponents> 5 5 <Component class="javax.swing.JFileChooser" name="jFileChooser1"> 6 </Component> 7 <Component class="javax.swing.JOptionPane" name="messageOptionPane"> 6 8 </Component> 7 9 </NonVisualComponents> -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXLoadFilesDialog.java
r1507 r1520 28 28 29 29 import java.io.File; 30 import java.util.ResourceBundle; 30 31 31 32 /** … … 38 39 private File nxdl = null; 39 40 private boolean OKButtonUsed = false; 40 41 private CheckNexusFileType check = null; 42 private ResourceBundle bundle = null; 41 43 /** Creates new form NXLoadFilesDialog */ 42 44 public NXLoadFilesDialog(java.awt.Frame parent, boolean modal) { 43 45 super(parent, modal); 44 46 initComponents(); 47 check = new CheckNexusFileType(); 48 bundle = ResourceBundle.getBundle( 49 "org/nexusformat/nxvalidate/resources/nxvalidate"); 45 50 } 46 51 … … 55 60 56 61 jFileChooser1 = new javax.swing.JFileChooser(); 62 messageOptionPane = new javax.swing.JOptionPane(); 57 63 jPanel1 = new javax.swing.JPanel(); 58 64 nxsLabel = new javax.swing.JLabel(); … … 172 178 if (returnVal == jFileChooser1.APPROVE_OPTION) { 173 179 nxs = jFileChooser1.getSelectedFile(); 174 nxsTextField.setText(nxs.getAbsolutePath()); 175 nxsTextField.setToolTipText(nxs.getAbsolutePath()); 180 181 if(check.checkNexusFile(nxs)){ 182 nxsTextField.setText(nxs.getAbsolutePath()); 183 nxsTextField.setToolTipText(nxs.getAbsolutePath()); 184 } else{ 185 nxs = null; 186 messageOptionPane.showMessageDialog(this, 187 bundle.getString("notNXDLFileMessage")); 188 } 189 190 176 191 } else { 177 192 nxs = null; … … 189 204 if (returnVal == jFileChooser1.APPROVE_OPTION) { 190 205 nxdl = jFileChooser1.getSelectedFile(); 191 nxdcTextField.setText(nxdl.getAbsolutePath()); 192 nxdcTextField.setToolTipText(nxdl.getAbsolutePath()); 206 207 if(check.checkNXDLFile(nxdl)){ 208 nxdcTextField.setText(nxdl.getAbsolutePath()); 209 nxdcTextField.setToolTipText(nxdl.getAbsolutePath()); 210 } else{ 211 nxdl = null; 212 messageOptionPane.showMessageDialog(this, 213 bundle.getString("notNXDLFileMessage")); 214 } 215 216 193 217 } else { 194 218 nxdl = null; … … 247 271 private javax.swing.JFileChooser jFileChooser1; 248 272 private javax.swing.JPanel jPanel1; 273 private javax.swing.JOptionPane messageOptionPane; 249 274 private javax.swing.JTextField nxdcTextField; 250 275 private javax.swing.JLabel nxdlLabel; -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXNodeMapper.java
r1519 r1520 122 122 /** 123 123 * Set the flag that says that this node is a documents node i.e. one of the 124 * list of nodes directly under the root no te that are the open NXS documents.124 * list of nodes directly under the root node that are the open NXS documents. 125 125 * @param isDocument a flag which is true if the node is a document node. 126 126 */ … … 218 218 } 219 219 220 /** 221 * Initially the Nexus file is converted to a reduced (all data removed) 222 * XML document via the Nexus convert command. This method gets the 223 * W3C DOM document of the reduced XML file. 224 * @return the W3C DOM document of the reduced XML file. 225 */ 220 226 public Document getReducedDoc() { 221 227 return reducedDoc; 222 228 } 223 229 230 /** 231 * Initially the Nexus file is converted to a reduced (all data removed) 232 * XML document via the Nexus convert command. This method sets the 233 * W3C DOM document of the reduced XML file. 234 * @param reducedDoc the W3C DOM document of the reduced XML file. 235 */ 224 236 public void setReducedDoc(Document reducedDoc) { 225 237 this.reducedDoc = reducedDoc; 226 238 } 227 239 240 /** 241 * If a node in the reduced XML document fails one of the schematron tests 242 * then the node can be marked as a bad node with a boolean flag. The flag 243 * is set to true if the node failed one of the tests. 244 * @param badNode true if the node failed one of the schematron tests. 245 */ 228 246 public void setBadNode(boolean badNode) { 229 247 this.badNode = badNode; 230 248 } 231 249 250 /** 251 * If a node in the reduced XML document fails one of the schematron tests 252 * then the node can be marked as a bad node with a boolean flag. The flag 253 * is set to true if the node failed one of the tests. 254 * @return true if the node failed one of the schematron tests. 255 */ 232 256 public boolean getBadNode() { 233 257 return badNode; 234 258 } 235 259 260 /** 261 * Get the W3C DOM node corresponding to this tree node. 262 * @return the W3C DOM node corresponding to this tree node. 263 */ 236 264 public Node getDomNode() { 237 265 return domNode; 238 266 } 239 267 268 /** 269 * A convenience method to force the checking if a node is bad 270 * (failed schematron tests). Sets the flag to indicate the node is bad. 271 */ 240 272 public void checkBadNode() { 241 273 if (!isRoot) { … … 247 279 } 248 280 281 /** 282 * Resets the various properties of a node, i.e flag to indicate that it 283 * is a bad node, the text for the tests that failed etc. 284 */ 249 285 public void resetNode() { 250 286 251 287 badNode = false; 252 253 288 domNode.setUserData("texts", null, null); 254 289 domNode.setUserData("tests", null, null); … … 258 293 } 259 294 295 /** 296 * This is a list of text strings which correspond to the error message 297 * results of the schematron tests. 298 * @return list of text strings corresponding to the schematron test results. 299 */ 260 300 public ArrayList<String> getNodeTexts() { 261 301 if (!isRoot) { … … 266 306 } 267 307 308 /** 309 * This is a list of text strings which correspond to the schematron 310 * test descriptions. 311 * @return list of text strings corresponding to the schematron test 312 * descriptions. 313 */ 268 314 public ArrayList<String> getNodeTests() { 269 315 if (!isRoot) { … … 274 320 } 275 321 322 /** 323 * This is a list of text strings which correspond to the schematron 324 * diagnostic errors. 325 * @return list of text strings corresponding to the schematron 326 * diagnostic errors. 327 */ 276 328 public ArrayList<String> getNodeDiags() { 277 329 if (!isRoot) { … … 378 430 return root; 379 431 380 } else if (domNode.getParentNode()!=null ){381 382 if (domNode.getParentNode().getNodeType() == domNode.DOCUMENT_NODE){383 384 Document doc = (Document) domNode.getParentNode();432 } else if (domNode.getParentNode() != null) { 433 434 if (domNode.getParentNode().getNodeType() == domNode.DOCUMENT_NODE) { 435 436 Document doc = (Document) domNode.getParentNode(); 385 437 386 438 return new NXNodeMapper(domNode.getParentNode(), true, 387 ((File)doc.getUserData("file")).getAbsolutePath());388 389 } else {439 ((File) doc.getUserData("file")).getAbsolutePath()); 440 441 } else { 390 442 391 443 return new NXNodeMapper(domNode.getParentNode(), false, 392 domNode.getParentNode().getNodeName()); 393 } 394 }else{ 395 return null; 396 } 397 398 } 399 444 domNode.getParentNode().getNodeName()); 445 } 446 } else { 447 return null; 448 } 449 450 } 451 452 /** 453 * Each node of the reduced XML document may have attributes associated 454 * with it, this method provides a list of the attributes. Each string 455 * contains the attribute name and the value. 456 * @return a list of the attributes and their values. 457 */ 400 458 public String[] getAttributeList() { 401 459 … … 412 470 413 471 for (int i = 0; i < na; ++i) { 414 atts.add(att.item(i).getNodeName() + " = " + att.item(i).getNodeValue()); 472 atts.add(att.item(i).getNodeName() + " = " + 473 att.item(i).getNodeValue()); 415 474 } 416 475 … … 419 478 } 420 479 480 /** 481 * Each node of the reduced XML document may have a value associated with it. 482 * This method returns that value as a string. 483 * @return the value of the XML node. 484 */ 421 485 public String getValue() { 422 486 … … 445 509 446 510 if (node.getNodeType() == ELEMENT_TYPE) { 447 448 511 nodes.add(node); 449 512 ++childCount; … … 469 532 } 470 533 534 /** 535 * Returns a list of nodes that represent the Nexus documents that are open 536 * i.e. that have been reduced. 537 * @return a list of Nexus document nodes. 538 */ 471 539 public ArrayList<NXNodeMapper> getOpenNodes() { 472 540 return documents; 473 541 } 474 542 543 /** 544 * Removes the list of nodes that represent the Nexus documents that are 545 * open i.e. that have been reduced. 546 */ 475 547 public void removeAllNodes() { 476 548 documents.clear(); 477 549 } 478 550 551 /** 552 * A class that represents the child nodes of a node from a 553 * reduced document. The child nodes are represented as an enumeration. 554 */ 479 555 private class children implements Enumeration { 480 556 … … 482 558 private boolean more = true; 483 559 private Node node = null; 560 private NXNodeMapper nxNode = null; 484 561 485 562 public boolean hasMoreElements() { 486 487 if (count < children.size()) { 488 more = true; 563 564 if (isRoot) { 565 566 if (documents == null) { 567 more = false; 568 return more; 569 } 570 571 if (count < documents.size()) { 572 more = true; 573 } else { 574 more = false; 575 } 489 576 } else { 490 more = false; 491 } 492 577 578 if (children == null) { 579 more = false; 580 return more; 581 } 582 583 if (count < children.size()) { 584 more = true; 585 } else { 586 more = false; 587 } 588 589 } 493 590 return more; 494 591 } 495 592 496 593 public Object nextElement() { 497 498 if (count < children.size()) { 499 node = children.get(count); 500 count++; 501 return new NXNodeMapper(node, false, node.getNodeName()); 502 } else { 503 throw new NoSuchElementException(); 504 } 505 594 595 if (isRoot) { 596 597 if (count < documents.size()) { 598 nxNode = documents.get(count); 599 count++; 600 return nxNode; 601 } else { 602 throw new NoSuchElementException(); 603 } 604 605 } else{ 606 607 if (count < children.size()) { 608 node = children.get(count); 609 count++; 610 return new NXNodeMapper(node, false, node.getNodeName()); 611 } else { 612 throw new NoSuchElementException(); 613 } 614 615 } 506 616 } 507 617 } -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXschematron.java
r1507 r1520 44 44 private File reducedNeXusFile; 45 45 private File schematronFile; 46 private File inputNexusFile; 46 47 private boolean keepTemp; 47 48 private InputStream dsdlIncludeXSLTStream = null; … … 52 53 // "iso_abstract_expand.xsl", "iso_svrl_for_xslt2.xsl"}; 53 54 54 public NXschematron(File reducedNeXusFile, File schematronFile,55 public NXschematron(File inputNexusFile, File reducedNeXusFile, File schematronFile, 55 56 final boolean keepTemp) { 56 57 57 58 this.reducedNeXusFile = reducedNeXusFile; 58 59 this.schematronFile = schematronFile; 60 this.inputNexusFile = inputNexusFile; 59 61 this.keepTemp = keepTemp; 60 62 … … 77 79 78 80 /** 79 * Transform an XML file to som thing else given ansXSLT transformation.81 * Transform an XML file to something else given an XSLT transformation. 80 82 * @param inputFilename the XML input file name. 81 83 * @param xslFilename the xslt file name. … … 92 94 93 95 /** 94 * Transform an XML file to som thing else given ansXSLT transformation.96 * Transform an XML file to something else given an XSLT transformation. 95 97 * @param inputFile the XML input file 96 98 * @param xslFile the xslt file. … … 178 180 179 181 // Now lets validate the actual reduced file. 180 File resultsFile = File.createTempFile("result", ".xml"); 182 //File resultsFile = File.createTempFile(inputNexusFile.getName() + ".result", ".xml"); 183 184 //File resultsFile = File.createTempFile(inputNexusFile.getName(). + ".result", ".xml"); 185 186 File resultsFile = new File(reducedNeXusFile.getName().replaceAll(".reduced", "") + ".result"); 181 187 182 188 if (!this.keepTemp) { … … 192 198 193 199 public static void main(String[] args) { 194 if (args.length != 2) {195 System.out.println("Must specify t woinput files");200 if (args.length != 3) { 201 System.out.println("Must specify three input files"); 196 202 return; 197 203 } 198 204 try { 199 NXschematron sch = new NXschematron( 200 new File(args[ 0]), new File(args[1]), false);205 NXschematron sch = new NXschematron(new File(args[0]), 206 new File(args[1]), new File(args[2]), false); 201 207 File results = sch.validate(); 202 208 System.out.println(results.getAbsolutePath()); -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXvalidate.java
r1507 r1520 191 191 192 192 // create the validation setup 193 NXschematron schematron = new NXschematron( reduced,193 NXschematron schematron = new NXschematron(file,reduced, 194 194 schematronFile, keepTemp); 195 195 -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXvalidateFrame.form
r1519 r1520 21 21 </SubComponents> 22 22 </Container> 23 <Component class="javax.swing.JFileChooser" name="jFileChooser1"> 24 </Component> 23 25 <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> 24 26 <SubComponents> … … 42 44 </MenuItem> 43 45 <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator4"> 46 </MenuItem> 47 <MenuItem class="javax.swing.JMenuItem" name="saveMenuItem"> 48 <Properties> 49 <Property name="text" type="java.lang.String" value="Save Results"/> 50 <Property name="toolTipText" type="java.lang.String" value="Save results to files."/> 51 </Properties> 52 <Events> 53 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveMenuItemActionPerformed"/> 54 </Events> 55 </MenuItem> 56 <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator7"> 44 57 </MenuItem> 45 58 <MenuItem class="javax.swing.JMenuItem" name="closeAllMenuItem"> -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXvalidateFrame.java
r1519 r1520 64 64 private UserSettings settings = null; 65 65 private File nxconvertFile = null; 66 private File saveDirectory = null; 66 67 private boolean foundNXconvert = false; 67 68 private MouseListener popupListener = null; 68 69 private TextPaneStyle txtStyle = null; 69 private File LoadingActions fileLoadingActions = null;70 private FileActions fileLoadingActions = null; 70 71 71 72 /** Creates new form NXvalidateFrame */ … … 130 131 txtStyle = new TextPaneStyle(jTextPane1); 131 132 132 fileLoadingActions = new File LoadingActions(this, jTree1, builder, domTree, root);133 fileLoadingActions = new FileActions(this, jTree1, builder, domTree, root); 133 134 134 135 } … … 146 147 treePopupMenu = new javax.swing.JPopupMenu(); 147 148 closeFileMenuItem = new javax.swing.JMenuItem(); 149 jFileChooser1 = new javax.swing.JFileChooser(); 148 150 jPanel2 = new javax.swing.JPanel(); 149 151 jSplitPane1 = new javax.swing.JSplitPane(); … … 156 158 openFilesMenuItem = new javax.swing.JMenuItem(); 157 159 jSeparator4 = new javax.swing.JPopupMenu.Separator(); 160 saveMenuItem = new javax.swing.JMenuItem(); 161 jSeparator7 = new javax.swing.JPopupMenu.Separator(); 158 162 closeAllMenuItem = new javax.swing.JMenuItem(); 159 163 jSeparator5 = new javax.swing.JPopupMenu.Separator(); … … 231 235 fileMenu.add(jSeparator4); 232 236 237 saveMenuItem.setText("Save Results"); 238 saveMenuItem.setToolTipText("Save results to files."); 239 saveMenuItem.addActionListener(new java.awt.event.ActionListener() { 240 public void actionPerformed(java.awt.event.ActionEvent evt) { 241 saveMenuItemActionPerformed(evt); 242 } 243 }); 244 fileMenu.add(saveMenuItem); 245 fileMenu.add(jSeparator7); 246 233 247 closeAllMenuItem.setText("Close All Files"); 234 248 closeAllMenuItem.addActionListener(new java.awt.event.ActionListener() { … … 321 335 322 336 private boolean loadOpenFilesDialog() { 337 338 NXLoadFilesDialog loadFile = new NXLoadFilesDialog(this, true); 339 loadFile.setModalityType(ModalityType.APPLICATION_MODAL); 340 loadFile.setVisible(true); 341 nxsFile = loadFile.getNXSFile(); 342 nxdlFile = loadFile.getNXDLFile(); 343 return loadFile.OKButtonUsed(); 344 345 } 346 347 private boolean saveResultsFilesDialog() { 323 348 324 349 NXLoadFilesDialog loadFile = new NXLoadFilesDialog(this, true); … … 461 486 dialogReportProblem.showMessageDialog(this, 462 487 bundle.getString("openSchemaFileMessage")); 463 464 465 488 } 466 489 } … … 511 534 private void exitAppMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitAppMenuItemActionPerformed 512 535 if (evt.getSource() == exitAppMenuItem) { 513 514 536 this.dispose(); 515 516 537 } 517 538 }//GEN-LAST:event_exitAppMenuItemActionPerformed … … 550 571 551 572 if (evt.getSource() == filterMenuItem) { 552 553 573 treeUtils.hideGoodNodes(jTree1); 554 555 574 } 556 575 557 576 }//GEN-LAST:event_filterMenuItemActionPerformed 577 578 private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuItemActionPerformed 579 if (evt.getSource() == saveMenuItem) { 580 581 jFileChooser1.setMultiSelectionEnabled(false); 582 jFileChooser1.setFileSelectionMode(jFileChooser1.DIRECTORIES_ONLY); 583 jFileChooser1.setApproveButtonText("Save"); 584 int returnVal = jFileChooser1.showOpenDialog(this); 585 586 if (returnVal == jFileChooser1.APPROVE_OPTION) { 587 588 saveDirectory = jFileChooser1.getSelectedFile(); 589 590 if(!saveDirectory.exists()){ 591 saveDirectory.mkdir(); 592 } 593 594 fileLoadingActions.setSaveDirectory(saveDirectory); 595 fileLoadingActions.setWhich(6); 596 Thread thread = new Thread(fileLoadingActions); 597 thread.start(); 598 599 dialogReportProblem.showMessageDialog( 600 this, 601 bundle.getString("savedResultsMessage")); 602 603 } else { 604 saveDirectory = null; 605 } 606 607 } 608 }//GEN-LAST:event_saveMenuItemActionPerformed 558 609 559 610 /** … … 581 632 private javax.swing.JMenu helpMenu; 582 633 private javax.swing.JMenuItem helpMenuItem; 634 private javax.swing.JFileChooser jFileChooser1; 583 635 private javax.swing.JMenuBar jMenuBar1; 584 636 private javax.swing.JPanel jPanel2; … … 591 643 private javax.swing.JPopupMenu.Separator jSeparator5; 592 644 private javax.swing.JPopupMenu.Separator jSeparator6; 645 private javax.swing.JPopupMenu.Separator jSeparator7; 593 646 private javax.swing.JSplitPane jSplitPane1; 594 647 private javax.swing.JTextPane jTextPane1; 595 648 private javax.swing.JTree jTree1; 596 649 private javax.swing.JMenuItem openFilesMenuItem; 650 private javax.swing.JMenuItem saveMenuItem; 597 651 private javax.swing.JMenuItem settingsMenuItem; 598 652 private javax.swing.JMenu toolsMenu; -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/TextPaneStyle.java
r1507 r1520 130 130 if (node.getNodeTexts() != null) { 131 131 132 for (int i = 0; i 133 < node.getNodeTexts().size(); 134 ++i) { 132 for (int i = 0; i < node.getNodeTexts().size(); ++i) { 135 133 doc.insertString(doc.getLength(), 136 134 node.getNodeTexts().get(i), doc.getStyle("error")); … … 138 136 doc.insertString(doc.getLength(), newline + newline, 139 137 doc.getStyle("heading")); 140 141 142 138 } 143 139 -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/ValidatorUtils.java
r1511 r1520 44 44 private File nxconvertFile = null; 45 45 46 public ValidatorUtils(File nxconvertFile) { 46 47 public ValidatorUtils(File nxsFile, File nxconvertFile) { 47 48 48 49 this.nxconvertFile = nxconvertFile; 49 50 this.nxsFile = nxsFile; 50 51 } 51 52 … … 157 158 158 159 // create the validation setup 159 NXschematron schematron = new NXschematron( reduced,160 NXschematron schematron = new NXschematron(nxsFile, reduced, 160 161 schematronFile, keepTemp); 161 162 … … 165 166 Logger.getLogger(ValidatorUtils.class.getName()).log(Level.SEVERE, 166 167 "While creating validation report"); 167 throw new NXvalidateException("While creating validation report" );168 throw new NXvalidateException("While creating validation report", e); 168 169 } 169 170 } -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/exceptions/NXvalidateException.java
r1512 r1520 47 47 super(msg); 48 48 } 49 50 public NXvalidateException(String msg, Throwable cause) { 51 super(msg,cause); 52 } 53 54 public NXvalidateException(Throwable cause) { 55 super(cause); 56 } 57 49 58 } -
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/resources/nxvalidate.properties
r1504 r1520 22 22 closeAllWarningMessage=Are you sure you want to close all files? 23 23 filesNotNexusError=Some files have been detected as not being Nexus/HDF files and have been unchecked in the include column. 24 savedResultsMessage=Results have been saved. 25 notNXDLFileMessage=File is not a NXDL file, please select a NXDL file. 26 notNexusFileMessage=File is not a Nexus file, please select a Nexus file.
Note: See TracChangeset
for help on using the changeset viewer.
