From: SVN by r. <sv...@ca...> - 2008-08-03 11:37:46
|
Author: roy Date: 2008-08-03 13:37:34 +0200 (Sun, 03 Aug 2008) New Revision: 278 Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java Log: improved help of dump/read commands code cleanup Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2008-08-02 10:11:20 UTC (rev 277) +++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2008-08-03 11:37:34 UTC (rev 278) @@ -1233,11 +1233,13 @@ StringBuilder returnValue = new StringBuilder(); returnValue.append("Available key mappings:\n"); int max = 0; - Iterator<KeyAction> iKeyActions = actionKeys.values().iterator(); + List<KeyAction> keys = new ArrayList<KeyAction>(actionKeys.values()); + keys.addAll(0, specialActionKeys.values()); + Iterator<KeyAction> iKeyActions = keys.iterator(); while (iKeyActions.hasNext()) { max = Math.max(max, iKeyActions.next().getHelp().toString().indexOf('\t')); } - iKeyActions = actionKeys.values().iterator(); + iKeyActions = keys.iterator(); while (iKeyActions.hasNext()) { returnValue.append(" "); //returnValue.append(iKeyActions.next().getHelp()); @@ -1390,6 +1392,7 @@ } else { dumpFileName = nextPart; } + int rowCount = 0; try { File f = new File(toFileName(dumpFileName +".dmp")); fileName = f.getAbsolutePath(); @@ -1423,6 +1426,7 @@ dumpWriter.write("</col>\n"); } dumpWriter.write(" </row>\n"); + rowCount++; } dumpWriter.write("</dump>"); } catch (SQLException e) { @@ -1436,7 +1440,7 @@ Logger.getLogger(AbstractSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex); } } - return "Dump to "+fileName+" done."; + return "Dump to "+fileName+" done. ("+ rowCount+" rows written)"; } @Override @@ -1456,7 +1460,9 @@ } @Override public CharSequence getHelp() { - return "tablename [where clause]"; + return "tablename [where clause]\n" + + "For example: dump users where role='manager';\n\n" + + "See 'read' for options to read the dump file back into the table"; } @Override public boolean abort() { @@ -1483,6 +1489,7 @@ } else { dumpFileName = nextPart; } + int rowCount = 0; try { File f = new File(toFileName(dumpFileName +".dmp")); fileName = f.getAbsolutePath(); @@ -1506,7 +1513,6 @@ String values = ") values ("; Element n = (Element) nodeList.item(0); // row NodeList cols = n.getElementsByTagName("col"); - output("LENGTH : "+ n.getNodeName() +"/ "+ cols.getLength()); for (int colNr = 0; colNr < cols.getLength(); colNr++) { query += cols.item(colNr).getAttributes().getNamedItem("name").getNodeValue(); values += "?"; @@ -1538,6 +1544,7 @@ } } pstmt.executeUpdate(); + rowCount++; } } catch (SQLException e) { throw new IllegalStateException("Failed to execute update query for dump("+fileName+"): " + e.toString(), e); @@ -1546,7 +1553,7 @@ } catch (Exception e) { throw new IllegalStateException("Failed to read dump ("+fileName+"): " + e.toString(), e); } - return "Read from "+fileName+" done."; + return "Read from "+fileName+" done. (" + rowCount+" rows imported)"; } @Override @@ -1566,7 +1573,8 @@ } @Override public CharSequence getHelp() { - return "filename: read dump file from filename\n"; + return "filename: read dump file from filename\n"+ + "See 'dump' for options to create a dump file"; } @Override public boolean abort() { Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2008-08-02 10:11:20 UTC (rev 277) +++ src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2008-08-03 11:37:34 UTC (rev 278) @@ -26,10 +26,7 @@ import nl.improved.sqlclient.AbstractSQLShellWindow; import nl.improved.sqlclient.InputKey; import nl.improved.sqlclient.Point; -import nl.improved.sqlclient.SQLCommand; import nl.improved.sqlclient.Screen; -import nl.improved.sqlclient.TabCompletionInfo; -import nl.improved.sqlclient.commands.Command; /** * SQLShell window based on the jcurses library. @@ -135,6 +132,7 @@ }; } window.setVisible(true); + // repaint loop while (isRunning()) { Screen screen = getScreen(); if (!dontRepaint && repaint) { @@ -157,7 +155,6 @@ */ @Override public void close() { - debug("CLOSE CALLED"); super.close(); window.close(); } |