Changeset 1504
- Timestamp:
- 13/08/10 16:34:17 (18 months ago)
- Location:
- trunk/applications/NXconvertpy
- Files:
-
- 5 added
- 12 edited
-
nbproject/build-impl.xml (modified) (1 diff)
-
nbproject/genfiles.properties (modified) (1 diff)
-
src/org/nexusformat/nxvalidate/BulkLoadFilesFrame.form (added)
-
src/org/nexusformat/nxvalidate/BulkLoadFilesFrame.java (added)
-
src/org/nexusformat/nxvalidate/CheckNexusFileType.java (added)
-
src/org/nexusformat/nxvalidate/FileLoadingActions.java (added)
-
src/org/nexusformat/nxvalidate/NXLoadFilesDialog.form (modified) (4 diffs)
-
src/org/nexusformat/nxvalidate/NXLoadFilesDialog.java (modified) (9 diffs)
-
src/org/nexusformat/nxvalidate/NXNodeMapper.java (modified) (1 diff)
-
src/org/nexusformat/nxvalidate/NXReducedToTree.java (modified) (1 diff)
-
src/org/nexusformat/nxvalidate/NXValidateDialog.java (modified) (3 diffs)
-
src/org/nexusformat/nxvalidate/NXconvert.java (modified) (4 diffs)
-
src/org/nexusformat/nxvalidate/NXvalidateFrame.form (modified) (4 diffs)
-
src/org/nexusformat/nxvalidate/NXvalidateFrame.java (modified) (26 diffs)
-
src/org/nexusformat/nxvalidate/TextPaneStyle.java (added)
-
src/org/nexusformat/nxvalidate/TreeUtils.java (modified) (2 diffs)
-
src/org/nexusformat/nxvalidate/resources/nxvalidate.properties (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/applications/NXconvertpy/nbproject/build-impl.xml
r1498 r1504 694 694 </fileset> 695 695 </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> 696 704 </target> 697 705 <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview"> -
trunk/applications/NXconvertpy/nbproject/genfiles.properties
r1498 r1504 5 5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 6 nbproject/build-impl.xml.data.CRC32=a5620c1d 7 nbproject/build-impl.xml.script.CRC32= 3c7842f38 nbproject/build-impl.xml.stylesheet.CRC32= 78c6a6ee@1.38.1.457 nbproject/build-impl.xml.script.CRC32=183f2507 8 nbproject/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" ?> 2 2 3 3 <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> … … 64 64 <Group type="103" groupAlignment="0" attributes="0"> 65 65 <Component id="nxsLabel" alignment="0" min="-2" max="-2" attributes="0"/> 66 <Component id="nxd cLabel" alignment="0" min="-2" max="-2" attributes="0"/>66 <Component id="nxdlLabel" alignment="0" min="-2" max="-2" attributes="0"/> 67 67 </Group> 68 68 <EmptySpace max="-2" attributes="0"/> … … 95 95 <EmptySpace min="-2" pref="28" max="-2" attributes="0"/> 96 96 <Group type="103" groupAlignment="3" attributes="0"> 97 <Component id="nxd cLabel" alignment="3" min="-2" max="-2" attributes="0"/>97 <Component id="nxdlLabel" alignment="3" min="-2" max="-2" attributes="0"/> 98 98 <Component id="nxdcTextField" alignment="3" min="-2" max="-2" attributes="0"/> 99 99 <Component id="openButton2" alignment="3" min="-2" max="-2" attributes="0"/> … … 128 128 </Events> 129 129 </Component> 130 <Component class="javax.swing.JLabel" name="nxd cLabel">130 <Component class="javax.swing.JLabel" name="nxdlLabel"> 131 131 <Properties> 132 <Property name="text" type="java.lang.String" value="Load NXD C:"/>132 <Property name="text" type="java.lang.String" value="Load NXDL:"/> 133 133 </Properties> 134 134 </Component> -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXLoadFilesDialog.java
r1498 r1504 21 21 22 22 private File nxs = null; 23 private File nxd c= null;23 private File nxdl = null; 24 24 private boolean OKButtonUsed = false; 25 25 /** Creates new form NXLoadFilesDialog */ … … 43 43 nxsTextField = new javax.swing.JTextField(); 44 44 openButton1 = new javax.swing.JButton(); 45 nxd cLabel = new javax.swing.JLabel();45 nxdlLabel = new javax.swing.JLabel(); 46 46 nxdcTextField = new javax.swing.JTextField(); 47 47 openButton2 = new javax.swing.JButton(); … … 66 66 }); 67 67 68 nxd cLabel.setText("Load NXDC:");68 nxdlLabel.setText("Load NXDL:"); 69 69 70 70 nxdcTextField.setEditable(false); … … 101 101 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 102 102 .addComponent(nxsLabel) 103 .addComponent(nxd cLabel))103 .addComponent(nxdlLabel)) 104 104 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 105 105 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) … … 109 109 .addGap(15, 15, 15) 110 110 .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()) 122 115 ); 123 116 jPanel1Layout.setVerticalGroup( … … 131 124 .addGap(28, 28, 28) 132 125 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 133 .addComponent(nxd cLabel)126 .addComponent(nxdlLabel) 134 127 .addComponent(nxdcTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 135 128 .addComponent(openButton2)) … … 179 172 180 173 if (returnVal == jFileChooser1.APPROVE_OPTION) { 181 nxd c= jFileChooser1.getSelectedFile();182 nxdcTextField.setText(nxd c.getAbsolutePath());183 nxdcTextField.setToolTipText(nxd c.getAbsolutePath());174 nxdl = jFileChooser1.getSelectedFile(); 175 nxdcTextField.setText(nxdl.getAbsolutePath()); 176 nxdcTextField.setToolTipText(nxdl.getAbsolutePath()); 184 177 } else { 185 nxd c= null;178 nxdl = null; 186 179 } 187 180 … … 207 200 return nxs; 208 201 } 209 public File getNXD CFile(){210 return nxd c;202 public File getNXDLFile(){ 203 return nxdl; 211 204 } 212 205 … … 237 230 private javax.swing.JFileChooser jFileChooser1; 238 231 private javax.swing.JPanel jPanel1; 239 private javax.swing.JLabel nxdcLabel;240 232 private javax.swing.JTextField nxdcTextField; 233 private javax.swing.JLabel nxdlLabel; 241 234 private javax.swing.JLabel nxsLabel; 242 235 private javax.swing.JTextField nxsTextField; -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXNodeMapper.java
r1503 r1504 374 374 } 375 375 376 public ArrayList<NXNodeMapper> getOpenNodes(){ 377 return documents; 378 } 379 380 public void removeAllNodes(){ 381 documents.clear(); 382 } 383 376 384 private class children implements Enumeration { 377 385 -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXReducedToTree.java
r1503 r1504 19 19 * This maps the NX Reduced XML Document (as a DOM document) to 20 20 * a JTree model. 21 * @author ser6521 * @author Stephen Rankin 22 22 */ 23 23 public class NXReducedToTree extends DefaultTreeModel { -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXValidateDialog.java
r1498 r1504 21 21 22 22 private File nxs = null; 23 private File nxd c= null;23 private File nxdl = null; 24 24 private boolean OKButtonUsed = false; 25 25 /** Creates new form NXLoadFilesDialog */ … … 134 134 135 135 if (returnVal == jFileChooser1.APPROVE_OPTION) { 136 nxd c= jFileChooser1.getSelectedFile();137 nxdcTextField.setText(nxd c.getAbsolutePath());138 nxdcTextField.setToolTipText(nxd c.getAbsolutePath());136 nxdl = jFileChooser1.getSelectedFile(); 137 nxdcTextField.setText(nxdl.getAbsolutePath()); 138 nxdcTextField.setToolTipText(nxdl.getAbsolutePath()); 139 139 } else { 140 nxd c= null;140 nxdl = null; 141 141 } 142 142 … … 160 160 161 161 162 public File getNXD CFile(){163 return nxd c;164 } 165 166 public void setNXD CFile(File file){167 nxd c= file;168 nxdcTextField.setText(nxd c.getAbsolutePath());162 public File getNXDLFile(){ 163 return nxdl; 164 } 165 166 public void setNXDLFile(File file){ 167 nxdl = file; 168 nxdcTextField.setText(nxdl.getAbsolutePath()); 169 169 } 170 170 -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXconvert.java
r1501 r1504 5 5 import java.util.logging.Level; 6 6 import java.util.logging.Logger; 7 import org.nexusformat.nxvalidate.exceptions.NXConvertpyException; 7 8 8 9 public class NXconvert { … … 41 42 } 42 43 43 public File convert() throws IOException, InterruptedException {44 public File convert() throws IOException, InterruptedException, NXConvertpyException { 44 45 45 46 Logger.getLogger(NXconvert.class.getName()).log( 46 47 Level.INFO, "Creating " + redfile.getAbsolutePath()); 47 48 // the command to run49 //String command = props.getProperty(NXCONVERT) +50 // " -d " + this.rawfile + " " + redfile;51 48 52 49 String command = ""; … … 54 51 command = convertFile.getAbsolutePath() + 55 52 " -d " + this.rawfile + " " + redfile;; 56 System.out.println(command);57 53 } 58 54 else{ … … 78 74 buffer.append("\" failed. Returned "); 79 75 buffer.append(exitValue); 80 throw new IOException(buffer.toString());76 throw new NXConvertpyException(buffer.toString()); 81 77 } 82 78 return redfile; -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/NXvalidateFrame.form
r1503 r1504 23 23 <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> 24 24 <SubComponents> 25 <Menu class="javax.swing.JMenu" name=" jMenu1">25 <Menu class="javax.swing.JMenu" name="fileMenu"> 26 26 <Properties> 27 27 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> … … 38 38 </Events> 39 39 </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> 40 60 </SubComponents> 41 61 </Menu> 42 <Menu class="javax.swing.JMenu" name=" jMenu2">62 <Menu class="javax.swing.JMenu" name="toolsMenu"> 43 63 <Properties> 44 64 <Property name="text" type="java.lang.String" value="Tools"/> … … 66 86 <Property name="text" type="java.lang.String" value="Bulk Validation"/> 67 87 </Properties> 88 <Events> 89 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bulkMenuItemActionPerformed"/> 90 </Events> 68 91 </MenuItem> 69 92 <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator3"> … … 76 99 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="settingsMenuItemActionPerformed"/> 77 100 </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> 78 120 </MenuItem> 79 121 </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 11 28 package org.nexusformat.nxvalidate; 12 29 13 import java.awt.Color;14 30 import java.awt.Dialog.ModalityType; 15 31 import java.awt.event.MouseListener; … … 21 37 import java.util.logging.Level; 22 38 import java.util.logging.Logger; 39 import javax.swing.JOptionPane; 23 40 import 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;29 41 import javax.swing.tree.MutableTreeNode; 42 import javax.swing.tree.TreePath; 30 43 import javax.xml.parsers.DocumentBuilder; 31 44 import javax.xml.parsers.DocumentBuilderFactory; 32 45 import javax.xml.parsers.ParserConfigurationException; 33 import org.nexusformat.nxvalidate.exceptions.NXConvertpyException;34 46 import org.w3c.dom.Document; 35 import org.xml.sax.SAXException;36 47 37 48 /** … … 45 56 private NXReducedToTree domTree = null; 46 57 private NXNodeMapper root = null; 47 private ValidatorUtils validator = null;48 58 private ResourceBundle bundle = null; 49 59 private File nxsFile = null; 50 private File nxd cFile = null;60 private File nxdlFile = null; 51 61 private File reducedFile = null; 52 62 private File resultsFile = null; 53 63 private TreeUtils treeUtils = null; 54 private ArrayList<Report> reports;55 64 private UserSettings settings = null; 56 65 private File nxconvertFile = null; 57 66 private boolean foundNXconvert = false; 58 67 private MouseListener popupListener = null; 68 private TextPaneStyle txtStyle = null; 69 private FileLoadingActions fileLoadingActions = null; 70 59 71 /** Creates new form NXvalidateFrame */ 60 72 public NXvalidateFrame() { … … 96 108 nxconvertFile = settings.getNXconvert(); 97 109 98 if (!settings.foundNXconvert()){110 if (!settings.foundNXconvert()) { 99 111 displayErrorMessage( 100 bundle.getString("nxconvertMissingError"));112 bundle.getString("nxconvertMissingError")); 101 113 foundNXconvert = false; 102 } 103 else{ 114 } else { 104 115 foundNXconvert = true; 105 116 } … … 117 128 jTree1.addMouseListener(popupListener); 118 129 119 130 txtStyle = new TextPaneStyle(jTextPane1); 131 132 fileLoadingActions = new FileLoadingActions(this, jTree1, builder, domTree, root); 133 120 134 } 121 135 … … 139 153 jTextPane1 = new javax.swing.JTextPane(); 140 154 jMenuBar1 = new javax.swing.JMenuBar(); 141 jMenu1= new javax.swing.JMenu();155 fileMenu = new javax.swing.JMenu(); 142 156 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(); 144 162 validateSelectedMenuItem = new javax.swing.JMenuItem(); 145 163 jSeparator2 = new javax.swing.JPopupMenu.Separator(); … … 149 167 jSeparator3 = new javax.swing.JPopupMenu.Separator(); 150 168 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(); 151 173 152 174 closeFileMenuItem.setText("Close File"); … … 197 219 getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); 198 220 199 jMenu1.setText(bundle.getString("fileMenuItem")); // NOI18N221 fileMenu.setText(bundle.getString("fileMenuItem")); // NOI18N 200 222 201 223 openFilesMenuItem.setText("Open Files"); … … 205 227 } 206 228 }); 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"); 212 252 213 253 validateSelectedMenuItem.setText("Validate Selected"); … … 217 257 } 218 258 }); 219 jMenu2.add(validateSelectedMenuItem);220 jMenu2.add(jSeparator2);259 toolsMenu.add(validateSelectedMenuItem); 260 toolsMenu.add(jSeparator2); 221 261 222 262 filterMenuItem.setText("Filter Good Values"); 223 jMenu2.add(filterMenuItem);224 jMenu2.add(jSeparator1);263 toolsMenu.add(filterMenuItem); 264 toolsMenu.add(jSeparator1); 225 265 226 266 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); 229 274 230 275 settingsMenuItem.setText("Settings"); … … 234 279 } 235 280 }); 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); 239 295 240 296 setJMenuBar(jMenuBar1); … … 252 308 dialogReportProblem.showMessageDialog(this, ta); 253 309 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 file265 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 }292 310 } 293 311 … … 298 316 loadFile.setVisible(true); 299 317 nxsFile = loadFile.getNXSFile(); 300 nxd cFile = loadFile.getNXDCFile();318 nxdlFile = loadFile.getNXDLFile(); 301 319 return loadFile.OKButtonUsed(); 302 320 … … 307 325 NXValidateDialog loadValidate = new NXValidateDialog(this, true); 308 326 loadValidate.setModalityType(ModalityType.APPLICATION_MODAL); 309 if (nxd cFile != null) {310 loadValidate.setNXD CFile(nxdcFile);327 if (nxdlFile != null) { 328 loadValidate.setNXDLFile(nxdlFile); 311 329 } 312 330 loadValidate.setVisible(true); 313 nxd cFile = loadValidate.getNXDCFile();331 nxdlFile = loadValidate.getNXDLFile(); 314 332 return loadValidate.OKButtonUsed(); 315 333 … … 333 351 if (evt.getSource() == openFilesMenuItem) { 334 352 335 if (!foundNXconvert){353 if (!foundNXconvert) { 336 354 displayErrorMessage( 337 bundle.getString("nxconvertMissingError"));355 bundle.getString("nxconvertMissingError")); 338 356 return; 339 357 } … … 343 361 if (result) { 344 362 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(); 346 368 } else { 347 369 dialogReportProblem.showMessageDialog(this, … … 359 381 NXNodeMapper node = 360 382 (NXNodeMapper) jTree1.getSelectionPath().getLastPathComponent(); 361 updateTextPane(node); 362 383 txtStyle.updateTextPane(node); 363 384 } 364 385 } … … 370 391 if (evt.getSource() == validateSelectedMenuItem) { 371 392 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) { 373 408 displayErrorMessage( 374 bundle.getString("nxconvertMissingError"));409 bundle.getString("nxconvertMissingError")); 375 410 return; 376 411 } … … 383 418 //current selected tree. 384 419 if (treeUtils.getNXDCFile(jTree1) != null) { 385 nxd cFile = treeUtils.getNXDCFile(jTree1);420 nxdlFile = treeUtils.getNXDCFile(jTree1); 386 421 } 387 422 … … 400 435 401 436 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(); 456 450 457 451 } else { … … 459 453 bundle.getString("openSchemaFileMessage")); 460 454 455 461 456 } 462 457 } … … 479 474 } 480 475 481 if (!foundNXconvert){476 if (!foundNXconvert) { 482 477 displayErrorMessage( 483 bundle.getString("nxconvertMissingError"));478 bundle.getString("nxconvertMissingError")); 484 479 return; 485 480 } … … 490 485 491 486 private void closeFileMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeFileMenuItemActionPerformed 492 487 493 488 if (evt.getSource() == closeFileMenuItem) { 494 489 495 490 NXNodeMapper node = treeUtils.getBaseNode(jTree1); 496 if (node!=null){497 if (!node.isRoot()){491 if (node != null) { 492 if (!node.isRoot()) { 498 493 root.removeNode(node); 499 domTree.removeNodeFromParent((MutableTreeNode) node);494 domTree.removeNodeFromParent((MutableTreeNode) node); 500 495 domTree.updateTree(); 501 496 } 502 497 } 503 504 498 505 499 } 506 500 }//GEN-LAST:event_closeFileMenuItemActionPerformed 507 501 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)); 587 521 } 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 674 539 675 540 /** … … 687 552 } 688 553 // Variables declaration - do not modify//GEN-BEGIN:variables 554 private javax.swing.JMenuItem aboutMenuItem; 689 555 private javax.swing.JMenuItem bulkMenuItem; 556 private javax.swing.JMenuItem closeAllMenuItem; 690 557 private javax.swing.JMenuItem closeFileMenuItem; 691 558 private javax.swing.JOptionPane dialogReportProblem; 559 private javax.swing.JMenuItem exitAppMenuItem; 560 private javax.swing.JMenu fileMenu; 692 561 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; 695 564 private javax.swing.JMenuBar jMenuBar1; 696 565 private javax.swing.JPanel jPanel2; … … 700 569 private javax.swing.JPopupMenu.Separator jSeparator2; 701 570 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; 702 574 private javax.swing.JSplitPane jSplitPane1; 703 575 private javax.swing.JTextPane jTextPane1; … … 705 577 private javax.swing.JMenuItem openFilesMenuItem; 706 578 private javax.swing.JMenuItem settingsMenuItem; 579 private javax.swing.JMenu toolsMenu; 707 580 private javax.swing.JPopupMenu treePopupMenu; 708 581 private javax.swing.JMenuItem validateSelectedMenuItem; -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/TreeUtils.java
r1503 r1504 67 67 public Document getReducedDoc(JTree tree) { 68 68 if (getNode(tree) != null) { 69 70 69 return getNode(tree).getReducedDoc(); 71 70 } else { … … 76 75 public Document getResultsDoc(JTree tree) { 77 76 if (getNode(tree) != null) { 78 79 77 return getNode(tree).getResultsDoc(); 80 78 } else { -
trunk/applications/NXconvertpy/src/org/nexusformat/nxvalidate/resources/nxvalidate.properties
r1500 r1504 10 10 openNexusFileMessage=You need to select a Nexus file to open. 11 11 fileMenuItem=File 12 openSchemaFileMessage=You need to select a Schematronfile to open.12 openSchemaFileMessage=You need to select an NXDL file to open. 13 13 applicationTitle=ISIS Nexus File Validation Tool 14 14 validationCompleteMessage=Validation Complete … … 20 20 noConvertCommandFound=No nxconvert command found, cannot validate. 21 21 defaultUNIXNXconvert2=/usr/bin/nxconvert 22 closeAllWarningMessage=Are you sure you want to close all files? 23 filesNotNexusError=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.
