Return-Path: Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 41415 invoked by uid 500); 21 Jun 2003 10:39:15 -0000 Received: (qmail 41361 invoked from network); 21 Jun 2003 10:39:14 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 21 Jun 2003 10:39:14 -0000 Received: (qmail 49381 invoked by uid 1516); 21 Jun 2003 10:39:13 -0000 Date: 21 Jun 2003 10:39:13 -0000 Message-ID: <20030621103913.49380.qmail@icarus.apache.org> From: florianbruckner@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/gui/actions GenerateJavaClassesAction.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N florianbruckner 2003/06/21 03:39:13 Modified: src/java/org/apache/ojb/tools/mapping/reversedb/gui/actions GenerateJavaClassesAction.java Log: improve error reporting; use writeXML(PrintWriter) instead of getXML() Revision Changes Path 1.4 +25 -61 db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/gui/actions/GenerateJavaClassesAction.java Index: GenerateJavaClassesAction.java =================================================================== RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/gui/actions/GenerateJavaClassesAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- GenerateJavaClassesAction.java 8 Nov 2002 13:47:38 -0000 1.3 +++ GenerateJavaClassesAction.java 21 Jun 2003 10:39:13 -0000 1.4 @@ -54,63 +54,7 @@ * . */ -/* - * ==================================================================== - * - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ - +import javax.swing.JOptionPane; /** * * @author Florian Bruckner @@ -131,6 +75,7 @@ { // 1. Open a Filechooser dialog to get the directory for the java Files javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser(); + fileChooser.setDialogTitle("Select Directory for Java generation"); fileChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY); int rc = fileChooser.showSaveDialog(mainFrame); if (rc == javax.swing.JFileChooser.APPROVE_OPTION) @@ -138,19 +83,35 @@ java.io.File f = fileChooser.getSelectedFile(); try { - if (!f.isDirectory()) return; + if (!f.isDirectory()) + { + JOptionPane.showMessageDialog(mainFrame, "Selected item is not a directory", "Generate Java", JOptionPane.ERROR_MESSAGE); + return; + } if (f.canWrite()) { mainFrame.getDBMeta().generateJava(f, "", ""); } + else + { + JOptionPane.showMessageDialog(mainFrame, "Cannot write to selected directory", "Generate Java", JOptionPane.ERROR_MESSAGE); + return; + } } catch (java.io.FileNotFoundException fnfe) { - fnfe.printStackTrace(); + fnfe.printStackTrace(); + JOptionPane.showMessageDialog(mainFrame, "File not found:\n" + fnfe.getMessage(), "Generate Java", JOptionPane.ERROR_MESSAGE); } catch (java.io.IOException ioex) { - ioex.printStackTrace(); + ioex.printStackTrace(); + JOptionPane.showMessageDialog(mainFrame, "I/O Error:\n" + ioex.getMessage(), "Generate Java", JOptionPane.ERROR_MESSAGE); + } + catch (Throwable t) + { + t.printStackTrace(); + JOptionPane.showMessageDialog(mainFrame, "Error:\n" + t.getMessage(), "Generate Java", JOptionPane.ERROR_MESSAGE); } } } @@ -159,6 +120,9 @@ /***************************** Changelog ***************************** // $Log$ +// Revision 1.4 2003/06/21 10:39:13 florianbruckner +// improve error reporting; use writeXML(PrintWriter) instead of getXML() +// // Revision 1.3 2002/11/08 13:47:38 brj // corrected some compiler warnings //