|
From: SVN by r. <sv...@ca...> - 2009-01-26 08:42:56
|
Author: roy
Date: 2009-01-26 09:42:48 +0100 (Mon, 26 Jan 2009)
New Revision: 370
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
src/main/java/nl/improved/sqlclient/SQLShell.java
src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java
src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java
Log:
fixes in exception handling/logging
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-26 07:50:33 UTC (rev 369)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-26 08:42:48 UTC (rev 370)
@@ -18,6 +18,7 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -130,10 +131,14 @@
*/
private boolean run = true; // set to false on quit
private File errFile;
+ private PrintStream errorStream;
+ private PrintStream outStream;
/**
* Constructor.
*/
public AbstractSQLShellWindow() {
+ errorStream = System.err;
+ outStream = System.out;
try {
errFile = File.createTempFile("sqlshell", ".err");
errFile.deleteOnExit();
@@ -141,6 +146,7 @@
} catch (IOException ex) {
Logger.getLogger(AbstractSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex);
}
+
screen = new Screen();
char[] emptyLineChar = new char[getScreenWidth()];
Arrays.fill(emptyLineChar, ' ');
@@ -598,6 +604,19 @@
spoolWriter = null;
} catch(Exception e) {/*ignore*/}
}
+ System.setErr(errorStream);
+ System.setOut(outStream);
+ File errFile = getErrFile();
+ if (errFile != null && errFile.length() > 0L) {
+ try {
+ System.out.println("There where errors during execution of sqlshell:");
+ BufferedReader reader = new BufferedReader(new FileReader(errFile));
+ String line;
+ while ( (line = reader.readLine()) != null) {
+ System.out.println(line);
+ }
+ } catch(Exception e) {}
+ }
}
protected File getErrFile() {
Modified: src/main/java/nl/improved/sqlclient/SQLShell.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-26 07:50:33 UTC (rev 369)
+++ src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-26 08:42:48 UTC (rev 370)
@@ -108,8 +108,12 @@
return argsMap;
}
public static void main(String[] args) throws InterruptedException, IOException {
- PrintStream errorStream = System.err;
- PrintStream outStream = System.out;
+ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+
+ public void uncaughtException(Thread t, Throwable e) {
+ //throw new UnsupportedOperationException("Not supported yet.");
+ }
+ });
final Map<String, String> argsMap = parseHelp(args);
AbstractSQLShellWindow sqlshellWindow;
if (argsMap.get(INPUT) != null) {
@@ -199,16 +203,5 @@
}
}
sqlshellWindow.show();
- System.setErr(errorStream);
- System.setOut(outStream);
- File errFile = sqlshellWindow.getErrFile();
- if (errFile != null && errFile.length() > 0L) {
- System.out.println("There where errors during execution of sqlshell:");
- BufferedReader reader = new BufferedReader(new FileReader(errFile));
- String line;
- while ( (line = reader.readLine()) != null) {
- System.out.println(line);
- }
- }
}
}
Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-26 07:50:33 UTC (rev 369)
+++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-26 08:42:48 UTC (rev 370)
@@ -39,6 +39,7 @@
public class CharvaSQLShellWindow extends AbstractSQLShellWindow {
private JTextArea textComponent;
private OutputStream debugOut;
+ private JFrame frame;
/**
* Constructor.
@@ -213,8 +214,13 @@
@Override
public void close() {
+ frame.hide();
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ Logger.getLogger(CharvaSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex);
+ }
super.close();
- Toolkit.getDefaultToolkit().getTopWindow().hide();
}
@@ -366,7 +372,7 @@
}
public void show() {
- JFrame frame = new JFrame() {
+ frame = new JFrame() {
@Override
public void draw() {
Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-26 07:50:33 UTC (rev 369)
+++ src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-26 08:42:48 UTC (rev 370)
@@ -227,8 +227,8 @@
@Override
public void close() {
+ sqlShell.close();
super.close();
- sqlShell.close();
// TODO
}
|