View Javadoc

1   package baseCode.gui;
2   
3   import javax.swing.JOptionPane;
4   
5   import org.apache.commons.logging.Log;
6   import org.apache.commons.logging.LogFactory;
7   
8   import baseCode.util.FileTools;
9   
10  /***
11   * Little oft-used functions.
12   * 
13   * @version $Id: GuiUtil.java,v 1.11 2005/04/07 20:43:08 pavlidis Exp $
14   */
15  
16  public class GuiUtil {
17  
18      protected static final Log log = LogFactory.getLog( GuiUtil.class );
19  
20      /***
21       * @param message
22       * @param e
23       */
24      public static void error( String message, Exception e ) {
25          JOptionPane.showMessageDialog( null, "Error: " + message + "\n" + e, "Error", JOptionPane.ERROR_MESSAGE );
26          log.error( e );
27          e.printStackTrace();
28      }
29  
30      /***
31       * @param message
32       */
33      public static void error( String message ) {
34          JOptionPane.showMessageDialog( null, "Error: " + message + "\n", "Error", JOptionPane.ERROR_MESSAGE );
35          log.error( message );
36      }
37  
38      /***
39       * @param filename
40       * @return
41       * @see baseCode.util.FileTools#checkPathIsReadableFile(String)
42       */
43      public static boolean testFile( String filename ) {
44          if ( !FileTools.testFile( filename ) ) {
45              error( "A required file field is not valid." );
46              return false;
47          }
48          return false;
49      }
50  
51      /***
52       * @param text
53       * @return
54       */
55      public static boolean testDir( String filename ) {
56          if ( !FileTools.testDir( filename ) ) {
57              error( "A required directory field is not valid." );
58              return false;
59          }
60          return true;
61      }
62  
63  }