summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2008-07-30 21:47:23 +0000
committerSilenio Quarti <silenio>2008-07-30 21:47:23 +0000
commite6996491cee7311e9013affa5737d1b990fc94fa (patch)
treed33c9a562025baad487294f8d381f72cdecf4aca /bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa
parent90cffad57b2c0ad67dbf68bc30b3f25f5bc7e83e (diff)
downloadeclipse.platform.swt-e6996491cee7311e9013affa5737d1b990fc94fa.tar.gz
eclipse.platform.swt-e6996491cee7311e9013affa5737d1b990fc94fa.tar.xz
eclipse.platform.swt-e6996491cee7311e9013affa5737d1b990fc94fa.zip
make TransferData.type be an int because of other platforms
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ByteArrayTransfer.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Transfer.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TransferData.java2
4 files changed, 21 insertions, 19 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ByteArrayTransfer.java
index e1c8453869..0136a5c8e4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ByteArrayTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -121,7 +121,7 @@ import org.eclipse.swt.internal.cocoa.*;
public abstract class ByteArrayTransfer extends Transfer {
public TransferData[] getSupportedTypes() {
- String[] types = getTypeNames();
+ int[] types = getTypeIds();
TransferData[] data = new TransferData[types.length];
for (int i = 0; i < types.length; i++) {
data[i] = new TransferData();
@@ -132,9 +132,9 @@ public TransferData[] getSupportedTypes() {
public boolean isSupportedType(TransferData transferData){
if (transferData == null) return false;
- String[] types = getTypeNames();
+ int[] types = getTypeIds();
for (int i = 0; i < types.length; i++) {
- if (types[i] != null && types[i].equals(transferData.type)) return true;
+ if (transferData.type == types[i]) return true;
}
return false;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java
index 183d026205..625b699a46 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java
@@ -290,7 +290,7 @@ public Object getContents(Transfer transfer, int clipboards) {
tdata.data = pasteboard.dataForType(type);
}
if (tdata.data != null) {
- tdata.type = Transfer.getString(type);
+ tdata.type = Transfer.registerType(Transfer.getString(type));
return transfer.nativeToJava(tdata);
}
}
@@ -444,10 +444,10 @@ public void setContents(Object[] data, Transfer[] dataTypes, int clipboards) {
String[] typeNames = dataTypes[i].getTypeNames();
for (int j=0; j<typeNames.length; j++) {
TransferData transferData = new TransferData();
- transferData.type = typeNames[j];
+ transferData.type = Transfer.registerType(typeNames[j]);
dataTypes[i].javaToNative(data[i], transferData);
NSObject tdata = transferData.data;
- NSString dataType = NSString.stringWith(transferData.type);
+ NSString dataType = NSString.stringWith(typeNames[j]);
pasteboard.addTypes(NSArray.arrayWithObject(dataType), null);
if (dataType.isEqual(OS.NSStringPboardType) ||
dataType.isEqual(OS.NSRTFPboardType)) {
@@ -512,7 +512,7 @@ public TransferData[] getAvailableTypes(int clipboards) {
TransferData[] result = new TransferData[count];
for (int i = 0; i < count; i++) {
result[i] = new TransferData();
- result[i].type = Transfer.getString(new NSString(types.objectAtIndex(i)));
+ result[i].type = Transfer.registerType(Transfer.getString(new NSString(types.objectAtIndex(i))));
}
return result;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Transfer.java
index 9920165c83..5064ddade8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Transfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Transfer.java
@@ -30,8 +30,7 @@ import org.eclipse.swt.internal.cocoa.*;
*/
public abstract class Transfer {
-static String[] types = new String[4];
-static int typeCount;
+static String[] TYPES = new String[4];
static String getString (NSString str) {
char[] chars = new char[str.length()];
@@ -142,19 +141,22 @@ abstract protected Object nativeToJava(TransferData transferData);
* @return the unique identifier associated with this data type
*/
public static int registerType(String formatName) {
- for (int i = 0; i < typeCount; i++) {
- String type = types[i];
+ /* Note the type 0 is not used */
+ int index = 1;
+ while (index < TYPES.length) {
+ String type = TYPES[index];
if (type != null && formatName.equals(type)) {
- return i;
+ return index;
}
+ index++;
}
- if (typeCount + 1 == types.length) { // types[0] is null
- String[] newTypes = new String[types.length + 4];
- System.arraycopy(types, 0, newTypes, 0, types.length);
- types = newTypes;
+ if (index == TYPES.length) {
+ String[] newTypes = new String[TYPES.length + 4];
+ System.arraycopy(TYPES, 0, newTypes, 0, TYPES.length);
+ TYPES = newTypes;
}
- types[++typeCount] = formatName;
- return typeCount;
+ TYPES[index] = formatName;
+ return index;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TransferData.java
index b573eeabb1..31a52da04f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TransferData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/TransferData.java
@@ -40,7 +40,7 @@ public class TransferData {
* platforms and should never be accessed from application code.
* </p>
*/
- public String type;
+ public int type;
/**
* The data being transferred.