Changeset 1504


Ignore:
Timestamp:
13/08/10 16:34:17 (18 months ago)
Author:
Stephen Rankin
Message:

Bulk Load working but not really tested. Fixed various bugs fixed, but single file validation is not working now! Close all files function added. Check for NEXUS/HDF files added. Added threads for file loading actions. Some refactoring of code. refs #236.

Location:
trunk/applications/NXconvertpy
Files:
5 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/applications/NXconvertpy/nbproject/build-impl.xml

    r1498 r1504  
    694694            </fileset> 
    695695        </javadoc> 
     696        <copy todir="${dist.javadoc.dir}"> 
     697            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}"> 
     698                <filename name="**/doc-files/**"/> 
     699            </fileset> 
     700            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> 
     701                <include name="**/doc-files/**"/> 
     702            </fileset> 
     703        </copy> 
    696704    </target> 
    697705    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview"> 
  • trunk/applications/NXconvertpy/nbproject/genfiles.properties

    r1498 r1504  
    55# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 
    66nbproject/build-impl.xml.data.CRC32=a5620c1d 
    7 nbproject/build-impl.xml.script.CRC32=3c7842f3 
    8 nbproject/build-impl.xml.stylesheet.CRC32=78c6a6ee@1.38.1.45 
     7nbproject/build-impl.xml.script.CRC32=183f2507 
     8nbproject/build-impl.xml.stylesheet.CRC32=f33e10ff@1.38.2.45 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXLoadFilesDialog.form

    r1498 r1504  
    1 <?xml version="1.0" encoding="UTF-8" ?> 
     1<?xml version="1.1" encoding="UTF-8" ?> 
    22 
    33<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> 
     
    6464                          <Group type="103" groupAlignment="0" attributes="0"> 
    6565                              <Component id="nxsLabel" alignment="0" min="-2" max="-2" attributes="0"/> 
    66                               <Component id="nxdcLabel" alignment="0" min="-2" max="-2" attributes="0"/> 
     66                              <Component id="nxdlLabel" alignment="0" min="-2" max="-2" attributes="0"/> 
    6767                          </Group> 
    6868                          <EmptySpace max="-2" attributes="0"/> 
     
    9595                  <EmptySpace min="-2" pref="28" max="-2" attributes="0"/> 
    9696                  <Group type="103" groupAlignment="3" attributes="0"> 
    97                       <Component id="nxdcLabel" alignment="3" min="-2" max="-2" attributes="0"/> 
     97                      <Component id="nxdlLabel" alignment="3" min="-2" max="-2" attributes="0"/> 
    9898                      <Component id="nxdcTextField" alignment="3" min="-2" max="-2" attributes="0"/> 
    9999                      <Component id="openButton2" alignment="3" min="-2" max="-2" attributes="0"/> 
     
    128128          </Events> 
    129129        </Component> 
    130         <Component class="javax.swing.JLabel" name="nxdcLabel"> 
     130        <Component class="javax.swing.JLabel" name="nxdlLabel"> 
    131131          <Properties> 
    132             <Property name="text" type="java.lang.String" value="Load NXDC:"/> 
     132            <Property name="text" type="java.lang.String" value="Load NXDL:"/> 
    133133          </Properties> 
    134134        </Component> 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXLoadFilesDialog.java

    r1498 r1504  
    2121 
    2222    private File nxs = null; 
    23     private File nxdc = null; 
     23    private File nxdl = null; 
    2424    private boolean OKButtonUsed = false; 
    2525    /** Creates new form NXLoadFilesDialog */ 
     
    4343        nxsTextField = new javax.swing.JTextField(); 
    4444        openButton1 = new javax.swing.JButton(); 
    45         nxdcLabel = new javax.swing.JLabel(); 
     45        nxdlLabel = new javax.swing.JLabel(); 
    4646        nxdcTextField = new javax.swing.JTextField(); 
    4747        openButton2 = new javax.swing.JButton(); 
     
    6666        }); 
    6767 
    68         nxdcLabel.setText("Load NXDC:"); 
     68        nxdlLabel.setText("Load NXDL:"); 
    6969 
    7070        nxdcTextField.setEditable(false); 
     
    101101                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 
    102102                            .addComponent(nxsLabel) 
    103                             .addComponent(nxdcLabel)) 
     103                            .addComponent(nxdlLabel)) 
    104104                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    105105                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 
     
    109109                .addGap(15, 15, 15) 
    110110                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 
    111                     .addGroup(jPanel1Layout.createSequentialGroup() 
    112                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    113                         .addComponent(openButton1) 
    114                         .addContainerGap()) 
    115                     .addGroup(jPanel1Layout.createSequentialGroup() 
    116                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 
    117                         .addComponent(openButton2) 
    118                         .addContainerGap()) 
    119                     .addGroup(jPanel1Layout.createSequentialGroup() 
    120                         .addComponent(OKButton) 
    121                         .addContainerGap()))) 
     111                    .addComponent(openButton1) 
     112                    .addComponent(openButton2) 
     113                    .addComponent(OKButton)) 
     114                .addContainerGap()) 
    122115        ); 
    123116        jPanel1Layout.setVerticalGroup( 
     
    131124                .addGap(28, 28, 28) 
    132125                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 
    133                     .addComponent(nxdcLabel) 
     126                    .addComponent(nxdlLabel) 
    134127                    .addComponent(nxdcTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 
    135128                    .addComponent(openButton2)) 
     
    179172 
    180173            if (returnVal == jFileChooser1.APPROVE_OPTION) { 
    181                 nxdc = jFileChooser1.getSelectedFile(); 
    182                 nxdcTextField.setText(nxdc.getAbsolutePath()); 
    183                 nxdcTextField.setToolTipText(nxdc.getAbsolutePath()); 
     174                nxdl = jFileChooser1.getSelectedFile(); 
     175                nxdcTextField.setText(nxdl.getAbsolutePath()); 
     176                nxdcTextField.setToolTipText(nxdl.getAbsolutePath()); 
    184177            } else { 
    185                 nxdc = null; 
     178                nxdl = null; 
    186179            } 
    187180 
     
    207200        return nxs; 
    208201    } 
    209     public File getNXDCFile(){ 
    210         return nxdc; 
     202    public File getNXDLFile(){ 
     203        return nxdl; 
    211204    } 
    212205 
     
    237230    private javax.swing.JFileChooser jFileChooser1; 
    238231    private javax.swing.JPanel jPanel1; 
    239     private javax.swing.JLabel nxdcLabel; 
    240232    private javax.swing.JTextField nxdcTextField; 
     233    private javax.swing.JLabel nxdlLabel; 
    241234    private javax.swing.JLabel nxsLabel; 
    242235    private javax.swing.JTextField nxsTextField; 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXNodeMapper.java

    r1503 r1504  
    374374    } 
    375375 
     376    public ArrayList<NXNodeMapper> getOpenNodes(){ 
     377        return documents; 
     378    } 
     379 
     380    public void removeAllNodes(){ 
     381        documents.clear(); 
     382    } 
     383 
    376384    private class children implements Enumeration { 
    377385 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXReducedToTree.java

    r1503 r1504  
    1919 * This maps the NX Reduced XML Document (as a DOM document) to 
    2020 * a JTree model. 
    21  * @author ser65 
     21 * @author Stephen Rankin 
    2222 */ 
    2323public class NXReducedToTree extends DefaultTreeModel { 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXValidateDialog.java

    r1498 r1504  
    2121 
    2222    private File nxs = null; 
    23     private File nxdc = null; 
     23    private File nxdl = null; 
    2424    private boolean OKButtonUsed = false; 
    2525    /** Creates new form NXLoadFilesDialog */ 
     
    134134 
    135135            if (returnVal == jFileChooser1.APPROVE_OPTION) { 
    136                 nxdc = jFileChooser1.getSelectedFile(); 
    137                 nxdcTextField.setText(nxdc.getAbsolutePath()); 
    138                 nxdcTextField.setToolTipText(nxdc.getAbsolutePath()); 
     136                nxdl = jFileChooser1.getSelectedFile(); 
     137                nxdcTextField.setText(nxdl.getAbsolutePath()); 
     138                nxdcTextField.setToolTipText(nxdl.getAbsolutePath()); 
    139139            } else { 
    140                 nxdc = null; 
     140                nxdl = null; 
    141141            } 
    142142 
     
    160160 
    161161     
    162     public File getNXDCFile(){ 
    163         return nxdc; 
    164     } 
    165  
    166     public void setNXDCFile(File file){ 
    167         nxdc = file; 
    168         nxdcTextField.setText(nxdc.getAbsolutePath()); 
     162    public File getNXDLFile(){ 
     163        return nxdl; 
     164    } 
     165 
     166    public void setNXDLFile(File file){ 
     167        nxdl = file; 
     168        nxdcTextField.setText(nxdl.getAbsolutePath()); 
    169169    } 
    170170 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXconvert.java

    r1501 r1504  
    55import java.util.logging.Level; 
    66import java.util.logging.Logger; 
     7import org.nexusformat.nxvalidate.exceptions.NXConvertpyException; 
    78 
    89public class NXconvert { 
     
    4142    } 
    4243 
    43     public File convert() throws IOException, InterruptedException { 
     44    public File convert() throws IOException, InterruptedException, NXConvertpyException { 
    4445 
    4546        Logger.getLogger(NXconvert.class.getName()).log( 
    4647                Level.INFO, "Creating " + redfile.getAbsolutePath()); 
    47  
    48         // the command to run 
    49         //String command = props.getProperty(NXCONVERT) + 
    50          //       " -d " + this.rawfile + " " + redfile; 
    5148 
    5249        String command = ""; 
     
    5451            command = convertFile.getAbsolutePath() + 
    5552                " -d " + this.rawfile + " " + redfile;; 
    56             System.out.println(command); 
    5753        } 
    5854        else{ 
     
    7874            buffer.append("\" failed. Returned "); 
    7975            buffer.append(exitValue); 
    80             throw new IOException(buffer.toString()); 
     76            throw new NXConvertpyException(buffer.toString()); 
    8177        } 
    8278        return redfile; 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXvalidateFrame.form

    r1503 r1504  
    2323    <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> 
    2424      <SubComponents> 
    25         <Menu class="javax.swing.JMenu" name="jMenu1"> 
     25        <Menu class="javax.swing.JMenu" name="fileMenu"> 
    2626          <Properties> 
    2727            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> 
     
    3838              </Events> 
    3939            </MenuItem> 
     40            <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator4"> 
     41            </MenuItem> 
     42            <MenuItem class="javax.swing.JMenuItem" name="closeAllMenuItem"> 
     43              <Properties> 
     44                <Property name="text" type="java.lang.String" value="Close All Files"/> 
     45              </Properties> 
     46              <Events> 
     47                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeAllMenuItemActionPerformed"/> 
     48              </Events> 
     49            </MenuItem> 
     50            <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator5"> 
     51            </MenuItem> 
     52            <MenuItem class="javax.swing.JMenuItem" name="exitAppMenuItem"> 
     53              <Properties> 
     54                <Property name="text" type="java.lang.String" value="Exit"/> 
     55              </Properties> 
     56              <Events> 
     57                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitAppMenuItemActionPerformed"/> 
     58              </Events> 
     59            </MenuItem> 
    4060          </SubComponents> 
    4161        </Menu> 
    42         <Menu class="javax.swing.JMenu" name="jMenu2"> 
     62        <Menu class="javax.swing.JMenu" name="toolsMenu"> 
    4363          <Properties> 
    4464            <Property name="text" type="java.lang.String" value="Tools"/> 
     
    6686                <Property name="text" type="java.lang.String" value="Bulk Validation"/> 
    6787              </Properties> 
     88              <Events> 
     89                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bulkMenuItemActionPerformed"/> 
     90              </Events> 
    6891            </MenuItem> 
    6992            <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator3"> 
     
    7699                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="settingsMenuItemActionPerformed"/> 
    77100              </Events> 
     101            </MenuItem> 
     102          </SubComponents> 
     103        </Menu> 
     104        <Menu class="javax.swing.JMenu" name="helpMenu"> 
     105          <Properties> 
     106            <Property name="text" type="java.lang.String" value="Help"/> 
     107          </Properties> 
     108          <SubComponents> 
     109            <MenuItem class="javax.swing.JMenuItem" name="helpMenuItem"> 
     110              <Properties> 
     111                <Property name="text" type="java.lang.String" value="Help Content"/> 
     112              </Properties> 
     113            </MenuItem> 
     114            <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator6"> 
     115            </MenuItem> 
     116            <MenuItem class="javax.swing.JMenuItem" name="aboutMenuItem"> 
     117              <Properties> 
     118                <Property name="text" type="java.lang.String" value="About"/> 
     119              </Properties> 
    78120            </MenuItem> 
    79121          </SubComponents> 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXvalidateFrame.java

    r1503 r1504  
    1 /* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
    5  
    6 /* 
    7  * NXvalidateFrame.java 
    8  * 
    9  * Created on 02-Jun-2010, 14:17:04 
    10  */ 
     1 /* NeXus - Neutron & X-ray Common Data Format 
     2  * 
     3  * NeXus file validation GUI tool. 
     4  * 
     5  * Copyright (C) 2010 Stephen Rankin 
     6  * 
     7  * This library is free software; you can redistribute it and/or 
     8  * modify it under the terms of the GNU Lesser General Public 
     9  * License as published by the Free Software Foundation; either 
     10  * version 2 of the License, or (at your option) any later version. 
     11  * 
     12  * This library is distributed in the hope that it will be useful, 
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     15  * Lesser General Public License for more details. 
     16  * 
     17  * You should have received a copy of the GNU Lesser General Public 
     18  * License along with this library; if not, write to the Free Software 
     19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20  * 
     21  * For further information, see <http://www.neutron.anl.gov/NeXus/> 
     22  * 
     23  * NXvalidateFrame.java 
     24  * 
     25  * Created on 02-Jun-2010, 14:17:04 
     26  */ 
     27 
    1128package org.nexusformat.nxvalidate; 
    1229 
    13 import java.awt.Color; 
    1430import java.awt.Dialog.ModalityType; 
    1531import java.awt.event.MouseListener; 
     
    2137import java.util.logging.Level; 
    2238import java.util.logging.Logger; 
     39import javax.swing.JOptionPane; 
    2340import javax.swing.JTextArea; 
    24 import javax.swing.text.BadLocationException; 
    25 import javax.swing.text.Style; 
    26 import javax.swing.text.StyleConstants; 
    27 import javax.swing.text.StyleContext; 
    28 import javax.swing.text.StyledDocument; 
    2941import javax.swing.tree.MutableTreeNode; 
     42import javax.swing.tree.TreePath; 
    3043import javax.xml.parsers.DocumentBuilder; 
    3144import javax.xml.parsers.DocumentBuilderFactory; 
    3245import javax.xml.parsers.ParserConfigurationException; 
    33 import org.nexusformat.nxvalidate.exceptions.NXConvertpyException; 
    3446import org.w3c.dom.Document; 
    35 import org.xml.sax.SAXException; 
    3647 
    3748/** 
     
    4556    private NXReducedToTree domTree = null; 
    4657    private NXNodeMapper root = null; 
    47     private ValidatorUtils validator = null; 
    4858    private ResourceBundle bundle = null; 
    4959    private File nxsFile = null; 
    50     private File nxdcFile = null; 
     60    private File nxdlFile = null; 
    5161    private File reducedFile = null; 
    5262    private File resultsFile = null; 
    5363    private TreeUtils treeUtils = null; 
    54     private ArrayList<Report> reports; 
    5564    private UserSettings settings = null; 
    5665    private File nxconvertFile = null; 
    5766    private boolean foundNXconvert = false; 
    5867    private MouseListener popupListener = null; 
     68    private TextPaneStyle txtStyle = null; 
     69    private FileLoadingActions fileLoadingActions = null; 
     70 
    5971    /** Creates new form NXvalidateFrame */ 
    6072    public NXvalidateFrame() { 
     
    96108            nxconvertFile = settings.getNXconvert(); 
    97109 
    98             if(!settings.foundNXconvert()){ 
     110            if (!settings.foundNXconvert()) { 
    99111                displayErrorMessage( 
    100                             bundle.getString("nxconvertMissingError")); 
     112                        bundle.getString("nxconvertMissingError")); 
    101113                foundNXconvert = false; 
    102             } 
    103             else{ 
     114            } else { 
    104115                foundNXconvert = true; 
    105116            } 
     
    117128        jTree1.addMouseListener(popupListener); 
    118129 
    119          
     130        txtStyle = new TextPaneStyle(jTextPane1); 
     131 
     132        fileLoadingActions = new FileLoadingActions(this, jTree1, builder, domTree, root); 
     133 
    120134    } 
    121135 
     
    139153        jTextPane1 = new javax.swing.JTextPane(); 
    140154        jMenuBar1 = new javax.swing.JMenuBar(); 
    141         jMenu1 = new javax.swing.JMenu(); 
     155        fileMenu = new javax.swing.JMenu(); 
    142156        openFilesMenuItem = new javax.swing.JMenuItem(); 
    143         jMenu2 = new javax.swing.JMenu(); 
     157        jSeparator4 = new javax.swing.JPopupMenu.Separator(); 
     158        closeAllMenuItem = new javax.swing.JMenuItem(); 
     159        jSeparator5 = new javax.swing.JPopupMenu.Separator(); 
     160        exitAppMenuItem = new javax.swing.JMenuItem(); 
     161        toolsMenu = new javax.swing.JMenu(); 
    144162        validateSelectedMenuItem = new javax.swing.JMenuItem(); 
    145163        jSeparator2 = new javax.swing.JPopupMenu.Separator(); 
     
    149167        jSeparator3 = new javax.swing.JPopupMenu.Separator(); 
    150168        settingsMenuItem = new javax.swing.JMenuItem(); 
     169        helpMenu = new javax.swing.JMenu(); 
     170        helpMenuItem = new javax.swing.JMenuItem(); 
     171        jSeparator6 = new javax.swing.JPopupMenu.Separator(); 
     172        aboutMenuItem = new javax.swing.JMenuItem(); 
    151173 
    152174        closeFileMenuItem.setText("Close File"); 
     
    197219        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); 
    198220 
    199         jMenu1.setText(bundle.getString("fileMenuItem")); // NOI18N 
     221        fileMenu.setText(bundle.getString("fileMenuItem")); // NOI18N 
    200222 
    201223        openFilesMenuItem.setText("Open Files"); 
     
    205227            } 
    206228        }); 
    207         jMenu1.add(openFilesMenuItem); 
    208  
    209         jMenuBar1.add(jMenu1); 
    210  
    211         jMenu2.setText("Tools"); 
     229        fileMenu.add(openFilesMenuItem); 
     230        fileMenu.add(jSeparator4); 
     231 
     232        closeAllMenuItem.setText("Close All Files"); 
     233        closeAllMenuItem.addActionListener(new java.awt.event.ActionListener() { 
     234            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     235                closeAllMenuItemActionPerformed(evt); 
     236            } 
     237        }); 
     238        fileMenu.add(closeAllMenuItem); 
     239        fileMenu.add(jSeparator5); 
     240 
     241        exitAppMenuItem.setText("Exit"); 
     242        exitAppMenuItem.addActionListener(new java.awt.event.ActionListener() { 
     243            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     244                exitAppMenuItemActionPerformed(evt); 
     245            } 
     246        }); 
     247        fileMenu.add(exitAppMenuItem); 
     248 
     249        jMenuBar1.add(fileMenu); 
     250 
     251        toolsMenu.setText("Tools"); 
    212252 
    213253        validateSelectedMenuItem.setText("Validate Selected"); 
     
    217257            } 
    218258        }); 
    219         jMenu2.add(validateSelectedMenuItem); 
    220         jMenu2.add(jSeparator2); 
     259        toolsMenu.add(validateSelectedMenuItem); 
     260        toolsMenu.add(jSeparator2); 
    221261 
    222262        filterMenuItem.setText("Filter Good Values"); 
    223         jMenu2.add(filterMenuItem); 
    224         jMenu2.add(jSeparator1); 
     263        toolsMenu.add(filterMenuItem); 
     264        toolsMenu.add(jSeparator1); 
    225265 
    226266        bulkMenuItem.setText("Bulk Validation"); 
    227         jMenu2.add(bulkMenuItem); 
    228         jMenu2.add(jSeparator3); 
     267        bulkMenuItem.addActionListener(new java.awt.event.ActionListener() { 
     268            public void actionPerformed(java.awt.event.ActionEvent evt) { 
     269                bulkMenuItemActionPerformed(evt); 
     270            } 
     271        }); 
     272        toolsMenu.add(bulkMenuItem); 
     273        toolsMenu.add(jSeparator3); 
    229274 
    230275        settingsMenuItem.setText("Settings"); 
     
    234279            } 
    235280        }); 
    236         jMenu2.add(settingsMenuItem); 
    237  
    238         jMenuBar1.add(jMenu2); 
     281        toolsMenu.add(settingsMenuItem); 
     282 
     283        jMenuBar1.add(toolsMenu); 
     284 
     285        helpMenu.setText("Help"); 
     286 
     287        helpMenuItem.setText("Help Content"); 
     288        helpMenu.add(helpMenuItem); 
     289        helpMenu.add(jSeparator6); 
     290 
     291        aboutMenuItem.setText("About"); 
     292        helpMenu.add(aboutMenuItem); 
     293 
     294        jMenuBar1.add(helpMenu); 
    239295 
    240296        setJMenuBar(jMenuBar1); 
     
    252308        dialogReportProblem.showMessageDialog(this, ta); 
    253309 
    254    } 
    255  
    256  
    257     private void loadFiles() { 
    258         try { 
    259  
    260             //Reduce the file with NXConvert. 
    261             NXconvert convert = new NXconvert(nxsFile, true, nxconvertFile); 
    262             File reducedFile = convert.convert(); 
    263  
    264             //Display reduced file 
    265             Document document = builder.parse(reducedFile); 
    266             NXNodeMapper node = new NXNodeMapper( 
    267                     document, true, nxsFile); 
    268             node.setReducedDoc(document); 
    269             if (nxdcFile != null) { 
    270                 node.setSchematronFile(nxdcFile); 
    271             } 
    272             node.setReducedFile(reducedFile); 
    273             node.setRoot(root); 
    274             root.insert(node); 
    275             domTree.updateTree(); 
    276             nxsFile = null; 
    277             nxdcFile = null; 
    278  
    279         } catch (InterruptedException ex) { 
    280             Logger.getLogger( 
    281                     NXvalidateFrame.class.getName()).log(Level.SEVERE, 
    282                     null, ex); 
    283         } catch (SAXException ex) { 
    284             Logger.getLogger( 
    285                     NXvalidateFrame.class.getName()).log(Level.SEVERE, 
    286                     null, ex); 
    287         } catch (IOException ex) { 
    288             Logger.getLogger( 
    289                     NXvalidateFrame.class.getName()).log(Level.SEVERE, 
    290                     null, ex); 
    291         } 
    292310    } 
    293311 
     
    298316        loadFile.setVisible(true); 
    299317        nxsFile = loadFile.getNXSFile(); 
    300         nxdcFile = loadFile.getNXDCFile(); 
     318        nxdlFile = loadFile.getNXDLFile(); 
    301319        return loadFile.OKButtonUsed(); 
    302320 
     
    307325        NXValidateDialog loadValidate = new NXValidateDialog(this, true); 
    308326        loadValidate.setModalityType(ModalityType.APPLICATION_MODAL); 
    309         if (nxdcFile != null) { 
    310             loadValidate.setNXDCFile(nxdcFile); 
     327        if (nxdlFile != null) { 
     328            loadValidate.setNXDLFile(nxdlFile); 
    311329        } 
    312330        loadValidate.setVisible(true); 
    313         nxdcFile = loadValidate.getNXDCFile(); 
     331        nxdlFile = loadValidate.getNXDLFile(); 
    314332        return loadValidate.OKButtonUsed(); 
    315333 
     
    333351        if (evt.getSource() == openFilesMenuItem) { 
    334352 
    335             if(!foundNXconvert){ 
     353            if (!foundNXconvert) { 
    336354                displayErrorMessage( 
    337                             bundle.getString("nxconvertMissingError")); 
     355                        bundle.getString("nxconvertMissingError")); 
    338356                return; 
    339357            } 
     
    343361            if (result) { 
    344362                if (nxsFile != null) { 
    345                     loadFiles(); 
     363                    fileLoadingActions.setWhich(1); 
     364                    fileLoadingActions.setNXSFile(nxsFile); 
     365                    fileLoadingActions.setNXConvertFile(nxconvertFile); 
     366                    fileLoadingActions.setNXDLFile(nxdlFile); 
     367                    (new Thread(fileLoadingActions)).start(); 
    346368                } else { 
    347369                    dialogReportProblem.showMessageDialog(this, 
     
    359381                NXNodeMapper node = 
    360382                        (NXNodeMapper) jTree1.getSelectionPath().getLastPathComponent(); 
    361                 updateTextPane(node); 
    362  
     383                txtStyle.updateTextPane(node); 
    363384            } 
    364385        } 
     
    370391        if (evt.getSource() == validateSelectedMenuItem) { 
    371392 
    372             if(!foundNXconvert){ 
     393            //Nothing selected in tree 
     394            if (jTree1.isSelectionEmpty()) { 
     395                return; 
     396            } 
     397 
     398            //Root node selected in tree 
     399            TreePath selected = jTree1.getSelectionPath(); 
     400            int size = selected.getPath().length; 
     401            NXNodeMapper endNode = (NXNodeMapper) selected.getPath()[size - 1]; 
     402            if (endNode.isRoot()) { 
     403                return; 
     404            } 
     405 
     406            //No nxconvert binary found. 
     407            if (!foundNXconvert) { 
    373408                displayErrorMessage( 
    374                             bundle.getString("nxconvertMissingError")); 
     409                        bundle.getString("nxconvertMissingError")); 
    375410                return; 
    376411            } 
     
    383418            //current selected tree. 
    384419            if (treeUtils.getNXDCFile(jTree1) != null) { 
    385                 nxdcFile = treeUtils.getNXDCFile(jTree1); 
     420                nxdlFile = treeUtils.getNXDCFile(jTree1); 
    386421            } 
    387422 
     
    400435 
    401436            if (result) { 
    402                 if (nxdcFile != null) { 
    403  
    404                     try { 
    405  
    406                         //Validation has already been done so we reset the tree 
    407                         //before doing the validation again. 
    408                         if (resultsDoc != null) { 
    409                             SVRLNodeFilter filter = new SVRLNodeFilter(); 
    410                             filter.setFilterDocument(resultsDoc); 
    411                             filter.setDocument(reducedDoc); 
    412                             filter.resetBadNodes(); 
    413                         } 
    414  
    415                         //Do the validation. 
    416                         if(nxconvertFile!=null){ 
    417                             validator = new ValidatorUtils(nxconvertFile); 
    418                         } 
    419                         else{ 
    420                              displayErrorMessage( 
    421                             bundle.getString("nxconvertMissingError")); 
    422                             return; 
    423                         } 
    424                         validator.setSchematron(nxdcFile); 
    425                         validator.setReduced(reducedFile); 
    426                         resultsFile = validator.validate(); 
    427  
    428                         SVRLNodeFilter filter = new SVRLNodeFilter(); 
    429  
    430                         resultsDoc = builder.parse(resultsFile); 
    431                         filter.setFilterDocument(resultsDoc); 
    432                         filter.setDocument(reducedDoc); 
    433                         filter.getBadNodeList(); 
    434  
    435                         treeUtils.setResultsDoc(jTree1, resultsDoc); 
    436                         treeUtils.setResultsFile(jTree1, resultsFile); 
    437  
    438                         domTree.updateTree(); 
    439                         Logger.getLogger(NXvalidateFrame.class.getName()).log( 
    440                                 Level.INFO, "Finished Validating."); 
    441                         dialogReportProblem.showMessageDialog( 
    442                                 this, 
    443                                 bundle.getString("validationCompleteMessage")); 
    444  
    445  
    446                     } catch (NXConvertpyException ex) { 
    447                         Logger.getLogger(NXvalidateFrame.class.getName()).log( 
    448                                 Level.SEVERE, null, ex); 
    449                     } catch (SAXException ex) { 
    450                         Logger.getLogger(NXvalidateFrame.class.getName()).log( 
    451                                 Level.SEVERE, null, ex); 
    452                     } catch (IOException ex) { 
    453                         Logger.getLogger(NXvalidateFrame.class.getName()).log( 
    454                                 Level.SEVERE, null, ex); 
    455                     } 
     437                if (nxdlFile != null) { 
     438 
     439                    fileLoadingActions.setWhich(2); 
     440                    fileLoadingActions.setNXSFile(nxsFile); 
     441                    fileLoadingActions.setNXConvertFile(nxconvertFile); 
     442                    fileLoadingActions.setNXDLFile(nxdlFile); 
     443                    fileLoadingActions.setReducedFile(reducedFile); 
     444                    fileLoadingActions.setReducedDoc(reducedDoc); 
     445                    fileLoadingActions.setResultsDoc(resultsDoc); 
     446 
     447                    Thread thread = new Thread(fileLoadingActions); 
     448 
     449                    thread.start(); 
    456450 
    457451                } else { 
     
    459453                            bundle.getString("openSchemaFileMessage")); 
    460454 
     455                     
    461456                } 
    462457            } 
     
    479474            } 
    480475 
    481             if(!foundNXconvert){ 
     476            if (!foundNXconvert) { 
    482477                displayErrorMessage( 
    483                             bundle.getString("nxconvertMissingError")); 
     478                        bundle.getString("nxconvertMissingError")); 
    484479                return; 
    485480            } 
     
    490485 
    491486    private void closeFileMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeFileMenuItemActionPerformed 
    492          
     487 
    493488        if (evt.getSource() == closeFileMenuItem) { 
    494489 
    495490            NXNodeMapper node = treeUtils.getBaseNode(jTree1); 
    496             if(node!=null){ 
    497                 if(!node.isRoot()){ 
     491            if (node != null) { 
     492                if (!node.isRoot()) { 
    498493                    root.removeNode(node); 
    499                     domTree.removeNodeFromParent((MutableTreeNode)node); 
     494                    domTree.removeNodeFromParent((MutableTreeNode) node); 
    500495                    domTree.updateTree(); 
    501496                } 
    502497            } 
    503              
    504498 
    505499        } 
    506500    }//GEN-LAST:event_closeFileMenuItemActionPerformed 
    507501 
    508     private void updateTextPane(NXNodeMapper node) { 
    509  
    510         String newline = "\n"; 
    511         String[] initString = { 
    512             "another ", //italic 
    513             "styled ", //bold 
    514             "text ", //small 
    515             "component, ", //large 
    516             "which supports embedded components..." + newline,//regular 
    517             " " + newline, //button 
    518             "...and embedded icons..." + newline, //regular 
    519             " ", //icon 
    520             newline + "JTextPane is a subclass of JEditorPane that " 
    521             + "uses a StyledEditorKit and StyledDocument, and provides " 
    522             + "cover methods for interacting with those objects." 
    523         }; 
    524  
    525         String[] initStyles = {"regular", "italic", "bold", "small", "large", 
    526             "regular", "button", "regular", "icon", 
    527             "regular" 
    528         }; 
    529  
    530  
    531         StyledDocument doc = jTextPane1.getStyledDocument(); 
    532  
    533         addStylesToDocument( 
    534                 doc); 
    535         String[] atts = node.getAttributeList(); 
    536  
    537  
    538  
    539         try { 
    540             doc.remove(0, doc.getLength()); 
    541  
    542             doc.insertString(0, node.toString() 
    543                     + newline + newline, doc.getStyle("title")); 
    544  
    545             doc.insertString(doc.getLength(), "Attributes:" 
    546                     + newline + newline, doc.getStyle("heading")); 
    547  
    548  
    549  
    550             for (int i = 0; i 
    551                     < atts.length; i++) { 
    552                 doc.insertString(doc.getLength(), 
    553                         "@ " + atts[i] + newline, doc.getStyle("bold")); 
    554  
    555  
    556             } 
    557  
    558             doc.insertString(doc.getLength(), newline + newline, 
    559                     doc.getStyle("heading")); 
    560  
    561             doc.insertString(doc.getLength(), "Node Value:" 
    562                     + newline + newline, doc.getStyle("heading")); 
    563  
    564             doc.insertString(doc.getLength(), 
    565                     node.getValue(), doc.getStyle("bold")); 
    566  
    567             doc.insertString(doc.getLength(), newline + newline, 
    568                     doc.getStyle("heading")); 
    569  
    570             doc.insertString(doc.getLength(), "Validation Tests:" 
    571                     + newline + newline, doc.getStyle("heading")); 
    572  
    573  
    574  
    575             if (node.getNodeTests() != null) { 
    576  
    577                 for (int i = 0; i 
    578                         < node.getNodeTests().size(); 
    579                         ++i) { 
    580                     doc.insertString(doc.getLength(), 
    581                             node.getNodeTests().get(i), doc.getStyle("bold")); 
    582  
    583                     doc.insertString(doc.getLength(), newline + newline, 
    584                             doc.getStyle("heading")); 
    585  
    586  
     502    private void exitAppMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitAppMenuItemActionPerformed 
     503        if (evt.getSource() == exitAppMenuItem) { 
     504 
     505            this.dispose(); 
     506 
     507        } 
     508    }//GEN-LAST:event_exitAppMenuItemActionPerformed 
     509 
     510    private void closeAllMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeAllMenuItemActionPerformed 
     511        if (evt.getSource() == closeAllMenuItem) { 
     512 
     513            int result = dialogReportProblem.showConfirmDialog(this, 
     514                    bundle.getString("closeAllWarningMessage"), null, 
     515                    JOptionPane.OK_CANCEL_OPTION); 
     516 
     517            if (result == 0) { 
     518                ArrayList<NXNodeMapper> nodes = root.getOpenNodes(); 
     519                for (int i = 0; i < nodes.size(); ++i) { 
     520                    domTree.removeNodeFromParent((MutableTreeNode) nodes.get(i)); 
    587521                } 
    588  
    589             } 
    590  
    591             doc.insertString(doc.getLength(), "Validation Errors:" 
    592                     + newline + newline, doc.getStyle("errorheading")); 
    593  
    594             if (node.getNodeTexts() != null) { 
    595  
    596                 for (int i = 0; i 
    597                         < node.getNodeTexts().size(); 
    598                         ++i) { 
    599                     doc.insertString(doc.getLength(), 
    600                             node.getNodeTexts().get(i), doc.getStyle("error")); 
    601  
    602                     doc.insertString(doc.getLength(), newline + newline, 
    603                             doc.getStyle("heading")); 
    604  
    605  
    606                 } 
    607  
    608             } 
    609  
    610             doc.insertString(doc.getLength(), "Diagnostic Errors:" 
    611                     + newline + newline, doc.getStyle("errorheading")); 
    612  
    613             if (node.getNodeDiags() != null) { 
    614  
    615                 for (int i = 0; i 
    616                         < node.getNodeDiags().size(); 
    617                         ++i) { 
    618                     doc.insertString(doc.getLength(), 
    619                             node.getNodeDiags().get(i), doc.getStyle("error")); 
    620  
    621                     doc.insertString(doc.getLength(), newline + newline, 
    622                             doc.getStyle("heading")); 
    623  
    624                 } 
    625  
    626             } 
    627  
    628         } catch (BadLocationException ex) { 
    629             Logger.getLogger(NXvalidateFrame.class.getName()).log(Level.SEVERE, 
    630                     null, ex); 
    631         } 
    632  
    633     } 
    634  
    635     protected void addStylesToDocument(StyledDocument doc) { 
    636  
    637         //Initialize some styles. 
    638         Style def = StyleContext.getDefaultStyleContext(). 
    639                 getStyle(StyleContext.DEFAULT_STYLE); 
    640  
    641         Style regular = doc.addStyle("regular", def); 
    642         StyleConstants.setFontFamily(def, "SansSerif"); 
    643  
    644         Style s = doc.addStyle("italic", regular); 
    645         StyleConstants.setItalic(s, true); 
    646  
    647         s = doc.addStyle("bold", regular); 
    648         StyleConstants.setBold(s, true); 
    649  
    650         s = doc.addStyle("small", regular); 
    651         StyleConstants.setFontSize(s, 10); 
    652  
    653         s = doc.addStyle("large", regular); 
    654         StyleConstants.setFontSize(s, 16); 
    655  
    656         s = doc.addStyle("heading", regular); 
    657         StyleConstants.setFontSize(s, 16); 
    658         StyleConstants.setBold(s, true); 
    659  
    660         s = doc.addStyle("title", regular); 
    661         StyleConstants.setFontSize(s, 24); 
    662         StyleConstants.setBold(s, true); 
    663  
    664         s = doc.addStyle("errorheading", regular); 
    665         StyleConstants.setFontSize(s, 16); 
    666         StyleConstants.setBold(s, true); 
    667         StyleConstants.setForeground(s, Color.red); 
    668  
    669         s = doc.addStyle("error", regular); 
    670         StyleConstants.setBold(s, true); 
    671         StyleConstants.setForeground(s, Color.red); 
    672  
    673     } 
     522                root.removeAllNodes(); 
     523                domTree.updateTree(); 
     524            } 
     525        } 
     526    }//GEN-LAST:event_closeAllMenuItemActionPerformed 
     527 
     528    private void bulkMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bulkMenuItemActionPerformed 
     529 
     530        if (evt.getSource() == bulkMenuItem) { 
     531 
     532            fileLoadingActions.setNXConvertFile(nxconvertFile); 
     533            BulkLoadFilesFrame bulk = new BulkLoadFilesFrame(fileLoadingActions); 
     534            bulk.setVisible(true); 
     535 
     536        } 
     537 
     538    }//GEN-LAST:event_bulkMenuItemActionPerformed 
    674539 
    675540    /** 
     
    687552    } 
    688553    // Variables declaration - do not modify//GEN-BEGIN:variables 
     554    private javax.swing.JMenuItem aboutMenuItem; 
    689555    private javax.swing.JMenuItem bulkMenuItem; 
     556    private javax.swing.JMenuItem closeAllMenuItem; 
    690557    private javax.swing.JMenuItem closeFileMenuItem; 
    691558    private javax.swing.JOptionPane dialogReportProblem; 
     559    private javax.swing.JMenuItem exitAppMenuItem; 
     560    private javax.swing.JMenu fileMenu; 
    692561    private javax.swing.JMenuItem filterMenuItem; 
    693     private javax.swing.JMenu jMenu1; 
    694     private javax.swing.JMenu jMenu2; 
     562    private javax.swing.JMenu helpMenu; 
     563    private javax.swing.JMenuItem helpMenuItem; 
    695564    private javax.swing.JMenuBar jMenuBar1; 
    696565    private javax.swing.JPanel jPanel2; 
     
    700569    private javax.swing.JPopupMenu.Separator jSeparator2; 
    701570    private javax.swing.JPopupMenu.Separator jSeparator3; 
     571    private javax.swing.JPopupMenu.Separator jSeparator4; 
     572    private javax.swing.JPopupMenu.Separator jSeparator5; 
     573    private javax.swing.JPopupMenu.Separator jSeparator6; 
    702574    private javax.swing.JSplitPane jSplitPane1; 
    703575    private javax.swing.JTextPane jTextPane1; 
     
    705577    private javax.swing.JMenuItem openFilesMenuItem; 
    706578    private javax.swing.JMenuItem settingsMenuItem; 
     579    private javax.swing.JMenu toolsMenu; 
    707580    private javax.swing.JPopupMenu treePopupMenu; 
    708581    private javax.swing.JMenuItem validateSelectedMenuItem; 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/TreeUtils.java

    r1503 r1504  
    6767    public Document getReducedDoc(JTree tree) { 
    6868        if (getNode(tree) != null) { 
    69  
    7069            return getNode(tree).getReducedDoc(); 
    7170        } else { 
     
    7675    public Document getResultsDoc(JTree tree) { 
    7776        if (getNode(tree) != null) { 
    78  
    7977            return getNode(tree).getResultsDoc(); 
    8078        } else { 
  • trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/resources/nxvalidate.properties

    r1500 r1504  
    1010openNexusFileMessage=You need to select a Nexus file to open. 
    1111fileMenuItem=File 
    12 openSchemaFileMessage=You need to select a Schematron file to open. 
     12openSchemaFileMessage=You need to select an NXDL file to open. 
    1313applicationTitle=ISIS Nexus File Validation Tool 
    1414validationCompleteMessage=Validation Complete 
     
    2020noConvertCommandFound=No nxconvert command found, cannot validate. 
    2121defaultUNIXNXconvert2=/usr/bin/nxconvert 
     22closeAllWarningMessage=Are you sure you want to close all files? 
     23filesNotNexusError=Some files have been detected as not being Nexus/HDF files and have been unchecked in the include column. 
Note: See TracChangeset for help on using the changeset viewer.