Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28296/app/src/net/sourceforge/squirrel_sql/client/session
Modified Files:
FileManager.java
Log Message:
Loading and Saving files on Windows produced multiple CR (carriage return) chars in files. When copy and paste was used on such files multiple empty lines were created.
Index: FileManager.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/FileManager.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** FileManager.java 9 Sep 2009 20:46:53 -0000 1.19
--- FileManager.java 11 Feb 2010 00:09:53 -0000 1.20
***************
*** 124,128 ****
iRead = bis.read(bytes);
}
! _sqlPanelAPI.appendSQLScript(sb.toString(), true);
setFile(file);
prefs.setFilePreviousDir(file.getAbsolutePath());
--- 124,128 ----
iRead = bis.read(bytes);
}
! _sqlPanelAPI.appendSQLScript(convertPlatformEOLToLineFeed(sb.toString()), true);
setFile(file);
prefs.setFilePreviousDir(file.getAbsolutePath());
***************
*** 139,143 ****
}
-
public boolean saveIntern(boolean toNewFile)
{
--- 139,142 ----
***************
*** 292,304 ****
*/
private String getEntireSQLScriptWithPlatformEolChar() {
- String platformEolStr = StringUtilities.getEolStr();
String result = _sqlPanelAPI.getEntireSQLScript();
! if (result != null && !"".equals(result) && !platformEolStr.equals("\n")) {
! result = result.replaceAll("\\n", platformEolStr);
}
return result;
}
!
private void setFile(File file)
{
--- 291,328 ----
*/
private String getEntireSQLScriptWithPlatformEolChar() {
String result = _sqlPanelAPI.getEntireSQLScript();
!
! return convertLineFeedToPlatformEOL(result);
! }
!
! private String convertLineFeedToPlatformEOL(String result)
! {
! String platformEolStr = StringUtilities.getEolStr();
! if( result != null && !"".equals(result) && !platformEolStr.equals("\n") )
! {
! result = result.replaceAll("\\n", platformEolStr);
}
return result;
}
!
! /**
! * Without calling this method when loading a file on Windows
! * method convertLineFeedToPlatformEOL() which is called when saving a file
! * would create duplicate \r each time a file is opened and saved.
! */
! private String convertPlatformEOLToLineFeed(String s)
! {
! String platformEolStr = StringUtilities.getEolStr();
!
! if(null == s || "".equals(s) || platformEolStr.equals("\n"))
! {
! return s;
! }
!
! return s.replaceAll(platformEolStr, "\n");
! }
!
!
private void setFile(File file)
{
|