Revision: 6563
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6563&view=rev
Author: gerdwagner
Date: 2012-01-30 20:11:16 +0000 (Mon, 30 Jan 2012)
Log Message:
-----------
Duplicate line works for selected text
Modified Paths:
--------------
trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/parser/kernel/ErrorStream.java
trunk/sql12/doc/src/main/resources/changes.txt
trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/DuplicateLineAction.java
Modified: trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/parser/kernel/ErrorStream.java
===================================================================
--- trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/parser/kernel/ErrorStream.java 2012-01-23 18:53:11 UTC (rev 6562)
+++ trunk/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/parser/kernel/ErrorStream.java 2012-01-30 20:11:16 UTC (rev 6563)
@@ -5,7 +5,7 @@
public class ErrorStream {
- int count; // number of errors detected
+ int count; // number of errors detected
public String fileName;
/** Internationalized strings for this class */
@@ -92,7 +92,7 @@
case ParsingConstants.KW_NULL: {s = "\"NULL\" "+EXPECTED_STR; break;}
case ParsingConstants.KW_DESC: {s = "\"DESC\" "+EXPECTED_STR; break;}
case ParsingConstants.KW_ASC: {s = "\"ASC\" "+EXPECTED_STR; break;}
- case 52: {s = "\"-\" "+EXPECTED_STR; break;}
+ case ParsingConstants.KW_MINUS_SIGN: {s = "\"-\" "+EXPECTED_STR; break;}
case 53: {s = "\":\" "+EXPECTED_STR; break;}
case ParsingConstants.KW_NOT: {s = "\"NOT\" "+EXPECTED_STR; break;}
case 55: {s = "\"/\" "+EXPECTED_STR; break;}
@@ -161,7 +161,7 @@
case 112: {s = INVALID_STR +" ForeignKey"; break;}
case 113: {s = INVALID_STR +" ColumnDefault"; break;}
case 114: {s = INVALID_STR +" DataType"; break;}
- case 115: {s = INVALID_STR +" InSetExpr"; break;}
+ case ParsingConstants.KW_INSET: {s = INVALID_STR +" InSetExpr"; break;}
case 116: {s = INVALID_STR +" LikeTest"; break;}
case 117: {s = INVALID_STR +" WordOperator"; break;}
case 118: {s = INVALID_STR +" MathOperator"; break;}
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2012-01-23 18:53:11 UTC (rev 6562)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2012-01-30 20:11:16 UTC (rev 6563)
@@ -6,11 +6,15 @@
Enhancements:
+
+Syntax Plugin:
+ Duplicate line (ctrl+d) now duplicates the line at cursor if no text is selected
+ and duplicates the selection if a selection exists.
+
Hibernate Plugin:
On Windows the class path's files defined in the Hibernate configuration would remain locked even
after disconnecting Hibernate. This doesn't happen anymore when Hibernate is run in its own process.
-
Graph Plugin:
Tables can be added to a Graph from within the SQL-Editor (accessible from right mouse menu and tools popup).
Modified: trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/DuplicateLineAction.java
===================================================================
--- trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/DuplicateLineAction.java 2012-01-23 18:53:11 UTC (rev 6562)
+++ trunk/sql12/plugins/syntax/src/main/java/net/sourceforge/squirrel_sql/plugins/syntax/DuplicateLineAction.java 2012-01-30 20:11:16 UTC (rev 6563)
@@ -48,48 +48,67 @@
{
try
{
- JTextComponent txtComp = sqlEntryPanel.getTextComponent();
+ String selectedText = sqlEntryPanel.getSelectedText();
- int docLen = txtComp.getDocument().getLength();
- String text = txtComp.getDocument().getText(0, txtComp.getDocument().getLength());
+ if(null != selectedText && 0 < selectedText.length())
+ {
+ JTextComponent txtComp = sqlEntryPanel.getTextComponent();
+ int selectionEnd = sqlEntryPanel.getSelectionEnd();
- int caretPosition = txtComp.getCaretPosition();
-
- int lineBeg = 0;
- for (int i = caretPosition - 1; i > 0; --i)
+ txtComp.getDocument().insertString(selectionEnd, selectedText, null);
+ sqlEntryPanel.setSelectionStart(selectionEnd);
+ sqlEntryPanel.setSelectionEnd(selectionEnd + selectedText.length());
+ }
+ else
{
- if (text.charAt(i) == '\n')
- {
- lineBeg = i;
- break;
- }
+ duplicateCurrentLine(sqlEntryPanel);
}
- int lineEnd = txtComp.getDocument().getLength();
- for (int i = caretPosition; i < docLen; ++i)
+ }
+ catch (BadLocationException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void duplicateCurrentLine(ISQLEntryPanel sqlEntryPanel) throws BadLocationException
+ {
+ JTextComponent txtComp = sqlEntryPanel.getTextComponent();
+
+ int docLen = txtComp.getDocument().getLength();
+ String text = txtComp.getDocument().getText(0, txtComp.getDocument().getLength());
+
+ int caretPosition = txtComp.getCaretPosition();
+
+ int lineBeg = 0;
+ for (int i = caretPosition - 1; i > 0; --i)
+ {
+ if (text.charAt(i) == '\n')
{
- if (text.charAt(i) == '\n')
- {
- lineEnd = i;
- break;
- }
+ lineBeg = i;
+ break;
}
+ }
- String line = text.substring(lineBeg, lineEnd);
-
- if (0 == lineBeg)
+ int lineEnd = txtComp.getDocument().getLength();
+ for (int i = caretPosition; i < docLen; ++i)
+ {
+ if (text.charAt(i) == '\n')
{
- line += "\n";
+ lineEnd = i;
+ break;
}
+ }
+ String line = text.substring(lineBeg, lineEnd);
- txtComp.getDocument().insertString(lineBeg, line, null);
-
- }
- catch (BadLocationException e)
+ if (0 == lineBeg)
{
- throw new RuntimeException(e);
+ line += "\n";
}
+
+
+ txtComp.getDocument().insertString(lineBeg, line, null);
}
public void setSQLPanel(ISQLPanelAPI panel)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|