From: SVN by r. <sv...@ca...> - 2007-10-08 09:49:50
|
Author: rotman Date: 2007-10-08 11:49:45 +0200 (Mon, 08 Oct 2007) New Revision: 164 Modified: ChangeLog src/main/java/nl/improved/sqlclient/SQLShell.java Log: Add exit on ^D implementation Modified: ChangeLog =================================================================== --- ChangeLog 2007-10-02 09:57:31 UTC (rev 163) +++ ChangeLog 2007-10-08 09:49:45 UTC (rev 164) @@ -4,6 +4,7 @@ * fix to stop spooled lines being appended to each other. * Improve tab completion for update * NullPointerException fix when not running from jar. + * Quit with ^D (on empty commandline) 0.2 (17-09-2007) * Search in history (for example by entering '/query' to make the current command the last command with query in it) Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2007-10-02 09:57:31 UTC (rev 163) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2007-10-08 09:49:45 UTC (rev 164) @@ -278,6 +278,10 @@ cursorPosition.x = 0; } else debug("Unknown character: "+ inp.getCode()); + } else if (inp.toString().equals("")) { //Ctrl+D + if (commandLines.getCommandString().length() == 0) { //Quit on empty commandline, ignore otherwise + new QuitCommand().execute(new SQLCommand()); + } } else { if (inp.getCharacter() == '\n') { // execute the command |
From: SVN by r. <sv...@ca...> - 2007-10-28 11:58:27
|
Author: roy Date: 2007-10-28 12:57:24 +0100 (Sun, 28 Oct 2007) New Revision: 189 Modified: ChangeLog src/main/java/nl/improved/sqlclient/SQLShell.java src/main/java/nl/improved/sqlclient/TabCompletionInfo.java Log: added batch command completion (list filenames) Modified: ChangeLog =================================================================== --- ChangeLog 2007-10-28 11:41:30 UTC (rev 188) +++ ChangeLog 2007-10-28 11:57:24 UTC (rev 189) @@ -1,3 +1,8 @@ +0.4 + * Improve tab comnpletion + * Added tabcompletion for: + * desc + * execute batch command 0.3 (09-10-2007) * focus fix in login dialog * Improve desc table to show primary key Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2007-10-28 11:41:30 UTC (rev 188) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2007-10-28 11:57:24 UTC (rev 189) @@ -585,6 +585,9 @@ if (info.getMatchType() == TabCompletionInfo.MatchType.COLUMN_NAMES) { return nullToEmpty(findMatch(getColumnNames(info.getPossibleMatches()), info.getStart())); } + if (info.getMatchType() == TabCompletionInfo.MatchType.UNKNOWN) { + return nullToEmpty(findMatch(info.getPossibleMatches(), info.getStart())); + } Toolkit.beep(); return ""; } @@ -1150,8 +1153,22 @@ * @return some tab completion info for the specified command. */ public TabCompletionInfo getTabCompletionInfo(SQLCommand command, Point commandPoint) { - return null; + String fileName = command.getCommandString().substring(1).trim(); // cutoff '@' + String dirName; + if (fileName.equals("")) { + fileName = "."; + dirName = "."; + } else { + fileName = toFileName(fileName); + if (fileName.indexOf('/') > 0) { + dirName = new File(fileName).getParent(); + } else { + dirName = "."; + } + } + return new TabCompletionInfo(TabCompletionInfo.MatchType.UNKNOWN,Arrays.asList(new File(dirName).list()) , fileName); } + public CharSequence getHelp() { return "Specify filename to execute a 'batch' command.\n"+ "For example '@mystatements.sql' executes all statements part of the mystatements.sql file in the current directory."+ Modified: src/main/java/nl/improved/sqlclient/TabCompletionInfo.java =================================================================== --- src/main/java/nl/improved/sqlclient/TabCompletionInfo.java 2007-10-28 11:41:30 UTC (rev 188) +++ src/main/java/nl/improved/sqlclient/TabCompletionInfo.java 2007-10-28 11:57:24 UTC (rev 189) @@ -18,7 +18,7 @@ import java.util.List; public class TabCompletionInfo { - public enum MatchType {SQL_KEYWORD, TABLE_NAMES, COLUMN_NAMES, UNKNOWN} + public enum MatchType {SQL_KEYWORD, TABLE_NAMES, COLUMN_NAMES, FILE_NAMES, UNKNOWN} private MatchType type; private List<String> possibleMatches; |
From: SVN by r. <sv...@ca...> - 2008-07-16 20:47:50
|
Author: roy Date: 2008-07-16 22:47:38 +0200 (Wed, 16 Jul 2008) New Revision: 263 Modified: ChangeLog src/main/java/nl/improved/sqlclient/SQLShell.java src/main/java/nl/improved/sqlclient/SQLUtil.java Log: fix array indexout of bounds.. a try for better quit.. Modified: ChangeLog =================================================================== --- ChangeLog 2008-05-19 20:55:11 UTC (rev 262) +++ ChangeLog 2008-07-16 20:47:38 UTC (rev 263) @@ -3,6 +3,7 @@ * Fix desc table for columns containing numbers * Added tab completion for connect @ * Fix tabcompletion when using LIKE comparisons + * Fix for index out of bounds for strings without spaces 0.5 (2008-03-14) * Allow for commands to start in the background, this will allow to continue Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2008-05-19 20:55:11 UTC (rev 262) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2008-07-16 20:47:38 UTC (rev 263) @@ -258,7 +258,10 @@ actionKeys.put("", new KeyAction() { public void execute() { StringBuilder lineBuffer = commandLines.getEditableLines().get(cursorPosition.y); - int previousBreak = SQLUtil.getLastBreakIndex(lineBuffer.substring(0, cursorPosition.x)); + int previousBreak = SQLUtil.getLastBreakIndex(lineBuffer.substring(0, cursorPosition.x-1)); + if (lineBuffer.charAt(previousBreak) == ' ' || lineBuffer.charAt(previousBreak) == '\t') { + previousBreak++; + } lineBuffer.delete(previousBreak, cursorPosition.x); cursorPosition.x = previousBreak; } @@ -484,7 +487,10 @@ // check if the new line is becoming too long if (currentLine.length() > MAX_LINE_LENGTH) { // TODO search for lastspace that is not between '' ?? - int lastSpace = currentLine.lastIndexOf(" "); + int lastSpace = SQLUtil.getLastBreakIndex(currentLine.toString());//currentLine.lastIndexOf(" "); + if (lastSpace == -1) { + lastSpace = currentLine.length(); + } // check if there are enough 'next' lines // if not.. add one if (editableLines.size()-1 == cursorPosition.y) { @@ -574,6 +580,7 @@ e.printStackTrace(new PrintWriter(sw)); sw.flush(); lastExceptionDetails = sw.toString(); + output(sw.toString()); } /** @@ -1159,7 +1166,9 @@ } @Override public CharSequence execute(SQLCommand command) { - hide(); // quit + //close(); + hide(); + Window.closeAllWindows(); return "Application terminated."; } @Override @@ -1605,7 +1614,9 @@ public static void main(String[] args) { SQLShell shell = new SQLShell(); - shell.show(); + shell.setVisible(false); + shell.setVisible(true); + //shell.show(); //Interpret first argument as a connect argument if (args.length > 0) { Modified: src/main/java/nl/improved/sqlclient/SQLUtil.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLUtil.java 2008-05-19 20:55:11 UTC (rev 262) +++ src/main/java/nl/improved/sqlclient/SQLUtil.java 2008-07-16 20:47:38 UTC (rev 263) @@ -293,6 +293,10 @@ } + /** + * Returns the index of last spacing in the string. + * this method is used for clearing or breaking lines. + */ public static int getLastBreakIndex(String s) { int spaceIndex = 0; char[] breakCharacters = new char[]{' ', '\t', '.', ','}; |
From: SVN by r. <sv...@ca...> - 2009-02-20 23:46:05
|
Author: roy Date: 2009-02-20 22:59:19 +0100 (Fri, 20 Feb 2009) New Revision: 379 Modified: pom.xml src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java src/main/java/nl/improved/sqlclient/TabCompletionInfo.java Log: small code cleanup version 0.7 started Modified: pom.xml =================================================================== --- pom.xml 2009-02-20 20:54:04 UTC (rev 378) +++ pom.xml 2009-02-20 21:59:19 UTC (rev 379) @@ -19,7 +19,7 @@ <groupId>nl.improved</groupId> <artifactId>sqlshell</artifactId> <packaging>jar</packaging> - <version>0.6.2</version> + <version>0.7-SNAPSHOT</version> <name>SQLShell ~ the improved sqlclient</name> <url>http://sqlshell.sourceforge.org</url> <build> Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-02-20 20:54:04 UTC (rev 378) +++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-02-20 21:59:19 UTC (rev 379) @@ -927,12 +927,13 @@ * @param sub the start of the match * @return the match starting with sub minus the sub itself in the correct casing */ - protected CharSequence findMatch(List<String> values, String sub) { + protected CharSequence findMatch(List<String> values, CharSequence sub) { List<String> matches = new ArrayList<String>(); Iterator<String> iValues = values.iterator(); + String subUpper = sub.toString().toUpperCase(); while (iValues.hasNext()) { String value = iValues.next(); - if (value.toUpperCase().startsWith(sub.toUpperCase())) { + if (value.toUpperCase().startsWith(subUpper)) { matches.add(value); } } @@ -954,7 +955,7 @@ } if (match != null) { match = DBConnector.getInstance().translateDbVar(match); - if (sub.length() > 0 && !match.startsWith(sub)) { // case insensitive change + if (sub.length() > 0 && !match.startsWith(sub.toString())) { // case insensitive change Point cursorPosition = screen.getCursorPosition(); List<StringBuffer> lines = getEditableCommand().getEditableLines(); if (lines.get(cursorPosition.y).length() >=sub.length()) { Modified: src/main/java/nl/improved/sqlclient/TabCompletionInfo.java =================================================================== --- src/main/java/nl/improved/sqlclient/TabCompletionInfo.java 2009-02-20 20:54:04 UTC (rev 378) +++ src/main/java/nl/improved/sqlclient/TabCompletionInfo.java 2009-02-20 21:59:19 UTC (rev 379) @@ -22,13 +22,13 @@ private MatchType type; private List<String> possibleMatches; - private String start; + private CharSequence start; public TabCompletionInfo(MatchType type, List<String> possibleMatches) { this(type, possibleMatches, ""); } - public TabCompletionInfo(MatchType type, List<String> possibleMatches, String start) { + public TabCompletionInfo(MatchType type, List<String> possibleMatches, CharSequence start) { this.type = type; this.possibleMatches = possibleMatches; this.start = start; @@ -40,7 +40,7 @@ public List<String> getPossibleMatches() { return possibleMatches; } - public String getStart() { + public CharSequence getStart() { return start; } |