[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-swt-dev] Mac OS 10.4 Finder drag and drop development
|
10.4 is not a *reference* platform. Given that a significant portion of
the Mac community is in the process of upgrading to 10.4, it would be
silly to not try and make this work. [note: this is not an opportunity to
start a discussion of the merits of 10.4 and whether or not you should
upgrade.]
McQ.
Randy Hudson <hudsonr@xxxxxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx
05/17/05 10:35
Please respond to
"Eclipse Platform SWT component developers list."
To
"Eclipse Platform SWT component developers list."
<platform-swt-dev@xxxxxxxxxxx>
cc
Subject
Re: [platform-swt-dev] Mac OS 10.4 Finder drag and drop development
10.4 is not a supported platform.
http://www.eclipse.org/eclipse/development/eclipse_project_plan_3_1.html#TargetOperatingEnvironments
-Randy
Eric Zimmerman <eric@xxxxxxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx
05/16/2005 08:02 PM
Please respond to
"Eclipse Platform SWT component developers list."
To
"platform-swt-dev@xxxxxxxxxxx" <platform-swt-dev@xxxxxxxxxxx>
cc
Subject
[platform-swt-dev] Mac OS 10.4 Finder drag and drop development
Drag and Drop to and from the finder in Mac OS 10.4 does not work
(Already submitted as a bug). I have spent the last couple of days
working on a fix but, I seem to be stuck.
I have fixed the drop source capabilities within eclipse by adding type
'furl' to the FileTransfer Class and implementing the correct
nativeToJava switch to do the processing: (Following the guidelines
here: http://developer.apple.com/technotes/tn/tn2022.html)
if (transferData.type == FURLID) {
int encoding = OS.CFStringGetSystemEncoding();
int count = transferData.data.length;
String[] fileNames = new String[count];
for (int i = 0; i < count; i++) {
System.out.println("url: " + new
String(transferData.data[i]));
byte[] urlData = transferData.data[i];
int url =
OS.CFURLCreateWithBytes(OS.kCFAllocatorDefault, urlData, urlData.length,
encoding, 0);
if (url == 0) return null;
try {
int path = OS.CFURLCopyFileSystemPath(url,
OS.kCFURLPOSIXPathStyle);
if (path == 0) return null;
try {
int length = OS.CFStringGetLength(path);
if (length == 0) return null;
char[] buffer = new char[length];
CFRange range = new CFRange();
range.length = length;
OS.CFStringGetCharacters(path, range, buffer);
fileNames[i] = new String(buffer);
System.out.println("filename: " + fileNames[i]);
} finally {
OS.CFRelease(path);
}
} finally {
OS.CFRelease(url);
}
}
return fileNames;
}
I had to wrap the CFURLCreateWithBytes native method into the swt-pi
library in order to accomplish this.
I then figured the issue with drag out was probably the reciprical
problem so I implemented the javaToNative furl processing:
if (transferData.type == FURLID) {
System.out.println("Requesting furlid transfer");
byte[][] data = new byte[files.length][];
for (int i = 0; i < data.length; i++) {
File file = new File(files[i]);
boolean isDirectory = file.isDirectory();
String fileName = files[i];
char[] chars = new char[fileName.length()];
fileName.getChars(0, chars.length, chars, 0);
int cfstring =
OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars,
chars.length);
if (cfstring == 0) return;
try {
int url =
OS.CFURLCreateWithFileSystemPath(OS.kCFAllocatorDefault, cfstring,
OS.kCFURLPOSIXPathStyle, isDirectory);
if (url == 0) return;
try {
int encoding = OS.CFStringGetSystemEncoding();
int theData =
OS.CFURLCreateData(OS.kCFAllocatorDefault, url, encoding, true);
if(theData == 0) return;
try {
int length = OS.CFDataGetLength(theData);
byte[] buffer = new byte[length];
CFRange range = new CFRange();
range.length = length;
OS.CFDataGetBytes(theData, range, buffer);
System.out.println("FURL: " + new
String(buffer));
data[i] = buffer;
} finally {
OS.CFRelease(theData);
}
} finally {
OS.CFRelease(url);
}
} finally {
OS.CFRelease(cfstring);
}
}
transferData.data = data;
transferData.result = 0;
}
To do this I also needed to wrap CFURLCreateData, CFDataGetLength, and
CFDataGetBytes in the swt-pi library. This code seems to function
correctly as a dragflavor since it is accepted by most applications
other than the finder.
Whenever I attempt to drag from my application in the finder I get a
positive result back from the trackDrag method that should indicate the
finder accepted my drag, but nothing shows up in the finder. :-(
I believe I have done most of the work to make this happen but am just
missing a little step to finish it off. If anybody can give me some
advice on where to look or something to try I will submit all of my
wrappers and code that are developed.
Thanks,
Eric
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev