Changeset 1520 for trunk


Ignore:
Timestamp:
02/09/10 18:26:36 (17 months ago)
Author:
Stephen Rankin
Message:

Added save results feature and single file checking (NXDL). Update of Javadocs. ref#236.

Location:
trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate
Files:
13 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/BulkLoadFilesFrame.java

    r1507 r1520  
    4545    private File nxdlFile = null; 
    4646    private ArrayList<String> dataFileList = null; 
    47     private FileLoadingActions fileLoadingActions = null; 
     47    private FileActions fileLoadingActions = null; 
    4848    private boolean badFiles = false; 
    4949    private ResourceBundle bundle = null; 
    5050    private ArrayList<String> dataFileSelectedList = null; 
     51    private CheckNexusFileType check = null; 
    5152 
    5253    /** Creates new form BulkLoadFilesFrame */ 
    53     public BulkLoadFilesFrame(FileLoadingActions fileLoadingActions) { 
     54    public BulkLoadFilesFrame(FileActions fileLoadingActions) { 
    5455        initComponents(); 
    5556        this.fileLoadingActions = fileLoadingActions; 
    5657        bundle = ResourceBundle.getBundle( 
    5758                "org/nexusformat/nxvalidate/resources/nxvalidate"); 
     59        check = new CheckNexusFileType(); 
    5860 
    5961    } 
     
    6365        bundle = ResourceBundle.getBundle( 
    6466                "org/nexusformat/nxvalidate/resources/nxvalidate"); 
     67        check = new CheckNexusFileType(); 
    6568    } 
    6669 
     
    213216            if (returnVal == jFileChooser1.APPROVE_OPTION) { 
    214217                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                
    217231            } else { 
    218232                nxdlFile = null; 
     
    253267 
    254268    private void updateTable() throws FileNotFoundException, IOException { 
    255  
    256  
    257         CheckNexusFileType check = new CheckNexusFileType(); 
    258269 
    259270        DefaultTableModel tableModel = new DefaultTableModel(new Object[][]{ 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/CheckNexusFileType.java

    r1507 r1520  
    5656            builder = factory.newDocumentBuilder(); 
    5757        } 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); 
    5960        } 
    6061    } 
     
    6869     * @throws IOException 
    6970     */ 
    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        } 
    8085        return false; 
    81  
    8286    } 
    8387 
     
    8993     * @throws IOException 
    9094     */ 
    91     public boolean checkHDF5(File file) throws FileNotFoundException, IOException { 
     95    public boolean checkHDF5(File file) throws FileNotFoundException, 
     96                                               IOException { 
    9297 
    9398        byte[] b = new byte[7]; 
     
    121126     * @throws IOException 
    122127     */ 
    123     public boolean checkHDF4(File file) throws FileNotFoundException, IOException { 
     128    public boolean checkHDF4(File file) throws FileNotFoundException, 
     129                                               IOException { 
    124130 
    125131        byte[] b = new byte[4]; 
     
    148154     * @throws IOException 
    149155     */ 
    150     private boolean checkNexusXML(File file) throws FileNotFoundException, IOException { 
     156    private boolean checkNexusXML(File file) { 
    151157 
    152158        boolean result = false; 
     
    186192 
    187193    } 
     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 
    188242} 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/FileActions.java

    r1519 r1520  
    2121 * For further information, see <http://www.neutron.anl.gov/NeXus/> 
    2222 * 
    23  * FileLoadingActions.java 
     23 * FileActions.java 
    2424 * 
    2525 */ 
     
    2727 
    2828import java.io.File; 
     29import java.io.FileInputStream; 
     30import java.io.FileOutputStream; 
    2931import java.io.IOException; 
     32import java.io.InputStream; 
     33import java.io.OutputStream; 
    3034import java.util.ArrayList; 
     35import java.util.Enumeration; 
    3136import java.util.ResourceBundle; 
    3237import org.w3c.dom.Document; 
     
    4449 * @author Stephen Rankin 
    4550 */ 
    46 public class FileLoadingActions implements Runnable { 
     51public class FileActions implements Runnable { 
    4752 
    4853    private File nxsFile = null; 
     
    5156    private File resultsFile = null; 
    5257    private File nxconvertFile = null; 
     58    private File saveDirectory = null; 
    5359    private DocumentBuilderFactory factory = null; 
    5460    private DocumentBuilder builder = null; 
     
    7177    private boolean isNotBulk = false; 
    7278 
    73     public FileLoadingActions(NXvalidateFrame frame, JTree jTree, 
     79    public FileActions(NXvalidateFrame frame, JTree jTree, 
    7480            DocumentBuilder builder, NXReducedToTree domTree, 
    7581            NXNodeMapper root) { 
     
    134140    public void setDataFileList(ArrayList<String> dataFileList) { 
    135141        this.dataFileList = dataFileList; 
     142    } 
     143 
     144    public File getSaveDirectory() { 
     145        return saveDirectory; 
     146    } 
     147 
     148    public void setSaveDirectory(File saveDirectory) { 
     149        this.saveDirectory = saveDirectory; 
    136150    } 
    137151 
     
    159173            //Do the validation. 
    160174            if (nxconvertFile != null) { 
    161                 validator = new ValidatorUtils(nxconvertFile); 
     175                validator = new ValidatorUtils(nxsFile,nxconvertFile); 
    162176            } else { 
    163177                dialogReportProblem.showMessageDialog( 
     
    232246        } catch (InterruptedException ex) { 
    233247            Logger.getLogger( 
    234                     NXvalidateFrame.class.getName()).log(Level.SEVERE, 
     248                    FileActions.class.getName()).log(Level.SEVERE, 
    235249                    null, ex); 
    236250        } catch (SAXException ex) { 
    237251            Logger.getLogger( 
    238                     NXvalidateFrame.class.getName()).log(Level.SEVERE, 
     252                    FileActions.class.getName()).log(Level.SEVERE, 
    239253                    null, ex); 
    240254        } catch (IOException ex) { 
    241255            Logger.getLogger( 
    242                     NXvalidateFrame.class.getName()).log(Level.SEVERE, 
     256                    FileActions.class.getName()).log(Level.SEVERE, 
    243257                    null, ex); 
    244258        } 
     
    316330        } 
    317331 
     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        } 
    318373    } 
    319374 
     
    336391        }else if (which == 5) { 
    337392            bulkValidate(); 
    338         } 
    339  
     393        } else if (which == 6) { 
     394            saveResults(saveDirectory); 
     395        } 
    340396    } 
    341397} 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXLoadFilesDialog.form

    r1504 r1520  
    44  <NonVisualComponents> 
    55    <Component class="javax.swing.JFileChooser" name="jFileChooser1"> 
     6    </Component> 
     7    <Component class="javax.swing.JOptionPane" name="messageOptionPane"> 
    68    </Component> 
    79  </NonVisualComponents> 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXLoadFilesDialog.java

    r1507 r1520  
    2828 
    2929import java.io.File; 
     30import java.util.ResourceBundle; 
    3031 
    3132/** 
     
    3839    private File nxdl = null; 
    3940    private boolean OKButtonUsed = false; 
    40  
     41    private CheckNexusFileType check = null; 
     42    private ResourceBundle bundle = null; 
    4143    /** Creates new form NXLoadFilesDialog */ 
    4244    public NXLoadFilesDialog(java.awt.Frame parent, boolean modal) { 
    4345        super(parent, modal); 
    4446        initComponents(); 
     47        check = new CheckNexusFileType(); 
     48        bundle = ResourceBundle.getBundle( 
     49                "org/nexusformat/nxvalidate/resources/nxvalidate"); 
    4550    } 
    4651 
     
    5560 
    5661        jFileChooser1 = new javax.swing.JFileChooser(); 
     62        messageOptionPane = new javax.swing.JOptionPane(); 
    5763        jPanel1 = new javax.swing.JPanel(); 
    5864        nxsLabel = new javax.swing.JLabel(); 
     
    172178            if (returnVal == jFileChooser1.APPROVE_OPTION) { 
    173179                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                 
    176191            } else { 
    177192                nxs = null; 
     
    189204            if (returnVal == jFileChooser1.APPROVE_OPTION) { 
    190205                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                 
    193217            } else { 
    194218                nxdl = null; 
     
    247271    private javax.swing.JFileChooser jFileChooser1; 
    248272    private javax.swing.JPanel jPanel1; 
     273    private javax.swing.JOptionPane messageOptionPane; 
    249274    private javax.swing.JTextField nxdcTextField; 
    250275    private javax.swing.JLabel nxdlLabel; 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXNodeMapper.java

    r1519 r1520  
    122122    /** 
    123123     * 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 note that are the open NXS documents. 
     124     * list of nodes directly under the root node that are the open NXS documents. 
    125125     * @param isDocument a flag which is true if the node is a document node. 
    126126     */ 
     
    218218    } 
    219219 
     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     */ 
    220226    public Document getReducedDoc() { 
    221227        return reducedDoc; 
    222228    } 
    223229 
     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     */ 
    224236    public void setReducedDoc(Document reducedDoc) { 
    225237        this.reducedDoc = reducedDoc; 
    226238    } 
    227239 
     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     */ 
    228246    public void setBadNode(boolean badNode) { 
    229247        this.badNode = badNode; 
    230248    } 
    231249 
     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     */ 
    232256    public boolean getBadNode() { 
    233257        return badNode; 
    234258    } 
    235259 
     260    /** 
     261     * Get the W3C DOM node corresponding to this tree node. 
     262     * @return the W3C DOM node corresponding to this tree node. 
     263     */ 
    236264    public Node getDomNode() { 
    237265        return domNode; 
    238266    } 
    239267 
     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     */ 
    240272    public void checkBadNode() { 
    241273        if (!isRoot) { 
     
    247279    } 
    248280 
     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     */ 
    249285    public void resetNode() { 
    250286 
    251287        badNode = false; 
    252  
    253288        domNode.setUserData("texts", null, null); 
    254289        domNode.setUserData("tests", null, null); 
     
    258293    } 
    259294 
     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     */ 
    260300    public ArrayList<String> getNodeTexts() { 
    261301        if (!isRoot) { 
     
    266306    } 
    267307 
     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     */ 
    268314    public ArrayList<String> getNodeTests() { 
    269315        if (!isRoot) { 
     
    274320    } 
    275321 
     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     */ 
    276328    public ArrayList<String> getNodeDiags() { 
    277329        if (!isRoot) { 
     
    378430            return root; 
    379431 
    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(); 
    385437 
    386438                return new NXNodeMapper(domNode.getParentNode(), true, 
    387                     ((File)doc.getUserData("file")).getAbsolutePath()); 
    388  
    389             } else{ 
     439                        ((File) doc.getUserData("file")).getAbsolutePath()); 
     440 
     441            } else { 
    390442 
    391443                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     */ 
    400458    public String[] getAttributeList() { 
    401459 
     
    412470 
    413471            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()); 
    415474            } 
    416475 
     
    419478    } 
    420479 
     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     */ 
    421485    public String getValue() { 
    422486 
     
    445509 
    446510            if (node.getNodeType() == ELEMENT_TYPE) { 
    447  
    448511                nodes.add(node); 
    449512                ++childCount; 
     
    469532    } 
    470533 
     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     */ 
    471539    public ArrayList<NXNodeMapper> getOpenNodes() { 
    472540        return documents; 
    473541    } 
    474542 
     543     /** 
     544     * Removes the list of nodes that represent the Nexus documents that are 
     545     * open i.e. that have been reduced. 
     546     */ 
    475547    public void removeAllNodes() { 
    476548        documents.clear(); 
    477549    } 
    478550 
     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     */ 
    479555    private class children implements Enumeration { 
    480556 
     
    482558        private boolean more = true; 
    483559        private Node node = null; 
     560        private NXNodeMapper nxNode = null; 
    484561 
    485562        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                } 
    489576            } 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            } 
    493590            return more; 
    494591        } 
    495592 
    496593        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            } 
    506616        } 
    507617    } 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXschematron.java

    r1507 r1520  
    4444    private File reducedNeXusFile; 
    4545    private File schematronFile; 
     46    private File inputNexusFile; 
    4647    private boolean keepTemp; 
    4748    private InputStream dsdlIncludeXSLTStream = null; 
     
    5253    //    "iso_abstract_expand.xsl", "iso_svrl_for_xslt2.xsl"}; 
    5354 
    54     public NXschematron(File reducedNeXusFile, File schematronFile, 
     55    public NXschematron(File inputNexusFile, File reducedNeXusFile, File schematronFile, 
    5556            final boolean keepTemp) { 
    5657 
    5758        this.reducedNeXusFile = reducedNeXusFile; 
    5859        this.schematronFile = schematronFile; 
     60        this.inputNexusFile = inputNexusFile; 
    5961        this.keepTemp = keepTemp; 
    6062 
     
    7779 
    7880    /** 
    79      * Transform an XML file to somthing else given ans XSLT transformation. 
     81     * Transform an XML file to something else given an XSLT transformation. 
    8082     * @param inputFilename the XML input file name. 
    8183     * @param xslFilename the xslt file name. 
     
    9294 
    9395    /** 
    94      * Transform an XML file to somthing else given ans XSLT transformation. 
     96     * Transform an XML file to something else given an XSLT transformation. 
    9597     * @param inputFile the XML input file 
    9698     * @param xslFile the xslt file. 
     
    178180 
    179181        // 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"); 
    181187 
    182188        if (!this.keepTemp) { 
     
    192198 
    193199    public static void main(String[] args) { 
    194         if (args.length != 2) { 
    195             System.out.println("Must specify two input files"); 
     200        if (args.length != 3) { 
     201            System.out.println("Must specify three input files"); 
    196202            return; 
    197203        } 
    198204        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); 
    201207            File results = sch.validate(); 
    202208            System.out.println(results.getAbsolutePath()); 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXvalidate.java

    r1507 r1520  
    191191             
    192192            // create the validation setup 
    193             NXschematron schematron = new NXschematron(reduced, 
     193            NXschematron schematron = new NXschematron(file,reduced, 
    194194                    schematronFile, keepTemp); 
    195195 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXvalidateFrame.form

    r1519 r1520  
    2121      </SubComponents> 
    2222    </Container> 
     23    <Component class="javax.swing.JFileChooser" name="jFileChooser1"> 
     24    </Component> 
    2325    <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> 
    2426      <SubComponents> 
     
    4244            </MenuItem> 
    4345            <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"> 
    4457            </MenuItem> 
    4558            <MenuItem class="javax.swing.JMenuItem" name="closeAllMenuItem"> 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/NXvalidateFrame.java

    r1519 r1520  
    6464    private UserSettings settings = null; 
    6565    private File nxconvertFile = null; 
     66    private File saveDirectory = null; 
    6667    private boolean foundNXconvert = false; 
    6768    private MouseListener popupListener = null; 
    6869    private TextPaneStyle txtStyle = null; 
    69     private FileLoadingActions fileLoadingActions = null; 
     70    private FileActions fileLoadingActions = null; 
    7071 
    7172    /** Creates new form NXvalidateFrame */ 
     
    130131        txtStyle = new TextPaneStyle(jTextPane1); 
    131132 
    132         fileLoadingActions = new FileLoadingActions(this, jTree1, builder, domTree, root); 
     133        fileLoadingActions = new FileActions(this, jTree1, builder, domTree, root); 
    133134 
    134135    } 
     
    146147        treePopupMenu = new javax.swing.JPopupMenu(); 
    147148        closeFileMenuItem = new javax.swing.JMenuItem(); 
     149        jFileChooser1 = new javax.swing.JFileChooser(); 
    148150        jPanel2 = new javax.swing.JPanel(); 
    149151        jSplitPane1 = new javax.swing.JSplitPane(); 
     
    156158        openFilesMenuItem = new javax.swing.JMenuItem(); 
    157159        jSeparator4 = new javax.swing.JPopupMenu.Separator(); 
     160        saveMenuItem = new javax.swing.JMenuItem(); 
     161        jSeparator7 = new javax.swing.JPopupMenu.Separator(); 
    158162        closeAllMenuItem = new javax.swing.JMenuItem(); 
    159163        jSeparator5 = new javax.swing.JPopupMenu.Separator(); 
     
    231235        fileMenu.add(jSeparator4); 
    232236 
     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 
    233247        closeAllMenuItem.setText("Close All Files"); 
    234248        closeAllMenuItem.addActionListener(new java.awt.event.ActionListener() { 
     
    321335 
    322336    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() { 
    323348 
    324349        NXLoadFilesDialog loadFile = new NXLoadFilesDialog(this, true); 
     
    461486                    dialogReportProblem.showMessageDialog(this, 
    462487                            bundle.getString("openSchemaFileMessage")); 
    463  
    464                      
    465488                } 
    466489            } 
     
    511534    private void exitAppMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitAppMenuItemActionPerformed 
    512535        if (evt.getSource() == exitAppMenuItem) { 
    513  
    514536            this.dispose(); 
    515  
    516537        } 
    517538    }//GEN-LAST:event_exitAppMenuItemActionPerformed 
     
    550571 
    551572        if (evt.getSource() == filterMenuItem) { 
    552  
    553573            treeUtils.hideGoodNodes(jTree1); 
    554  
    555574        } 
    556575 
    557576    }//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 
    558609 
    559610    /** 
     
    581632    private javax.swing.JMenu helpMenu; 
    582633    private javax.swing.JMenuItem helpMenuItem; 
     634    private javax.swing.JFileChooser jFileChooser1; 
    583635    private javax.swing.JMenuBar jMenuBar1; 
    584636    private javax.swing.JPanel jPanel2; 
     
    591643    private javax.swing.JPopupMenu.Separator jSeparator5; 
    592644    private javax.swing.JPopupMenu.Separator jSeparator6; 
     645    private javax.swing.JPopupMenu.Separator jSeparator7; 
    593646    private javax.swing.JSplitPane jSplitPane1; 
    594647    private javax.swing.JTextPane jTextPane1; 
    595648    private javax.swing.JTree jTree1; 
    596649    private javax.swing.JMenuItem openFilesMenuItem; 
     650    private javax.swing.JMenuItem saveMenuItem; 
    597651    private javax.swing.JMenuItem settingsMenuItem; 
    598652    private javax.swing.JMenu toolsMenu; 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/TextPaneStyle.java

    r1507 r1520  
    130130            if (node.getNodeTexts() != null) { 
    131131 
    132                 for (int i = 0; i 
    133                         < node.getNodeTexts().size(); 
    134                         ++i) { 
     132                for (int i = 0; i < node.getNodeTexts().size(); ++i) { 
    135133                    doc.insertString(doc.getLength(), 
    136134                            node.getNodeTexts().get(i), doc.getStyle("error")); 
     
    138136                    doc.insertString(doc.getLength(), newline + newline, 
    139137                            doc.getStyle("heading")); 
    140  
    141  
    142138                } 
    143139 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/ValidatorUtils.java

    r1511 r1520  
    4444    private File nxconvertFile = null; 
    4545 
    46     public ValidatorUtils(File nxconvertFile) { 
     46 
     47    public ValidatorUtils(File nxsFile, File nxconvertFile) { 
    4748 
    4849        this.nxconvertFile = nxconvertFile; 
    49  
     50        this.nxsFile = nxsFile; 
    5051    } 
    5152 
     
    157158 
    158159            // create the validation setup 
    159             NXschematron schematron = new NXschematron(reduced, 
     160            NXschematron schematron = new NXschematron(nxsFile, reduced, 
    160161                    schematronFile, keepTemp); 
    161162 
     
    165166                Logger.getLogger(ValidatorUtils.class.getName()).log(Level.SEVERE, 
    166167                        "While creating validation report"); 
    167                 throw new NXvalidateException("While creating validation report"); 
     168                throw new NXvalidateException("While creating validation report", e); 
    168169            } 
    169170        } 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/exceptions/NXvalidateException.java

    r1512 r1520  
    4747        super(msg); 
    4848    } 
     49 
     50    public NXvalidateException(String msg, Throwable cause) { 
     51        super(msg,cause); 
     52    } 
     53 
     54    public NXvalidateException(Throwable cause) { 
     55        super(cause); 
     56    } 
     57 
    4958} 
  • trunk/applications/NXvalidate/src/org/nexusformat/nxvalidate/resources/nxvalidate.properties

    r1504 r1520  
    2222closeAllWarningMessage=Are you sure you want to close all files? 
    2323filesNotNexusError=Some files have been detected as not being Nexus/HDF files and have been unchecked in the include column. 
     24savedResultsMessage=Results have been saved. 
     25notNXDLFileMessage=File is not a NXDL file, please select a NXDL file. 
     26notNexusFileMessage=File is not a Nexus file, please select a Nexus file. 
Note: See TracChangeset for help on using the changeset viewer.