Coverage Report - us.daveread.utility.formatcheck.gui.FormatCheckFrame
 
Classes in this File Line Coverage Branch Coverage Complexity
FormatCheckFrame
0%
0/481
0%
0/72
2.868
 
 1  
 package us.daveread.utility.formatcheck.gui;
 2  
 
 3  
 import javax.swing.JFrame;
 4  
 import java.awt.HeadlessException;
 5  
 import java.awt.*;
 6  
 import java.awt.event.*;
 7  
 import javax.swing.*;
 8  
 import javax.swing.border.*;
 9  
 import java.util.*;
 10  
 import java.io.*;
 11  
 import java.text.DecimalFormat;
 12  
 import java.text.NumberFormat;
 13  
 import us.daveread.utility.formatcheck.ConstantsInterface;
 14  
 import us.daveread.utility.formatcheck.images.ImageUtility;
 15  
 import us.daveread.utility.formatcheck.print.Print;
 16  
 import us.daveread.utility.formatcheck.format.*;
 17  
 import us.daveread.utility.formatcheck.util.Configuration;
 18  
 import us.daveread.utility.sixsigma.SigmaCalculator;
 19  
 import us.daveread.utility.sixsigma.gui.SigmaCalculatorDialog;
 20  
 import org.apache.log4j.Logger;
 21  
 import org.apache.log4j.PropertyConfigurator;
 22  
 
 23  
 /**
 24  
  * <p>Title: FormatCheckFrame
 25  
  * <p>Description: GUI for user interaction with the FormatCheck utility
 26  
  * <p>Copyright: Copyright (c) 2005
 27  
  * <p>This program is free software; you can redistribute it and/or modify
 28  
  * it under the terms of the GNU General Public License as published by
 29  
  * the Free Software Foundation; either version 2 of the License, or
 30  
  * (at your option) any later version.
 31  
  * <p>This program is distributed in the hope that it will be useful,
 32  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 33  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 34  
  * GNU General Public License for more details.
 35  
  * <p>You should have received a copy of the GNU General Public License
 36  
  * along with this program; if not, write to the Free Software
 37  
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 38  
  * </p>
 39  
  *
 40  
  * @author David Read
 41  
  * @version $Id: FormatCheckFrame.java,v 1.3 2006/06/14 23:34:01 daveread Exp $
 42  
  */
 43  
 public class FormatCheckFrame extends JFrame implements ActionListener,
 44  
         WindowListener, Runnable {
 45  
 
 46  
     /** Logger configuration file name */
 47  
     private final static String FILENAME_LOGGER = "FormatCheck.Logger";
 48  
 
 49  
     /** File name of application's icon file - must be in the
 50  
      *  us.daveread.utility.formatcheck.images package
 51  
      */
 52  
     public final static String ICON = "FormatCheckIcon.gif";
 53  
 
 54  
     /** The directory, relative to the application execution directory,
 55  
      *  containing the XML files woith the format definitions.
 56  
      */
 57  
     public final static String FORMAT_DIR = "Formats";
 58  
 
 59  
     /** The set of known format types, loaded form the format type XML files */
 60  
     private Map formatTypes;
 61  
 
 62  
     /** Collection of record numbers with errors reported on latest run */
 63  
     private java.util.List lastErrorRecords;
 64  
 
 65  
     /** The combobox allowing the user to choose a format to apply */
 66  
     private JComboBox formatTypeChoice;
 67  
 
 68  
     /** The label to display the chosen input file name */
 69  
     private JLabel fileNameChoice;
 70  
 
 71  
     /** The button used to open the File-Open dialog, to choose an input file */
 72  
     private JButton fileNameFileDialogButton;
 73  
 
 74  
     /** The button used to run the validation against the chosen input file */
 75  
     private JButton runButton;
 76  
 
 77  
     /** Display area for all validation messages */
 78  
     private JTextArea resultsDisplay;
 79  
 
 80  
     /** Display area for brief status messages */
 81  
     private JLabel statusDisplay;
 82  
 
 83  
     /** The file chosen for validation */
 84  
     private File fileChosen;
 85  
 
 86  
     /** Menu item to save results to a file */
 87  
     private JMenuItem menuFileSave;
 88  
 
 89  
     /** Menu item to print results */
 90  
     private JMenuItem menuFilePrint;
 91  
 
 92  
     /** Menu item to print parsed records */
 93  
     private JMenuItem menuFilePrintRecords;
 94  
 
 95  
     /** Menu item to print parsed records that had errors */
 96  
     private JMenuItem menuFilePrintErrorRecords;
 97  
 
 98  
     /** Menu item to exit program */
 99  
     private JMenuItem menuFileExit;
 100  
 
 101  
     /** Menu item to copy selected results to clipboard */
 102  
     private JMenuItem menuEditCopy;
 103  
 
 104  
     /** Menu item to select all results */
 105  
     private JMenuItem menuEditSelectAll;
 106  
 
 107  
     /** Menu item to open the sigma calculator */
 108  
     private JMenuItem menuToolsSigmaCalculator;
 109  
 
 110  
     /** Menu item to refresh XML format definitions */
 111  
     private JMenuItem menuToolsReloadFormats;
 112  
 
 113  
     /** Menu item to display the application "About" box */
 114  
     private JMenuItem menuHelpAbout;
 115  
 
 116  
     /** Logger */
 117  0
     private static final Logger logger = Logger.getLogger(FormatCheckFrame.class);
 118  
 
 119  
     /**
 120  
      * Creates and shows the GUI
 121  
      *
 122  
      * @throws HeadlessException If there is no graphical device present
 123  
      */
 124  0
     public FormatCheckFrame() throws HeadlessException {
 125  0
         setupLogger();
 126  
 
 127  0
         addWindowListener(this);
 128  0
         setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
 129  
 
 130  0
         setTitle("FormatCheck");
 131  
         try {
 132  0
             this.setIconImage(new ImageIcon(ImageUtility.getImageAsByteArray(
 133  
                     ICON)).getImage());
 134  0
         } catch (Exception excAny) {
 135  0
             logger.error("Failed to set icon", excAny);
 136  0
         }
 137  
 
 138  0
         setup();
 139  
 
 140  0
         center(this, null);
 141  
 
 142  0
         setVisible(true);
 143  0
     }
 144  
 
 145  
     /**
 146  
      * Main GUI setup.  Loads the format types and creates the GUI widgets.
 147  
      */
 148  
     private void setup() {
 149  0
         setupGUI();
 150  0
         setupFormatTypes();
 151  0
         setControls();
 152  0
     }
 153  
 
 154  
     /**
 155  
      * Configure the logger
 156  
      */
 157  
     private void setupLogger() {
 158  0
         PropertyConfigurator.configure(Configuration.instance().getFile(
 159  
                 FILENAME_LOGGER).getAbsolutePath());
 160  
 
 161  0
         if (logger.isDebugEnabled()) {
 162  0
             Properties props = System.getProperties();
 163  0
             Set keys = props.keySet();
 164  0
             Iterator keyItr = keys.iterator();
 165  
 
 166  0
             while (keyItr.hasNext()) {
 167  0
                 String key = (String) keyItr.next();
 168  0
                 logger.debug("Prop: [" + key + "]=[" + System.getProperty(key) +
 169  
                              "]");
 170  
             }
 171  
         }
 172  0
     }
 173  
 
 174  
 
 175  
     /**
 176  
      * Creates, populates and arranges the GUI widgets.
 177  
      */
 178  
     private void setupGUI() {
 179  
         JPanel mainPanel;
 180  
         JPanel tempPanel;
 181  
         JPanel innerPanel;
 182  
 
 183  0
         setupMenu();
 184  
 
 185  0
         getContentPane().setLayout(new BorderLayout());
 186  
 
 187  0
         mainPanel = new JPanel();
 188  0
         mainPanel.setLayout(new BorderLayout());
 189  
 
 190  
         // Upper area - controls
 191  0
         tempPanel = new JPanel();
 192  0
         tempPanel.setLayout(new GridLayout(0, 1));
 193  
 
 194  
         // Format Type Selection
 195  0
         formatTypeChoice = new JComboBox();
 196  0
         innerPanel = new JPanel();
 197  0
         innerPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
 198  0
         innerPanel.add(formatTypeChoice);
 199  0
         formatTypeChoice.addActionListener(this);
 200  0
         tempPanel.add(innerPanel);
 201  
 
 202  
         // Input File Selection
 203  0
         innerPanel = new JPanel();
 204  0
         innerPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
 205  0
         innerPanel.add(fileNameFileDialogButton = new JButton("Choose File..."));
 206  0
         fileNameFileDialogButton.setMnemonic('C');
 207  0
         fileNameFileDialogButton.addActionListener(this);
 208  0
         innerPanel.add(fileNameChoice = new JLabel());
 209  0
         tempPanel.add(innerPanel);
 210  
 
 211  
         // Run button
 212  0
         innerPanel = new JPanel();
 213  0
         innerPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
 214  0
         innerPanel.add(runButton = new JButton("Verify File"));
 215  0
         runButton.setMnemonic('V');
 216  0
         runButton.addActionListener(this);
 217  0
         tempPanel.add(innerPanel);
 218  
 
 219  0
         tempPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
 220  
 
 221  
         // Add controls to top of panel
 222  0
         mainPanel.add(tempPanel, BorderLayout.NORTH);
 223  
 
 224  
         // Add message area to center of panel
 225  0
         mainPanel.add(new JScrollPane(resultsDisplay = new JTextArea(20, 50)),
 226  
                 BorderLayout.CENTER);
 227  0
         resultsDisplay.setEditable(false);
 228  
 
 229  
         // Add status display to bottom of panel
 230  0
         tempPanel = new JPanel();
 231  0
         tempPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 232  0
         tempPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
 233  0
         tempPanel.add(statusDisplay = new JLabel());
 234  0
         statusDisplay.setFont(new Font(statusDisplay.getFont().getName(),
 235  
                                        statusDisplay.getFont().getStyle(), 9));
 236  0
         mainPanel.add(tempPanel, BorderLayout.SOUTH);
 237  
 
 238  
         // Add all controls (entire panel) to center of window
 239  0
         getContentPane().add(mainPanel, BorderLayout.CENTER);
 240  
 
 241  0
         pack();
 242  0
     }
 243  
 
 244  
     /**
 245  
      * Populate the combobox with the known format types
 246  
      */
 247  
     private void populateFormatTypes() {
 248  
         java.util.List lFormatTypes;
 249  
         Iterator lFormatType;
 250  
 
 251  0
         formatTypeChoice.removeAllItems();
 252  
 
 253  0
         lFormatTypes = new ArrayList();
 254  0
         lFormatType = formatTypes.values().iterator();
 255  0
         while (lFormatType.hasNext()) {
 256  0
             lFormatTypes.add(lFormatType.next());
 257  
         }
 258  0
         Collections.sort(lFormatTypes);
 259  
 
 260  
         // Place the "Choose One... selection at the top of the list
 261  0
         lFormatTypes.add(0, new FormatType("Choose a Format Type...", "N/A"));
 262  0
         lFormatType = lFormatTypes.iterator();
 263  
 
 264  0
         while (lFormatType.hasNext()) {
 265  0
             formatTypeChoice.addItem(lFormatType.next());
 266  
         }
 267  0
     }
 268  
 
 269  
     /**
 270  
      * Creates the application's menu
 271  
      */
 272  
     private void setupMenu() {
 273  
         JMenuBar menuBar;
 274  
         JMenu menu;
 275  
 
 276  0
         menuBar = new JMenuBar();
 277  0
         setJMenuBar(menuBar);
 278  
 
 279  
         // File Menu
 280  0
         menu = new JMenu("File");
 281  0
         menu.setMnemonic(KeyEvent.VK_F);
 282  0
         menu.getAccessibleContext().setAccessibleDescription(
 283  
                 "Menu items related to report file access");
 284  0
         menuBar.add(menu);
 285  
 
 286  
         // File | Save
 287  0
         menuFileSave = new JMenuItem("Save Results");
 288  0
         menuFileSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
 289  
                 ActionEvent.CTRL_MASK));
 290  0
         menuFileSave.setMnemonic(KeyEvent.VK_S);
 291  0
         menuFileSave.getAccessibleContext().setAccessibleDescription(
 292  
                 "Save results to a file");
 293  0
         menuFileSave.addActionListener(this);
 294  0
         menu.add(menuFileSave);
 295  
 
 296  0
         menu.addSeparator();
 297  
 
 298  
         // File | Print
 299  0
         menuFilePrint = new JMenuItem("Print Results");
 300  0
         menuFilePrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,
 301  
                 ActionEvent.CTRL_MASK));
 302  0
         menuFilePrint.setMnemonic(KeyEvent.VK_P);
 303  0
         menuFilePrint.getAccessibleContext().setAccessibleDescription(
 304  
                 "Print results to a printer");
 305  0
         menuFilePrint.addActionListener(this);
 306  0
         menu.add(menuFilePrint);
 307  
 
 308  0
         menu.addSeparator();
 309  
 
 310  
         // File | Print Parsed Records
 311  0
         menuFilePrintRecords = new JMenuItem("Print Records");
 312  0
         menuFilePrintRecords.setMnemonic(KeyEvent.VK_R);
 313  0
         menuFilePrintRecords.getAccessibleContext().setAccessibleDescription(
 314  
                 "Print records based on user-supplied record numbers");
 315  0
         menuFilePrintRecords.addActionListener(this);
 316  0
         menu.add(menuFilePrintRecords);
 317  
 
 318  
         // File | Print Error Records
 319  0
         menuFilePrintErrorRecords = new JMenuItem("Print Records with Errors");
 320  0
         menuFilePrintErrorRecords.setMnemonic(KeyEvent.VK_E);
 321  0
         menuFilePrintErrorRecords.getAccessibleContext().
 322  
                 setAccessibleDescription(
 323  
                         "Print parsed records that had errors to a printer");
 324  0
         menuFilePrintErrorRecords.addActionListener(this);
 325  0
         menu.add(menuFilePrintErrorRecords);
 326  
 
 327  0
         menu.addSeparator();
 328  
 
 329  
         // File | Exit
 330  0
         menuFileExit = new JMenuItem("Exit");
 331  0
         menuFileExit.setMnemonic(KeyEvent.VK_X);
 332  0
         menuFileExit.getAccessibleContext().setAccessibleDescription(
 333  
                 "Close the FormatCheck application");
 334  0
         menuFileExit.addActionListener(this);
 335  0
         menu.add(menuFileExit);
 336  
 
 337  
         // Edit Menu
 338  0
         menu = new JMenu("Edit");
 339  0
         menu.setMnemonic(KeyEvent.VK_E);
 340  0
         menu.getAccessibleContext().setAccessibleDescription(
 341  
                 "REsults access menu items");
 342  0
         menuBar.add(menu);
 343  
 
 344  
         // Edit | Copy
 345  0
         menuEditCopy = new JMenuItem("Copy");
 346  0
         menuEditCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
 347  
                 ActionEvent.CTRL_MASK));
 348  0
         menuEditCopy.setMnemonic(KeyEvent.VK_C);
 349  0
         menuEditCopy.getAccessibleContext().setAccessibleDescription(
 350  
                 "Copy the selected results");
 351  0
         menuEditCopy.addActionListener(this);
 352  0
         menu.add(menuEditCopy);
 353  
 
 354  0
         menu.addSeparator();
 355  
 
 356  
         // Edit | Select All
 357  0
         menuEditSelectAll = new JMenuItem("Select All");
 358  0
         menuEditSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
 359  
                 ActionEvent.CTRL_MASK));
 360  0
         menuEditSelectAll.setMnemonic(KeyEvent.VK_A);
 361  0
         menuEditSelectAll.getAccessibleContext().setAccessibleDescription(
 362  
                 "Copy the selected results");
 363  0
         menuEditSelectAll.addActionListener(this);
 364  0
         menu.add(menuEditSelectAll);
 365  
 
 366  
         // Tools Menu
 367  0
         menu = new JMenu("Tools");
 368  0
         menu.setMnemonic(KeyEvent.VK_T);
 369  0
         menu.getAccessibleContext().setAccessibleDescription(
 370  
                 "Utility menu items");
 371  0
         menuBar.add(menu);
 372  
 
 373  
         // Tools | Sigma Calculator
 374  0
         menuToolsSigmaCalculator = new JMenuItem("Sigma Calculator");
 375  0
         menuToolsSigmaCalculator.setMnemonic(KeyEvent.VK_C);
 376  0
         menuToolsSigmaCalculator.getAccessibleContext().
 377  
                 setAccessibleDescription(
 378  
                         "Basic Sigma Calculator");
 379  0
         menuToolsSigmaCalculator.addActionListener(this);
 380  0
         menu.add(menuToolsSigmaCalculator);
 381  
 
 382  0
         menu.addSeparator();
 383  
 
 384  
         // Tools | Reload Definitions
 385  0
         menuToolsReloadFormats = new JMenuItem("Reload Definitions");
 386  0
         menuToolsReloadFormats.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.
 387  
                 VK_R,
 388  
                 ActionEvent.ALT_MASK));
 389  0
         menuToolsReloadFormats.setMnemonic(KeyEvent.VK_R);
 390  0
         menuToolsReloadFormats.getAccessibleContext().setAccessibleDescription(
 391  
                 "Reload the format definitions");
 392  0
         menuToolsReloadFormats.addActionListener(this);
 393  0
         menu.add(menuToolsReloadFormats);
 394  
 
 395  
         // Help Menu
 396  0
         menu = new JMenu("Help");
 397  0
         menu.setMnemonic(KeyEvent.VK_H);
 398  0
         menu.getAccessibleContext().setAccessibleDescription(
 399  
                 "Usage and support information");
 400  0
         menuBar.add(menu);
 401  
 
 402  
         // Help | About
 403  0
         menuHelpAbout = new JMenuItem("About");
 404  0
         menuHelpAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
 405  
                 ActionEvent.ALT_MASK));
 406  0
         menuHelpAbout.setMnemonic(KeyEvent.VK_A);
 407  0
         menuHelpAbout.getAccessibleContext().setAccessibleDescription(
 408  
                 "Application information");
 409  0
         menuHelpAbout.addActionListener(this);
 410  0
         menu.add(menuHelpAbout);
 411  0
     }
 412  
 
 413  
     /**
 414  
      * Enables and disables widgets based on state of data.
 415  
      */
 416  
     private void setControls() {
 417  0
         fileNameFileDialogButton.setEnabled(formatTypeChoice.getSelectedIndex() !=
 418  
                                             0);
 419  0
         runButton.setEnabled(formatTypeChoice.getSelectedIndex() != 0 &&
 420  
                              fileChosen != null);
 421  0
         if (fileChosen == null) {
 422  0
             fileNameChoice.setText(fileNameFileDialogButton.isEnabled() ?
 423  
                                    "Please Select A File For Processing" : "");
 424  
         } else {
 425  0
             fileNameChoice.setText(fileChosen.getName());
 426  
         }
 427  
 
 428  0
         menuFileSave.setEnabled(resultsDisplay.getText().length() > 0);
 429  0
         menuFilePrintRecords.setEnabled(runButton.isEnabled());
 430  0
         menuFilePrintErrorRecords.setEnabled(runButton.isEnabled() &&
 431  
                                              lastErrorRecords.size() > 0);
 432  0
         menuFilePrint.setEnabled(menuFileSave.isEnabled());
 433  
 
 434  0
         menuEditCopy.setEnabled(menuFileSave.isEnabled());
 435  0
         menuEditSelectAll.setEnabled(menuFileSave.isEnabled());
 436  
 
 437  0
         clearStatusMessage();
 438  0
     }
 439  
 
 440  
     /**
 441  
      * Loads the format types from the XML format definition files.
 442  
      */
 443  
     private void setupFormatTypes() {
 444  
         FormatType oneType;
 445  
         String errors;
 446  
 
 447  0
         formatTypes = new HashMap();
 448  
 
 449  0
         File files[] = new File(FORMAT_DIR).listFiles();
 450  
 
 451  0
         for (int fileNum = 0; fileNum < files.length; ++fileNum) {
 452  0
             if (files[fileNum].getName().toLowerCase().endsWith(".xml")) {
 453  0
                 oneType = new FormatTypeParser(files[fileNum]);
 454  
 
 455  
                 // Error handling
 456  0
                 errors = ((FormatTypeParser) oneType).getErrorMessages();
 457  0
                 if (errors.length() == 0) {
 458  0
                     formatTypes.put(oneType.getName(), oneType);
 459  0
                     logger.debug("Added format type[" + oneType.getName() + "]");
 460  0
                     logger.debug("First Record Type[" +
 461  
                                  oneType.getRecordType(0).getDescription() +
 462  
                                  "]");
 463  0
                     logger.debug("First Field Name[" +
 464  
                                  oneType.getRecordType(0).getFieldType(0).
 465  
                                  getName() + "]");
 466  0
                     logger.debug("First Field DataType Description[" +
 467  
                                  oneType.getRecordType(0).getFieldType(0).
 468  
                                  getDataType().getDescription() + "]");
 469  
                 } else {
 470  
                     // Errors to report
 471  
                     // Add XML file name to beginning of set of errors
 472  
                     //errors = Utils.characterInsert(errors, "\n", 60, 90, " ,:;");
 473  
                     // Only keep the first five errors, otherwise the dialog box gets
 474  
                     // too tall and the user cannot see the OK button;
 475  
                     //String errorsParsed[] = errors.split("\n");
 476  
                     //if (errorsParsed.length > 5) {
 477  
                     //  errors = "";
 478  
                     //  for (int line = 0;line < 5;++line) {
 479  
                     //    errors += errorsParsed[line] + "\n";
 480  
                     //  }
 481  
                     //}
 482  
                     //errors = Utils.characterInsert(errors, "\n", 60, 90, " ,:;");
 483  0
                     errors =
 484  
                             "Errors Occured During Setup\n\nFormat File Name: " +
 485  
                             files[fileNum].getName() + "\n\n" + errors;
 486  0
                     JTextArea message = new JTextArea(errors, 20, 60);
 487  0
                     message.setLineWrap(true);
 488  0
                     message.setWrapStyleWord(true);
 489  0
                     JOptionPane.showMessageDialog(this,
 490  
                                                   new JScrollPane(message),
 491  
                                                   "XML Format File Errors",
 492  
                                                   JOptionPane.ERROR_MESSAGE);
 493  
                 }
 494  
             }
 495  
         }
 496  
 
 497  0
         populateFormatTypes();
 498  0
         clearErrorRecords();
 499  0
         setControls();
 500  0
     }
 501  
 
 502  
     /**
 503  
      * Adds a message to the results display, moving the cursor to the new
 504  
      * end position (causing the new message to scroll onto the visible area
 505  
      * if it was off the bottom).
 506  
      *
 507  
      * @param message String The message being appended into the message area
 508  
      */
 509  
     private void appendResult(String message) {
 510  0
         resultsDisplay.append(message);
 511  0
         resultsDisplay.setCaretPosition(resultsDisplay.getText().length());
 512  0
     }
 513  
 
 514  
     /**
 515  
      * Clears the results display.
 516  
      */
 517  
     private void clearResult() {
 518  0
         resultsDisplay.setText("");
 519  0
     }
 520  
 
 521  
     /**
 522  
      * Sets the message in the status message widget.
 523  
      *
 524  
      * @param aMessage String The status message
 525  
      */
 526  
     private void setStatusMessage(String aMessage) {
 527  0
         statusDisplay.setText(aMessage);
 528  0
     }
 529  
 
 530  
     /**
 531  
      * Clears the status message widget.
 532  
      */
 533  
     private void clearStatusMessage() {
 534  0
         statusDisplay.setText(" ");
 535  0
     }
 536  
 
 537  
     /**
 538  
      * Centers a window on the parent window or the screen.  If the parent
 539  
      * is null, or smaller than the child, the child is centered on the
 540  
      * screen.
 541  
      *
 542  
      * @param winaChild The window being centered.
 543  
      * @param winaParent The parent window, or null if no parent frame exists.
 544  
      */
 545  
     public static void center(Window winaChild, Window winaParent) {
 546  
         Dimension dimlParentSize, dimlMySize;
 547  
         Point ptlUpperLeft;
 548  
         int ilX, ilY;
 549  0
         dimlMySize = winaChild.getSize();
 550  0
         if (winaParent == null) {
 551  0
             dimlParentSize = Toolkit.getDefaultToolkit().getScreenSize();
 552  0
             ptlUpperLeft = new Point(0, 0);
 553  
         } else {
 554  0
             dimlParentSize = winaParent.getSize();
 555  0
             ptlUpperLeft = winaParent.getLocation();
 556  
 
 557  0
             if (dimlMySize.width >= dimlParentSize.width ||
 558  
                 dimlMySize.height >= dimlParentSize.height) {
 559  0
                 dimlParentSize = Toolkit.getDefaultToolkit().getScreenSize();
 560  0
                 ptlUpperLeft = new Point(0, 0);
 561  
             }
 562  
         }
 563  0
         if (dimlParentSize.width >= dimlMySize.width) {
 564  0
             ilX = (dimlParentSize.width - dimlMySize.width) / 2;
 565  
         } else {
 566  0
             ilX = 0;
 567  
         }
 568  0
         if (dimlParentSize.height >= dimlMySize.height) {
 569  0
             ilY = (dimlParentSize.height - dimlMySize.height) / 2;
 570  
         } else {
 571  0
             ilY = 0;
 572  
         }
 573  0
         ilX += ptlUpperLeft.x;
 574  0
         ilY += ptlUpperLeft.y;
 575  0
         winaChild.setLocation(ilX, ilY);
 576  0
     }
 577  
 
 578  
     /**
 579  
      * Allows the user to choose a file to be validated.
 580  
      */
 581  
     private void chooseFile() {
 582  
         JFileChooser fileChooser;
 583  
         int returnValue;
 584  
 
 585  0
         if (fileChosen != null) {
 586  0
             fileChooser = new JFileChooser(fileChosen.getParentFile());
 587  0
             fileChooser.setSelectedFile(fileChosen);
 588  
         } else {
 589  0
             fileChooser = new JFileChooser();
 590  
         }
 591  
 
 592  0
         fileChooser.setDialogTitle("Choose a File to Validate as " +
 593  
                                    formatTypeChoice.getSelectedItem());
 594  0
         returnValue = fileChooser.showOpenDialog(this);
 595  
 
 596  0
         if (returnValue == JFileChooser.APPROVE_OPTION) {
 597  0
             fileChosen = fileChooser.getSelectedFile();
 598  
         } else {
 599  0
             fileChosen = null;
 600  
         }
 601  
 
 602  0
         clearErrorRecords();
 603  0
         setControls();
 604  0
     }
 605  
 
 606  
     /**
 607  
      * Verify the chosen input file using the chosen format.  The actual
 608  
      * execution is carried out on a separate thread.
 609  
      */
 610  
     private synchronized void runVerify() {
 611  0
         runButton.setEnabled(false);
 612  
 
 613  
         try {
 614  0
             new Thread(this).start();
 615  0
         } catch (Throwable any) {
 616  0
             appendResult("\nError during processing\nError Type: " +
 617  
                          any.getClass().getName() + "\nError Message: " +
 618  
                          any.getMessage());
 619  0
             setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
 620  0
         }
 621  0
     }
 622  
 
 623  
     /**
 624  
      * Print a user-entered set of records from the input file.
 625  
      */
 626  
     private void filePrintRecords() {
 627  
         String userEnteredRecords;
 628  
         String[] parsedInput, parsedEntry;
 629  
         java.util.List recordNumbers;
 630  
         int whichInput;
 631  
         int low, high;
 632  
 
 633  0
         recordNumbers = new ArrayList();
 634  
 
 635  0
         userEnteredRecords = JOptionPane.showInputDialog(this, "Enter a list of record numbers separated by commas\nor a range of record numbers separated by a hyphen.",
 636  
                 "Enter Record Numbers", JOptionPane.QUESTION_MESSAGE);
 637  
 
 638  0
         if (userEnteredRecords != null &&
 639  
             userEnteredRecords.trim().length() > 0) {
 640  0
             parsedInput = userEnteredRecords.split(",");
 641  0
             for (whichInput = 0; whichInput < parsedInput.length; ++whichInput) {
 642  0
                 parsedEntry = parsedInput[whichInput].split("-");
 643  0
                 if (parsedEntry.length == 2) {
 644  
                     try {
 645  0
                         low = Integer.parseInt(parsedEntry[0]);
 646  0
                         high = Integer.parseInt(parsedEntry[1]);
 647  0
                         if (low > high) {
 648  0
                             JOptionPane.showMessageDialog(this,
 649  
                                     "The range, " +
 650  
                                     parsedInput[whichInput] +
 651  
                                     ", starts after it ends",
 652  
                                     "Error In Input Range",
 653  
                                     JOptionPane.ERROR_MESSAGE);
 654  0
                         } else if (low < 1) {
 655  0
                             JOptionPane.showMessageDialog(this,
 656  
                                     "The range, " +
 657  
                                     parsedInput[whichInput] +
 658  
                                     ", starts before record 1",
 659  
                                     "Error In Input Range",
 660  
                                     JOptionPane.ERROR_MESSAGE);
 661  
                         } else {
 662  0
                             for (int range = low; range <= high; ++range) {
 663  0
                                 recordNumbers.add(new Integer(range));
 664  
                             }
 665  
                         }
 666  0
                     } catch (Throwable any) {
 667  0
                         JOptionPane.showMessageDialog(this,
 668  
                                 "The range, " +
 669  
                                 parsedInput[whichInput] +
 670  
                                 ", has non-numeric values",
 671  
                                 "Error In Input Range",
 672  
                                 JOptionPane.ERROR_MESSAGE);
 673  0
                     }
 674  
                 } else {
 675  
                     try {
 676  0
                         low = Integer.parseInt(parsedInput[whichInput]);
 677  0
                         if (low < 1) {
 678  0
                             JOptionPane.showMessageDialog(this,
 679  
                                     "The record number, " +
 680  
                                     parsedInput[whichInput] +
 681  
                                     ", starts before record 1",
 682  
                                     "Error In Input Record",
 683  
                                     JOptionPane.ERROR_MESSAGE);
 684  
                         } else {
 685  0
                             recordNumbers.add(new Integer(low));
 686  
                         }
 687  0
                     } catch (Throwable any) {
 688  0
                         JOptionPane.showMessageDialog(this,
 689  
                                 "The record number, " +
 690  
                                 parsedInput[whichInput] +
 691  
                                 ", has non-numeric values",
 692  
                                 "Error In Input Record",
 693  
                                 JOptionPane.ERROR_MESSAGE);
 694  0
                     }
 695  
                 }
 696  
             }
 697  0
             if (recordNumbers.size() > 0) {
 698  0
                 printRecords(recordNumbers, "Records: " + userEnteredRecords);
 699  
             }
 700  
         }
 701  0
     }
 702  
 
 703  
     /**
 704  
      * Print the records that were flagged with errors when verified
 705  
      */
 706  
     private void filePrintErrorRecords() {
 707  0
         printRecords(lastErrorRecords, "Records With Reported Errors");
 708  0
     }
 709  
 
 710  
     /**
 711  
      * Print the records from the current file, using the List of
 712  
      * Integer objects to obtain the record numbers to be printed.
 713  
      *
 714  
      * @param recordNumbers List The list of record numbers to be printed
 715  
      */
 716  
     private void printRecords(java.util.List recordNumbers, String title) {
 717  
         int[] records;
 718  
 
 719  0
         records = new int[recordNumbers.size()];
 720  
 
 721  0
         for (int rec = 0; rec < recordNumbers.size(); ++rec) {
 722  0
             records[rec] = ((Integer) recordNumbers.get(rec)).intValue();
 723  
         }
 724  
 
 725  0
         printParsedRecords(records, title);
 726  0
     }
 727  
 
 728  
     /**
 729  
      * Print the records from the current file, using the integer array
 730  
      * to obtain the record numbers to be printed.
 731  
      *
 732  
      * @param recordNumbers int[] The record numbers to be printed
 733  
      */
 734  
     private void printParsedRecords(int[] recordNumbers, String title) {
 735  
         BufferedReader in;
 736  
         ProgressMonitorInputStream inProgress;
 737  
         ProgressMonitor progress;
 738  
         String oneReport;
 739  
         String data;
 740  
         StringBuffer fullReport;
 741  
         int recIndex, record;
 742  
         FormatType chosenFormatType;
 743  
 
 744  0
         Arrays.sort(recordNumbers);
 745  0
         fullReport = new StringBuffer();
 746  
 
 747  0
         chosenFormatType = (FormatType) formatTypeChoice.getSelectedItem();
 748  0
         record = 0;
 749  0
         recIndex = 0;
 750  
         try {
 751  
             // Open file
 752  0
             inProgress = new
 753  
                          ProgressMonitorInputStream(this,
 754  
                     "Printing Records from " +
 755  
                     fileNameChoice.getText() +
 756  
                     " as " + chosenFormatType.getName(),
 757  
                     new FileInputStream(fileChosen));
 758  
 
 759  0
             in = new BufferedReader(new InputStreamReader(new
 760  
                     BufferedInputStream(
 761  
                             inProgress)));
 762  0
             progress = inProgress.getProgressMonitor();
 763  
 
 764  
             // Reset validation state of format object
 765  0
             chosenFormatType.newValidation();
 766  
 
 767  
             // Validate each record
 768  0
             while (recIndex < recordNumbers.length && (data = in.readLine()) != null &&
 769  
                     !progress.isCanceled()) {
 770  0
                 ++record;
 771  
 
 772  0
                 logger.debug("record[" + record + "]");
 773  0
                 if (record == recordNumbers[recIndex]) {
 774  0
                     if (fullReport.length() == 0) {
 775  0
                         fullReport.append("File: " + fileChosen.getAbsolutePath() +
 776  
                                           "\n");
 777  0
                         fullReport.append("Format: " + chosenFormatType.getName() +
 778  
                                           "\n");
 779  
                     }
 780  0
                     fullReport.append("\nLine: " + record +
 781  
                                       "\n------------------------------------------------------\n");
 782  0
                     oneReport = chosenFormatType.getReportableParsedRecord(data);
 783  0
                     fullReport.append(oneReport);
 784  0
                     fullReport.append(
 785  
                             "------------------------------------------------------\n");
 786  
 
 787  0
                     ++recIndex;
 788  
                 }
 789  
             }
 790  
 
 791  0
             if (fullReport.length() > 0) {
 792  0
                 Print print = new Print(title);
 793  0
                 print.print(fullReport.toString(), false);
 794  
             }
 795  0
         } catch (Throwable any) {
 796  0
             JOptionPane.showMessageDialog(this,
 797  
                                           "Error during error record printing\nError Type: " +
 798  
                                           any.getClass().getName() +
 799  
                                           "\nError Message: " +
 800  
                                           any.getMessage(),
 801  
                                           "Error During Record Printing",
 802  
                                           JOptionPane.ERROR_MESSAGE);
 803  0
             logger.error("Error printing record", any);
 804  0
         }
 805  0
     }
 806  
 
 807  
     /**
 808  
      * Clear the historical list of record numbers reported with errors
 809  
      */
 810  
     private void clearErrorRecords() {
 811  0
         lastErrorRecords = new ArrayList();
 812  0
     }
 813  
 
 814  
     /**
 815  
      * Add a record number to the historical list of record numbers reported with
 816  
      * errors.
 817  
      *
 818  
      * @param aRecordNum int The record number to add to the list
 819  
      */
 820  
     private void addErrorRecord(int aRecordNum) {
 821  0
         lastErrorRecords.add(new Integer(aRecordNum));
 822  0
     }
 823  
 
 824  
     /**
 825  
      * Reads the input file and sends each record to the chosen format
 826  
      * to be validated.  Writes the resulting messages to the message
 827  
      * area and calculates the resulting sigma.
 828  
      */
 829  
     private void verifyContent() {
 830  
         BufferedReader in;
 831  
         ProgressMonitorInputStream inProgress;
 832  
         ProgressMonitor progress;
 833  
         String data;
 834  
         FormatType chosenFormatType;
 835  
         ValidationResult oneResult;
 836  
         SigmaCalculator calc;
 837  
         int record;
 838  
         int totalOpportunities, totalDefects;
 839  
         StringBuffer results;
 840  
         Date start, setStart, setStop, remainingTime;
 841  
         long positStart, positStop;
 842  
 
 843  0
         setCursor(new Cursor(Cursor.WAIT_CURSOR));
 844  
 
 845  0
         results = new StringBuffer();
 846  0
         clearResult();
 847  0
         clearStatusMessage();
 848  0
         totalOpportunities = totalDefects = 0;
 849  0
         chosenFormatType = (FormatType) formatTypeChoice.getSelectedItem();
 850  0
         record = 0;
 851  0
         in = null;
 852  0
         inProgress = null;
 853  0
         progress = null;
 854  0
         oneResult = null;
 855  
 
 856  0
         clearErrorRecords();
 857  
 
 858  0
         start = new Date();
 859  0
         setStart = new Date();
 860  0
         positStart = 0;
 861  0
         positStop = 0;
 862  
 
 863  
         try {
 864  
             // Open file
 865  0
             inProgress = new
 866  
                          ProgressMonitorInputStream(this,
 867  
                     "Verifying " + fileNameChoice.getText() +
 868  
                     " as " + chosenFormatType.getName(),
 869  
                     new FileInputStream(fileChosen));
 870  
 
 871  0
             in = new BufferedReader(new InputStreamReader(new
 872  
                     BufferedInputStream(
 873  
                             inProgress)));
 874  0
             progress = inProgress.getProgressMonitor();
 875  
 
 876  
             // Reset validation state of format object
 877  0
             chosenFormatType.newValidation();
 878  
 
 879  
             // Validate each record
 880  0
             while ((data = in.readLine()) != null && !progress.isCanceled()) {
 881  0
                 ++record;
 882  0
                 positStop += data.length();
 883  
 
 884  0
                 logger.debug("record[" + record + "] length[" + data.length() +
 885  
                              "]");
 886  0
                 if (data.length() == 1) {
 887  0
                     logger.debug("char code[" + (int) data.charAt(0) + "]");
 888  
                 }
 889  
 
 890  
                 // Mainframe exports have EOF-type character at last line
 891  
                 // Ignore line in this case
 892  0
                 if (data.length() == 1 && data.charAt(0) < 32) {
 893  0
                     logger.debug("record[" + record +
 894  
                                  "] ignored (EOF character)");
 895  0
                     continue;
 896  
                 }
 897  
 
 898  0
                 if (record % 1000 == 0) {
 899  0
                     setStop = new Date();
 900  0
                     remainingTime = new Date(setStop.getTime() +
 901  
                                              (long)
 902  
                                              (((double) (setStop.getTime() -
 903  
                             setStart.getTime())) /
 904  
                                               (positStop - positStart) *
 905  
                                               (fileChosen.length() - positStop)));
 906  0
                     setStatusMessage("Record: " +
 907  
                                      record +
 908  
                                      "  Elapsed: " +
 909  
                                      Utils.timeElapsedFormat(start, setStop) +
 910  
                                      "  Remaining: " +
 911  
                                      Utils.timeElapsedFormat(setStop,
 912  
                             remainingTime));
 913  0
                     setStart = setStop;
 914  0
                     positStart = positStop;
 915  
                 }
 916  
 
 917  0
                 oneResult = chosenFormatType.validate(data, record);
 918  0
                 totalOpportunities += oneResult.getNumOpportunities();
 919  0
                 totalDefects += oneResult.getNumDefects();
 920  0
                 for (int defect = 0; defect < oneResult.getNumDefects();
 921  0
                                   ++defect) {
 922  0
                     results.append("Line " + record + ":" +
 923  
                                    oneResult.getDefectMessage(defect) + "\n");
 924  
                 }
 925  0
                 if (oneResult.getNumDefects() > 0) {
 926  0
                     addErrorRecord(record);
 927  
                 }
 928  
             }
 929  
 
 930  0
             if (oneResult != null) {
 931  0
                 oneResult = chosenFormatType.validateLastCorrect(oneResult.
 932  
                         getMatchedRecordTypeId());
 933  0
                 totalOpportunities += oneResult.getNumOpportunities();
 934  0
                 totalDefects += oneResult.getNumDefects();
 935  0
                 for (int defect = 0; defect < oneResult.getNumDefects();
 936  0
                                   ++defect) {
 937  0
                     results.append("Line " + record + ":" +
 938  
                                    oneResult.getDefectMessage(defect) + "\n");
 939  
                 }
 940  0
                 if (oneResult.getNumDefects() > 0) {
 941  0
                     addErrorRecord(record);
 942  
                 }
 943  
             }
 944  
 
 945  
             // Summary
 946  0
             if (progress != null && progress.isCanceled()) {
 947  
                 // User cancelled processing
 948  0
                 results.append(
 949  
                         "\n*** User cancelled processing of the file. ***\n");
 950  0
                 results.insert(0, "Input File: " + fileChosen.getAbsolutePath() +
 951  
                                "\nRun Time:" + new Date() +
 952  
                                "\nFile Type:" + chosenFormatType.getName() +
 953  
                                "\nXML Rules Version:" +
 954  
                                chosenFormatType.getVersion() +
 955  
                                "\nRecords Read:" + record +
 956  
                                "\n*** User cancelled processing of the file. ***\n\n");
 957  
             } else {
 958  
                 // Processing completed to end of file
 959  0
                 calc = new SigmaCalculator(totalOpportunities, totalDefects);
 960  0
                 results.insert(0, "Input File: " + fileChosen.getAbsolutePath() +
 961  
                                "\nRun Time:" + new Date() +
 962  
                                "\nFile Type:" + chosenFormatType.getName() +
 963  
                                "\nXML Rules Version:" +
 964  
                                chosenFormatType.getVersion() +
 965  
                                "\nRecords Read:" + record +
 966  
                                "\nOpportunities:" + totalOpportunities +
 967  
                                "\nDefects:" + totalDefects +
 968  
                                "\nDPMO:" + calc.getDPMO(0) +
 969  
                                "\nSigma:" + calc.getSigma(2) +
 970  
                                "\n\n");
 971  
             }
 972  0
         } catch (Throwable any) {
 973  0
             if (progress == null || !progress.isCanceled()) {
 974  0
                 results.insert(0, "Error during processing\nError Type: " +
 975  
                                any.getClass().getName() + "\nError Message: " +
 976  
                                any.getMessage() + "\n\n");
 977  0
                 logger.error("Error validating content", any);
 978  
             }
 979  0
         } finally {
 980  0
             appendResult(results.toString());
 981  0
             resultsDisplay.setCaretPosition(0);
 982  
             // Close file, if open
 983  0
             if (in != null) {
 984  
                 try {
 985  0
                     in.close();
 986  0
                 } catch (Throwable any) {
 987  
                     // Nothing to do
 988  0
                 }
 989  
             }
 990  0
         }
 991  
 
 992  0
         setControls();
 993  
 
 994  0
         setStatusMessage("Records Processed: " + record + "  Total Time: " +
 995  
                          Utils.timeElapsedFormat(start, new Date()));
 996  
 
 997  0
         setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
 998  0
     }
 999  
 
 1000  
     /**
 1001  
      * Save the current results, displayed in the message area, to a file.
 1002  
      * The user is prompted to enter a file path, using a File-Save dialog.
 1003  
      */
 1004  
     private void fileSave() {
 1005  
         JFileChooser fileChooser;
 1006  
         File fileToWrite;
 1007  
         String fileToWritePath;
 1008  
         String data;
 1009  
         int returnValue;
 1010  
         boolean askAgain;
 1011  
         PrintWriter out;
 1012  
         BufferedReader in;
 1013  
 
 1014  0
         if (fileChosen != null) {
 1015  0
             fileChooser = new JFileChooser(fileChosen.getAbsolutePath());
 1016  
         } else {
 1017  0
             fileChooser = new JFileChooser();
 1018  
         }
 1019  
 
 1020  
         do {
 1021  0
             askAgain = false;
 1022  0
             fileToWrite = null;
 1023  0
             fileChooser.setDialogTitle("Save Results");
 1024  0
             fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
 1025  0
             returnValue = fileChooser.showSaveDialog(this);
 1026  
 
 1027  0
             if (returnValue == JFileChooser.APPROVE_OPTION) {
 1028  0
                 fileToWrite = fileChooser.getSelectedFile();
 1029  
 
 1030  0
                 if (fileToWrite.exists()) {
 1031  0
                     returnValue = JOptionPane.showConfirmDialog(this,
 1032  
                             "The file " + fileToWrite.getName() +
 1033  
                             " already exists.\n\nAre you sure you want to overwrite it?",
 1034  
                             "File Exists", JOptionPane.YES_NO_CANCEL_OPTION,
 1035  
                             JOptionPane.QUESTION_MESSAGE);
 1036  0
                     if (returnValue != JOptionPane.YES_OPTION) {
 1037  0
                         fileToWrite = null;
 1038  
                     }
 1039  0
                     if (returnValue == JOptionPane.NO_OPTION) {
 1040  0
                         askAgain = true;
 1041  
                     }
 1042  
                 }
 1043  
             }
 1044  0
         } while (askAgain);
 1045  
 
 1046  0
         if (fileToWrite != null) {
 1047  0
             out = null;
 1048  0
             in = null;
 1049  0
             fileToWritePath = fileToWrite.getAbsolutePath();
 1050  0
             if (!fileToWritePath.toLowerCase().endsWith(".txt")) {
 1051  0
                 fileToWritePath += ".txt";
 1052  
             }
 1053  
 
 1054  
             try {
 1055  0
                 out = new PrintWriter(new FileWriter(fileToWrite, false));
 1056  0
                 in = new BufferedReader(new StringReader(resultsDisplay.getText()));
 1057  
 
 1058  0
                 while ((data = in.readLine()) != null) {
 1059  0
                     out.println(data);
 1060  
                 }
 1061  0
                 setStatusMessage("Results saved to " + fileToWrite.getName());
 1062  0
             } catch (Throwable any) {
 1063  0
                 JOptionPane.showMessageDialog(this,
 1064  
                                               "Failed to write file: " +
 1065  
                                               fileToWrite.getName() +
 1066  
                                               "\n\nError Type: " +
 1067  
                                               any.getClass().getName() +
 1068  
                                               "\nError Msg: " + any.getMessage(),
 1069  
                                               "Failed to Write File",
 1070  
                                               JOptionPane.ERROR_MESSAGE);
 1071  0
                 setStatusMessage("Failed to save results");
 1072  0
             } finally {
 1073  0
                 if (out != null) {
 1074  
                     try {
 1075  0
                         out.close();
 1076  0
                     } catch (Throwable any) {
 1077  
                         // Nothing to do
 1078  0
                     }
 1079  
                 }
 1080  0
             }
 1081  
         }
 1082  0
     }
 1083  
 
 1084  
     /**
 1085  
      * Print the current results, displayed in the message area.
 1086  
      */
 1087  
     private void filePrint() {
 1088  
         Print printer;
 1089  
 
 1090  0
         printer = new Print("Format Check Results");
 1091  0
         printer.print(resultsDisplay.getText());
 1092  0
     }
 1093  
 
 1094  
     /**
 1095  
      * Copy the selected portion of results display to the clipboard.
 1096  
      */
 1097  
     private void copySelectedResults() {
 1098  0
         resultsDisplay.copy();
 1099  0
     }
 1100  
 
 1101  
     /**
 1102  
      * Select all of the content in the result display.
 1103  
      */
 1104  
     private void selectAll() {
 1105  0
         resultsDisplay.selectAll();
 1106  0
     }
 1107  
 
 1108  
     /**
 1109  
      * Display the sigma calculator
 1110  
      */
 1111  
     private void helpSigmaCalc() {
 1112  0
         SigmaCalculatorDialog dialog = new SigmaCalculatorDialog(this);
 1113  0
         dialog.setVisible(true);
 1114  0
     }
 1115  
 
 1116  
     /**
 1117  
      * Show the application's "About" box.  This should give information including
 1118  
      * the application name and version.
 1119  
      */
 1120  
     private void helpAbout() {
 1121  
         String slMessage;
 1122  
         Runtime objlRuntime;
 1123  
         NumberFormat fmtlNumber;
 1124  
 
 1125  0
         fmtlNumber = new DecimalFormat("#,###");
 1126  
 
 1127  0
         slMessage = "FormatCheck" + "\nVersion: " + ConstantsInterface.VERSION;
 1128  
 
 1129  0
         slMessage += "\n\nFormat Check Tool\n\n";
 1130  
 
 1131  0
         slMessage += "David Read\nwww.daveread.us\n\n";
 1132  
 
 1133  0
         objlRuntime = Runtime.getRuntime();
 1134  
 
 1135  0
         slMessage += "JVM: " + System.getProperty("java.version") + ", " +
 1136  
                 System.getProperty("java.vendor");
 1137  0
         slMessage += "\nOS: " + System.getProperty("os.name") + ", " +
 1138  
                 System.getProperty("os.version") + ", " +
 1139  
                 System.getProperty("os.arch");
 1140  0
         slMessage += "\nMemory: Allocated[" +
 1141  
                 fmtlNumber.format(objlRuntime.totalMemory()) +
 1142  
                 "]  Free[" +
 1143  
                 fmtlNumber.format(objlRuntime.freeMemory()) + "]";
 1144  0
         slMessage += "\nMemory: Max[" + fmtlNumber.format(objlRuntime.maxMemory()) +
 1145  
                 "]  Allocated[" + fmtlNumber.format(objlRuntime.totalMemory()) +
 1146  
                 "]  Free[" + fmtlNumber.format(objlRuntime.freeMemory()) + "]";
 1147  0
         slMessage += "\nProcessors: " + objlRuntime.availableProcessors();
 1148  
 
 1149  0
         JOptionPane.showMessageDialog(this, slMessage, "About FormatCheck",
 1150  
                                       JOptionPane.INFORMATION_MESSAGE);
 1151  
 
 1152  0
     }
 1153  
 
 1154  
     /**
 1155  
      * Close the application, disposing of the GUI.
 1156  
      */
 1157  
     private void closeApplication() {
 1158  0
         dispose();
 1159  0
         System.exit(0);
 1160  0
     }
 1161  
 
 1162  
     // Begin Interface ActionListener
 1163  
 
 1164  
     public void actionPerformed(ActionEvent evtaWhat) {
 1165  
         Object objlSource;
 1166  
 
 1167  0
         objlSource = evtaWhat.getSource();
 1168  
 
 1169  0
         if (objlSource == formatTypeChoice) {
 1170  0
             clearErrorRecords();
 1171  0
             setControls();
 1172  0
         } else if (objlSource == fileNameFileDialogButton) {
 1173  0
             chooseFile();
 1174  0
         } else if (objlSource == runButton) {
 1175  0
             runVerify();
 1176  0
         } else if (objlSource == menuFileSave) {
 1177  0
             fileSave();
 1178  0
         } else if (objlSource == menuFilePrint) {
 1179  0
             filePrint();
 1180  0
         } else if (objlSource == menuFilePrintRecords) {
 1181  0
             filePrintRecords();
 1182  0
         } else if (objlSource == menuFilePrintErrorRecords) {
 1183  0
             filePrintErrorRecords();
 1184  0
         } else if (objlSource == menuFileExit) {
 1185  0
             closeApplication();
 1186  0
         } else if (objlSource == menuEditCopy) {
 1187  0
             copySelectedResults();
 1188  0
         } else if (objlSource == menuEditSelectAll) {
 1189  0
             selectAll();
 1190  0
         } else if (objlSource == menuToolsReloadFormats) {
 1191  0
             setupFormatTypes();
 1192  0
             setStatusMessage("Format definitions reloaded");
 1193  0
         } else if (objlSource == menuToolsSigmaCalculator) {
 1194  0
             helpSigmaCalc();
 1195  0
         } else if (objlSource == menuHelpAbout) {
 1196  0
             helpAbout();
 1197  
         }
 1198  0
     }
 1199  
 
 1200  
     // End Interface ActionListener
 1201  
 
 1202  
     // Begin Interface WindowListener
 1203  
 
 1204  
     public void windowActivated(WindowEvent evtaWhat) {
 1205  0
     }
 1206  
 
 1207  
     public void windowClosed(WindowEvent evtaWhat) {
 1208  0
     }
 1209  
 
 1210  
     public void windowClosing(WindowEvent evtaWhat) {
 1211  0
         closeApplication();
 1212  0
     }
 1213  
 
 1214  
     public void windowDeactivated(WindowEvent evtaWhat) {
 1215  0
     }
 1216  
 
 1217  
     public void windowDeiconified(WindowEvent evtaWhat) {
 1218  0
     }
 1219  
 
 1220  
     public void windowIconified(WindowEvent evtaWhat) {
 1221  0
     }
 1222  
 
 1223  
     public void windowOpened(WindowEvent evtaWhat) {
 1224  0
     }
 1225  
 
 1226  
     // End Interface WindowListener
 1227  
 
 1228  
     // Begin Runnable Interface
 1229  
 
 1230  
     /**
 1231  
      * Call the method to verify the input file
 1232  
      */
 1233  
     public void run() {
 1234  0
         verifyContent();
 1235  0
     }
 1236  
 
 1237  
     // End Runnable Interface
 1238  
 
 1239  
 }