Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Try to resolve the Linux drag-and-drop issues by reordering the prefe…
…rred drop types, and stripping nulls from the resultant string.

[#1091 state:resolved tagged:committed]
  • Loading branch information
cyberfox committed May 2, 2010
1 parent 53b0164 commit 4d5bbda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/com/jbidwatcher/ui/JDropListener.java
Expand Up @@ -28,9 +28,9 @@ public class JDropListener implements DropTargetListener {
private DataFlavor _urlFlavor = null;

private static final String[][] _str_flavors = {
{ "UTF8Html", "text/html; class=java.io.InputStream; charset=utf-8" },
{ "UTF8Html", "text/html; class=java.io.InputStream; charset=UTF-8" },
{ "isoFlavor", "text/plain; class=java.io.InputStream; charset=iso8859-1" },
{ "utfFlavor", "text/plain; class=java.io.InputStream; charset=utf-8" },
{ "utfFlavor", "text/plain; class=java.io.InputStream; charset=UTF-8" },
{ "ascFlavor", "text/plain; class=java.io.InputStream; charset=ascii" },
{ "pl2Flavor", "text/plain; class=java.io.InputStream" },
{ "thtmlFlavor", "text/html" },
Expand Down Expand Up @@ -123,8 +123,8 @@ private boolean testFlavor(DataFlavor inFlavor, DropTargetDragEvent t) {
}

private DataFlavor testAllFlavors(Transferable t) {
if(testFlavor(_htmlFlavor, t)) return _htmlFlavor;
if(testFlavor(_utf8HtmlFlavor, t)) return _utf8HtmlFlavor;
if(testFlavor(_htmlFlavor, t)) return _htmlFlavor;
if(testFlavor(_thtmlFlavor, t)) return _thtmlFlavor;

if(testFlavor(_urlFlavor, t)) return _urlFlavor;
Expand All @@ -140,8 +140,8 @@ private DataFlavor testAllFlavors(Transferable t) {
}

private DataFlavor testAllFlavors(DropTargetDragEvent dtde) {
if(testFlavor(_htmlFlavor, dtde)) return _htmlFlavor;
if(testFlavor(_utf8HtmlFlavor, dtde)) return _utf8HtmlFlavor;
if(testFlavor(_htmlFlavor, dtde)) return _htmlFlavor;
if(testFlavor(_thtmlFlavor, dtde)) return _thtmlFlavor;

if(testFlavor(_urlFlavor, dtde)) return _urlFlavor;
Expand Down
9 changes: 4 additions & 5 deletions src/com/jbidwatcher/ui/TargetDrop.java
Expand Up @@ -31,14 +31,13 @@ public TargetDrop() {
mTargetName = null;
}

private String stripNewlines(String instr) {
int index;
private String cleanText(String instr) {
String outstr = instr;

index = outstr.indexOf('\n');
int index = Math.min(outstr.indexOf('\n'), outstr.indexOf('\0'));
while(index != -1) {
outstr = outstr.substring(0, index) + outstr.substring(index+1);
index = outstr.indexOf('\n');
index = Math.min(outstr.indexOf('\n'), outstr.indexOf('\0'));
}
return outstr;
}
Expand All @@ -49,7 +48,7 @@ public void receiveDropString(StringBuffer dropped) {
return;
}

dropped = new StringBuffer(stripNewlines(dropped.toString()));
dropped = new StringBuffer(cleanText(dropped.toString()));
if(sUberDebug) JConfig.log().logDebug("Dropping :" + dropped + ":");

// Is it an 'HTML Fragment' as produced by Mozilla, NS6, and IE5+?
Expand Down

0 comments on commit 4d5bbda

Please sign in to comment.