[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Fri Mar 23 20:23:52 UTC 2007


gordonp
Fri Mar 23 16:23:52 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv20366/src/main/ca/ucalgary/seahawk/gui

Modified Files:
	FileAndTextTransferHandler.java 
Log Message:
Improved pasted data handling: RTF now interpreted as such, HTML somewhat cleaned up
moby-live/Java/src/main/ca/ucalgary/seahawk/gui FileAndTextTransferHandler.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java	2007/02/08 16:59:57	1.3
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java	2007/03/23 20:23:52	1.4
@@ -174,17 +174,29 @@
 		}
 
                 // Otherwise save the data to a temp file and load it as a URL
-                File savedFile = File.createTempFile("seahawkDataDrop", "");
+		String suffix = "";
+		if(text.indexOf("{\\rtf") == 0){
+		    suffix = ".rtf";
+		}
+		else if(text.indexOf("<") != -1 && text.indexOf(">") > text.indexOf("<") && 
+			text.indexOf("/") != -1){
+		    suffix = ".html";
+		}
+                File savedFile = File.createTempFile("seahawkDataDrop", suffix);
 	        savedFile.deleteOnExit();
 	        FileOutputStream out = new FileOutputStream(savedFile);
-		if(text.indexOf("<html") == -1 &&
-		   text.indexOf("<") != -1 && text.indexOf(">") > text.indexOf("<") && 
-		   text.indexOf("/") != -1){
-		    // Add html tag around the contents if it's hypertext, so it's a full document and
-		    // JEditorPane doesn't do funny stuff.
-		    out.write("<html>".getBytes());
-		    out.write(text.getBytes());
-		    out.write("</html>".getBytes());
+		if(suffix.equals(".html")){
+		    // Sometimes you get ?? at the start of pasted html, we'll clean it up
+		    if(text.indexOf("??") == 0){
+			text = text.substring(2);
+		    }
+		    if(text.indexOf("<html") == -1){
+			// Add html tag around the contents if it's hypertext, so it's a full document and
+			// JEditorPane doesn't do funny stuff.
+			out.write("<html>".getBytes());
+			out.write(text.getBytes());
+			out.write("</html>".getBytes());
+		    }
 		}
 		else{
 		    // Treat as plain text if there are no hyperlinks




More information about the MOBY-guts mailing list