Revision: 5918
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=5918&view=rev
Author: gerdwagner
Date: 2010-10-13 02:17:07 +0000 (Wed, 13 Oct 2010)
Log Message:
-----------
New SQL Script preference that allows to choose the escape string for new lines.
Modified Paths:
--------------
trunk/sql12/doc/src/main/resources/changes.txt
trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferenceBean.java
trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferencesPanel.java
trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/table_script/CreateDataScriptCommand.java
trunk/sql12/plugins/sqlscript/src/main/resources/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/I18NStrings.properties
trunk/sql12/web-site/home.html
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2010-10-12 11:42:00 UTC (rev 5917)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2010-10-13 02:17:07 UTC (rev 5918)
@@ -6,6 +6,9 @@
Enhancements:
+SQL Scripts Plugin:
+ New preference that allows to choose the escape string for new lines. See Global Preferences --> Tab SQL Scripts
+
Hibernate Plugin:
- New handling of limiting object count for HQL queries. This may prevent severe performance problems.
Formerly the limit was set more or less under the hood (SQL limit was used).
Modified: trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferenceBean.java
===================================================================
--- trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferenceBean.java 2010-10-12 11:42:00 UTC (rev 5917)
+++ trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferenceBean.java 2010-10-13 02:17:07 UTC (rev 5918)
@@ -37,6 +37,8 @@
private boolean qualifyTableNames = true;
private boolean useDoubleQuotes = true;
+ private boolean escapeNewLine = true;
+ private String escapeNewLineString = ESCAPE_NEW_LINE_STRING_DEFAULT;
public static final int NO_ACTION = 0;
@@ -60,8 +62,9 @@
* whether or not to override the update referential action for FK defs.
*/
private boolean updateRefAction = false;
+ public static final String ESCAPE_NEW_LINE_STRING_DEFAULT = "\\n";
- public SQLScriptPreferenceBean() {
+ public SQLScriptPreferenceBean() {
super();
}
@@ -191,6 +194,31 @@
useDoubleQuotes = b;
}
+ public boolean isEscapeNewLine()
+ {
+ return escapeNewLine;
+ }
+ public void setEscapeNewLine(boolean escapeNewLine)
+ {
+ this.escapeNewLine = escapeNewLine;
+ }
+
+ public void setEscapeNewLineString(String escapeNewLineString)
+ {
+ if(null == escapeNewLineString)
+ {
+ this.escapeNewLineString = ESCAPE_NEW_LINE_STRING_DEFAULT;
+ }
+ else
+ {
+ this.escapeNewLineString = escapeNewLineString;
+ }
+ }
+
+ public String getEscapeNewLineString()
+ {
+ return escapeNewLineString;
+ }
}
Modified: trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferencesPanel.java
===================================================================
--- trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferencesPanel.java 2010-10-12 11:42:00 UTC (rev 5917)
+++ trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferencesPanel.java 2010-10-13 02:17:07 UTC (rev 5918)
@@ -18,18 +18,11 @@
*/
package net.sourceforge.squirrel_sql.plugins.sqlscript.prefs;
-import java.awt.Component;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
+import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
@@ -67,6 +60,12 @@
JLabel deleteActionLabel = null;
JLabel updateActionLabel = null;
+
+
+ JCheckBox escapeNewLineCheckBox;
+ JLabel escapeNewLineLabel;
+ JTextField escapeNewLineTextfield;
+
public SQLScriptPreferencesPanel(SQLScriptPreferenceBean prefs) {
super();
@@ -91,12 +90,19 @@
//i18n[SQLScriptPreferencesPanel.borderTitle=SQL Script Preferences]
String borderTitle = s_stringMgr.getString("SQLScriptPreferencesPanel.borderTitle");
result.setBorder(getTitledBorder(borderTitle));
- addQualifyTableNamesCheckBox(result, 0, 0);
+
+ addQualifyTableNamesCheckBox(result, 0, 0);
addUseDoubleQuotesCheckBox(result, 0, 1);
+
addDeleteRefActionCheckBox(result, 0, 2);
addDeleteActionComboBox(result, 0, 3);
+
addUpdateRefActionCheckBox(result, 0, 4);
addUpdateActionComboBox(result, 0, 5);
+
+ addEscapeNewLineCheckBox(result, 0, 6);
+ addEscapeNewLineTextField(result, 0, 7);
+
return result;
}
@@ -190,6 +196,28 @@
panel.add(updateReferentialActionCheckbox, c);
}
+ private void addEscapeNewLineCheckBox(JPanel panel, int col, int row) {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = col;
+ c.gridy = row;
+ c.anchor = GridBagConstraints.WEST;
+
+ String cbLabelStr =
+ s_stringMgr.getString("SQLScriptPreferencesPanel.escapeNewLine");
+
+ escapeNewLineCheckBox = new JCheckBox(cbLabelStr);
+
+ escapeNewLineCheckBox.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ boolean enabled = escapeNewLineCheckBox.isSelected();
+ escapeNewLineLabel.setEnabled(enabled);
+ escapeNewLineTextfield.setEnabled(enabled);
+ }
+ });
+
+ panel.add(escapeNewLineCheckBox, c);
+ }
+
private void addDeleteActionComboBox(JPanel panel, int col, int row) {
GridBagConstraints c = new GridBagConstraints();
c.gridx = col;
@@ -256,8 +284,29 @@
panel.add(subpanel, c);
}
+ private void addEscapeNewLineTextField(JPanel panel, int col, int row) {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = col;
+ c.gridy = row;
+ c.insets = new Insets(5,25,0,0);
+ c.anchor = GridBagConstraints.WEST;
+
+ JPanel subpanel = new JPanel();
+
+ String cbLabelStr =
+ s_stringMgr.getString("SQLScriptPreferencesPanel.escapeNewLineTextfieldLabel");
+ escapeNewLineLabel = new JLabel(cbLabelStr);
+ escapeNewLineLabel.setHorizontalAlignment(JLabel.LEFT);
+
+ escapeNewLineTextfield = new JTextField();
+ escapeNewLineTextfield.setPreferredSize(new Dimension(50, escapeNewLineCheckBox.getPreferredSize().height));
+ subpanel.add(escapeNewLineLabel);
+ subpanel.add(escapeNewLineTextfield);
+ panel.add(subpanel, c);
+ }
+
+
-
private Border getTitledBorder(String title) {
CompoundBorder border =
new CompoundBorder(new EmptyBorder(10,10,10,10),
@@ -275,6 +324,13 @@
updateReferentialActionCheckbox.setSelected(_prefs.isUpdateRefAction());
updateActionComboBox.setEnabled(updateReferentialActionCheckbox.isSelected());
updateActionComboBox.setSelectedIndex(_prefs.getUpdateAction());
+
+ escapeNewLineCheckBox.setSelected(_prefs.isEscapeNewLine());
+ escapeNewLineTextfield.setText(_prefs.getEscapeNewLineString());
+ escapeNewLineTextfield.setEnabled(_prefs.isEscapeNewLine());
+ escapeNewLineLabel.setEnabled(_prefs.isEscapeNewLine());
+
+
}
@@ -287,6 +343,16 @@
_prefs.setDeleteAction(action);
action = updateActionComboBox.getSelectedIndex();
_prefs.setUpdateAction(action);
+
+ _prefs.setEscapeNewLine(escapeNewLineCheckBox.isSelected());
+
+ String escapeString = SQLScriptPreferenceBean.ESCAPE_NEW_LINE_STRING_DEFAULT;
+ if(null != escapeNewLineTextfield.getText())
+ {
+ escapeString = escapeNewLineTextfield.getText();
+ }
+ _prefs.setEscapeNewLineString(escapeString);
+
SQLScriptPreferencesManager.savePrefs();
}
Modified: trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/table_script/CreateDataScriptCommand.java
===================================================================
--- trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/table_script/CreateDataScriptCommand.java 2010-10-12 11:42:00 UTC (rev 5917)
+++ trunk/sql12/plugins/sqlscript/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlscript/table_script/CreateDataScriptCommand.java 2010-10-13 02:17:07 UTC (rev 5918)
@@ -389,25 +389,11 @@
sResult = sb.toString();
}
- iIndex = sResult.indexOf('\n');
- if (iIndex != -1)
+ if (SQLScriptPreferencesManager.getPreferences().isEscapeNewLine())
{
- int iPrev = 0;
- StringBuffer sb = new StringBuffer();
- sb.append(sResult.substring(iPrev, iIndex));
- sb.append("\\n");
- iPrev = iIndex + 1;
- iIndex = sResult.indexOf('\n', iPrev + 1);
- while (iIndex != -1)
- {
- sb.append(sResult.substring(iPrev, iIndex));
- sb.append("\\n");
- iPrev = iIndex + 1;
- iIndex = sResult.indexOf('\n', iPrev + 1);
- }
- sb.append(sResult.substring(iPrev));
- sResult = sb.toString();
+ sResult = escapeNewlines(sResult);
}
+
sbValues.append("\'");
sbValues.append(sResult);
sbValues.append("\'");
@@ -442,7 +428,34 @@
srcResult.close();
}
- /**
+ private String escapeNewlines(String sResult)
+ {
+ String escape = SQLScriptPreferencesManager.getPreferences().getEscapeNewLineString();
+
+ int iIndex;
+ iIndex = sResult.indexOf('\n');
+ if (iIndex != -1)
+ {
+ int iPrev = 0;
+ StringBuffer sb = new StringBuffer();
+ sb.append(sResult.substring(iPrev, iIndex));
+ sb.append(escape);
+ iPrev = iIndex + escape.length();
+ iIndex = sResult.indexOf('\n', iPrev-1);
+ while (iIndex != -1)
+ {
+ sb.append(sResult.substring(iPrev-1, iIndex));
+ sb.append(escape);
+ iPrev = iIndex + escape.length();
+ iIndex = sResult.indexOf('\n', iPrev-1);
+ }
+ sb.append(sResult.substring(iPrev-1));
+ sResult = sb.toString();
+ }
+ return sResult;
+ }
+
+ /**
* Returns the sub-second precision value from the specified timestamp if supported by the session's
* dialect.
*
Modified: trunk/sql12/plugins/sqlscript/src/main/resources/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/I18NStrings.properties
===================================================================
--- trunk/sql12/plugins/sqlscript/src/main/resources/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/I18NStrings.properties 2010-10-12 11:42:00 UTC (rev 5917)
+++ trunk/sql12/plugins/sqlscript/src/main/resources/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/I18NStrings.properties 2010-10-13 02:17:07 UTC (rev 5918)
@@ -15,3 +15,5 @@
SQLScriptPreferencesPanel.useDoubleQuotesForQualifying=Use double quotes (") for qualifying
+SQLScriptPreferencesPanel.escapeNewLine=New lines in literals should be escaped by
+SQLScriptPreferencesPanel.escapeNewLineTextfieldLabel=Escape character/string:
Modified: trunk/sql12/web-site/home.html
===================================================================
--- trunk/sql12/web-site/home.html 2010-10-12 11:42:00 UTC (rev 5917)
+++ trunk/sql12/web-site/home.html 2010-10-13 02:17:07 UTC (rev 5918)
@@ -77,7 +77,7 @@
<P><B>
For all changes see <a
- href="http://squirrel-sql.svn.sourceforge.net/viewvc/squirrel-sql/trunk/sql12/doc/changes.txt">Changelog</a>.
+ href="http://squirrel-sql.svn.sourceforge.net/viewvc/squirrel-sql/trunk/sql12/doc/src/main/resources/changes.txt">Changelog</a>.
Likewise, please refer SQuirreL's help section for an overview of all features.
<p><a href="#installation">Download</A></p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|